pax_global_header 0000666 0000000 0000000 00000000064 14174067766 0014534 g ustar 00root root 0000000 0000000 52 comment=9da400af13b6ccd8562bdc087e4b63c762b47d00
tmdbsimple-2.9.1/ 0000775 0000000 0000000 00000000000 14174067766 0013705 5 ustar 00root root 0000000 0000000 tmdbsimple-2.9.1/.github/ 0000775 0000000 0000000 00000000000 14174067766 0015245 5 ustar 00root root 0000000 0000000 tmdbsimple-2.9.1/.github/workflows/ 0000775 0000000 0000000 00000000000 14174067766 0017302 5 ustar 00root root 0000000 0000000 tmdbsimple-2.9.1/.github/workflows/python-package.yml 0000664 0000000 0000000 00000003066 14174067766 0022744 0 ustar 00root root 0000000 0000000 # This workflow will install Python dependencies, run lint, execute tests, and
# upload coverage with a variety of Python versions.
name: build
on:
push:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
pip install pytest
pip install pytest-cov
pip install codecov
pip install requests
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
env:
TMDB_API_KEY: ${{ secrets.TMDB_API_KEY }}
TMDB_USERNAME: ${{ secrets.TMDB_USERNAME }}
TMDB_PASSWORD: ${{ secrets.TMDB_PASSWORD }}
TMDB_SESSION_ID: ${{ secrets.TMDB_SESSION_ID }}
run: |
pytest --cov=tmdbsimple --cov-report term-missing --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
name: codecov-tmdbsimple
tmdbsimple-2.9.1/.github/workflows/python-publish.yml 0000664 0000000 0000000 00000001271 14174067766 0023013 0 ustar 00root root 0000000 0000000 # This workflows will upload tmdbsimple to PyPI using Twine when a tag
# (release) is pushed.
name: pypi
on:
push:
tags:
- '*'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
tmdbsimple-2.9.1/.gitignore 0000664 0000000 0000000 00000000263 14174067766 0015676 0 ustar 00root root 0000000 0000000 # Python files
*.py[cod]
*.py.swo
*.egg-info
__pycache__
build
dist
# Make files
Makefile
# Build files
.coverage
coverage.xml
htmlcov
# Editor files
## Vim files
.*.swp
.idea
tmdbsimple-2.9.1/LICENSE 0000664 0000000 0000000 00000104461 14174067766 0014720 0 ustar 00root root 0000000 0000000 GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
{one line to give the program's name and a brief idea of what it does.}
Copyright (C) {year} {name of author}
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
{project} Copyright (C) {year} {fullname}
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
.
tmdbsimple-2.9.1/README.md 0000664 0000000 0000000 00000013632 14174067766 0015171 0 ustar 00root root 0000000 0000000 tmdbsimple
==========




A wrapper for The Movie Database API v3
---------------------------------------
*tmdbsimple* is a wrapper, written in Python, for The Movie Database (TMDb) API
v3. By calling the functions available in *tmdbsimple* you can simplify your
code and easily access a vast amount of movie, tv, and cast data. To learn
more about The Movie Database API, check out the [overview](
http://www.themoviedb.org/documentation/api) and [documentation](
https://developers.themoviedb.org/3).
Features
--------
- COMPLETELY UPDATED AND FULLY TESTED.
- Supports only [Python versions with TLS
1.2](http://pyfound.blogspot.com/2017/01/time-to-upgrade-your-python-tls-v12.html).
Keep it simple!
- Tested with Python 3.6, 3.7, and 3.8.
- One-to-one mapping between *tmdbsimple* methods and TMDb endpoints.
- Implements all TMDb methods, including Accounts and Authentication.
- Easy to access data using Python class attributes.
- Easy to experiment with *tmdbsimple* functions inside the Python interpreter.
- Code tested with unittests. Refer to the unittest code for method call syntax.
Installation
------------
*tmdbsimple* is available on the Python Package Index (PyPI) at
https://pypi.python.org/pypi/tmdbsimple.
You can install *tmdbsimple* using one of the following techniques.
- Use pip:
```
pip install tmdbsimple
```
- Download the .zip or .tar.gz file from PyPI and install it yourself
- Download the [source from Github](http://github.com/celiao/tmdbsimple) and
install it yourself
If you install it yourself, also install
[requests](https://requests.readthedocs.io/en/master/).
API Key
-------
You will need an API key to The Movie Database to access the API. To obtain a
key, follow these steps:
1) Register for and verify an [account](https://www.themoviedb.org/account/signup).
2) [Log into](https://www.themoviedb.org/login) your account.
3) Select the API section on left side of your account page.
4) Click on the link to generate a new API key and follow the instructions.
Examples
--------
Once you have the *tmdbsimple* package installed and a TMDb API key, you can
start to play with the data.
First, import the library and assign your API_KEY.
```python
import tmdbsimple as tmdb
tmdb.API_KEY = 'YOUR_API_KEY_HERE'
```
_Optionally_, set a timeout for requests. See [here](https://docs.python-requests.org/en/master/user/advanced/#timeouts) for more info.
```python
tmdb.REQUESTS_TIMEOUT = 5 # seconds, for both connect and read
```
or
```python
tmdb.REQUESTS_TIMEOUT = (2, 5) # seconds, for connect and read specifically
```
_Optionally_, configure the library to use your own REQUESTS_SESSION. See [here](https://docs.python-requests.org/en/master/user/advanced/#session-objects) for more info.
```python
import requests
tmdb.REQUESTS_SESSION = requests.Session()
```
To communicate with The Movie Database API, create an instance of one of the
object types, call one of the methods on the instance, and access the instance
attributes. Use keys to access the values of attributes that are dictionaries.
In this example, we create a movie instance for 'The Matrix' and determine the
budget and certification.
```python
>>> movie = tmdb.Movies(603)
>>> response = movie.info()
>>> movie.title
'The Matrix'
>>> movie.budget
63000000
>>> response = movie.releases()
>>> for c in movie.countries:
... if c['iso_3166_1'] == 'US':
... print(c['certification'])
...
'R'
```
Let's play with the interface a bit more. Suppose you and your friend are
arguing over which movie in the Bourne series was most popular. Your friend
says the first in a series is always most popular. You disagree.
```python
>>> search = tmdb.Search()
>>> response = search.movie(query='The Bourne')
>>> for s in search.results:
... print(s['title'], s['id'], s['release_date'], s['popularity'])
...
The Bourne Ultimatum 2503 2007-08-03 55.2447062124256
The Bourne Supremacy 2502 2004-07-23 43.4553609681985
The Bourne Identity 2501 2002-06-06 38.5531563780592
The Bourne Legacy 49040 2012-08-10 9.90635210153143
The Bourne Identity 8677 1988-05-08 1.53988446573129
Bette Bourne: It Goes with the Shoes 179304 0.23
```
You are correct! Now you claim the producers should be able to make sequels
cheaper, based on what they learned from making the first movie. To be fair,
you compute the budget per minute of runtime. Your friend disagrees, claiming
the producers spend more money trying to out do the previous sequel.
```python
>>> identity = tmdb.Movies(2501)
>>> response = identity.info()
>>> identity.budget, identity.runtime
(60000000, 119)
>>> int(identity.budget/identity.runtime)
504201
>>> supremacy = tmdb.Movies(2502)
>>> response = supremacy.info()
>>> supremacy.budget, supremacy.runtime
(75000000, 108)
>>> int(supremacy.budget/supremacy.runtime)
694444
>>> ultimatum = tmdb.Movies(2503)
>>> response = ultimatum.info()
>>> ultimatum.budget, ultimatum.runtime
(70000000, 115)
>>> int(ultimatum.budget/ultimatum.runtime)
608695
```
In this case you are both correct. The third movie was cheaper than the
second, which was more expensive than the first.
You also can call one of the methods without explicitly instanciating an
object.
```python
>>> response = tmdb.Movies(603).info()
>>> response['budget']
63000000
```
If you use Authentication to access a user Account, be sure to check out
https://www.themoviedb.org/documentation/api/sessions.
If you like this wrapper, and would like access to even more movie and TV data,
check out *rtsimple* https://pypi.python.org/pypi/rtsimple, a wrapper for the
Rotten Tomatoes API.
tmdbsimple-2.9.1/setup.cfg 0000664 0000000 0000000 00000000057 14174067766 0015530 0 ustar 00root root 0000000 0000000 [flake8]
exclude = .git,__pycache__,build,dist
tmdbsimple-2.9.1/setup.py 0000664 0000000 0000000 00000002423 14174067766 0015420 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# See http://pythonhosted.org/an_example_pypi_project/setuptools.html
# See https://packaging.python.org/tutorials/packaging-projects/#uploading-your-project-to-pypi
from setuptools import setup
with open("README.md", "r") as fh:
long_description = fh.read()
setup(
name='tmdbsimple',
version='2.9.1',
author='Celia Oakley',
author_email='celia.oakley@alumni.stanford.edu',
description='A Python wrapper for The Movie Database API v3',
keywords=['movie', 'the movie database', 'movie database', 'tmdb',
'wrapper', 'database', 'themoviedb', 'moviedb', 'api'],
url='https://github.com/celiao/tmdbsimple',
download_url='https://github.com/celiao/tmdbsimple/tarball/2.9.1',
packages=['tmdbsimple'],
long_description=long_description,
long_description_content_type="text/markdown",
install_requires=['requests'],
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Topic :: Utilities",
],
)
tmdbsimple-2.9.1/tests/ 0000775 0000000 0000000 00000000000 14174067766 0015047 5 ustar 00root root 0000000 0000000 tmdbsimple-2.9.1/tests/__init__.py 0000664 0000000 0000000 00000001112 14174067766 0017153 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
"""
__init__.py
~~~~~~~~~~~
This test suite checks the methods of tmdbsimple.
Use the following command to run all the tests:
python -W ignore:ResourceWarning -m unittest discover tests
:copyright: (c) 2013-2022 by Celia Oakley.
:license: GPLv3, see LICENSE for more details.
"""
"""
Either place your API_KEY in the following constant:
"""
API_KEY = ''
"""
or include it in a keys.py file.
"""
try:
from .keys import API_KEY, USERNAME, PASSWORD, SESSION_ID
except ImportError:
pass
__all__ = ['API_KEY', 'USERNAME', 'PASSWORD', 'SESSION_ID']
tmdbsimple-2.9.1/tests/keys.py 0000664 0000000 0000000 00000001205 14174067766 0016372 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
"""
keys.py
~~~~~~~
This file contains the private keys for tmdbsimple.
See:
https://developers.themoviedb.org/3/getting-started/introduction
https://developers.themoviedb.org/3/getting-started/authentication
https://developers.themoviedb.org/3/authentication/how-do-i-generate-a-session-id
"""
import os
API_KEY = os.environ.get('TMDB_API_KEY') or ''
USERNAME = os.environ.get('TMDB_USERNAME') or ''
PASSWORD = os.environ.get('TMDB_PASSWORD') or ''
SESSION_ID = os.environ.get('TMDB_SESSION_ID') or ''
tmdbsimple-2.9.1/tests/test_account.py 0000664 0000000 0000000 00000021075 14174067766 0020121 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
"""
test_account.py
~~~~~~~~~~~~~~~
This test suite checks the methods of the Account class of tmdbsimple.
Created by Celia Oakley on 2013-11-05
:copyright: (c) 2013-2022 by Celia Oakley.
:license: GPLv3, see LICENSE for more details.
"""
import unittest
import tmdbsimple as tmdb
from tests import API_KEY, SESSION_ID, USERNAME, PASSWORD
tmdb.API_KEY = API_KEY
"""
Constants
"""
MOVIETITLE = 'The Brother from Another Planet'
TVTITLE = 'Breaking Bad'
FAVORITE_MOVIE_ID = 62211
WATCHLIST_MEDIA_ID = 11
LIST_ID = '509ec17b19c2950a0600050d'
LIST_CREATED_BY = 'travisbell'
LIST_MOVIE_ID = 76203 # Argo
LIST_NAME = 'My newly created list'
LIST_DESCRIPTION = 'No duplicates here'
LIST_LANGUAGE = 'de'
LIST_ITEM_MEDIA_ID = 550
"""
Status codes and messages
"""
SUCCESS_PERIOD = 'The item/record was created successfully.'
SUCCESSFUL_UPDATE = 12
SUCCESSFUL_REMOVE_ITEM = 13
SUCCESSFUL_DELETE = 12
class AccountTestCase(unittest.TestCase):
# run this test with a valid session_id and authenticated account
def test_account_info(self):
username = USERNAME
account = tmdb.Account(SESSION_ID)
account.info()
self.assertEqual(account.username, username)
def test_account_lists(self):
account = tmdb.Account(SESSION_ID)
account.info() # to set account.id
account.lists()
self.assertTrue(hasattr(account, 'results'))
def test_account_favorite_movies(self):
movietitle = MOVIETITLE
account = tmdb.Account(SESSION_ID)
account.info() # to set account.id
account.favorite_movies()
self.assertEqual(account.results[0]['title'], movietitle)
def test_account_favorite_tv(self):
tvtitle = TVTITLE
account = tmdb.Account(SESSION_ID)
account.info() # to set account.id
account.favorite_tv()
self.assertEqual(account.results[0]['name'], tvtitle)
def test_account_favorite(self):
status_code = SUCCESSFUL_UPDATE
account = tmdb.Account(SESSION_ID)
account.info() # to set account.id
kwargs = {
'media_type': 'movie',
'movie_id': FAVORITE_MOVIE_ID,
'favorite': True,
}
account.favorite(**kwargs)
self.assertEqual(account.status_code, status_code)
def test_account_rated_movies(self):
account = tmdb.Account(SESSION_ID)
account.info() # to set account.id
kwargs = {'page': 1, 'sort_by': 'created_at.asc'}
account.rated_movies(**kwargs)
self.assertTrue(hasattr(account, 'results'))
def test_account_rated_tv(self):
account = tmdb.Account(SESSION_ID)
account.info() # to set account.id
kwargs = {'page': 1, 'sort_by': 'created_at.asc'}
account.rated_tv(**kwargs)
self.assertTrue(hasattr(account, 'results'))
def test_account_rated_tv_episodes(self):
account = tmdb.Account(SESSION_ID)
account.info() # to set account.id
kwargs = {'page': 1, 'sort_by': 'created_at.asc'}
account.rated_tv_episodes(**kwargs)
self.assertTrue(hasattr(account, 'results'))
def test_account_watchlist_movies(self):
movietitle = MOVIETITLE
account = tmdb.Account(SESSION_ID)
account.info() # to set account.id
kwargs = {'page': 1, 'sort_by': 'created_at.asc'}
account.watchlist_movies(**kwargs)
self.assertEqual(account.results[0]['title'], movietitle)
def test_account_watchlist_tv(self):
tvtitle = TVTITLE
account = tmdb.Account(SESSION_ID)
account.info() # to set account.id
kwargs = {'page': 1, 'sort_by': 'created_at.asc'}
account.watchlist_tv(**kwargs)
self.assertEqual(account.results[0]['name'], tvtitle)
def test_account_watchlist(self):
status_code = SUCCESSFUL_UPDATE
account = tmdb.Account(SESSION_ID)
account.info() # to set account.id
kwargs = {
'media_type': 'movie',
'media_id': WATCHLIST_MEDIA_ID,
'watchlist': 'true',
}
account.watchlist(**kwargs)
self.assertEqual(account.status_code, status_code)
class AuthenticationTestCase(unittest.TestCase):
def test_authentication_guest_session_new(self):
success = True
auth = tmdb.Authentication()
auth.guest_session_new()
self.assertEqual(auth.success, success)
def test_authentication_token_new(self):
success = True
auth = tmdb.Authentication()
auth.token_new()
self.assertEqual(auth.success, success)
# Example usage only.
# User needs to approve request token, so would error here.
# See https://developers.themoviedb.org/3/authentication/how-do-i-generate-a-session-id.
# test_authentication_session_new(self):
# kwargs = {'request_token': auth.request_token}
# success = True
# auth = tmdb.Authentication()
# response = auth.session_new(**kwargs)
# self.assertEqual(auth.success, success)
# test_authentication_token_validate_with_login(self):
kwargs = {
'request_token': auth.request_token,
'username': USERNAME,
'password': PASSWORD,
}
success = True
auth = tmdb.Authentication()
auth.token_validate_with_login(**kwargs)
self.assertEqual(auth.success, success)
# Example usage only.
# Don't want to delete session every time test is run.
# test_session_delete(self):
# kwargs = {'session_id': SESSION_ID}
# success = True
# auth = tmdb.Authentication()
# response = auth.session_delete(**kwargs)
# self.assertEqual(auth.success, success)
class GuestSessionsTestCase(unittest.TestCase):
def test_guest_sessions_rated_movies(self):
# get a guest session id
auth = tmdb.Authentication()
auth.guest_session_new()
guest_session_id = auth.guest_session_id
# get a list of rated movies for the guest session id
guest_session = tmdb.GuestSessions(guest_session_id)
guest_session.rated_movies()
self.assertTrue(hasattr(guest_session, 'results'))
def test_guest_sessions_rated_tv(self):
# get a guest session id
auth = tmdb.Authentication()
auth.guest_session_new()
guest_session_id = auth.guest_session_id
# get a list of rated tv shows for the guest session id
guest_session = tmdb.GuestSessions(guest_session_id)
guest_session.rated_tv()
self.assertTrue(hasattr(guest_session, 'results'))
def test_guest_sessions_rated_tv_episodes(self):
# get a guest session id
auth = tmdb.Authentication()
auth.guest_session_new()
guest_session_id = auth.guest_session_id
# get a list of rated tv episodes for the guest session id
guest_session = tmdb.GuestSessions(guest_session_id)
guest_session.rated_tv_episodes()
self.assertTrue(hasattr(guest_session, 'results'))
class ListsTestCase(unittest.TestCase):
def test_lists_info(self):
id = LIST_ID
created_by = LIST_CREATED_BY
lst = tmdb.Lists(id)
lst.info()
self.assertEqual(lst.created_by, created_by)
def test_lists_item_status(self):
id = LIST_ID
movie_id = LIST_MOVIE_ID
lst = tmdb.Lists(id)
lst.item_status(movie_id=movie_id)
self.assertTrue(hasattr(lst, 'item_present'))
def test_lists_create_add_remove_clear_delete(self):
kwargs = {
'name': LIST_NAME,
'description': LIST_DESCRIPTION,
'language': LIST_LANGUAGE,
}
status_message = SUCCESS_PERIOD
lst = tmdb.Lists(0, SESSION_ID)
lst.list_create(**kwargs)
self.assertEqual(lst.status_message, status_message)
status_code = SUCCESSFUL_UPDATE
lst.add_item(media_id=LIST_ITEM_MEDIA_ID)
self.assertEqual(lst.status_code, status_code)
status_code = SUCCESSFUL_REMOVE_ITEM
lst.remove_item(media_id=LIST_ITEM_MEDIA_ID)
self.assertEqual(lst.status_code, status_code)
status_code = SUCCESSFUL_UPDATE
lst.list_clear(confirm='true')
self.assertEqual(lst.status_code, status_code)
# TODO: add list_delete check when list delete bug is fixed:
# https://www.themoviedb.org/talk/5e7bb85aeec4f30018aa327c#5f0b5ff91f98d100361f3037.
# Deletes list, but returns 500 error rather than 201.
# status_code = SUCCESSFUL_DELETE
# lst.list_delete()
# self.assertEqual(lst.status_code, status_code)
tmdbsimple-2.9.1/tests/test_base.py 0000664 0000000 0000000 00000003601 14174067766 0017372 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
"""
test_base.py
~~~~~~~~~~~~~~~
This test suite checks the methods of the TMDB class of tmdbsimple.
Created by Celia Oakley on 2018-01-06
:copyright: (c) 2018-2022 by Celia Oakley.
:license: GPLv3, see LICENSE for more details.
"""
import unittest
import tmdbsimple as tmdb
from tests import API_KEY
tmdb.API_KEY = API_KEY
"""
Constants
"""
MOVIE_ID = 103332
MOVIEQUERY1 = 'Matrix'
MOVIEQUERY2 = 'Star Wars'
MOVIEQUERY3 = 'Kind'
class TMDBTestCase(unittest.TestCase):
# We want to be able to call methods multiple times.
# If a method returns a dict with a key of the same name as the method,
# e.g., Movies.keywords(), an attribute won't be set.
# Confirm for this case that the method can be called again.
def test_tmdb_set_attrs_to_values_method_equals_attribute(self):
id = MOVIE_ID
movie = tmdb.Movies(id)
movie.keywords()
raised = False
try:
movie.keywords()
except Exception:
raised = True
self.assertFalse(raised)
# Confirm for multiple calls to the same method with different arguments,
# that the attributes are updated.
def test_tmdb_set_attrs_to_values_attribute_multiple_calls(self):
search = tmdb.Search()
search.movie(query=MOVIEQUERY1)
title1 = search.results[0]['original_title']
search.movie(query=MOVIEQUERY2)
title2 = search.results[0]['original_title']
self.assertNotEqual(title1, title2)
# Confirm boolean parameters are handled properly in _get_params().
def test_tmdb_get_params_bool(self):
search = tmdb.Search()
search.movie(query=MOVIEQUERY3, include_adult=True)
total_results1 = search.total_results
search.movie(query=MOVIEQUERY3, include_adult='true')
total_results2 = search.total_results
self.assertEqual(total_results1, total_results2)
tmdbsimple-2.9.1/tests/test_changes.py 0000664 0000000 0000000 00000001474 14174067766 0020076 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
"""
test_changes.py
~~~~~~~~~~~~~~~
This test suite checks the methods of the Changes class of tmdbsimple.
Created by Celia Oakley on 2013-11-05
:copyright: (c) 2013-2022 by Celia Oakley.
:license: GPLv3, see LICENSE for more details.
"""
import unittest
import tmdbsimple as tmdb
from tests import API_KEY
tmdb.API_KEY = API_KEY
class ChangesTestCase(unittest.TestCase):
def test_changes_movie(self):
changes = tmdb.Changes()
changes.movie()
self.assertTrue(hasattr(changes, 'results'))
def test_changes_tv(self):
change = tmdb.Changes()
change.tv()
self.assertTrue(hasattr(change, 'results'))
def test_changes_person(self):
change = tmdb.Changes()
change.person()
self.assertTrue(hasattr(change, 'results'))
tmdbsimple-2.9.1/tests/test_configuration.py 0000664 0000000 0000000 00000007140 14174067766 0021331 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
"""
test_configuration.py
~~~~~~~~~~~~~~~~~~~~~
This test suite checks the methods of the Configuration class of tmdbsimple.
Created by Celia Oakley on 2013-11-05
:copyright: (c) 2013-2022 by Celia Oakley.
:license: GPLv3, see LICENSE for more details.
"""
import unittest
import re
import tmdbsimple as tmdb
from tests import API_KEY
tmdb.API_KEY = API_KEY
"""
Constants
"""
CHANGE_KEYS = ['adult', 'air_date', 'also_known_as', 'alternative_titles',
'biography', 'birthday', 'budget', 'cast', 'certifications',
'character_names', 'created_by', 'crew', 'deathday', 'episode',
'episode_number', 'episode_run_time', 'freebase_id', 'freebase_mid',
'general', 'genres', 'guest_stars', 'homepage', 'images', 'imdb_id',
'languages', 'name', 'network', 'origin_country', 'original_name',
'original_title', 'overview', 'parts', 'place_of_birth', 'plot_keywords',
'production_code', 'production_companies', 'production_countries',
'releases', 'revenue', 'runtime', 'season', 'season_number',
'season_regular', 'spoken_languages', 'status', 'tagline', 'title',
'translations', 'tvdb_id', 'tvrage_id', 'type', 'video', 'videos'
]
ISO_3166_1 = 'iso_3166_1'
ANDORRA = 'AD'
ISO_639_1 = 'iso_639_1'
NO_LANGUAGE = 'xx'
AFRIKAANS_SA = 'af-ZA'
class ConfigurationTestCase(unittest.TestCase):
def test_configuration_info(self):
change_keys = CHANGE_KEYS
config = tmdb.Configuration()
config.info()
self.assertEqual(config.change_keys, change_keys)
# Also test that bad API_KEY results in exception
# Restore key for sequential tests
api_key_save = tmdb.API_KEY
tmdb.API_KEY = 0
config = tmdb.Configuration()
self.assertRaises(tmdb.APIKeyError, config.info)
tmdb.API_KEY = api_key_save
def test_configuration_countries(self):
config = tmdb.Configuration()
response = config.countries()
# Countries are two capital letters
self.assertTrue(re.match('^[A-Z]{2}$', response[0][ISO_3166_1]))
def test_configuration_jobs(self):
config = tmdb.Configuration()
config.jobs()
self.assertTrue(hasattr(config, 'jobs'))
def test_configuration_languages(self):
config = tmdb.Configuration()
response = config.languages()
# Languages are two lowercase letters
self.assertTrue(re.match('^[a-z]{2}$', response[0][ISO_639_1]))
def test_configuration_primary_translations(self):
config = tmdb.Configuration()
response = config.primary_translations()
# First primary translation is Afrikaans (South Africa)
self.assertEqual(response[0], AFRIKAANS_SA)
def test_configuration_timezones(self):
config = tmdb.Configuration()
response = config.timezones()
# First country is Andorra
self.assertEqual(response[0][ISO_3166_1], ANDORRA)
class CertificationsTestCase(unittest.TestCase):
def test_certifications_movie_list(self):
certifications = tmdb.Certifications()
certifications.movie_list()
self.assertTrue(hasattr(certifications, 'certifications'))
def test_certifications_tv_list(self):
certifications = tmdb.Certifications()
certifications.tv_list()
self.assertTrue(hasattr(certifications, 'certifications'))
def test_certifications_list(self):
certifications = tmdb.Certifications()
certifications.list()
self.assertTrue(hasattr(certifications, 'certifications'))
tmdbsimple-2.9.1/tests/test_discover.py 0000664 0000000 0000000 00000003436 14174067766 0020304 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
"""
test_discover.py
~~~~~~~~~~~~~~~~
This test suite checks the methods of the Discover class of tmdbsimple.
Created by Celia Oakley on 2013-11-05
:copyright: (c) 2013-2022 by Celia Oakley.
:license: GPLv3, see LICENSE for more details.
"""
import unittest
import tmdbsimple as tmdb
from tests import API_KEY
tmdb.API_KEY = API_KEY
"""
Constants
"""
DISCOVER_YEAR = 2004
DISCOVER_VOTE_AVERAGE_GTE = 5
DISCOVER_VOTE_AVERAGE_LTE = 5
class DiscoverTestCase(unittest.TestCase):
def test_discover_movie(self):
discover = tmdb.Discover()
discover.movie(page=1, year=DISCOVER_YEAR)
self.assertTrue(hasattr(discover, 'results'))
# Test dot usage
def test_discover_movie_dot_gte(self):
discover = tmdb.Discover()
kwargs = {'page': 2, 'vote_average.gte': DISCOVER_VOTE_AVERAGE_GTE}
discover.movie(**kwargs)
self.assertTrue(hasattr(discover, 'results'))
# Test underscore usage
def test_discover_movie_underscore_gte(self):
discover = tmdb.Discover()
discover.movie(page=2, vote_average_gte=DISCOVER_VOTE_AVERAGE_GTE)
self.assertTrue(hasattr(discover, 'results'))
def test_discover_movie_underscore_lte(self):
discover = tmdb.Discover()
discover.movie(page=2, vote_average_lte=DISCOVER_VOTE_AVERAGE_LTE)
self.assertTrue(hasattr(discover, 'results'))
def test_discover_tv_underscore_gte(self):
discover = tmdb.Discover()
discover.tv(page=2, vote_average_gte=DISCOVER_VOTE_AVERAGE_GTE)
self.assertTrue(hasattr(discover, 'results'))
def test_discover_tv_underscore_lte(self):
discover = tmdb.Discover()
discover.tv(page=2, vote_average_lte=DISCOVER_VOTE_AVERAGE_LTE)
self.assertTrue(hasattr(discover, 'results'))
tmdbsimple-2.9.1/tests/test_find.py 0000664 0000000 0000000 00000002205 14174067766 0017377 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
"""
test_find.py
~~~~~~~~~~~~
This test suite checks the methods of the Find class of tmdbsimple.
Created by Celia Oakley on 2013-11-05
:copyright: (c) 2013-2022 by Celia Oakley.
:license: GPLv3, see LICENSE for more details.
"""
import unittest
import tmdbsimple as tmdb
from tests import API_KEY
tmdb.API_KEY = API_KEY
"""
Constants
"""
FIND_MOVIE_ID = 'tt0266543'
FIND_SOURCE = 'imdb_id'
FIND_TITLE = 'Finding Nemo'
TRENDING_MEDIA_TYPE = 'movie'
TRENDING_TIME_WINDOW = 'week'
class FindTestCase(unittest.TestCase):
def test_find_info(self):
id = FIND_MOVIE_ID
external_source = FIND_SOURCE
title = FIND_TITLE
find = tmdb.Find(id)
find.info(external_source=external_source)
self.assertEqual(find.movie_results[0]['title'], title)
class TrendingTestCase(unittest.TestCase):
def test_trending_info(self):
media_type = TRENDING_MEDIA_TYPE
time_window = TRENDING_TIME_WINDOW
trend = tmdb.Trending(media_type=media_type, time_window=time_window)
trend.info()
self.assertEqual(trend.results[0]['media_type'], TRENDING_MEDIA_TYPE)
tmdbsimple-2.9.1/tests/test_genres.py 0000664 0000000 0000000 00000001561 14174067766 0017746 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
"""
test_genres.py
~~~~~~~~~~~~~~
This test suite checks the methods of the Genres class of tmdbsimple.
Created by Celia Oakley on 2013-11-05
:copyright: (c) 2013-2022 by Celia Oakley.
:license: GPLv3, see LICENSE for more details.
"""
import unittest
import tmdbsimple as tmdb
from tests import API_KEY
tmdb.API_KEY = API_KEY
"""
Constants
"""
GENRE_ID = 18
class GenresTestCase(unittest.TestCase):
def test_genres_movie_list(self):
genre = tmdb.Genres()
genre.movie_list()
self.assertTrue(hasattr(genre, 'genres'))
def test_genres_tv_list(self):
genre = tmdb.Genres()
genre.tv_list()
self.assertTrue(hasattr(genre, 'genres'))
def test_genres_movies(self):
id = GENRE_ID
genre = tmdb.Genres(id)
genre.movies()
self.assertTrue(hasattr(genre, 'results'))
tmdbsimple-2.9.1/tests/test_movies.py 0000664 0000000 0000000 00000016451 14174067766 0017771 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
"""
test_movies.py
~~~~~~~~~~~~~~
This test suite checks the methods of the Movies class of tmdbsimple.
Created by Celia Oakley on 2013-11-05
:copyright: (c) 2013-2022 by Celia Oakley.
:license: GPLv3, see LICENSE for more details.
"""
import unittest
import tmdbsimple as tmdb
from tests import API_KEY, SESSION_ID
tmdb.API_KEY = API_KEY
"""
Constants
"""
MOVIE_ID = 103332
MOVIE_TITLE = 'Ruby Sparks'
MOVIE_TITLE_GERMAN = 'Ruby Sparks - Meine fabelhafte Freundin'
MOVIE_ID_ALTERNATIVE = 550
RATING = 7.5
COLLECTION_ID = 10
COLLECTION_NAME = 'Star Wars Collection'
COMPANY_ID = 1
COMPANY_NAME = 'Lucasfilm'
KEYWORD_ID = 1721
KEYWORD_NAME = 'fight'
REVIEW_ID = '5013bc76760ee372cb00253e'
REVIEW_AUTHOR = 'Chris'
"""
Status Codes
"""
SUCCESSFUL_CREATE = 1
SUCCESSFUL_UPDATE = 12
SUCCESSFUL_DELETE = 13
class MoviesTestCase(unittest.TestCase):
def test_movies_info(self):
id = MOVIE_ID
title = MOVIE_TITLE
movie = tmdb.Movies(id)
movie.info()
self.assertEqual(movie.title, title)
def test_movies_info_with_params(self):
id = MOVIE_ID
title = MOVIE_TITLE_GERMAN
movie = tmdb.Movies(id)
movie.info(language='de')
self.assertEqual(movie.title, title)
def test_movies_account_states(self):
id = MOVIE_ID_ALTERNATIVE
movie = tmdb.Movies(id)
movie.account_states(session_id=SESSION_ID)
self.assertTrue(hasattr(movie, 'favorite'))
def test_movies_alternative_titles(self):
id = MOVIE_ID_ALTERNATIVE
movie = tmdb.Movies(id)
movie.alternative_titles()
self.assertTrue(hasattr(movie, 'titles'))
def test_movies_changes(self):
id = MOVIE_ID
movie = tmdb.Movies(id)
movie.changes()
self.assertTrue(hasattr(movie, 'changes'))
def test_movies_credits(self):
id = MOVIE_ID
movie = tmdb.Movies(id)
movie.credits()
self.assertTrue(hasattr(movie, 'cast'))
def test_movies_external_ids(self):
id = MOVIE_ID
movie = tmdb.Movies(id)
movie.external_ids()
self.assertTrue(hasattr(movie, 'imdb_id'))
def test_movies_images(self):
id = MOVIE_ID
movie = tmdb.Movies(id)
movie.images()
self.assertTrue(hasattr(movie, 'backdrops'))
def test_movies_keywords(self):
id = MOVIE_ID
movie = tmdb.Movies(id)
movie.keywords()
self.assertTrue(hasattr(movie, 'keywords'))
def test_movies_lists(self):
id = MOVIE_ID
movie = tmdb.Movies(id)
movie.lists()
self.assertTrue(hasattr(movie, 'results'))
def test_movies_recommendations(self):
id = MOVIE_ID
movie = tmdb.Movies(id)
movie.recommendations()
self.assertTrue(hasattr(movie, 'results'))
def test_movies_release_dates(self):
id = MOVIE_ID
movie = tmdb.Movies(id)
movie.release_dates()
self.assertTrue(hasattr(movie, 'results'))
def test_movies_reviews(self):
id = MOVIE_ID
movie = tmdb.Movies(id)
movie.reviews()
self.assertTrue(hasattr(movie, 'results'))
def test_movies_similar_movies(self):
id = MOVIE_ID_ALTERNATIVE
movie = tmdb.Movies(id)
movie.similar_movies()
self.assertTrue(hasattr(movie, 'results'))
def test_movies_translations(self):
id = MOVIE_ID_ALTERNATIVE
movie = tmdb.Movies(id)
movie.translations()
self.assertTrue(hasattr(movie, 'translations'))
def test_movies_videos(self):
id = MOVIE_ID
movie = tmdb.Movies(id)
movie.videos()
self.assertTrue(hasattr(movie, 'results'))
def test_movies_watch_providers(self):
id = MOVIE_ID
movie = tmdb.Movies(id)
movie.watch_providers()
self.assertTrue(hasattr(movie, 'results'))
def test_movies_rating_and_rating_delete(self):
status_code_create = SUCCESSFUL_CREATE
status_code_update = SUCCESSFUL_UPDATE
status_code_delete = SUCCESSFUL_DELETE
id = MOVIE_ID
movie = tmdb.Movies(id)
movie.rating(session_id=SESSION_ID, value=RATING)
self.assertTrue(movie.status_code == status_code_create
or movie.status_code == status_code_update)
movie.rating_delete(session_id=SESSION_ID)
self.assertEqual(movie.status_code, status_code_delete)
def test_movies_latest(self):
movie = tmdb.Movies()
movie.latest()
self.assertTrue(hasattr(movie, 'popularity'))
def test_movies_now_playing(self):
movie = tmdb.Movies()
movie.now_playing()
self.assertTrue(hasattr(movie, 'results'))
def test_movies_popular(self):
movie = tmdb.Movies()
movie.popular()
self.assertTrue(hasattr(movie, 'results'))
def test_movies_top_rated(self):
movie = tmdb.Movies()
movie.top_rated()
self.assertTrue(hasattr(movie, 'results'))
def test_movies_upcoming(self):
movie = tmdb.Movies()
movie.upcoming()
self.assertTrue(hasattr(movie, 'results'))
def test_movies_releases(self):
id = MOVIE_ID
movie = tmdb.Movies(id)
movie.releases()
self.assertTrue(hasattr(movie, 'countries'))
class CollectionsTestCase(unittest.TestCase):
def test_collections_info(self):
id = COLLECTION_ID
name = COLLECTION_NAME
collection = tmdb.Collections(id)
collection.info()
self.assertEqual(collection.name, name)
def test_collections_images(self):
id = COLLECTION_ID
collection = tmdb.Collections(id)
collection.images()
self.assertTrue(hasattr(collection, 'backdrops'))
def test_collections_translations(self):
id = COLLECTION_ID
collection = tmdb.Collections(id)
collection.translations()
self.assertTrue(hasattr(collection, 'translations'))
class CompaniesTestCase(unittest.TestCase):
def test_companies_info(self):
id = COMPANY_ID
name = COMPANY_NAME
company = tmdb.Companies(id)
company.info()
self.assertEqual(company.name, name)
def test_companies_alternative_names(self):
id = COMPANY_ID
company = tmdb.Companies(id)
company.alternative_names()
self.assertTrue(hasattr(company, 'results'))
def test_companies_images(self):
id = COMPANY_ID
company = tmdb.Companies(id)
company.images()
self.assertTrue(hasattr(company, 'logos'))
def test_companies_movies(self):
id = COMPANY_ID
company = tmdb.Companies(id)
company.movies()
self.assertTrue(hasattr(company, 'results'))
class KeywordsTestCase(unittest.TestCase):
def test_keywords_info(self):
id = KEYWORD_ID
name = KEYWORD_NAME
keyword = tmdb.Keywords(id)
keyword.info()
self.assertEqual(keyword.name, name)
def test_keywords_movies(self):
id = KEYWORD_ID
keyword = tmdb.Keywords(id)
keyword.movies()
self.assertTrue(hasattr(keyword, 'results'))
class ReviewsTestCase(unittest.TestCase):
def test_reviews_info(self):
id = REVIEW_ID
author = REVIEW_AUTHOR
review = tmdb.Reviews(id)
review.info()
self.assertEqual(review.author, author)
tmdbsimple-2.9.1/tests/test_people.py 0000664 0000000 0000000 00000005151 14174067766 0017746 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
"""
test_people.py
~~~~~~~~~~~~~~
This test suite checks the methods of the People class of tmdbsimple.
Created by Celia Oakley on 2013-11-05
:copyright: (c) 2013-2022 by Celia Oakley.
:license: GPLv3, see LICENSE for more details.
"""
import unittest
import tmdbsimple as tmdb
from tests import API_KEY
tmdb.API_KEY = API_KEY
"""
Constants
"""
PEOPLE_ID = 287
PEOPLE_NAME = 'Brad Pitt'
CREDITS_ID = '52542282760ee313280017f9'
CREDITS_DEPARTMENT = 'Acting'
class PeopleTestCase(unittest.TestCase):
def test_people_info(self):
id = PEOPLE_ID
name = PEOPLE_NAME
person = tmdb.People(id)
person.info()
self.assertEqual(person.name, name)
def test_people_changes(self):
id = PEOPLE_ID
person = tmdb.People(id)
person.changes()
self.assertTrue(hasattr(person, 'changes'))
def test_people_movie_credits(self):
id = PEOPLE_ID
person = tmdb.People(id)
person.movie_credits()
self.assertTrue(hasattr(person, 'cast'))
def test_people_tv_credits(self):
id = PEOPLE_ID
person = tmdb.People(id)
person.tv_credits()
self.assertTrue(hasattr(person, 'cast'))
def test_people_combined_credits(self):
id = PEOPLE_ID
person = tmdb.People(id)
person.combined_credits()
self.assertTrue(hasattr(person, 'cast'))
def test_people_external_ids(self):
id = PEOPLE_ID
person = tmdb.People(id)
person.external_ids()
self.assertTrue(hasattr(person, 'tvrage_id'))
def test_people_images(self):
id = PEOPLE_ID
person = tmdb.People(id)
person.images()
self.assertTrue(hasattr(person, 'profiles'))
def test_people_tagged_images(self):
id = PEOPLE_ID
person = tmdb.People(id)
person.tagged_images()
self.assertTrue(hasattr(person, 'results'))
def test_people_translations(self):
id = PEOPLE_ID
person = tmdb.People(id)
person.translations()
self.assertTrue(hasattr(person, 'translations'))
def test_people_latest(self):
person = tmdb.People()
person.latest()
self.assertTrue(hasattr(person, 'name'))
def test_people_popular(self):
person = tmdb.People()
person.popular()
self.assertTrue(hasattr(person, 'results'))
class CreditsTestCase(unittest.TestCase):
def test_credits_info(self):
id = CREDITS_ID
department = CREDITS_DEPARTMENT
credit = tmdb.Credits(id)
credit.info()
self.assertEqual(credit.department, department)
tmdbsimple-2.9.1/tests/test_requests_session.py 0000664 0000000 0000000 00000001402 14174067766 0022073 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
"""
test_requests_session.py
~~~~~~~~~~~~~~
This test suite checks having a user-defined REQUESTS_SESSION with tmdbsimple.
Created by Celia Oakley on 2022-01-18
:copyright: (c) 2013-2022 by Celia Oakley.
:license: GPLv3, see LICENSE for more details.
"""
import unittest
import tmdbsimple as tmdb
from tests import API_KEY
tmdb.API_KEY = API_KEY
import requests
tmdb.REQUESTS_SESSION = requests.Session() # specify an explicit session
"""
Constants
"""
MOVIE_ID = 103332
MOVIE_TITLE = 'Ruby Sparks'
class RequestsSessionTestCase(unittest.TestCase):
def test_requests_session(self):
id = MOVIE_ID
title = MOVIE_TITLE
movie = tmdb.Movies(id)
movie.info()
self.assertEqual(movie.title, title)
tmdbsimple-2.9.1/tests/test_search.py 0000664 0000000 0000000 00000003413 14174067766 0017726 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
"""
test_search.py
~~~~~~~~~~~~~~
This test suite checks the methods of the Search class of tmdbsimple.
Created by Celia Oakley on 2013-11-05
:copyright: (c) 2013-2022 by Celia Oakley.
:license: GPLv3, see LICENSE for more details.
"""
import unittest
import tmdbsimple as tmdb
from tests import API_KEY
tmdb.API_KEY = API_KEY
"""
Constants
"""
QUERY_1 = 'Club'
QUERY_2 = 'Avenger'
QUERY_3 = 'Breaking'
QUERY_4 = 'Brad Pitt'
QUERY_6 = 'Sony Pictures'
QUERY_7 = 'fight'
QUERY_8 = 'blackjack'
class SearchTestCase(unittest.TestCase):
def test_search_company(self):
query = QUERY_6
search = tmdb.Search()
search.company(query=query)
self.assertTrue(hasattr(search, 'results'))
def test_search_collection(self):
query = QUERY_2
search = tmdb.Search()
search.collection(query=query)
self.assertTrue(hasattr(search, 'results'))
def test_search_keyword(self):
query = QUERY_7
search = tmdb.Search()
search.keyword(query=query)
self.assertTrue(hasattr(search, 'results'))
def test_search_movie(self):
query = QUERY_1
search = tmdb.Search()
search.movie(query=query)
self.assertTrue(hasattr(search, 'results'))
def test_search_multi(self):
query = QUERY_8
search = tmdb.Search()
search.multi(query=query)
self.assertTrue(hasattr(search, 'results'))
def test_search_person(self):
query = QUERY_4
search = tmdb.Search()
search.person(query=query)
self.assertTrue(hasattr(search, 'results'))
def test_search_tv(self):
query = QUERY_3
search = tmdb.Search()
search.tv(query=query)
self.assertTrue(hasattr(search, 'results'))
tmdbsimple-2.9.1/tests/test_tv.py 0000664 0000000 0000000 00000025153 14174067766 0017117 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
"""
test_tv.py
~~~~~~~~~~
This test suite checks the methods of the Test class of tmdbsimple.
Created by Celia Oakley on 2013-11-05
:copyright: (c) 2013-2022 by Celia Oakley.
:license: GPLv3, see LICENSE for more details.
"""
import unittest
import tmdbsimple as tmdb
from tests import API_KEY, SESSION_ID
tmdb.API_KEY = API_KEY
"""
Constants
"""
TV_ID = 1396
TV_NAME = 'Breaking Bad'
TV_IMDB_ID = 'tt0903747'
RATING = 7.5
TV_SEASON_ID = 3572
TV_SEASON_NUMBER = 1
TV_SEASON_NAME = 'Season 1'
TV_SEASON_TVDB_ID = 2547
TV_EPISODE_ID = 62085
TV_EPISODE_NUMBER = 1
TV_EPISODE_NAME = 'Pilot'
TV_EPISODE_IMDB_ID = 'tt0959621'
TV_EPISODE_GROUP_ID = '5acf93e60e0a26346d0000ce'
NETWORK_ID = 49
NETWORK_NAME = 'HBO'
"""
Status codes and messages
"""
SUCCESSFUL_CREATE = 1
SUCCESSFUL_UPDATE = 12
SUCCESSFUL_DELETE = 13
class TVTestCase(unittest.TestCase):
def test_tv_info(self):
id = TV_ID
name = TV_NAME
tv = tmdb.TV(id)
tv.info()
self.assertEqual(tv.name, name)
def test_tv_account_states(self):
id = TV_ID
tv = tmdb.TV(id)
tv.account_states(session_id=SESSION_ID)
self.assertTrue(hasattr(tv, 'rated'))
def test_tv_alternative_titles(self):
id = TV_ID
tv = tmdb.TV(id)
tv.alternative_titles()
self.assertTrue(hasattr(tv, 'results'))
def test_tv_content_ratings(self):
id = TV_ID
tv = tmdb.TV(id)
tv.content_ratings()
self.assertTrue(hasattr(tv, 'results'))
def test_tv_credits(self):
id = TV_ID
tv = tmdb.TV(id)
tv.credits()
self.assertTrue(hasattr(tv, 'cast'))
def test_tv_episode_groups(self):
id = TV_ID
tv = tmdb.TV(id)
tv.episode_groups()
self.assertTrue(hasattr(tv, 'results'))
def test_tv_external_ids(self):
id = TV_ID
imdb_id = TV_IMDB_ID
tv = tmdb.TV(id)
tv.external_ids()
self.assertEqual(tv.imdb_id, imdb_id)
def test_tv_images(self):
id = TV_ID
tv = tmdb.TV(id)
tv.images()
self.assertTrue(hasattr(tv, 'backdrops'))
def test_tv_keywords(self):
id = TV_ID
tv = tmdb.TV(id)
tv.keywords()
self.assertTrue(hasattr(tv, 'keywords'))
def test_tv_recommendations(self):
id = TV_ID
tv = tmdb.TV(id)
tv.recommendations()
self.assertTrue(hasattr(tv, 'results'))
def test_tv_reviews(self):
id = TV_ID
tv = tmdb.TV(id)
tv.reviews()
self.assertTrue(hasattr(tv, 'results'))
def test_tv_screened_theatrically(self):
id = TV_ID
tv = tmdb.TV(id)
tv.screened_theatrically()
self.assertTrue(hasattr(tv, 'results'))
def test_tv_similar(self):
id = TV_ID
tv = tmdb.TV(id)
tv.similar()
self.assertTrue(hasattr(tv, 'results'))
def test_tv_translations(self):
id = TV_ID
tv = tmdb.TV(id)
tv.translations()
self.assertTrue(hasattr(tv, 'translations'))
def test_tv_videos(self):
id = TV_ID
tv = tmdb.TV(id)
tv.videos()
self.assertTrue(hasattr(tv, 'results'))
def test_tv_watch_providers(self):
id = TV_ID
tv = tmdb.TV(id)
tv.watch_providers()
self.assertTrue(hasattr(tv, 'results'))
def test_tv_rating_and_rating_delete(self):
status_code_create = SUCCESSFUL_CREATE
status_code_update = SUCCESSFUL_UPDATE
status_code_delete = SUCCESSFUL_DELETE
id = TV_ID
tv = tmdb.TV(id)
tv.rating(session_id=SESSION_ID, value=RATING)
self.assertTrue(tv.status_code, status_code_create
or tv.status_code == status_code_update)
tv.rating_delete(session_id=SESSION_ID)
self.assertEqual(tv.status_code, status_code_delete)
def test_tv_latest(self):
tv = tmdb.TV()
tv.latest()
self.assertTrue(hasattr(tv, 'first_air_date'))
def test_tv_airing_today(self):
tv = tmdb.TV()
tv.airing_today()
self.assertTrue(hasattr(tv, 'results'))
def test_tv_on_the_air(self):
tv = tmdb.TV()
tv.on_the_air()
self.assertTrue(hasattr(tv, 'results'))
def test_tv_popular(self):
tv = tmdb.TV()
tv.popular()
self.assertTrue(hasattr(tv, 'results'))
def test_tv_top_rated(self):
tv = tmdb.TV()
tv.top_rated()
self.assertTrue(hasattr(tv, 'results'))
class TVSeasonsTestCase(unittest.TestCase):
def test_tv_seasons_info(self):
series_id = TV_SEASON_ID
season_number = TV_SEASON_NUMBER
name = TV_SEASON_NAME
tv_seasons = tmdb.TV_Seasons(series_id, season_number)
tv_seasons.info()
self.assertEqual(tv_seasons.name, name)
def test_tv_seasons_account_states(self):
series_id = TV_SEASON_ID
season_number = TV_SEASON_NUMBER
tv_seasons = tmdb.TV_Seasons(series_id, season_number)
tv_seasons.account_states(session_id=SESSION_ID)
self.assertTrue(hasattr(tv_seasons, 'results'))
def test_tv_seasons_credits(self):
series_id = TV_SEASON_ID
season_number = TV_SEASON_NUMBER
tv_seasons = tmdb.TV_Seasons(series_id, season_number)
tv_seasons.credits()
self.assertTrue(hasattr(tv_seasons, 'crew'))
def test_tv_seasons_external_ids(self):
series_id = TV_SEASON_ID
season_number = TV_SEASON_NUMBER
tvdb_id = TV_SEASON_TVDB_ID
tv_seasons = tmdb.TV_Seasons(series_id, season_number)
tv_seasons.external_ids()
self.assertEqual(tv_seasons.tvdb_id, tvdb_id)
def test_tv_seasons_images(self):
series_id = TV_SEASON_ID
season_number = TV_SEASON_NUMBER
tv_seasons = tmdb.TV_Seasons(series_id, season_number)
tv_seasons.images()
self.assertTrue(hasattr(tv_seasons, 'posters'))
def test_tv_seasons_videos(self):
series_id = TV_SEASON_ID
season_number = TV_SEASON_NUMBER
tv_seasons = tmdb.TV_Seasons(series_id, season_number)
tv_seasons.videos()
self.assertTrue(hasattr(tv_seasons, 'results'))
class TVEpisodesTestCase(unittest.TestCase):
def test_tv_episodes_info(self):
series_id = TV_ID
season_number = TV_SEASON_NUMBER
episode_number = TV_EPISODE_NUMBER
name = TV_EPISODE_NAME
tv_episode = tmdb.TV_Episodes(series_id, season_number, episode_number)
tv_episode.info()
self.assertEqual(tv_episode.name, name)
def test_tv_episodes_account_states(self):
series_id = TV_ID
season_number = TV_SEASON_NUMBER
episode_number = TV_EPISODE_NUMBER
tv_episode = tmdb.TV_Episodes(series_id, season_number, episode_number)
tv_episode.account_states(session_id=SESSION_ID)
self.assertTrue(hasattr(tv_episode, 'rated'))
def test_tv_episodes_credits(self):
series_id = TV_ID
season_number = TV_SEASON_NUMBER
episode_number = TV_EPISODE_NUMBER
tv_episode = tmdb.TV_Episodes(series_id, season_number, episode_number)
tv_episode.credits()
self.assertTrue(hasattr(tv_episode, 'guest_stars'))
def test_tv_episodes_external_ids(self):
series_id = TV_ID
season_number = TV_SEASON_NUMBER
episode_number = TV_EPISODE_NUMBER
imdb_id = TV_EPISODE_IMDB_ID
tv_episode = tmdb.TV_Episodes(series_id, season_number, episode_number)
tv_episode.external_ids()
self.assertEqual(tv_episode.imdb_id, imdb_id)
def test_tv_episodes_images(self):
series_id = TV_ID
season_number = TV_SEASON_NUMBER
episode_number = TV_EPISODE_NUMBER
tv_episode = tmdb.TV_Episodes(series_id, season_number, episode_number)
tv_episode.images()
self.assertTrue(hasattr(tv_episode, 'stills'))
def test_tv_episodes_translations(self):
series_id = TV_ID
season_number = TV_SEASON_NUMBER
episode_number = TV_EPISODE_NUMBER
tv_episode = tmdb.TV_Episodes(series_id, season_number, episode_number)
tv_episode.translations()
self.assertTrue(hasattr(tv_episode, 'translations'))
def test_tv_episodes_rating(self):
status_code_create = SUCCESSFUL_CREATE
status_code_update = SUCCESSFUL_UPDATE
status_code_delete = SUCCESSFUL_DELETE
series_id = TV_ID
season_number = TV_SEASON_NUMBER
episode_number = TV_EPISODE_NUMBER
tv_episode = tmdb.TV_Episodes(series_id, season_number, episode_number)
tv_episode.rating(session_id=SESSION_ID, value=RATING)
self.assertTrue(tv_episode.status_code == status_code_create
or tv_episode.status_code == status_code_update)
tv_episode.rating_delete(session_id=SESSION_ID)
self.assertEqual(tv_episode.status_code, status_code_delete)
def test_tv_episodes_videos(self):
series_id = TV_ID
season_number = TV_SEASON_NUMBER
episode_number = TV_EPISODE_NUMBER
tv_episode = tmdb.TV_Episodes(series_id, season_number, episode_number)
tv_episode.videos()
self.assertTrue(hasattr(tv_episode, 'results'))
class TVEpisodeGroupsTestCase(unittest.TestCase):
def test_tv_episode_groups_info(self):
tv_episode_group_id = TV_EPISODE_GROUP_ID
tv_episode_group = tmdb.TV_Episode_Groups(tv_episode_group_id)
tv_episode_group.info()
self.assertTrue(hasattr(tv_episode_group, 'groups'))
class TVChangesTestCase(unittest.TestCase):
def test_series_changes(self):
id = TV_ID
tv_changes = tmdb.TV_Changes(id)
tv_changes.series()
self.assertTrue(hasattr(tv_changes, 'changes'))
def test_season_changes(self):
id = TV_SEASON_ID
tv_changes = tmdb.TV_Changes(id)
tv_changes.season()
self.assertTrue(hasattr(tv_changes, 'changes'))
def test_episode_changes(self):
id = TV_EPISODE_ID
tv_changes = tmdb.TV_Changes(id)
tv_changes.episode()
self.assertTrue(hasattr(tv_changes, 'changes'))
class NetworksTestCase(unittest.TestCase):
def test_networks_info(self):
id = NETWORK_ID
name = NETWORK_NAME
network = tmdb.Networks(id)
network.info()
self.assertEqual(network.name, name)
def test_networks_alternative_names(self):
id = NETWORK_ID
network = tmdb.Networks(id)
network.alternative_names()
self.assertTrue(hasattr(network, 'results'))
def test_networks_images(self):
id = NETWORK_ID
network = tmdb.Networks(id)
network.images()
self.assertTrue(hasattr(network, 'logos'))
tmdbsimple-2.9.1/tmdbsimple/ 0000775 0000000 0000000 00000000000 14174067766 0016045 5 ustar 00root root 0000000 0000000 tmdbsimple-2.9.1/tmdbsimple/__init__.py 0000664 0000000 0000000 00000003574 14174067766 0020167 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
"""
tmdbsimple
~~~~~~~~~~
*tmdbsimple* is a wrapper, written in Python, for The Movie Database (TMDb)
API v3. By calling the functions available in *tmdbsimple* you can simplify
your code and easily access a vast amount of movie, tv, and cast data. To find
out more about The Movie Database API, check out the overview page
http://www.themoviedb.org/documentation/api and documentation page
https://developers.themoviedb.org/3/getting-started
https://www.themoviedb.org/documentation/api/status-codes
:copyright: (c) 2013-2022 by Celia Oakley.
:license: GPLv3, see LICENSE for more details
"""
__title__ = 'tmdbsimple'
__version__ = '2.9.1'
__author__ = 'Celia Oakley'
__copyright__ = 'Copyright (c) 2013-2022 Celia Oakley'
__license__ = 'GPLv3'
import os
import requests
from .account import Account, Authentication, GuestSessions, Lists
from .base import APIKeyError
from .changes import Changes
from .configuration import Configuration, Certifications
from .discover import Discover
from .find import Find, Trending
from .genres import Genres
from .movies import Movies, Collections, Companies, Keywords, Reviews
from .people import People, Credits
from .search import Search
from .tv import TV, TV_Seasons, TV_Episodes, TV_Episode_Groups, TV_Changes, Networks
__all__ = ['Account', 'Authentication', 'GuestSessions', 'Lists',
'APIKeyError',
'Changes',
'Configuration', 'Certifications',
'Discover',
'Find', 'Trending',
'Genres',
'Movies', 'Collections', 'Companies', 'Keywords', 'Reviews',
'People', 'Credits'
'Search',
'TV', 'TV_Seasons', 'TV_Episodes', 'TV_Episode_Groups', 'TV_Changes', 'Networks'
]
API_KEY = os.environ.get('TMDB_API_KEY', None)
API_VERSION = '3'
REQUESTS_SESSION = None
REQUESTS_TIMEOUT = os.environ.get('TMDB_REQUESTS_TIMEOUT', None)
tmdbsimple-2.9.1/tmdbsimple/account.py 0000664 0000000 0000000 00000045204 14174067766 0020060 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
"""
tmdbsimple.account
~~~~~~~~~~~~~~~~~~
This module implements the Account, Authentication, and Lists functionality
of tmdbsimple.
Created by Celia Oakley on 2013-10-31.
:copyright: (c) 2013-2022 by Celia Oakley
:license: GPLv3, see LICENSE for more details
"""
from .base import TMDB
class Account(TMDB):
"""
Account functionality.
See: https://developers.themoviedb.org/3/account
https://www.themoviedb.org/documentation/api/sessions
"""
BASE_PATH = 'account'
URLS = {
'info': '',
'lists': '/{id}/lists',
'favorite_movies': '/{id}/favorite/movies',
'favorite_tv': '/{id}/favorite/tv',
'favorite': '/{id}/favorite',
'rated_movies': '/{id}/rated/movies',
'rated_tv': '/{id}/rated/tv',
'rated_tv_episodes': '/{id}/rated/tv/episodes',
'watchlist_movies': '/{id}/watchlist/movies',
'watchlist_tv': '/{id}/watchlist/tv',
'watchlist': '/{id}/watchlist',
}
def __init__(self, session_id):
super(Account, self).__init__()
self.session_id = session_id
def info(self, **kwargs):
"""
Get your account details.
Args:
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('info')
kwargs.update({'session_id': self.session_id})
response = self._GET(path, kwargs)
self.id = response['id']
self._set_attrs_to_values(response)
return response
def lists(self, **kwargs):
"""
Get all of the lists created by an account. Will include private lists
if you are the owner.
Args:
language: (optional) ISO 639-1 code.
page: (optional) Minimum 1, maximum 1000, default 1.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('lists')
kwargs.update({'session_id': self.session_id})
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def favorite_movies(self, **kwargs):
"""
Get the list of your favorite movies.
Args:
language: (optional) ISO 639-1 code.
sort_by: (optional) Allowed Values: created_at.asc, created_at.desc
page: (optional) Minimum 1, maximum 1000, default 1.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('favorite_movies')
kwargs.update({'session_id': self.session_id})
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def favorite_tv(self, **kwargs):
"""
Get the list of your favorite TV shows.
Args:
language: (optional) ISO 639-1 code.
sort_by: (optional) Allowed Values: created_at.asc, created_at.desc
page: (optional) Minimum 1, maximum 1000, default 1.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('favorite_tv')
kwargs.update({'session_id': self.session_id})
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def favorite(self, **kwargs):
"""
This method allows you to mark a movie or TV show as a favorite item.
Args:
media_type: 'movie' | 'tv'
media_id: The id of the media.
favorite: True (to add) | False (to remove).
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('favorite')
kwargs.update({'session_id': self.session_id})
payload = {
'media_type': kwargs.pop('media_type', None),
'media_id': kwargs.pop('media_id', None),
'favorite': kwargs.pop('favorite', None),
}
response = self._POST(path, kwargs, payload)
self._set_attrs_to_values(response)
return response
def rated_movies(self, **kwargs):
"""
Get a list of all the movies you have rated.
Args:
language: (optional) ISO 639-1 value.
sort_by: (optional) Allowed Values: created_at.asc, created_at.desc
page: (optional) Minimum 1, maximum 1000, default 1.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('rated_movies')
kwargs.update({'session_id': self.session_id})
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def rated_tv(self, **kwargs):
"""
Get a list of all the TV shows you have rated.
Args:
language: (optional) ISO 639-1 value.
sort_by: (optional) Allowed Values: created_at.asc, created_at.desc
page: (optional) Minimum 1, maximum 1000, default 1.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('rated_tv')
kwargs.update({'session_id': self.session_id})
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def rated_tv_episodes(self, **kwargs):
"""
Get a list of all the TV episodes you have rated.
Args:
language: (optional) ISO 639-1 value.
sort_by: (optional) Allowed Values: created_at.asc, created_at.desc
page: (optional) Minimum 1, maximum 1000, default 1.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('rated_tv_episodes')
kwargs.update({'session_id': self.session_id})
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def watchlist_movies(self, **kwargs):
"""
Get a list of all the movies you have added to your watchlist.
Args:
language: (optional) ISO 639-1 value.
sort_by: (optional) Allowed Values: created_at.asc, created_at.desc
page: (optional) Minimum 1, maximum 1000, default 1.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('watchlist_movies')
kwargs.update({'session_id': self.session_id})
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def watchlist_tv(self, **kwargs):
"""
Get a list of all the TV shows you have added to your watchlist.
Args:
language: (optional) ISO 639-1 value.
sort_by: (optional) Allowed Values: created_at.asc, created_at.desc
page: (optional) Minimum 1, maximum 1000, default 1.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('watchlist_tv')
kwargs.update({'session_id': self.session_id})
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def watchlist(self, **kwargs):
"""
Add a movie or TV show to your watchlist.
Args:
media_type: 'movie' | 'tv'
media_id: The id of the media.
watchlist: True (to add) | False (to remove).
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('watchlist')
kwargs.update({'session_id': self.session_id})
payload = {
'media_type': kwargs.pop('media_type', None),
'media_id': kwargs.pop('media_id', None),
'watchlist': kwargs.pop('watchlist', None),
}
response = self._POST(path, kwargs, payload)
self._set_attrs_to_values(response)
return response
class Authentication(TMDB):
"""
Authentication functionality.
See: https://developers.themoviedb.org/3/authentication
https://www.themoviedb.org/documentation/api/sessions
"""
BASE_PATH = 'authentication'
URLS = {
'guest_session_new': '/guest_session/new',
'token_new': '/token/new',
'session_new': '/session/new',
'token_validate_with_login': '/token/validate_with_login',
'session_delete': '/session',
}
def guest_session_new(self, **kwargs):
"""
This method will let you create a new guest session. Guest sessions
are a type of session that will let a user rate movies and TV shows
but not require them to have a TMDb user account. More
information about user authentication can be found here
(https://developers.themoviedb.org/3/authentication/how-do-i-generate-a-session-id).
Please note, you should only generate a single guest session per
user (or device) as you will be able to attach the ratings to a
TMDb user account in the future. There is also IP limits in place
so you should always make sure it's the end user doing the guest
session actions.
If a guest session is not used for the first time within 24 hours,
it will be automatically deleted.
Args:
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('guest_session_new')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def token_new(self, **kwargs):
"""
Create a temporary request token that can be used to validate a TMDb
user login. More details about how this works can be found here
(https://developers.themoviedb.org/3/authentication/how-do-i-generate-a-session-id).
Args:
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('token_new')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def session_new(self, **kwargs):
"""
You can use this method to create a fully valid session ID once a user
has validated the request token. More information about how this works
can be found here
(https://developers.themoviedb.org/3/authentication/how-do-i-generate-a-session-id).
Args:
request_token: The token you generated for the user to approve.
The token needs to be approved before being
used here.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('session_new')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def token_validate_with_login(self, **kwargs):
"""
This method allows an application to validate a request token by entering
a username and password.
Not all applications have access to a web view so this can be used as a
substitute.
Please note, the preferred method of validating a request token is to
have a user authenticate the request via the TMDb website. You can read
about that method here
(https://developers.themoviedb.org/3/authentication/how-do-i-generate-a-session-id).
If you decide to use this method please use HTTPS.
Args:
username: The user's username on TMDb.
password: The user's password on TMDb.
request_token: The token you generated for the user to approve.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('token_validate_with_login')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def session_delete(self, **kwargs):
"""
If you would like to delete (or "logout") from a session, call this
method with a valid session ID.
Args:
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('session_delete')
payload = {
'session_id': kwargs.pop('session_id', None),
}
response = self._DELETE(path, kwargs, payload)
self._set_attrs_to_values(response)
return response
class GuestSessions(TMDB):
"""
Guest Sessions functionality.
See: https://developers.themoviedb.org/3/guest-sessions
"""
BASE_PATH = 'guest_session'
URLS = {
'rated_movies': '/{guest_session_id}/rated/movies',
'rated_tv': '/{guest_session_id}/rated/tv',
'rated_tv_episodes': '/{guest_session_id}/rated/tv/episodes',
}
def __init__(self, guest_session_id=0):
super(GuestSessions, self).__init__()
self.guest_session_id = guest_session_id
def rated_movies(self, **kwargs):
"""
Get the rated movies for a guest session.
Args:
language: (optional) ISO 639-1 code.
sort_by: (optional) Allowed Values: created_at.asc, created_at.desc
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_guest_session_id_path('rated_movies')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def rated_tv(self, **kwargs):
"""
Get the rated TV shows for a guest session.
Args:
language: (optional) ISO 639-1 code.
sort_by: (optional) Allowed Values: created_at.asc, created_at.desc
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_guest_session_id_path('rated_tv')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def rated_tv_episodes(self, **kwargs):
"""
Get the rated TV episodes for a guest session.
Args:
language: (optional) ISO 639-1 code.
sort_by: (optional) Allowed Values: created_at.asc, created_at.desc
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_guest_session_id_path('rated_tv_episodes')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
class Lists(TMDB):
"""
Lists functionality.
See: https://developers.themoviedb.org/3/lists
"""
BASE_PATH = 'list'
URLS = {
'info': '/{id}',
'item_status': '/{id}/item_status',
'list_create': '',
'add_item': '/{id}/add_item',
'remove_item': '/{id}/remove_item',
'list_clear': '/{id}/clear',
'list_delete': '/{id}',
}
def __init__(self, id=0, session_id=0):
super(Lists, self).__init__()
self.id = id
self.session_id = session_id
def info(self, **kwargs):
"""
Get the details of a list.
Args:
language: (optional) ISO 639-1 code.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('info')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def item_status(self, **kwargs):
"""
You can use this method to check if a movie has already been added to
the list.
Args:
movie_id: The id of the movie. Minimum 1.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('item_status')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def list_create(self, **kwargs):
"""
Create a list.
Args:
name: Name of the list.
description: Description of the list.
language: (optional) ISO 639-1 code.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('list_create')
kwargs.update({'session_id': self.session_id})
payload = {
'name': kwargs.pop('name', None),
'description': kwargs.pop('description', None),
'language': kwargs.pop('language', None),
}
response = self._POST(path, kwargs, payload)
self._set_attrs_to_values(response)
self.id = self.list_id
return response
def add_item(self, **kwargs):
"""
Add a movie to a list.
Args:
media_id: A movie id. Minimum 1.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('add_item')
kwargs.update({'session_id': self.session_id})
payload = {
'media_id': kwargs.pop('media_id', None),
}
response = self._POST(path, kwargs, payload)
self._set_attrs_to_values(response)
return response
def remove_item(self, **kwargs):
"""
Remove a movie from a list.
Args:
media_id: A movie id. Minimum 1.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('remove_item')
kwargs.update({'session_id': self.session_id})
payload = {
'media_id': kwargs.pop('media_id', None),
}
response = self._POST(path, kwargs, payload)
self._set_attrs_to_values(response)
return response
def list_clear(self, **kwargs):
"""
Clear all of the items from a list.
Args:
confirm: True (do it) | False (don't do it)
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('list_clear')
kwargs.update({'session_id': self.session_id})
payload = {}
response = self._POST(path, kwargs, payload)
self._set_attrs_to_values(response)
return response
def list_delete(self, **kwargs):
"""
Delete a list.
Args:
None
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('list_delete')
kwargs.update({'session_id': self.session_id})
response = self._DELETE(path, kwargs)
self._set_attrs_to_values(response)
return response
tmdbsimple-2.9.1/tmdbsimple/base.py 0000664 0000000 0000000 00000010100 14174067766 0017321 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
"""
tmdbsimple.base
~~~~~~~~~~~~~~~
This module implements the base class of tmdbsimple.
Created by Celia Oakley on 2013-10-31.
:copyright: (c) 2013-2022 by Celia Oakley
:license: GPLv3, see LICENSE for more details
"""
import json
import requests
class APIKeyError(Exception):
pass
class TMDB(object):
headers = {'Content-Type': 'application/json',
'Accept': 'application/json',
'Connection': 'close'}
BASE_PATH = ''
URLS = {}
def __init__(self):
from . import API_VERSION, REQUESTS_SESSION, REQUESTS_TIMEOUT
self.base_uri = 'https://api.themoviedb.org'
self.base_uri += '/{version}'.format(version=API_VERSION)
self.session = REQUESTS_SESSION
self.timeout = REQUESTS_TIMEOUT
def _get_path(self, key):
return self.BASE_PATH + self.URLS[key]
def _get_id_path(self, key):
return self._get_path(key).format(id=self.id)
def _get_guest_session_id_path(self, key):
return self._get_path(key).format(
guest_session_id=self.guest_session_id)
def _get_credit_id_path(self, key):
return self._get_path(key).format(credit_id=self.credit_id)
def _get_media_type_time_window_path(self, key):
return self._get_path(key).format(
media_type=self.media_type, time_window=self.time_window)
def _get_tv_id_season_number_path(self, key):
return self._get_path(key).format(
tv_id=self.tv_id, season_number=self.season_number)
def _get_tv_id_season_number_episode_number_path(self, key):
return self._get_path(key).format(
tv_id=self.tv_id, season_number=self.season_number,
episode_number=self.episode_number)
def _get_complete_url(self, path):
return '{base_uri}/{path}'.format(base_uri=self.base_uri, path=path)
def _get_params(self, params):
from . import API_KEY
if not API_KEY:
raise APIKeyError
api_dict = {'api_key': API_KEY}
if params:
params.update(api_dict)
for key, value in params.items():
if isinstance(params[key], bool):
params[key] = 'true' if value is True else 'false'
else:
params = api_dict
return params
def _request(self, method, path, params=None, payload=None):
url = self._get_complete_url(path)
params = self._get_params(params)
# Create a new request session if no global session is defined
if self.session is None:
response = requests.request(
method,
url,
params=params,
data=json.dumps(payload) if payload else payload,
headers=self.headers, timeout=self.timeout
)
# Use the global requests session the user provided
else:
response = self.session.request(
method,
url,
params=params,
data=json.dumps(payload) if payload else payload,
headers=self.headers, timeout=self.timeout
)
response.raise_for_status()
response.encoding = 'utf-8'
return response.json()
def _GET(self, path, params=None):
return self._request('GET', path, params=params)
def _POST(self, path, params=None, payload=None):
return self._request('POST', path, params=params, payload=payload)
def _DELETE(self, path, params=None, payload=None):
return self._request('DELETE', path, params=params, payload=payload)
def _set_attrs_to_values(self, response={}):
"""
Set attributes to dictionary values.
- e.g.
>>> import tmdbsimple as tmdb
>>> movie = tmdb.Movies(103332)
>>> response = movie.info()
>>> movie.title # instead of response['title']
"""
if isinstance(response, dict):
for key in response.keys():
if not hasattr(self, key) or not callable(getattr(self, key)):
setattr(self, key, response[key])
tmdbsimple-2.9.1/tmdbsimple/changes.py 0000664 0000000 0000000 00000005503 14174067766 0020032 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
"""
tmdbsimple.changes
~~~~~~~~~~~~~~~~~~
This module implements the Changes functionality of tmdbsimple.
Created by Celia Oakley on 2013-10-31.
:copyright: (c) 2013-2022 by Celia Oakley
:license: GPLv3, see LICENSE for more details
"""
from .base import TMDB
class Changes(TMDB):
"""
Changes functionality.
See: https://developers.themoviedb.org/3/changes
"""
BASE_PATH = ''
URLS = {
'movie': 'movie/changes',
'tv': 'tv/changes',
'person': 'person/changes',
}
def movie(self, **kwargs):
"""
Get a list of all of the movie ids that have been changed
in the past 24 hours.
You can query it for up to 14 days worth of changed IDs at
a time with the start_date and end_date query parameters.
100 items are returned per page.
Args:
start_date: (optional) Expected format is 'YYYY-MM-DD'.
end_date: (optional) Expected format is 'YYYY-MM-DD'.
page: (optional) Minimum 1, maximum 1000, default 1.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('movie')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def tv(self, **kwargs):
"""
Get a list of all of the TV show ids that have been changed
in the past 24 hours.
You can query it for up to 14 days worth of changed IDs at
a time with the start_date and end_date query parameters.
100 items are returned per page.
Args:
start_date: (optional) Expected format is 'YYYY-MM-DD'.
end_date: (optional) Expected format is 'YYYY-MM-DD'.
page: (optional) Minimum 1, maximum 1000, default 1.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('tv')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def person(self, **kwargs):
"""
Get a list of all of the person ids that have been changed
in the past 24 hours.
You can query it for up to 14 days worth of changed IDs at
a time with the start_date and end_date query parameters.
100 items are returned per page.
Args:
start_date: (optional) Expected format is 'YYYY-MM-DD'.
end_date: (optional) Expected format is 'YYYY-MM-DD'.
page: (optional) Minimum 1, maximum 1000, default 1.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('person')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
tmdbsimple-2.9.1/tmdbsimple/configuration.py 0000664 0000000 0000000 00000012660 14174067766 0021273 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
"""
tmdbsimple.configuration
~~~~~~~~~~~~~~~~~~~~~~~~
This module implements the Configuration and Certifications functionality of
tmdbsimple.
Created by Celia Oakley on 2013-10-31.
:copyright: (c) 2013-2022 by Celia Oakley
:license: GPLv3, see LICENSE for more details
"""
from .base import TMDB
class Configuration(TMDB):
"""
Configuration functionality.
See: https://developers.themoviedb.org/3/configuration
"""
BASE_PATH = 'configuration'
URLS = {
'info': '',
'countries': '/countries',
'jobs': '/jobs',
'languages': '/languages',
'primary_translations': '/primary_translations',
'timezones': '/timezones',
}
def info(self, **kwargs):
"""
Get the system wide configuration information. Some elements of the API
require some knowledge of this configuration data. The purpose of this
is to try and keep the actual API responses as light as possible. It is
recommended you cache this data within your application and check for
updates every few days.
This method currently holds the data relevant to building image URLs as
well as the change key map.
To build an image URL, you will need 3 pieces of data. The base_url,
size and file_path. Simply combine them all and you will have a fully
qualified URL. Here’s an example URL:
https://image.tmdb.org/t/p/w500/8uO0gUM8aNqYLs1OsTBQiXu0fEv.jpg
The configuration method also contains the list of change keys which
can be useful if you are building an app that consumes data from the
change feed.
Args:
None
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('info')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def countries(self, **kwargs):
"""
Get the list of countries (ISO 3166-1 tags) used throughout TMDb.
Args:
None
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('countries')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def jobs(self, **kwargs):
"""
Get a list of the jobs and departments we use on TMDb.
Args:
None
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('jobs')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def languages(self, **kwargs):
"""
Get the list of languages (ISO 639-1 tags) used throughout TMDb.
Args:
None
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('languages')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def primary_translations(self, **kwargs):
"""
Get a list of the officially supported translations on TMDb.
Args:
None
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('primary_translations')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def timezones(self, **kwargs):
"""
Get the list of timezones used throughout TMDb.
Args:
None
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('timezones')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
class Certifications(TMDB):
"""
Certifications functionality.
See: https://developers.themoviedb.org/3/certifications
"""
BASE_PATH = 'certification'
URLS = {
'movie_list': '/movie/list',
'tv_list': '/tv/list',
}
def movie_list(self, **kwargs):
"""
Get an up to date list of the officially supported movie certifications on TMDb.
Args:
None
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('movie_list')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def tv_list(self, **kwargs):
"""
Get an up to date list of the officially supported TV show certifications on TMDb.
Args:
None
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('tv_list')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
# backward compatability, when only /movie/list existed
def list(self, **kwargs):
"""
Get the list of supported certifications for movies.
Args:
None
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('movie_list')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
tmdbsimple-2.9.1/tmdbsimple/discover.py 0000664 0000000 0000000 00000032105 14174067766 0020236 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
"""
tmdbsimple.discover
~~~~~~~~~~~~~~~~~~~
This module implements the Discover functionality of tmdbsimple.
Created by Celia Oakley on 2013-10-31.
:copyright: (c) 2013-2022 by Celia Oakley
:license: GPLv3, see LICENSE for more details
"""
from .base import TMDB
class Discover(TMDB):
"""
Discover functionality.
See: https://developers.themoviedb.org/3/discover
"""
BASE_PATH = 'discover'
URLS = {
'movie': '/movie',
'tv': '/tv',
}
def movie(self, **kwargs):
"""
Discover movies by different types of data like average rating, number
of votes, genres and certifications. You can get a valid list of
certifications from the certifications list method.
Discover also supports a nice list of sort options. See below for all
of the available options.
Please note, when using certification / certification.lte you must also
specify certification_country. These two parameters work together in
order to filter the results. You can only filter results with the
countries we have added to our certifications list.
If you specify the region parameter, the regional release date will be
used instead of the primary release date. The date returned will be the
first date based on your query (ie. if a with_release_type is
specified). It's important to note the order of the release types that
are used. Specifying "2|3" would return the limited theatrical release
date as opposed to "3|2" which would return the theatrical date.
Also note that a number of filters support being comma (,) or pipe (|)
separated. Comma's are treated like an AND and query while pipe's are
an OR.
Some examples of what can be done with discover can be found at
https://www.themoviedb.org/documentation/api/discover.
Args:
language: (optional) ISO 639-1 code.
region: (optional) Specify a ISO 3166-1 code.
sort_by: (optional) Allowed values: popularity.asc,
popularity.desc, release_date.asc, release_date.desc,
revenue.asc, revenue.desc, primary_release_date.asc,
primary_release_date.desc, original_title.asc,
original_title.desc, vote_average.asc, vote_average.desc,
vote_count.asc, vote_count.desc
Default: popularity.desc
certification_country: (optional) Used in conjunction with the
certification filter, use this to specify a country with a
valid certification.
certification: Filter results with a valid certification from the
'certification_country' field.
certification.gte: Filter and only include movies that have a
certification that is greater than or equal to the specified
value.
certification.lte: Filter and only include movies that have a
certification that is less than or equal to the specified
value.
include_adult: (optional) A filter and include or exclude adult
movies.
include_video: (optional) A filter to include or exclude videos.
page: (optional) Minimum 1, maximum 1000, default 1.
primary_release_year: (optional) A filter to limit the results to a
specific primary release year.
primary_release_date.gte: (optional) Filter and only include movies
that have a primary release date that is greater or equal to
the specified value.
primary_release_date.lte: (optional) Filter and only include movies
that have a primary release date that is less than or equal to
the specified value.
release_date.gte: (optional) Filter and only include movies that
have a primary release date that is greater or equal to the
specified value.
releaste_date.lte: (optional) Filter and only include movies that
have a primary release date that is less than or equal to the
specified value.
with_release_type: (optional) Specify a comma (AND) or pipe (OR)
separated value to filter release types by. These release types
map to the same values found on the movie release date method.
Minimum 1, maximum 6.
year: (optional) A filter to limit the results to a specific year
(looking at all release dates).
vote_count.gte: (optional) Filter and only include movies that have
a vote count that is greater or equal to the specified value.
Minimum 0.
vote_count.lte: (optional) Filter and only include movies that have
a vote count that is less than or equal to the specified value.
Minimum 1.
vote_average.gte: (optional) Filter and only include movies that
have a rating that is greater or equal to the specified value.
Minimum 0.
vote_average.lte: (optional) Filter and only include movies that
have a rating that is less than or equal to the specified value.
Minimum 0.
with_cast: (optional) A comma separated list of person ID's. Only
include movies that have one of the ID's added as an actor.
with_crew: (optional) A comma separated list of person ID's. Only
include movies that have one of the ID's added as a crew member.
with_people: (optional) A comma separated list of person ID's. Only
include movies that have one of the ID's added as a either a
actor or a crew member.
with_companies: (optional) A comma separated list of production
company ID's. Only include movies that have one of the ID's
added as a production company.
with_genres: (optional) Comma separated value of genre ids that you
want to include in the results.
without_genres: (optional) Comma separated value of genre ids that
you want to exclude from the results.
with_keywords: (optional) A comma separated list of keyword ID's.
Only includes movies that have one of the ID's added as a
keyword.
without_keywords: (optional) Exclude items with certain keywords.
You can comma and pipe seperate these values to create an 'AND' or 'OR' logic.
with_runtime.gte: (optional) Filter and only include movies that
have a runtime that is greater or equal to a value.
with_runtime.lte: (optional) Filter and only include movies that
have a runtime that is less than or equal to a value.
with_original_language: (optional) Specify an ISO 639-1 string to
filter results by their original language value.
Returns:
A dict respresentation of the JSON returned from the API.
"""
# Periods are not allowed in keyword arguments but several API
# arguments contain periods. See both usages in tests/test_discover.py.
for param in dict(kwargs):
if '_lte' in param:
kwargs[param.replace('_lte', '.lte')] = kwargs.pop(param)
if '_gte' in param:
kwargs[param.replace('_gte', '.gte')] = kwargs.pop(param)
path = self._get_path('movie')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def tv(self, **kwargs):
"""
Discover TV shows by different types of data like average rating,
number of votes, genres, the network they aired on and air dates.
Discover also supports a nice list of sort options. See below for all
of the available options.
Also note that a number of filters support being comma (,) or pipe (|)
separated. Comma's are treated like an AND and query while pipe's are
an OR.
Some examples of what can be done with discover can be found at
https://www.themoviedb.org/documentation/api/discover.
Args:
language: (optional) ISO 639-1 code.
sort_by: (optional) Available options are 'vote_average.desc',
'vote_average.asc', 'first_air_date.desc',
'first_air_date.asc', 'popularity.desc', 'popularity.asc'
sort_by: (optional) Allowed values: vote_average.desc,
vote_average.asc, first_air_date.desc, first_air_date.asc,
popularity.desc, popularity.asc
Default: popularity.desc
air_date.gte: (optional) Filter and only include TV shows that have
a air date (by looking at all episodes) that is greater or
equal to the specified value.
air_date.lte: (optional) Filter and only include TV shows that have
a air date (by looking at all episodes) that is less than or
equal to the specified value.
first_air_date.gte: (optional) Filter and only include TV shows
that have a original air date that is greater or equal to the
specified value. Can be used in conjunction with the
"include_null_first_air_dates" filter if you want to include
items with no air date.
first_air_date.lte: (optional) Filter and only include TV shows
that have a original air date that is less than or equal to the
specified value. Can be used in conjunction with the
"include_null_first_air_dates" filter if you want to include
items with no air date.
first_air_date_year: (optional) Filter and only include TV shows
that have a original air date year that equal to the specified
value. Can be used in conjunction with the
"include_null_first_air_dates" filter if you want to include
items with no air date.
page: (optional) Specify the page of results to query. Default 1.
timezone: (optional) Used in conjunction with the air_date.gte/lte
filter to calculate the proper UTC offset. Default
America/New_York.
vote_average.gte: (optional) Filter and only include movies that
have a rating that is greater or equal to the specified value.
Minimum 0.
vote_count.gte: (optional) Filter and only include movies that have
a rating that is less than or equal to the specified value.
Minimum 0.
with_genres: (optional) Comma separated value of genre ids that you
want to include in the results.
with_networks: (optional) Comma separated value of network ids that
you want to include in the results.
without_genres: (optional) Comma separated value of genre ids that
you want to exclude from the results.
with_runtime.gte: (optional) Filter and only include TV shows with
an episode runtime that is greater than or equal to a value.
with_runtime.lte: (optional) Filter and only include TV shows with
an episode runtime that is less than or equal to a value.
include_null_first_air_dates: (optional) Use this filter to include
TV shows that don't have an air date while using any of the
"first_air_date" filters.
with_original_language: (optional) Specify an ISO 639-1 string to
filter results by their original language value.
without_keywords: (optional) Exclude items with certain keywords.
You can comma and pipe seperate these values to create an 'AND'
or 'OR' logic.
screened_theatrically: (optional) Filter results to include items
that have been screened theatrically.
with_companies: (optional) A comma separated list of production
company ID's. Only include movies that have one of the ID's
added as a production company.
with_keywords: (optional) A comma separated list of keyword ID's.
Only includes TV shows that have one of the ID's added as a
keyword.
Returns:
A dict respresentation of the JSON returned from the API.
"""
# Periods are not allowed in keyword arguments but several API
# arguments contain periods. See both usages in tests/test_discover.py.
for param in dict(kwargs):
if '_lte' in param:
kwargs[param.replace('_lte', '.lte')] = kwargs.pop(param)
if '_gte' in param:
kwargs[param.replace('_gte', '.gte')] = kwargs.pop(param)
path = self._get_path('tv')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
tmdbsimple-2.9.1/tmdbsimple/find.py 0000664 0000000 0000000 00000005733 14174067766 0017347 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
"""
tmdbsimple.find
~~~~~~~~~~~~~~~
This module implements the Find functionality of tmdbsimple.
Created by Celia Oakley on 2013-10-31.
:copyright: (c) 2013-2022 by Celia Oakley
:license: GPLv3, see LICENSE for more details
"""
from .base import TMDB
class Find(TMDB):
"""
Find functionality.
See: https://developers.themoviedb.org/3/find
"""
BASE_PATH = 'find'
URLS = {
'info': '/{id}',
}
def __init__(self, id=0):
super(Find, self).__init__()
self.id = id
def info(self, **kwargs):
"""
The find method makes it easy to search for objects in our database by
an external id. For example, an IMDB ID.
This method will search all objects (movies, TV shows and people) and
return the results in a single response.
The supported external sources for each object are as follows.
Media Databases: IMDb ID, TVDB ID, Freebase MID*, Freebase ID*,
TVRage ID*
Social IDs: Facebook, Insagram, Twitter
Args:
language: (optional) ISO 639-1 code.
external_source: Allowed Values: imdb_id, freebase_mid,
freebase_id, tvdb_id, tvrage_id, facebook_id, twitter_id,
instagram_id
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('info')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
class Trending(TMDB):
"""
Trending functionality.
See: https://developers.themoviedb.org/3/trending
"""
BASE_PATH = 'trending'
URLS = {
'info': '/{media_type}/{time_window}',
}
def __init__(self, media_type='all', time_window='day'):
super(Trending, self).__init__()
self.media_type = media_type
self.time_window = time_window
def info(self, **kwargs):
"""
Get the daily or weekly trending items. The daily trending list tracks
items over the period of a day while items have a 24 hour half life.
The weekly list tracks items over a 7 day period, with a 7 day half
life.
Valid Media Types
'all': Include all movies, TV shows and people in the results as a
global trending list.
'movie': Show the trending movies in the results.
'tv': Show the trending TV shows in the results.
'people': Show the trending people in the results.
Valid Time Windows
'day': View the trending list for the day.
'week': View the trending list for the week.
Args:
None
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_media_type_time_window_path('info')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
tmdbsimple-2.9.1/tmdbsimple/genres.py 0000664 0000000 0000000 00000004605 14174067766 0017707 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
"""
tmdbsimple.genres
~~~~~~~~~~~~~~~~~
This module implements the Genres functionality of tmdbsimple.
Created by Celia Oakley on 2013-10-31.
:copyright: (c) 2013-2022 by Celia Oakley
:license: GPLv3, see LICENSE for more details
"""
from .base import TMDB
class Genres(TMDB):
"""
Genres functionality.
See: https://developers.themoviedb.org/3/genres
"""
BASE_PATH = 'genre'
URLS = {
'movie_list': '/movie/list',
'tv_list': '/tv/list',
'movies': '/{id}/movies', # backward compatability
}
def __init__(self, id=0):
super(Genres, self).__init__()
self.id = id
def movie_list(self, **kwargs):
"""
Get the list of official genres for movies.
Args:
language: (optional) ISO 639-1 code.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('movie_list')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def tv_list(self, **kwargs):
"""
Get the list of official genres for TV shows.
Args:
language: (optional) ISO 639-1 code.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('tv_list')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
# backward compatability
def movies(self, **kwargs):
"""
Get the list of movies for a particular genre by id. By default, only
movies with 10 or more votes are included.
Args:
page: (optional) Minimum 1, maximum 1000.
language: (optional) ISO 639-1 code.
include_all_movies: (optional) Toggle the inclusion of all movies
and not just those with 10 or more ratings.
Expected value is: True or False.
include_adult: (optional) Toggle the inclusion of adult titles.
Expected value is: True or False.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('movies')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
tmdbsimple-2.9.1/tmdbsimple/movies.py 0000664 0000000 0000000 00000053110 14174067766 0017721 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
"""
tmdbsimple.movies
~~~~~~~~~~~~~~~~~
This module implements the Movies, Collections, Companies, Keywords, and
Reviews functionality of tmdbsimple.
Created by Celia Oakley on 2013-10-31.
:copyright: (c) 2013-2022 by Celia Oakley
:license: GPLv3, see LICENSE for more details
"""
from .base import TMDB
class Movies(TMDB):
"""
Movies functionality.
See: https://developers.themoviedb.org/3/movies
"""
BASE_PATH = 'movie'
URLS = {
'info': '/{id}',
'account_states': '/{id}/account_states',
'alternative_titles': '/{id}/alternative_titles',
'changes': '/{id}/changes',
'credits': '/{id}/credits',
'external_ids': '/{id}/external_ids',
'images': '/{id}/images',
'keywords': '/{id}/keywords',
'lists': '/{id}/lists',
'recommendations': '/{id}/recommendations',
'release_dates': '/{id}/release_dates',
'reviews': '/{id}/reviews',
'similar_movies': '/{id}/similar_movies',
'translations': '/{id}/translations',
'videos': '/{id}/videos',
'watch_providers': '/{id}/watch/providers',
'rating': '/{id}/rating',
'rating_delete': '/{id}/rating',
'latest': '/latest',
'now_playing': '/now_playing',
'popular': '/popular',
'top_rated': '/top_rated',
'upcoming': '/upcoming',
'releases': '/{id}/releases', # backward compatability
}
def __init__(self, id=0):
super(Movies, self).__init__()
self.id = id
def info(self, **kwargs):
"""
Get the primary information about a movie.
Supports append_to_response. Read more about this at
https://developers.themoviedb.org/3/getting-started/append-to-response.
Args:
language: (optional) ISO 639-1 code.
append_to_response: (optional) Append requests within the same
namespace to the response.
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_id_path('info')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def account_states(self, **kwargs):
"""
Grab the following account states for a session:
- Movie rating
- If it belongs to your watchlist
- If it belongs to your favourite list
Args:
session_id: (required) See Authentication.
guest_session_id: (optional) See Authentication.
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_id_path('account_states')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def alternative_titles(self, **kwargs):
"""
Get all of the alternative titles for a movie.
Args:
country: (optional) ISO 3166-1 code.
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_id_path('alternative_titles')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def changes(self, **kwargs):
"""
Get the changes for a movie. By default only the last 24 hours are returned.
You can query up to 14 days in a single query by using the start_date
and end_date query parameters.
Args:
start_date: (optional) Filter the results with a start date.
Expected format is 'YYYY-MM-DD'.
end_date: (optional) Filter the results with a end date.
Expected format is 'YYYY-MM-DD'.
page: (optional) Minimum 1, maximum 1000, default 1.
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_id_path('changes')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def credits(self, **kwargs):
"""
Get the cast and crew for a movie.
Args:
None
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_id_path('credits')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def external_ids(self, **kwargs):
"""
Get the external ids for a movie. We currently support the following
external sources.
Media Databases - IMDb
Social IDs - Facebok, Instagram, Twitter
Args:
None
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_id_path('external_ids')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def images(self, **kwargs):
"""
Get the images that belong to a movie.
Querying images with a language parameter will filter the results. If
you want to include a fallback language (especially useful for
backdrops) you can use the include_image_language parameter. This
should be a comma seperated value like so:
include_image_language=en,null.
Args:
language: (optional) ISO 639-1 code.
include_image_language: (optional) Comma separated, a valid
ISO 69-1.
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_id_path('images')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def keywords(self):
"""
Get the keywords that have been added to a movie.
Args:
None
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_id_path('keywords')
response = self._GET(path)
self._set_attrs_to_values(response)
return response
def lists(self, **kwargs):
"""
Get a list of lists that this movie belongs to.
Args:
language: (optional) ISO 639-1 code.
page: (optional) Minimum 1, maximum 1000, default 1.
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_id_path('lists')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def recommendations(self, **kwargs):
"""
Get a list of recommended movies for a movie.
Args:
language: (optional) ISO 639-1 code.
page: (optional) Minimum 1, maximum 1000, default 1.
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_id_path('recommendations')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def release_dates(self, **kwargs):
"""
Get the release date along with the certification for a movie.
Release dates support different types:
1. Premiere
2. Theatrical (limited)
3. Theatrical
4. Digital
5. Physical
6. TV
Args:
None
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_id_path('release_dates')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def reviews(self, **kwargs):
"""
Get the user reviews for a movie.
Args:
language: (optional) ISO 639-1 code.
page: (optional) Minimum 1, maximum 1000, default 1.
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_id_path('reviews')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def similar_movies(self, **kwargs):
"""
Get a list of similar movies. This is not the same as the
"Recommendation" system you see on the website.
These items are assembled by looking at keywords and genres.
Args:
language: (optional) ISO 639-1 code.
page: (optional) Minimum 1, maximum 1000, default 1.
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_id_path('similar_movies')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def translations(self, **kwargs):
"""
Get a list of translations that have been created for a movie.
Args:
None
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_id_path('translations')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def videos(self, **kwargs):
"""
Get the videos that have been added to a movie.
Args:
language: (optional) ISO 639-1 code.
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_id_path('videos')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def watch_providers(self, **kwargs):
"""
Get a list of the availabilities per country by provider for movies.
Args:
None
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_id_path('watch_providers')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def rating(self, **kwargs):
"""
Rate a movie.
A valid session or guest session ID is required. You can read more
about how this works at
https://developers.themoviedb.org/3/authentication/how-do-i-generate-a-session-id.
Args:
session_id: (optional) See Authentication.
guest_session_id: (optional) See Authentication.
value: (required) This is the value of the rating you want to
submit. The value is expected to be between 0.5 and 10.0.
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_id_path('rating')
payload = {
'value': kwargs.pop('value', None),
}
response = self._POST(path, kwargs, payload)
self._set_attrs_to_values(response)
return response
def rating_delete(self, **kwargs):
"""
Remove your rating for a movie.
A valid session or guest session ID is required. You can read more
about how this works at
https://developers.themoviedb.org/3/authentication/how-do-i-generate-a-session-id.
Args:
session_id: (optional) See Authentication.
guest_session_id: (optional) See Authentication.
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_id_path('rating_delete')
payload = {
'value': kwargs.pop('value', None),
}
response = self._DELETE(path, kwargs, payload)
self._set_attrs_to_values(response)
return response
def latest(self, **kwargs):
"""
Get the most newly created movie. This is a live response and will
continuously change.
Args:
language: (optional) ISO 639-1 code.
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_path('latest')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def now_playing(self, **kwargs):
"""
Get a list of movies in theatres. This is a release type query that
looks for all movies that have a release type of 2 or 3 within the
specified date range.
You can optionally specify a region prameter which will narrow the
search to only look for theatrical release dates within the specified
country.
Args:
language: (optional) ISO 639-1 code.
page: (optional) Minimum 1, maximum 1000, default 1.
region: (optional) Specify a ISO 3166-1 code to filter release
dates. Must be uppercase.
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_path('now_playing')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def popular(self, **kwargs):
"""
Get a list of the current popular movies on TMDb. This list updates
daily.
Args:
language: (optional) ISO 639-1 code.
page: (optional) Minimum 1, maximum 1000, default 1.
region: (optional) Specify a ISO 3166-1 code to filter release
dates. Must be uppercase.
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_path('popular')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def top_rated(self, **kwargs):
"""
Get the top rated movies on TMDb.
Args:
language: (optional) ISO 639-1 code.
page: (optional) Minimum 1, maximum 1000, default 1.
region: (optional) Specify a ISO 3166-1 code to filter release
dates. Must be uppercase.
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_path('top_rated')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def upcoming(self, **kwargs):
"""
Get a list of upcoming movies in theatres. This is a release type query
that looks for all movies that have a release type of 2 or 3 within the
specified date range.
You can optionally specify a region prameter which will narrow the
search to only look for theatrical release dates within the specified
country.
Args:
language: (optional) ISO 639-1 code.
page: (optional) Minimum 1, maximum 1000, default 1.
region: (optional) Specify a ISO 3166-1 code to filter release
dates. Must be uppercase.
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_path('upcoming')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
# backward compatability
def releases(self, **kwargs):
"""
Get the release date and certification information by country for a
specific movie id.
Args:
None
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_id_path('releases')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
class Collections(TMDB):
"""
Collections functionality.
See: https://developers.themoviedb.org/3/collections
"""
BASE_PATH = 'collection'
URLS = {
'info': '/{id}',
'images': '/{id}/images',
'translations': '/{id}/translations',
}
def __init__(self, id):
super(Collections, self).__init__()
self.id = id
def info(self, **kwargs):
"""
Get collection details by id.
Args:
language: (optional) ISO 639-1 code.
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_id_path('info')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def images(self, **kwargs):
"""
Get the images for a collection by id.
Args:
language: (optional) ISO 639-1 code.
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_id_path('images')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def translations(self, **kwargs):
"""
Get a list of the translations for a collection by id.
Args:
language: (optional) ISO 639-1 code.
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_id_path('translations')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
class Companies(TMDB):
"""
Companies functionality.
See: https://developers.themoviedb.org/3/companies
"""
BASE_PATH = 'company'
URLS = {
'info': '/{id}',
'alternative_names': '/{id}/alternative_names',
'images': '/{id}/images',
'movies': '/{id}/movies', # backward compatability
}
def __init__(self, id=0):
super(Companies, self).__init__()
self.id = id
def info(self, **kwargs):
"""
Get a companies details by id.
Args:
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_id_path('info')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def alternative_names(self, **kwargs):
"""
Get the alternative names of a company.
Args:
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_id_path('alternative_names')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def images(self, **kwargs):
"""
Get a company's logos by id.
There are two image formats that are supported for companies, PNG's and
SVG's. You can see which type the original file is by looking at the
file_type field. We prefer SVG's as they are resolution independent and
as such, the width and height are only there to reflect the original
asset that was uploaded. An SVG can be scaled properly beyond those
dimensions if you call them as a PNG.
For more information about how SVG's and PNG's can be used, take a read
through https://developers.themoviedb.org/3/getting-started/images.
Args:
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_id_path('images')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
# backward compatability
def movies(self, **kwargs):
"""
Get the list of movies associated with a particular company.
Args:
language: (optional) ISO 639-1 code.
page: (optional) Minimum value of 1. Expected value is an integer.
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_id_path('movies')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
class Keywords(TMDB):
"""
Keywords functionality.
See: https://developers.themoviedb.org/3/keywords
"""
BASE_PATH = 'keyword'
URLS = {
'info': '/{id}',
'movies': '/{id}/movies',
}
def __init__(self, id):
super(Keywords, self).__init__()
self.id = id
def info(self, **kwargs):
"""
Get the details of a keyword.
Args:
None
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_id_path('info')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def movies(self, **kwargs):
"""
Get the movies that belong to a keyword.
We highly recommend using movie discover instead of this method as it
is much more flexible.
Args:
language: (optional) ISO 639-1 code.
include_adult: Choose whether to inlcude adult (pornography)
content in the results.
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_id_path('movies')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
class Reviews(TMDB):
"""
Reviews functionality.
See: https://developers.themoviedb.org/3/reviews
"""
BASE_PATH = 'review'
URLS = {
'info': '/{id}',
}
def __init__(self, id):
super(Reviews, self).__init__()
self.id = id
def info(self, **kwargs):
"""
Get the review details by id.
Args:
None
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_id_path('info')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
tmdbsimple-2.9.1/tmdbsimple/people.py 0000664 0000000 0000000 00000016526 14174067766 0017715 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
"""
tmdbsimple.people
~~~~~~~~~~~~~~~~~
This module implements the People and Credits functionality of tmdbsimple.
Created by Celia Oakley on 2013-10-31.
:copyright: (c) 2013-2022 by Celia Oakley
:license: GPLv3, see LICENSE for more details
"""
from .base import TMDB
class People(TMDB):
"""
People functionality.
See: https://developers.themoviedb.org/3/people
"""
BASE_PATH = 'person'
URLS = {
'info': '/{id}',
'changes': '/{id}/changes',
'movie_credits': '/{id}/movie_credits',
'tv_credits': '/{id}/tv_credits',
'combined_credits': '/{id}/combined_credits',
'external_ids': '/{id}/external_ids',
'images': '/{id}/images',
'tagged_images': '/{id}/tagged_images',
'translations': '/{id}/translations',
'latest': '/latest',
'popular': '/popular',
}
def __init__(self, id=0):
super(People, self).__init__()
self.id = id
def info(self, **kwargs):
"""
Get the primary person details by id.
Supports append_to_response. Read more about this at
https://developers.themoviedb.org/3/getting-started/append-to-response.
Args:
language: (optional) ISO 639-1 code.
append_to_response: (optional) Append requests within the same
namespace to the response.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('info')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def changes(self, **kwargs):
"""
Get the changes for a person. By default only the last 24 hours are returned.
You can query up to 14 days in a single query by using the start_date
and end_date query parameters.
Args:
start_date: (optional) Filter the results with a start date.
Expected format is 'YYYY-MM-DD'.
end_date: (optional) Filter the results with a end date.
Expected format is 'YYYY-MM-DD'.
page: (optional) Minimum 1, maximum 1000, default 1.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('changes')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def movie_credits(self, **kwargs):
"""
Get the movie credits for a person.
Args:
language: (optional) ISO 639-1 code.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('movie_credits')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def tv_credits(self, **kwargs):
"""
Get the TV show credits for a person.
You can query for some extra details about the credit with the credit
method.
Args:
language: (optional) ISO 639-1 code.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('tv_credits')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def combined_credits(self, **kwargs):
"""
Get the movie and TV credits together in a single response.
Args:
language: (optional) ISO 639-1 code.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('combined_credits')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def external_ids(self, **kwargs):
"""
Get the external ids for a person. We currently support the following external sources.
External Sources
- IMDB ID
- Facebook
- Freebase MID
- Freebase ID
- Instagram
- TVRage ID
- Twitter
Args:
language: (optional) ISO 639-1 code.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('external_ids')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def images(self, **kwargs):
"""
Get the images for a person.
Args:
None
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('images')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def tagged_images(self, **kwargs):
"""
Get the images that this person has been tagged in.
Args:
language: (optional) ISO 639-1 code.
page: (optional) Minimum 1, maximum 1000, default 1.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('tagged_images')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def translations(self, **kwargs):
"""
Get a list of translations that have been created for a person.
Args:
language: (optional) ISO 639-1 code.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('translations')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def latest(self, **kwargs):
"""
Get the most newly created person. This is a live response and will
continuously change.
Args:
language: (optional) ISO 639-1 code.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('latest')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def popular(self, **kwargs):
"""
Get the list of popular people on TMDb. This list updates daily.
Args:
language: (optional) ISO 639-1 code.
page: (optional) Minimum 1, maximum 1000, default 1.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('popular')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
class Credits(TMDB):
"""
Credits functionality.
See: https://developers.themoviedb.org/3/credits
"""
BASE_PATH = 'credit'
URLS = {
'info': '/{credit_id}',
}
def __init__(self, credit_id):
super(Credits, self).__init__()
self.credit_id = credit_id
def info(self, **kwargs):
"""
Get a movie or TV credit details by id.
Args:
None
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_credit_id_path('info')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
tmdbsimple-2.9.1/tmdbsimple/search.py 0000664 0000000 0000000 00000013436 14174067766 0017673 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
"""
tmdbsimple.search
~~~~~~~~~~~~~~~~~
This module implements the Search functionality of tmdbsimple.
Created by Celia Oakley on 2013-10-31.
:copyright: (c) 2013-2022 by Celia Oakley
:license: GPLv3, see LICENSE for more details
"""
from .base import TMDB
class Search(TMDB):
"""
Search functionality
See: https://developers.themoviedb.org/3/search
"""
BASE_PATH = 'search'
URLS = {
'company': '/company',
'collection': '/collection',
'keyword': '/keyword',
'movie': '/movie',
'multi': '/multi',
'person': '/person',
'tv': '/tv',
}
def company(self, **kwargs):
"""
Search for companies.
Args:
query: (required) Pass a text query to search. This value should be
URI encoded.
page: (optional) Minimum 1, maximum 1000, default 1.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('company')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def collection(self, **kwargs):
"""
Search for collections.
Args:
language: (optional) (optional) ISO 639-1 code.
query: (required) Pass a text query to search. This value should be
URI encoded.
page: (optional) Minimum 1, maximum 1000, default 1.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('collection')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def keyword(self, **kwargs):
"""
Search for keywords.
Args:
query: (required) Pass a text query to search. This value should be
URI encoded.
page: (optional) Minimum 1, maximum 1000, default 1.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('keyword')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def movie(self, **kwargs):
"""
Search for movies.
Args:
language: (optional) (optional) ISO 639-1 code.
query: (required) Pass a text query to search. This value should be
URI encoded.
page: (optional) Minimum 1, maximum 1000, default 1.
include_adult: (optional) Choose whether to inlcude adult
(pornography) content in the results.
region: (optional) Specify a ISO 3166-1 code to filter release
dates. Must be uppercase.
year: (optional) A filter to limit the results to a specific year
(looking at all release dates).
primary_release_year: (optional) A filter to limit the results to a
specific primary release year.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('movie')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def multi(self, **kwargs):
"""
Search multiple models in a single request. Multi search currently
supports searching for movies, tv shows and people in a single request.
Args:
language: (optional) (optional) ISO 639-1 code.
query: (required) Pass a text query to search. This value should be
URI encoded.
page: (optional) Minimum 1, maximum 1000, default 1.
include_adult: (optional) Choose whether to inlcude adult
(pornography) content in the results.
region: (optional) Specify a ISO 3166-1 code to filter release
dates. Must be uppercase.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('multi')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def person(self, **kwargs):
"""
Search for people.
Args:
language: (optional) (optional) ISO 639-1 code.
query: (required) Pass a text query to search. This value should be
URI encoded.
page: (optional) Minimum 1, maximum 1000, default 1.
include_adult: (optional) Choose whether to inlcude adult
(pornography) content in the results.
region: (optional) Specify a ISO 3166-1 code to filter release
dates. Must be uppercase.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('person')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def tv(self, **kwargs):
"""
Search for a TV show.
Args:
language: (optional) (optional) ISO 639-1 code.
query: (required) Pass a text query to search. This value should be
URI encoded.
page: (optional) Minimum 1, maximum 1000, default 1.
include_adult: (optional) Choose whether to inlcude adult
(pornography) content in the results.
first_air_date_year: (optional) Filter the results to only match
shows that have an air date with with value.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('tv')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
tmdbsimple-2.9.1/tmdbsimple/tv.py 0000664 0000000 0000000 00000074762 14174067766 0017070 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
"""
tmdbsimple.tv
~~~~~~~~~~~~~
This module implements the TV, TV Seasons, TV Episodes, and Networks
functionality of tmdbsimple.
Created by Celia Oakley on 2013-10-31.
:copyright: (c) 2013-2022 by Celia Oakley
:license: GPLv3, see LICENSE for more details
"""
from .base import TMDB
class TV(TMDB):
"""
TV functionality.
See: https://developers.themoviedb.org/3/tv
"""
BASE_PATH = 'tv'
URLS = {
'info': '/{id}',
'account_states': '/{id}/account_states',
'alternative_titles': '/{id}/alternative_titles',
'content_ratings': '/{id}/content_ratings',
'credits': '/{id}/credits',
'episode_groups': '/{id}/episode_groups',
'external_ids': '/{id}/external_ids',
'images': '/{id}/images',
'keywords': '/{id}/keywords',
'recommendations': '/{id}/recommendations',
'reviews': '/{id}/reviews',
'screened_theatrically': '/{id}/screened_theatrically',
'similar': '/{id}/similar',
'translations': '/{id}/translations',
'videos': '/{id}/videos',
'watch_providers': '/{id}/watch/providers',
'rating': '/{id}/rating',
'latest': '/latest',
'airing_today': '/airing_today',
'on_the_air': '/on_the_air',
'popular': '/popular',
'top_rated': '/top_rated',
}
def __init__(self, id=0):
super(TV, self).__init__()
self.id = id
def info(self, **kwargs):
"""
Get the primary TV show details by id.
Supports append_to_response. Read more about this at
https://developers.themoviedb.org/3/getting-started/append-to-response.
Args:
language: (optional) ISO 639 code.
append_to_response: (optional) Append requests within the same
namespace to the response.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('info')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def account_states(self, **kwargs):
"""
Grab the following account states for a session:
- TV show rating
- If it belongs to your watchlist
- If it belongs to your favourite list
Args:
language: (optional) ISO 3166-1 code.
session_id: (required) See Authentication.
guest_session_id: (optional) See Authentication.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('account_states')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def alternative_titles(self, **kwargs):
"""
Returns all of the alternative titles for a TV show.
Args:
language: (optional) ISO 3166-1 code.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('alternative_titles')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def content_ratings(self, **kwargs):
"""
Get the list of content ratings (certifications) that have been added
to a TV show.
Args:
language: (optional) ISO 3166-1 code.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('content_ratings')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def credits(self, **kwargs):
"""
Get the credits (cast and crew) that have been added to a TV show.
Args:
language: (optional) ISO 639 code.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('credits')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def episode_groups(self, **kwargs):
"""
Get all of the episode groups that have been created for a TV show.
With a group ID you can call the get TV episode group details method.
Args:
language: (optional) ISO 639 code.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('episode_groups')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def external_ids(self, **kwargs):
"""
Get the external ids for a TV show. We currently support the following
external sources.
Media Databases: IMDb ID, TVDB ID, Freebase MID*, Freebase ID*, TVRage
ID*
Social IDs: Facebook, Instagram, Twitter
*Defunct or no longer available as a service.
Args:
language: (optional) ISO 639 code.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('external_ids')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def images(self, **kwargs):
"""
Get the images that belong to a TV show.
Querying images with a language parameter will filter the results. If
you want to include a fallback language (especially useful for
backdrops) you can use the include_image_language parameter. This
should be a comma seperated value like so:
include_image_language=en,null.
Args:
language: (optional) ISO 639 code.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('images')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def keywords(self, **kwargs):
"""
Get the keywords that have been added to a TV show.
Args:
None
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('keywords')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def recommendations(self, **kwargs):
"""
Get the list of TV show recommendations for this item.
Args:
language: (optional) ISO 639-1 code.
page: (optional) Minimum 1, maximum 1000, default 1.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('recommendations')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def reviews(self, **kwargs):
"""
Get the reviews for a TV show.
Args:
language: (optional) ISO 639-1 code.
page: (optional) Minimum 1, maximum 1000, default 1.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('reviews')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def screened_theatrically(self, **kwargs):
"""
Get a list of seasons or episodes that have been screened in a film
festival or theatre.
Args:
None
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('screened_theatrically')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def similar(self, **kwargs):
"""
Get a list of similar TV shows. These items are assembled by looking at
keywords and genres.
Args:
language: (optional) ISO 639-1 code.
page: (optional) Minimum 1, maximum 1000, default 1.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('similar')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def translations(self, **kwargs):
"""
Get a list of the translations that exist for a TV show.
Args:
None
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('translations')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def videos(self, **kwargs):
"""
Get the videos that have been added to a TV show.
Args:
language: (optional) ISO 639 code.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('videos')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def watch_providers(self, **kwargs):
"""
Get a list of the availabilities per country by provider for tv.
Args:
None
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('watch_providers')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
def rating(self, **kwargs):
"""
Rate a TV show.
A valid session or guest session ID is required. You can read more
about how this works at
https://developers.themoviedb.org/3/authentication/how-do-i-generate-a-session-id.
Args:
session_id: (optional) See Authentication.
guest_session_id: (optional) See Authentication.
value: (required) This is the value of the rating you want to
submit. The value is expected to be between 0.5 and 10.0.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('rating')
payload = {
'value': kwargs.pop('value', None),
}
response = self._POST(path, kwargs, payload)
self._set_attrs_to_values(response)
return response
def rating_delete(self, **kwargs):
"""
Remove your rating for a TV show.
A valid session or guest session ID is required. You can read more
about how this works at
https://developers.themoviedb.org/3/authentication/how-do-i-generate-a-session-id.
Args:
session_id: (optional) See Authentication.
guest_session_id: (optional) See Authentication.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('rating')
payload = {
'value': kwargs.pop('value', None),
}
response = self._DELETE(path, kwargs, payload)
self._set_attrs_to_values(response)
return response
def latest(self, **kwargs):
"""
Get the most newly created TV show. This is a live response and will
continuously change.
Args:
language: (optional) ISO 639 code.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('latest')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def airing_today(self, **kwargs):
"""
Get a list of TV shows that are airing today. This query is purely day
based as we do not currently support airing times.
You can specify a timezone to offset the day calculation. Without a
specified timezone, this query defaults to EST (Eastern Time
UTC-05:00).
Args:
language: (optional) ISO 639 code.
page: (optional) Minimum 1, maximum 1000, default 1.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('airing_today')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def on_the_air(self, **kwargs):
"""
Get a list of shows that are currently on the air.
This query looks for any TV show that has an episode with an air date
in the next 7 days.
Args:
language: (optional) ISO 639 code.
page: (optional) Minimum 1, maximum 1000, default 1.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('on_the_air')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def popular(self, **kwargs):
"""
Get a list of the current popular TV shows on TMDb. This list updates
daily.
Args:
language: (optional) ISO 639 code.
page: (optional) Minimum 1, maximum 1000, default 1.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('popular')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def top_rated(self, **kwargs):
"""
Get a list of the top rated TV shows on TMDb.
Args:
language: (optional) ISO 639 code.
page: (optional) Minimum 1, maximum 1000, default 1.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('top_rated')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
class TV_Seasons(TMDB):
"""
TV Seasons functionality.
See: https://developers.themoviedb.org/3/tv-seasons
"""
BASE_PATH = 'tv/{tv_id}/season/{season_number}'
URLS = {
'info': '',
'account_states': '/account_states',
'credits': '/credits',
'external_ids': '/external_ids',
'images': '/images',
'videos': '/videos',
}
def __init__(self, tv_id, season_number):
super(TV_Seasons, self).__init__()
self.tv_id = tv_id
self.season_number = season_number
def info(self, **kwargs):
"""
Get the TV season details by id.
Supports append_to_response. Read more about this at
https://developers.themoviedb.org/3/getting-started/append-to-response.
Args:
language: (optional) ISO 639 code.
append_to_response: (optional) Append requests within the same
namespace to the response.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_tv_id_season_number_path('info')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def account_states(self, **kwargs):
"""
Returns all of the user ratings for the season's episodes.
Args:
language: (optional) ISO 639 code.
session_id: (required) See Authentication.
guest_session_id: (optional) See Authentication.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_tv_id_season_number_path('account_states')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def credits(self, **kwargs):
"""
Get the credits for TV season.
Args:
language: (optional) ISO 639 code.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_tv_id_season_number_path('credits')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def external_ids(self, **kwargs):
"""
Get the external ids for a TV season. We currently support the
following external sources.
Media Databases: TVDB ID, Freebase MID*, Freebase ID*, TVRage ID*
*Defunct or no longer available as a service.
Args:
language: (optional) ISO 639 code.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_tv_id_season_number_path('external_ids')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def images(self, **kwargs):
"""
Get the images that belong to a TV season.
Querying images with a language parameter will filter the results. If
you want to include a fallback language (especially useful for
backdrops) you can use the include_image_language parameter. This
should be a comma seperated value like so:
include_image_language=en,null.
Args:
language: (optional) ISO 639 code.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_tv_id_season_number_path('images')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def videos(self, **kwargs):
"""
Get the videos that have been added to a TV season.
Args:
language: (optional) ISO 639 code.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_tv_id_season_number_path('videos')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
class TV_Episodes(TMDB):
"""
TV Episodes functionality.
See: https://developers.themoviedb.org/3/tv-episodes
"""
BASE_PATH = 'tv/{tv_id}/season/{season_number}/episode/{episode_number}'
URLS = {
'info': '',
'account_states': '/account_states',
'credits': '/credits',
'external_ids': '/external_ids',
'images': '/images',
'translations': '/translations',
'rating': '/rating',
'videos': '/videos',
}
def __init__(self, tv_id, season_number, episode_number):
super(TV_Episodes, self).__init__()
self.tv_id = tv_id
self.season_number = season_number
self.episode_number = episode_number
def info(self, **kwargs):
"""
Get the TV episode details by id.
Supports append_to_response. Read more about this at
https://developers.themoviedb.org/3/getting-started/append-to-response.
Args:
language: (optional) ISO 639 code.
append_to_response: (optional) Append requests within the same
namespace to the response.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_tv_id_season_number_episode_number_path('info')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def account_states(self, **kwargs):
"""
Get your rating for an episode.
Args:
session_id: (required) See Authentication.
guest_session_id: (optional) See Authentication.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_tv_id_season_number_episode_number_path(
'account_states')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def credits(self, **kwargs):
"""
Get the credits (cast, crew and guest stars) for a TV episode.
Args:
None
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_tv_id_season_number_episode_number_path('credits')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def external_ids(self, **kwargs):
"""
Get the external ids for a TV episode. We currently support the
following external sources.
External Sources: IMDb ID, TVDB ID, Freebase MID*, Freebase ID*, TVRage
ID*
*Defunct or no longer available as a service.
Args:
None
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_tv_id_season_number_episode_number_path(
'external_ids')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def images(self, **kwargs):
"""
Get the images that belong to a TV episode.
Querying images with a language parameter will filter the results. If
you want to include a fallback language (especially useful for
backdrops) you can use the include_image_language parameter. This
should be a comma seperated value like so:
include_image_language=en,null.
Args:
None
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_tv_id_season_number_episode_number_path('images')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def translations(self, **kwargs):
"""
Get the translation data for an episode.
Args:
None
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_tv_id_season_number_episode_number_path(
'translations')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def rating(self, **kwargs):
"""
Rate a TV episode.
A valid session or guest session ID is required. You can read more
about how this works at
https://developers.themoviedb.org/3/authentication/how-do-i-generate-a-session-id.
Args:
session_id: (optional) See Authentication.
guest_session_id: (optional) See Authentication.
value: (required) This is the value of the rating you want to
submit. The value is expected to be between 0.5 and 10.0.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_tv_id_season_number_episode_number_path('rating')
payload = {
'value': kwargs.pop('value', None),
}
response = self._POST(path, kwargs, payload)
self._set_attrs_to_values(response)
return response
def rating_delete(self, **kwargs):
"""
Remove your rating for a TV episode.
A valid session or guest session ID is required. You can read more
about how this works at
https://developers.themoviedb.org/3/authentication/how-do-i-generate-a-session-id.
Args:
session_id: (optional) See Authentication.
guest_session_id: (optional) See Authentication.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_tv_id_season_number_episode_number_path('rating')
payload = {
'value': kwargs.pop('value', None),
}
response = self._DELETE(path, kwargs, payload)
self._set_attrs_to_values(response)
return response
def videos(self, **kwargs):
"""
Get the videos that have been added to a TV episode.
Args:
language: (optional) ISO 639 code.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_tv_id_season_number_episode_number_path('videos')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
class TV_Episode_Groups(TMDB):
"""
TV Episode Groups functionality.
See: https://developers.themoviedb.org/3/tv-episode-groups
"""
BASE_PATH = 'tv/episode_group'
URLS = {
'info': '/{id}',
}
def __init__(self, id):
super(TV_Episode_Groups, self).__init__()
self.id = id
def info(self, **kwargs):
"""
Get the details of a TV episode group. Groups support 7 different types
which are enumerated as the following:
1. Original air date
2. Absolute
3. DVD
4. Digital
5. Story arc
6. Production
7. TV
Args:
language: (optional) ISO 639 code.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('info')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
class TV_Changes(TMDB):
"""
Changes functionality for TV Series, Season and Episode.
See: https://developers.themoviedb.org/3/tv/get-tv-changes
https://developers.themoviedb.org/3/tv-seasons/get-tv-season-changes
https://developers.themoviedb.org/3/tv-episodes/get-tv-episode-changes
"""
BASE_PATH = 'tv'
URLS = {
'series': '/{id}/changes', # id => tv_id
'season': '/season/{id}/changes', # id => season_id
'episode': '/episode/{id}/changes', # id => episode_id
}
def __init__(self, id=0):
super(TV_Changes, self).__init__()
self.id = id
def series(self, **kwargs):
"""
Get the changes for a TV show. By default only the last 24 hours are returned.
You can query up to 14 days in a single query by using the start_date
and end_date query parameters.
TV show changes are different than movie changes in that there are some
edits on seasons and episodes that will create a change entry at the
show level. These can be found under the season and episode keys. These
keys will contain a series_id and episode_id. You can use the season
changes and episode changes methods to look these up individually.
Args:
start_date: (optional) Filter the results with a start date.
Expected format is 'YYYY-MM-DD'.
end_date: (optional) Filter the results with a end date.
Expected format is 'YYYY-MM-DD'.
page: (optional) Minimum 1, maximum 1000, default 1.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('series')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def season(self, **kwargs):
"""
Get the changes for a TV season. By default only the last 24 hours are returned.
You can query up to 14 days in a single query by using the start_date
and end_date query parameters.
Args:
start_date: (optional) Filter the results with a start date.
Expected format is 'YYYY-MM-DD'.
end_date: (optional) Filter the results with a end date.
Expected format is 'YYYY-MM-DD'.
page: (optional) Minimum 1, maximum 1000, default 1.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('season')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def episode(self, **kwargs):
"""
Get the changes for a TV episode. By default only the last 24 hours are returned.
You can query up to 14 days in a single query by using the start_date
and end_date query parameters.
Args:
start_date: (optional) Filter the results with a start date.
Expected format is 'YYYY-MM-DD'.
end_date: (optional) Filter the results with a end date.
Expected format is 'YYYY-MM-DD'.
page: (optional) Minimum 1, maximum 1000, default 1.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('episode')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
class Networks(TMDB):
"""
Networks functionality.
See: https://developers.themoviedb.org/3/networks
"""
BASE_PATH = 'network'
URLS = {
'info': '/{id}',
'alternative_names': '/{id}/alternative_names',
'images': '/{id}/images',
}
def __init__(self, id):
super(Networks, self).__init__()
self.id = id
def info(self, **kwargs):
"""
Get the details of a network.
Args:
None
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('info')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def alternative_names(self, **kwargs):
"""
Get the alternative names of a network.
Args:
None
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_id_path('alternative_names')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def images(self, **kwargs):
"""
Get a TV network logos by id.
There are two image formats that are supported for networks, PNG's and
SVG's. You can see which type the original file is by looking at the
file_type field. We prefer SVG's as they are resolution independent and
as such, the width and height are only there to reflect the original
asset that was uploaded. An SVG can be scaled properly beyond those
dimensions if you call them as a PNG.
For more information about how SVG's and PNG's can be used, take a read
through https://developers.themoviedb.org/3/getting-started/images.
Args:
None
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_id_path('images')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response