# -*- coding: utf-8 -*-
from distutils.core import setup

packages = \
['isle', 'isle.objects']

package_data = \
{'': ['*']}

setup_kwargs = {
    'name': 'isle',
    'version': '0.2.0',
    'description': 'A clear and distinct wrapper of The Movie Database API.',
    'long_description': '# THE MOVIE DATABASE PYTHON WRAPPER\n\n[![Build Status](https://travis-ci.org/dmkskn/isle.svg?branch=master)](https://travis-ci.org/dmkskn/isle)\n\n`isle` is a clear and distinct wrapper for The Movie Database API.\n\n## TABLE OF CONTENTS\n\n- [REQUIREMENTS](#REQUIREMENTS)\n- [INSTALLATION](#INSTALLATION)\n- [TMDB API KEY](#TMDB-API-KEY)\n- [FUNCTIONS](#FUNCTIONS)\n- [OBJECTS](#OBJECTS)\n- [ACCOUNT](#ACCOUNT)\n\n## REQUIREMENTS\n\n- **Python 3.6+**\n- **No dependencies** other than the standard library\n\n## INSTALLATION\n\nUsing `pip`:\n\n```python\npip install isle\n```\n\n## TMDB API KEY\n\nExport your TMDb API key as an environment variable:\n\n```bash\n$ export TMDB_API_KEY=\'YOUR_API_KEY\'\n```\n\nOr set the `TMDB_API_KEY` variable:\n\n```python\nimport isle\n\nisle.TMDB_API_KEY = \'YOUR_API_KEY\'\n```\n\n## FUNCTIONS\n\n### Search\nSearch functions look for movies, TV shows, people or companies by their names or titles.\n\nAll search functions are *generators*.\n\n```python\n>>> import inspect\n>>> import isle\n\n>>> inspect.isgenerator(isle.search_movie)\nTrue\n\n>>> inspect.isgenerator(isle.search_show)\nTrue\n\n>>> # and so on.\n```\n\n#### `isle.search_movie(query: str, **kwargs)`\n\nSearches for movies. It generates `Movie` instances.\n\nLet\'s search for Ozu\'s "Tokyo Story":\n\n```python\n>>> for movie in isle.search_movie("Tokyo Story"):\n...     print(movie)\n\nMovie(18148)\nMovie(528533)\n...\nMovie(104343)\n```\n\nLet\'s get only the first result:\n\n```python\n>>> tokyo_story = next(isle.search_movie("Tokyo Story", year=1953))\n\n>>> tokyo_story\nMovie(18148)\n```\n\nThere are several keyword arguments:\n\n - `year` — filters a movie by release year\n - `region` — filters release dates. Must be an ISO 3166-1 code (uppercase).\n - `include_adults` — chooses whether to inlcude adult (pornography) content in the results (bool).\n - `language` — displays translated data for the fields that support it (some default values in `Movie` object). Must be an ISO 639-1 code.\n\n\n#### `isle.search_show(query: str, **kwargs)`\n\nSearches for a TV show. It generates `Show` instances.\n\n```python\n>>> castle_rock = next(isle.search_show("Castle Rock"))\n\n>>> castle_rock\nShow(71116)\n```\nThere is a keyword argument `first_air_date_year`, which can be specified for more accurate results.\n\n#### `isle.search_person(query: str, **kwargs)`\n\nSearches for people. It generates `Person` instances.\n\n```python\n>>> john_cassavetes = next(isle.search_person("John Cassavetes"))\n\n>>> john_cassavetes\nPerson(11147)\n```\n\nThere are `language`, `region` and `include_adults` keyword arguments (see the part about `search_movie` above to understand what they change).\n\n#### `isle.search_company(query: str, **kwargs)`\n\nSearches for companies. It generates `Company` instances.\n\n```python\n>>> lucasfilm_company = next(isle.search_company("Lucasfilm"))\n\n>>> lucasfilm_company\nCompany(1)\n```\n\n### Discover\n\nLike search functions, all discover functions are also *generators*. But instead of searching by name or title, these ones descover movies or TV shows by different types of data like average rating, number of votes, genres and certifications.\n\n> To understand `options`, you need to read [this](https://developers.themoviedb.org/3/discover/movie-discover) and [this](https://developers.themoviedb.org/3/discover/tv-discover).\n\n#### `isle.discover_movies(options: dict)`\n\nDiscovers movies by different types of data.\n\nLet\'s discover the first 3 movies with Jason Schwartzman:\n\n```python\n>>> from itertools import islice\n\n>>> schwartzman = next(isle.search_person("Jason Schwartzman"))\n\n>>> options = {\n    "sort_by": "release_date.asc",\n    "with_cast": schwartzman.tmdb_id\n}\n\n>>> for movie in islice(isle.discover_movies(options), 3):\n...     print(f"\'{movie.year} - {movie.title[\'original\']}\'")\n\n\'1998 - Rushmore\'\n\'2001 - CQ\'\n\'2002 - Slackers\'\n```\n\n#### `isle.discover_shows(options: dict)`\n\nDiscovers TV shows by different types of data. It works like `discover_movies`, but note that the options are different.\n\nLet\'s discover top 3 most popular TV shows on TMDb:\n\n```python\n>>> options = {\'sort_by\': \'popularity.desc\'}\n\n>>> for show in islice(isle.discover_shows(options), 3):\n...     print(f"\'{show.vote.average:<10} {show.title[\'original\']}\'")\n\n\'8         ドラゴンボール\'\n\'6.7       The Flash\'\n\'6.8       The Big Bang Theory\'\n```\n\n### Find\n\n#### `isle.find(external_id: str, *, src: str, **options)`\n\nThe `find` function searches for objects (movies, TV shows and people) by an external ID (for example, an IMDb ID). It returns the results in a single response.\n\n```python\n>>> results = tmdb.find("tt0053604", src="imdb_id")\n\n>>> results\n{\'movie_results\': [Movie(284)], \'person_results\': [], \'tv_results\': []}\n```\n\n### Others\n\nOther functions return some general information, such as genres, languages, time zones supported in TMDb.\n\nLet\'s just list them all (you always can use the build-in `help` function to see more information):\n\n- `isle.get_movie_certifications(country=None)`\n- `isle.get_show_certifications(country=None)`\n- `isle.get_movie_genres(objects=False)`\n- `isle.get_show_genres(objects=False)`\n- `isle.get_image_configurations()`\n- `isle.get_countries(objects=False)`\n- `isle.get_jobs()`\n- `isle.get_languages(objects=False)`\n- `isle.get_primary_translations()`\n- `isle.get_timezones()`\n\n## OBJECTS\n\nLet\'s take a close look at `Movie`, `Show`, `Person` and `Company` objects.\n\n- They can be initialized by a TMDb ID or obtained by *search* and *discover* functions (as we see above).\n\n- They can be used in two different ways: use *methods* that return raw responses or use *properties* that enrich objects with more functionality (you\'ll see this below)\n\n### `Movie`\n\nRepresents a movie. It can be initialized with a TMDb ID.\n\n```python\n>>> movie = isle.Movie(18148)\n```\n\nNow the `movie` doesn\'t contain any data except the ID. It hasn\'t made any requests to the API yet (You can see how many requests were made by the `n_requests` attribute).\n\n```python\n>>> movie.data\n{\'id\': 18148}\n\n>>> movie.n_requests\n0\n```\n\n#### Methods\n`Movie` (as well as other objects, such as `Show`, `Person` or `Company`) has `get_<something>` and `iter_<something>` methods. Let\'s list them:\n\n- `get_all()`\n- `get_alternative_titles()`\n- `get_changes()`\n- `get_credits()`\n- `get_details()`\n- `get_external_ids()`\n- `get_images()`\n- `get_keywords()`\n- `get_release_dates()`\n- `get_translations()`\n- `get_videos()`\n- `iter_lists()`\n- `iter_recommendations()`\n- `iter_reviews()`\n- `iter_similar_movies()`\n\nEach method makes only *one* request to the API. That\'s why the best practice is  to use `get_all()` method instead of calling several other methods. So instead of doing the following:\n\n```python\n>>> movie = isle.Movie(18148)\n\n>>> credits = movie.get_credits() # making first request\n\n>>> movie.n_requests\n1\n\n>>> keywords = movie.get_keywords()  # making second request\n\n>>> movie.n_requests\n2\n```\n\nDo this:\n\n```python\n>>> movie = isle.Movie(18148)\n\n>>> movie.n_requests\n0\n\n>>> all_data = movie.get_all() # making first request\n\n>>> movie.n_requests\n1\n\n>>> credits, keywords = all_data["credits"], all_data["keywords"]\n\n>>> movie.n_requests\n1\n```\n\nAll the received data is saved in the `data` attribute. Now it contains all the data, because we\'ve called the `get_all()` method.\n\n```python\n>>> all_data == movie.data\nTrue\n\n>>> keywords == movie.data["keywords"]\nTrue\n```\n\nAll the data received with methods is structured in the same way as in the [raw](https://developers.themoviedb.org/3/movies/get-movie-details) API responses.\n\n#### Properties ☝️\n\nAnother way to get data is to use properties (it is actually the best way).\n\nLet\'s see an example. What if you need to get the titles of a movie in different languages? You can call `get_all()` and retrieve the titles from the `data` attribute:\n\n```python\n>>> movie.get_all()\n\n>>> acc = {}\n\n>>> acc["original"] = movie.data["original_title"]\n\n>>> acc["default"] = movie.data["title"]\n\n>>> for item in movie.data["translations"]["translations"]:\n...    acc[item["iso_3166_1"]] = item["data"]["title"]\n\n>>> acc\n{\'original\': \'東京物語\', \'default\': \'Tokyo Story\', \'RU\': \'Токийская повесть\', \'US\': \'Tokyo Story\',  ..., \'FR\': \'Voyage à Tokyo\'}\n\n```\n\nOr you can just use the `title` property:\n\n```python\n>>> movie = isle.Movie(18148)\n\n>>> movie.title\n{\'original\': \'東京物語\', \'default\': \'Tokyo Story\', \'RU\': \'Токийская повесть\', \'US\': \'Tokyo Story\',  ..., \'FR\': \'Voyage à Tokyo\'}\n\n>>> movie.n_requests\n1\n```\n\nIn the same way you can use the `overview` property:\n\n```python\n>>> movie.overview["FR"]\n"Un couple de personnes âgées rend visite à leurs enfants à Tokyo. D\'abord reçus avec les égards qui leur sont dûs, ils deviennent bientôt dérangeants dans leur vie quotidienne."\n```\n\nWhen a property is called, it searches for the required data in the `data` attribute and if there is no such data, it calls `get_all()` behind the scenes. After calling the `title` attribute, all the raw data is downloaded to the `data` attribute.\n\n```python\n>>> movie.genres\n[Genre(tmdb_id=18, name=\'Drama\')] # Genre is a `NamedTuple` object\n\n>>> person, credit = movie.crew[0]\n>>> person.name, credit.job\n(\'Yasujirō Ozu\', \'Director\')\n\n>>> person, credit = movie.cast[0]\n>>> person.name, credit.job, credit.character\n(\'Chishū Ryū\', \'Actor\', \'Shukishi Hirayama\')\n\n>>> movie.vote\nVote(average=8.3, count=292) # It is a `NamedTuple` object too\n\n>>> movie.releases["US"]\n[{\'certification\': \'\', \'type\': 3, \'date\': \'1972-03-13T00:00:00.000Z\', \'note\': \'\'}]\n\n>>> movie.n_requests\n1\n```\n\nWhen `search_movie` and `discover_movie` functions return `Movie` instances, they add initial data to the `data` atributes.\n\n```python\n>>> tokyo_story = next(isle.search_movie("Tokyo Story", year=1953))\n\n>>> tokyo_story.n_requests\n0\n\n>>> tokyo_story.year\n1953\n\n>>> tokyo_story.is_adult\nFalse\n\n>>> tokyo_story.popularity\n5.816\n\n>>> tokyo_story.n_requests # it did not make API requests yet\n0\n\n>>> # but\n>>> person, credit = tokyo_story.crew[0]\n>>> tokyo_story.n_requests\n1\n```\n\nIn the same way, `Movie` adds some initial data to the `data` attribute of `Person` and `Company` instances:\n\n```python\n>>> person, _ = tokyo_story.crew[0]\n\n>>> person.name\n\'Yasujirō Ozu\'\n\n>>> person.n_requests\n0\n\n>>> company = tokyo_story.companies[0]\n>>> company.name\n\'Shochiku Co., Ltd.\'\n\n>>> company.n_requests\n0\n```\n\nUse the build-in `help` function to see all available properties.\n\n### `Show`, `Person` and `Company`\n\nThese objects are similar to `Movie`. They also have `get_<something>` and `iter_<something>` methods and properties that do all the routine work.\n\nThe main difference is that `Company` doesn\'t have the `get_all()` method, so, behind the scenes, it can call several `get` methods (though the main information is returned by `get_details()`).\n\n```python\n>>> company = Company(1)\n\n>>> company.name\n\'Lucasfilm\'\n\n>>> company.homepage\n\'http://www.lucasfilm.com\'\n\n>>> company.n_requests\n1\n\n>>> company.logos # searches for images and calls `get_images` if there are no images in the `data` attribute\n[Image(heigh=99, width=295, _type=logo)]\n\n>>> company.n_requests\n2\n\n>>> company.also_known_as # searches for alternative_names and calls `get_alternative_names` if there are no names in the `data` attribute\n[]\n\n>>> company.n_requests\n3\n```\n\n### `Season`, `Episode`, `Credit` and others\n\nA `Season` is returned by a `Show` (and  an `Episode` is returned by `Season`). These ones and `Credit` are also similar to the main objects above.\n\n```python\n>>> show = next(isle.search_show("Castle Rock"))\n```\n\nSeason:\n\n```python\n>>> season = show.seasons[0]\n\n>>> all_raw_data = season.get_all()\n\n>>> season.n_requests\n1\n```\n\nEpisode:\n\n```python\n>>> season.title\n\'Season 1\'\n\n>>> episode = season.episodes[0]\n\n>>> f"{episode.n} episode of {episode.sn} season"\n\'1 episode of 1 season\'\n\n>>> episode.title[\'US\']\n\'Severance\'\n\n>>> episode.n_requests\n1\n```\n\nCredit:\n\n```python\n>>> person, credit = episode.crew[0]\n\n>>> credit\nCredit(5b6192b09251414064012485)\n\n>>> credit.department, credit.job\n(\'Directing\', \'Director\')\n\n>>> person.name == credit.person.name\nTrue\n```\n\nThere are a few objects such as `Language`, `Country`, `Genre`, `Keyword` and `Vote`. They are just [`NamedTuple`](https://docs.python.org/3/library/typing.html#typing.NamedTuple)-like objects.\n\n```python\n>>> movie = isle.Movie(18148)\n\n>>> isinstance(movie.vote, tuple)\nTrue\n\n>>> movie.vote[0] == movie.vote.average\nTrue\n```\n\nAnd there is an `Image`. It contains attributes which are the same as in the [raw dict](https://developers.themoviedb.org/3/movies/get-movie-images): `aspect_ratio`, `file_path`, `width`, `height`, etc. And the property `url` that makes a request to the TMDb API for [image configurations](https://developers.themoviedb.org/3/configuration/get-api-configuration) and returns `dict` with full URLs to the image.\n\n```python\n>>> poster = movie.posters[0]\n\n>>> poster.height poster.width, poster.file_path\n(952, 666, \'/3Zu3MojWSaV3rt5gX5fFdDO3GoF.jpg\')\n\n>>> poster.url[\'original\']\n\'https://image.tmdb.org/t/p//original/3Zu3MojWSaV3rt5gX5fFdDO3GoF.jpg\'\n\n>>> set(poster.sizes) == poster.url.keys()\nTrue\n```\n\n## ACCOUNT\n\nTo get started with a TMDb user account, create an instance of `Account` and log in with a user name and password:\n\n```python\n>>> import os\n\n>>> account = isle.Account()\n\n>>> account.login(os.getenv("TMDB_USERNAME"), os.getenv("TMDB_PASSWORD"))\n{\'success\': True, \'session_id\': \'7b2578cddffce240f5f3387527761802c0d5c1ef\'}\n```\n\nDon\'t try to seek out how to rate a movie inside a `Movie` instance or how to add a new list inside a `List` instance. All that can be done with a user account, can be done by an `Account` instance.\n\nRate:\n```python\n>>> account.rate(isle.Movie(18148), 8.5)\n{\'status_code\': 1, \'status_message\': \'Success.\'}\n\n>>> for movie in account.iter_rated_movies():\n...     print(movie)\nMovie(18148)\n\n>>> account.delete_rating(isle.Movie(18148))\n{\'status_code\': 13, \'status_message\': \'The item/record was deleted successfully.\'}\n```\n\nWatchlist:\n```python\n>>> account.add_to_watchlist(isle.Movie(18148))\n{\'status_code\': 1, \'status_message\': \'Success.\'}\n\n>>> for item in account.iter_movie_watchlist():\n...     print(item)\nMovie(18148)\n\n>>> account.remove_from_watchlist(isle.Movie(18148))\n{\'status_code\': 13, \'status_message\': \'The item/record was deleted successfully.\'}\n```\n\nAnd other things:\n\n```python\n>>> account.mark_as_favorite(isle.Movie(18148))\n{\'status_code\': 1, \'status_message\': \'Success.\'}\n\n>>> for movie in account.iter_favorite_movies():\n...     print(movie)\nMovie(18148)\n\n>>> for l in account.iter_lists():\n...     print(l)\nList(96926)\n```\n',
    'author': 'Dima Koskin',
    'author_email': 'dmksknn@gmail.com',
    'url': 'https://github.com/dmkskn/isle/',
    'packages': packages,
    'package_data': package_data,
    'python_requires': '>=3.6,<4.0',
}


setup(**setup_kwargs)
