pax_global_header 0000666 0000000 0000000 00000000064 13262565317 0014524 g ustar 00root root 0000000 0000000 52 comment=1b5d53abdd63471d0b3664c22fdfbd945f5bb947
tmdbsimple-2.2.0/ 0000775 0000000 0000000 00000000000 13262565317 0013665 5 ustar 00root root 0000000 0000000 tmdbsimple-2.2.0/.gitignore 0000664 0000000 0000000 00000000230 13262565317 0015650 0 ustar 00root root 0000000 0000000 # Python files
*.py[cod]
*.py.swo
*.egg-info
__pycache__
keys.py
build
dist
# Make files
Makefile
# editors
## Vim files
.*.swp
.idea
# other
notes
tmdbsimple-2.2.0/LICENSE 0000664 0000000 0000000 00000104461 13262565317 0014700 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.2.0/README.rst 0000664 0000000 0000000 00000012425 13262565317 0015360 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 page http://www.themoviedb.org/documentation/api and documentation page https://developers.themoviedb.org/3.
Features
--------
- COMPLETELY UPDATED AND FULLY TESTED. Updated with the latest Account, Authentication, Certification, GuestSession, List, Movie, People, Timezones, TV, TV Season, and TV Episode methods.
- Supports and tested under Python 2.7.6, 3.3.5, and 3.4.0
- One-to-one mapping between *tmdbsimple* functions and TMDb methods.
- Implements all TMDb methods, including Accounts and Authentication.
- Implements new TV features.
- Easy to access data using Python class attributes.
- Easy to experiment with *tmdbsimple* functions inside the Python interpreter.
- Code tested with unittests, which illustrate the function 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`_ and install it yourself
If you install it yourself, also install requests_.
.. _source from Github: http://github.com/celiao/tmdbsimple
.. _requests: http://www.python-requests.org/en/latest
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_.
2) `Log into`_ 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.
.. _account: https://www.themoviedb.org/account/signup
.. _Log into: https://www.themoviedb.org/login
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.
.. code-block:: python
>>> import tmdbsimple as tmdb
>>> tmdb.API_KEY = 'YOUR_API_KEY_HERE'
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.
.. code-block:: 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.
.. code-block:: 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.
.. code-block:: 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.
.. code-block:: 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.2.0/setup.py 0000664 0000000 0000000 00000002532 13262565317 0015401 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# See http://pythonhosted.org/an_example_pypi_project/setuptools.html
import os
from setuptools import setup
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
# requests[security]: http://stackoverflow.com/questions/29134512/insecureplatformwarning-a-true-sslcontext-object-is-not-available-this-prevent/29202163#29202163
setup(
name = 'tmdbsimple',
version = '2.2.0',
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.2.0',
packages = ['tmdbsimple'],
long_description=read('README.rst'),
install_requires = ['requests'],
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Topic :: Utilities",
],
)
tmdbsimple-2.2.0/tests/ 0000775 0000000 0000000 00000000000 13262565317 0015027 5 ustar 00root root 0000000 0000000 tmdbsimple-2.2.0/tests/__init__.py 0000664 0000000 0000000 00000000747 13262565317 0017150 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-2018 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 *
except ImportError:
pass
tmdbsimple-2.2.0/tests/keys.py.TEMPLATE 0000664 0000000 0000000 00000000550 13262565317 0017566 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
"""
keys.py
~~~~~~~
This file contains the private keys for tmdbsimple.
See: http://docs.themoviedb.apiary.io
http://docs.themoviedb.apiary.io/#accounts
http://docs.themoviedb.apiary.io/#authentication
https://www.themoviedb.org/documentation/api/sessions
"""
API_KEY = ''
SESSION_ID = ''
USERNAME = ''
PASSWORD = ''
tmdbsimple-2.2.0/tests/test_account.py 0000664 0000000 0000000 00000015622 13262565317 0020102 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-2018 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_ITEM_MEDIA_ID = 550
"""
Status codes and messages
"""
SUCCESSFUL_UPDATE = 12
SUCCESSFUL_DELETE = 13
SUCCESS_PERIOD = 'The item/record was created successfully.'
class AccountTestCase(unittest.TestCase):
# run this test with a valid session_id and authenticated account
def test_account_info(self):
username = USERNAME
acct = tmdb.Account(SESSION_ID)
response = acct.info()
self.assertEqual(acct.username, username)
def test_account_lists(self):
acct = tmdb.Account(SESSION_ID)
response = acct.info() # to set acct.id
response = acct.lists()
self.assertTrue(hasattr(acct, 'results'))
def test_account_favorite_movies(self):
movietitle = MOVIETITLE
acct = tmdb.Account(SESSION_ID)
response = acct.info() # to set acct.id
response = acct.favorite_movies()
self.assertEqual(acct.results[0]['title'], movietitle)
def test_account_favorite_tv(self):
tvtitle = TVTITLE
acct = tmdb.Account(SESSION_ID)
response = acct.info() # to set acct.id
response = acct.favorite_tv()
self.assertEqual(acct.results[0]['name'], tvtitle)
def test_account_favorite(self):
status_code = SUCCESSFUL_UPDATE
acct = tmdb.Account(SESSION_ID)
response = acct.info() # to set acct.id
kwargs = {
'media_type': 'movie',
'movie_id': FAVORITE_MOVIE_ID,
'favorite': True,
}
response = acct.favorite(**kwargs)
self.assertEqual(acct.status_code, status_code)
def test_account_rated_movies(self):
acct = tmdb.Account(SESSION_ID)
response = acct.info() # to set acct.id
kwargs = {'page': 1, 'sort_by': 'created_at.asc'}
response = acct.rated_movies(**kwargs)
self.assertTrue(hasattr(acct, 'results'))
def test_account_rated_tv(self):
acct = tmdb.Account(SESSION_ID)
response = acct.info() # to set acct.id
kwargs = {'page': 1, 'sort_by': 'created_at.asc'}
response = acct.rated_tv(**kwargs)
self.assertTrue(hasattr(acct, 'results'))
def test_account_watchlist_movies(self):
movietitle = MOVIETITLE
acct = tmdb.Account(SESSION_ID)
response = acct.info() # to set acct.id
kwargs = {'page': 1, 'sort_by': 'created_at.asc'}
response = acct.watchlist_movies(**kwargs)
self.assertEqual(acct.results[0]['title'], movietitle)
def test_account_watchlist_tv(self):
tvtitle = TVTITLE
acct = tmdb.Account(SESSION_ID)
response = acct.info() # to set acct.id
kwargs = {'page': 1, 'sort_by': 'created_at.asc'}
response = acct.watchlist_tv(**kwargs)
self.assertEqual(acct.results[0]['name'], tvtitle)
def test_account_watchlist(self):
status_code = SUCCESSFUL_UPDATE
acct = tmdb.Account(SESSION_ID)
response = acct.info() # to set acct.id
kwargs = {
'media_type': 'movie',
'media_id': WATCHLIST_MEDIA_ID,
'watchlist': 'true',
}
response = acct.watchlist(**kwargs)
self.assertEqual(acct.status_code, status_code)
class AuthenticationTestCase(unittest.TestCase):
def test_authentication_token_new(self):
success = True
auth = tmdb.Authentication()
response = auth.token_new()
#print(auth.request_token)
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()
response = auth.token_validate_with_login(**kwargs)
self.assertEqual(auth.success, success)
# test_authentication_session_new(self):
kwargs = {'request_token': auth.request_token}
success = True
auth = tmdb.Authentication()
response = auth.session_new(**kwargs)
#print(auth.session_id)
self.assertEqual(auth.success, success)
def test_authentication_guest_session_new(self):
success = True
auth = tmdb.Authentication()
response = auth.guest_session_new()
self.assertEqual(auth.success, success)
class GuestSessionsTestCase(unittest.TestCase):
def test_guest_sessions_rated_movies(self):
# get a guest session id
auth = tmdb.Authentication()
response = 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)
response = guest_session.rated_movies()
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)
response = 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)
response = 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,
}
status_message = SUCCESS_PERIOD
lst = tmdb.Lists(0, SESSION_ID)
#print(lst.session_id)
response = lst.create_list(**kwargs)
self.assertEqual(lst.status_message, status_message)
list_id = lst.list_id
status_code = SUCCESSFUL_UPDATE
lst = tmdb.Lists(list_id, SESSION_ID)
response = lst.add_item(media_id=LIST_ITEM_MEDIA_ID)
self.assertEqual(lst.status_code, status_code)
status_code = SUCCESSFUL_DELETE
lst = tmdb.Lists(list_id, SESSION_ID)
response = lst.remove_item(media_id=LIST_ITEM_MEDIA_ID)
self.assertEqual(lst.status_code, status_code)
status_code = SUCCESSFUL_UPDATE
lst = tmdb.Lists(list_id, SESSION_ID)
response = lst.clear_list(confirm='true')
self.assertEqual(lst.status_code, status_code)
tmdbsimple-2.2.0/tests/test_base.py 0000664 0000000 0000000 00000002761 13262565317 0017360 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 by Celia Oakley.
:license: GPLv3, see LICENSE for more details.
"""
import unittest
import tmdbsimple as tmdb
from tests import API_KEY, USERNAME, PASSWORD
tmdb.API_KEY = API_KEY
"""
Constants
"""
MOVIE_ID = 103332
MOVIEQUERY1 = 'Matrix'
MOVIEQUERY2 = 'Star Wars'
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)
response = movie.keywords()
raised = False
try:
movie.keywords()
except:
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()
response = search.movie(query=MOVIEQUERY1)
title1 = search.results[0]['original_title']
response = search.movie(query=MOVIEQUERY2)
title2 = search.results[0]['original_title']
self.assertNotEqual(title1, title2)
tmdbsimple-2.2.0/tests/test_changes.py 0000664 0000000 0000000 00000001535 13262565317 0020054 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-2018 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()
response = changes.movie()
self.assertTrue(hasattr(changes, 'results'))
def test_changes_person(self):
change = tmdb.Changes()
response = change.person()
self.assertTrue(hasattr(change, 'results'))
def test_changes_tv(self):
change = tmdb.Changes()
response = change.tv()
self.assertTrue(hasattr(change, 'results'))
tmdbsimple-2.2.0/tests/test_configuration.py 0000664 0000000 0000000 00000004304 13262565317 0021310 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-2018 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
"""
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']
class ConfigurationTestCase(unittest.TestCase):
def test_configuration_info(self):
change_keys = CHANGE_KEYS
config = tmdb.Configuration()
response = 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
class CertificationsTestCase(unittest.TestCase):
def test_certifications_list(self):
certifications = tmdb.Certifications()
response = certifications.list()
self.assertTrue(hasattr(certifications, 'certifications'))
class TimezonesTestCase(unittest.TestCase):
def test_timezones_list(self):
timezones = tmdb.Timezones()
response = timezones.list()
timezone_keys = list(response[0].keys())
self.assertEqual(timezone_keys[0], 'AD')
tmdbsimple-2.2.0/tests/test_discover.py 0000664 0000000 0000000 00000002230 13262565317 0020253 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-2018 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
class DiscoverTestCase(unittest.TestCase):
def test_discover_movie(self):
discover = tmdb.Discover()
response = discover.movie(page=1, year=DISCOVER_YEAR)
self.assertTrue(hasattr(discover, 'results'))
# Test dot usage
def test_discover_tv_dot(self):
discover = tmdb.Discover()
kwargs = {'page':2, 'vote_average.gte': DISCOVER_VOTE_AVERAGE_GTE}
response = discover.tv(**kwargs)
self.assertTrue(hasattr(discover, 'results'))
# Test underscore usage
def test_discover_tv_underscore(self):
discover = tmdb.Discover()
response = discover.tv(page=2,
vote_average_gte=DISCOVER_VOTE_AVERAGE_GTE)
self.assertTrue(hasattr(discover, 'results'))
tmdbsimple-2.2.0/tests/test_find.py 0000664 0000000 0000000 00000001400 13262565317 0017353 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-2018 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'
class FindTestCase(unittest.TestCase):
def test_find_info(self):
id = FIND_MOVIE_ID
external_source = FIND_SOURCE
title = FIND_TITLE
find = tmdb.Find(id)
response = find.info(external_source=external_source)
self.assertEqual(find.movie_results[0]['title'], title)
tmdbsimple-2.2.0/tests/test_genres.py 0000664 0000000 0000000 00000001623 13262565317 0017725 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-2018 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()
response = genre.movie_list()
self.assertTrue(hasattr(genre, 'genres'))
def test_genres_tv_list(self):
genre = tmdb.Genres()
response = genre.tv_list()
self.assertTrue(hasattr(genre, 'genres'))
def test_genres_movies(self):
id = GENRE_ID
genre = tmdb.Genres(id)
response = genre.movies()
self.assertTrue(hasattr(genre, 'results'))
tmdbsimple-2.2.0/tests/test_movies.py 0000664 0000000 0000000 00000015002 13262565317 0017740 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-2018 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_FRENCH = "Elle s'appelle Ruby"
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_UPDATE = 12
class MoviesTestCase(unittest.TestCase):
def test_movies_info(self):
id = MOVIE_ID
title = MOVIE_TITLE
movie = tmdb.Movies(id)
response = movie.info()
self.assertEqual(movie.title, title)
def test_movies_info_with_params(self):
id = MOVIE_ID
title = MOVIE_TITLE_FRENCH
movie = tmdb.Movies(id)
response = movie.info(language='fr')
self.assertEqual(movie.title, title)
def test_movies_alternative_titles(self):
id = MOVIE_ID_ALTERNATIVE
movie = tmdb.Movies(id)
response = movie.alternative_titles()
self.assertTrue(hasattr(movie, 'titles'))
def test_movies_credits(self):
id = MOVIE_ID
movie = tmdb.Movies(id)
response = movie.credits()
self.assertTrue(hasattr(movie, 'cast'))
def test_movies_external_ids(self):
id = MOVIE_ID
movie = tmdb.Movies(id)
response = movie.external_ids()
self.assertTrue(hasattr(movie, 'imdb_id'))
def test_movies_images(self):
id = MOVIE_ID
movie = tmdb.Movies(id)
response = movie.images()
self.assertTrue(hasattr(movie, 'backdrops'))
def test_movies_keywords(self):
id = MOVIE_ID
movie = tmdb.Movies(id)
response = movie.keywords()
self.assertTrue(hasattr(movie, 'keywords'))
def test_movies_release_dates(self):
id = MOVIE_ID
movie = tmdb.Movies(id)
response = movie.release_dates()
self.assertTrue(hasattr(movie, 'results'))
def test_movies_releases(self):
id = MOVIE_ID
movie = tmdb.Movies(id)
response = movie.releases()
self.assertTrue(hasattr(movie, 'countries'))
def test_movies_videos(self):
id = MOVIE_ID
movie = tmdb.Movies(id)
response = movie.videos()
self.assertTrue(hasattr(movie, 'results'))
def test_movies_translations(self):
id = MOVIE_ID_ALTERNATIVE
movie = tmdb.Movies(id)
response = movie.translations()
self.assertTrue(hasattr(movie, 'translations'))
def test_movies_similar_movies(self):
id = MOVIE_ID_ALTERNATIVE
movie = tmdb.Movies(id)
response = movie.similar_movies()
self.assertTrue(hasattr(movie, 'results'))
def test_movies_recommendations(self):
id = MOVIE_ID
movie = tmdb.Movies(id)
response = movie.recommendations()
self.assertTrue(hasattr(movie, 'results'))
def test_movies_reviews(self):
id = MOVIE_ID
movie = tmdb.Movies(id)
response = movie.reviews()
self.assertTrue(hasattr(movie, 'results'))
def test_movies_lists(self):
id = MOVIE_ID
movie = tmdb.Movies(id)
response = movie.lists()
self.assertTrue(hasattr(movie, 'results'))
def test_movies_changes(self):
id = MOVIE_ID
movie = tmdb.Movies(id)
response = movie.changes()
self.assertTrue(hasattr(movie, 'changes'))
def test_movies_latest(self):
movie = tmdb.Movies()
response = movie.latest()
self.assertTrue(hasattr(movie, 'popularity'))
def test_movies_upcoming(self):
movie = tmdb.Movies()
response = movie.upcoming()
self.assertTrue(hasattr(movie, 'results'))
def test_movies_now_playing(self):
movie = tmdb.Movies()
response = movie.now_playing()
self.assertTrue(hasattr(movie, 'results'))
def test_movies_popular(self):
movie = tmdb.Movies()
response = movie.popular()
self.assertTrue(hasattr(movie, 'results'))
def test_movies_top_rated(self):
movie = tmdb.Movies()
response = movie.top_rated()
self.assertTrue(hasattr(movie, 'results'))
def test_movies_account_states(self):
id = MOVIE_ID_ALTERNATIVE
movie = tmdb.Movies(id)
response = movie.account_states(session_id=SESSION_ID)
self.assertTrue(hasattr(movie, 'favorite'))
def test_movies_rating(self):
id = MOVIE_ID
status_code = SUCCESSFUL_UPDATE
movie = tmdb.Movies(id)
response = movie.rating(session_id=SESSION_ID, value=RATING)
self.assertEqual(movie.status_code, status_code)
class CollectionsTestCase(unittest.TestCase):
def test_collections_info(self):
id = COLLECTION_ID
name = COLLECTION_NAME
collection = tmdb.Collections(id)
response = collection.info()
self.assertEqual(collection.name, name)
def test_collections_images(self):
id = COLLECTION_ID
collection = tmdb.Collections(id)
response = collection.images()
self.assertTrue(hasattr(collection, 'backdrops'))
class CompaniesTestCase(unittest.TestCase):
def test_companies_info(self):
id = COMPANY_ID
name = COMPANY_NAME
company = tmdb.Companies(id)
response = company.info()
self.assertEqual(company.name, name)
def test_companies_movies(self):
id = COMPANY_ID
company = tmdb.Companies(id)
response = 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)
response = keyword.info()
self.assertEqual(keyword.name, name)
def test_keywords_movies(self):
id = KEYWORD_ID
keyword = tmdb.Keywords(id)
response = 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)
response = review.info()
self.assertEqual(review.author, author)
tmdbsimple-2.2.0/tests/test_people.py 0000664 0000000 0000000 00000005030 13262565317 0017722 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-2018 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 = 'Actors'
class PeopleTestCase(unittest.TestCase):
def test_people_info(self):
id = PEOPLE_ID
name = PEOPLE_NAME
person = tmdb.People(id)
response = person.info()
self.assertEqual(person.name, name)
def test_people_movie_credits(self):
id = PEOPLE_ID
person = tmdb.People(id)
response = person.movie_credits()
self.assertTrue(hasattr(person, 'cast'))
def test_people_tv_credits(self):
id = PEOPLE_ID
person = tmdb.People(id)
response = person.tv_credits()
self.assertTrue(hasattr(person, 'cast'))
def test_people_combined_credits(self):
id = PEOPLE_ID
person = tmdb.People(id)
response = person.combined_credits()
self.assertTrue(hasattr(person, 'cast'))
def test_people_external_ids(self):
id = PEOPLE_ID
person = tmdb.People(id)
response = person.external_ids()
self.assertTrue(hasattr(person, 'tvrage_id'))
def test_people_images(self):
id = PEOPLE_ID
person = tmdb.People(id)
response = person.images()
self.assertTrue(hasattr(person, 'profiles'))
def test_people_changes(self):
id = PEOPLE_ID
person = tmdb.People(id)
response = person.changes()
self.assertTrue(hasattr(person, 'changes'))
def test_people_popular(self):
person = tmdb.People()
response = person.popular()
self.assertTrue(hasattr(person, 'results'))
def test_people_latest(self):
person = tmdb.People()
response = person.latest()
self.assertTrue(hasattr(person, 'name'))
class CreditsTestCase(unittest.TestCase):
def test_credits_info(self):
id = CREDITS_ID
department = CREDITS_DEPARTMENT
credit = tmdb.Credits(id)
response = credit.info()
self.assertEqual(credit.department, department)
class JobsTestCase(unittest.TestCase):
def test_jobs_list(self):
lst = tmdb.Jobs()
response = lst.list()
self.assertTrue(hasattr(lst, 'jobs'))
tmdbsimple-2.2.0/tests/test_search.py 0000664 0000000 0000000 00000003530 13262565317 0017706 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-2018 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_movies(self):
query = QUERY_1
search = tmdb.Search()
response = search.movie(query=query)
self.assertTrue(hasattr(search, 'results'))
def test_search_collection(self):
query = QUERY_2
search = tmdb.Search()
response = search.collection(query=query)
self.assertTrue(hasattr(search, 'results'))
def test_search_tv(self):
query = QUERY_3
search = tmdb.Search()
response = search.tv(query=query)
self.assertTrue(hasattr(search, 'results'))
def test_search_person(self):
query = QUERY_4
search = tmdb.Search()
response = search.person(query=query)
self.assertTrue(hasattr(search, 'results'))
def test_search_company(self):
query = QUERY_6
search = tmdb.Search()
response = search.company(query=query)
self.assertTrue(hasattr(search, 'results'))
def test_search_keyword(self):
query = QUERY_7
search = tmdb.Search()
response = search.keyword(query=query)
self.assertTrue(hasattr(search, 'results'))
def test_search_multi(self):
query = QUERY_8
search = tmdb.Search()
response = search.multi(query=query)
self.assertTrue(hasattr(search, 'results'))
tmdbsimple-2.2.0/tests/test_tv.py 0000664 0000000 0000000 00000016232 13262565317 0017075 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-2018 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_NUMBER = 1
TV_EPISODE_NAME = 'Pilot'
TV_EPISODE_IMDB_ID = 'tt0959621'
NETWORK_ID = 49
NETWORK_NAME = 'HBO'
"""
Status codes and messages
"""
SUCCESSFUL_UPDATE = 12
class TVTestCase(unittest.TestCase):
def test_tv_info(self):
id = TV_ID
name = TV_NAME
tv = tmdb.TV(id)
response = tv.info()
self.assertEqual(tv.name, name)
def test_tv_alternative_titles(self):
id = TV_ID
tv = tmdb.TV(id)
response = tv.alternative_titles()
self.assertTrue(hasattr(tv, 'results'))
def test_tv_content_ratings(self):
id = TV_ID
tv = tmdb.TV(id)
response = tv.content_ratings()
self.assertTrue(hasattr(tv, 'results'))
def test_tv_credits(self):
id = TV_ID
tv = tmdb.TV(id)
response = tv.credits()
self.assertTrue(hasattr(tv, 'cast'))
def test_tv_external_ids(self):
id = TV_ID
imdb_id = TV_IMDB_ID
tv = tmdb.TV(id)
response = tv.external_ids()
self.assertEqual(tv.imdb_id, imdb_id)
def test_tv_images(self):
id = TV_ID
tv = tmdb.TV(id)
response = tv.images()
self.assertTrue(hasattr(tv, 'backdrops'))
def test_tv_rating(self):
id = TV_ID
status_code = SUCCESSFUL_UPDATE
tv = tmdb.TV(id)
response = tv.rating(session_id=SESSION_ID, value=RATING)
self.assertEqual(tv.status_code, status_code)
def test_tv_similar(self):
id = TV_ID
tv = tmdb.TV(id)
response = tv.similar()
self.assertTrue(hasattr(tv, 'results'))
def test_tv_recommendations(self):
id = TV_ID
tv = tmdb.TV(id)
response = tv.recommendations()
self.assertTrue(hasattr(tv, 'results'))
def test_tv_translations(self):
id = TV_ID
tv = tmdb.TV(id)
response = tv.translations()
self.assertTrue(hasattr(tv, 'translations'))
def test_tv_videos(self):
id = TV_ID
tv = tmdb.TV(id)
response = tv.videos()
self.assertTrue(hasattr(tv, 'results'))
def test_tv_latest(self):
tv = tmdb.TV()
response = tv.latest()
self.assertTrue(hasattr(tv, 'first_air_date'))
def test_tv_on_the_air(self):
tv = tmdb.TV()
response = tv.on_the_air()
self.assertTrue(hasattr(tv, 'results'))
def test_tv_airing_today(self):
tv = tmdb.TV()
response = tv.airing_today()
self.assertTrue(hasattr(tv, 'results'))
def test_tv_top_rated(self):
tv = tmdb.TV()
response = tv.top_rated()
self.assertTrue(hasattr(tv, 'results'))
def test_tv_popular(self):
tv = tmdb.TV()
response = tv.popular()
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)
response = tv_seasons.info()
self.assertEqual(tv_seasons.name, name)
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)
response = 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)
response = 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)
response = 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)
response = 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_episodes = tmdb.TV_Episodes(series_id, season_number, episode_number)
response = tv_episodes.info()
response = tv_episodes.info()
self.assertEqual(tv_episodes.name, name)
def test_tv_episodes_credits(self):
series_id = TV_ID
season_number = TV_SEASON_NUMBER
episode_number = TV_EPISODE_NUMBER
tv_episodes = tmdb.TV_Episodes(series_id, season_number, episode_number)
response = tv_episodes.credits()
self.assertTrue(hasattr(tv_episodes, '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_episodes = tmdb.TV_Episodes(series_id, season_number, episode_number)
response = tv_episodes.external_ids()
self.assertEqual(tv_episodes.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_episodes = tmdb.TV_Episodes(series_id, season_number, episode_number)
response = tv_episodes.images()
self.assertTrue(hasattr(tv_episodes, 'stills'))
def test_tv_episodes_rating(self):
series_id = TV_ID
season_number = TV_SEASON_NUMBER
episode_number = TV_EPISODE_NUMBER
status_code = SUCCESSFUL_UPDATE
tv_episodes = tmdb.TV_Episodes(series_id, season_number, episode_number)
response = tv_episodes.rating(session_id=SESSION_ID, value=RATING)
self.assertEqual(tv_episodes.status_code, status_code)
def test_tv_episodes_videos(self):
series_id = TV_ID
season_number = TV_SEASON_NUMBER
episode_number = TV_EPISODE_NUMBER
status_code = SUCCESSFUL_UPDATE
tv_episodes = tmdb.TV_Episodes(series_id, season_number, episode_number)
response = tv_episodes.videos()
self.assertTrue(hasattr(tv_episodes, 'results'))
class NetworksTestCase(unittest.TestCase):
def test_networks_info(self):
id = NETWORK_ID
name = NETWORK_NAME
network = tmdb.Networks(id)
response = network.info()
self.assertEqual(network.name, name)
tmdbsimple-2.2.0/tmdbsimple/ 0000775 0000000 0000000 00000000000 13262565317 0016025 5 ustar 00root root 0000000 0000000 tmdbsimple-2.2.0/tmdbsimple/__init__.py 0000664 0000000 0000000 00000002460 13262565317 0020140 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-2018 by Celia Oakley.
:license: GPLv3, see LICENSE for more details
"""
__title__ = 'tmdbsimple'
__version__ = '2.2.0'
__author__ = 'Celia Oakley'
__copyright__ = 'Copyright (c) 2013-2018 Celia Oakley'
__license__ = 'GPLv3'
import os
from .account import Account, Authentication, GuestSessions, Lists
from .base import APIKeyError
from .changes import Changes
from .configuration import Configuration, Certifications, Timezones
from .discover import Discover
from .find import Find
from .genres import Genres
from .movies import Movies, Collections, Companies, Keywords, Reviews
from .people import People, Credits, Jobs
from .search import Search
from .tv import TV, TV_Seasons, TV_Episodes, Networks
API_KEY = os.environ.get('TMDB_API_KEY', None)
API_VERSION = '3'
tmdbsimple-2.2.0/tmdbsimple/account.py 0000664 0000000 0000000 00000035400 13262565317 0020035 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-2018 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',
'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 the basic information for an account.
Call this method first, before calling other Account methods.
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 the lists that you have created and marked as a favorite.
Args:
page: (optional) Minimum 1, maximum 1000.
language: (optional) ISO 639-1 code.
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 favorite movies for an account.
Args:
page: (optional) Minimum 1, maximum 1000.
sort_by: (optional) 'created_at.asc' | 'created_at.desc'
language: (optional) ISO 639-1 code.
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 favorite TV series for an account.
Args:
page: (optional) Minimum 1, maximum 1000.
sort_by: (optional) 'created_at.asc' | 'created_at.desc'
language: (optional) ISO 639-1 code.
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):
"""
Add or remove a movie to an accounts favorite list.
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 the list of rated movies (and associated rating) for an account.
Args:
page: (optional) Minimum 1, maximum 1000.
sort_by: (optional) 'created_at.asc' | 'created_at.desc'
language: (optional) ISO 639-1 code.
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 the list of rated TV shows (and associated rating) for an account.
Args:
page: (optional) Minimum 1, maximum 1000.
sort_by: (optional) 'created_at.asc' | 'created_at.desc'
language: (optional) ISO 639-1 code.
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 watchlist_movies(self, **kwargs):
"""
Get the list of movies on an account watchlist.
Args:
page: (optional) Minimum 1, maximum 1000.
sort_by: (optional) 'created_at.asc' | 'created_at.desc'
language: (optional) ISO 639-1 code.
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 the list of TV series on an account watchlist.
Args:
page: (optional) Minimum 1, maximum 1000.
sort_by: (optional) 'created_at.asc' | 'created_at.desc'
language: (optional) ISO 639-1 code.
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 or remove a movie to an accounts watch list.
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 = {
'token_new': '/token/new',
'token_validate_with_login': '/token/validate_with_login',
'session_new': '/session/new',
'guest_session_new': '/guest_session/new',
}
def token_new(self, **kwargs):
"""
Generate a valid request token for user based authentication.
A request token is required to ask the user for permission to
access their account.
After obtaining the request_token, either:
(1) Direct your user to:
https://www.themoviedb.org/authenticate/REQUEST_TOKEN
or:
(2) Call token_validate_with_login() below.
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 token_validate_with_login(self, **kwargs):
"""
Authenticate a user with a TMDb username and password. The user
must have a verified email address and be registered on TMDb.
Args:
request_token: The token you generated for the user to approve.
username: The user's username on TMDb.
password: The user's password on TMDb.
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_new(self, **kwargs):
"""
Generate a session id for user based authentication.
A session id is required in order to use any of the write methods.
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 guest_session_new(self, **kwargs):
"""
Generate a guest session id.
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
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',
}
def __init__(self, guest_session_id=0):
super(GuestSessions, self).__init__()
self.guest_session_id = guest_session_id
def rated_movies(self, **kwargs):
"""
Get a list of rated moview for a specific guest session id.
Args:
page: (optional) Minimum 1, maximum 1000.
sort_by: (optional) 'created_at.asc' | 'created_at.desc'
language: (optional) ISO 639-1 code.
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
class Lists(TMDB):
"""
Lists functionality.
See: https://developers.themoviedb.org/3/lists
"""
BASE_PATH = 'list'
URLS = {
'info': '/{id}',
'item_status': '/{id}/item_status',
'create_list': '',
'add_item': '/{id}/add_item',
'remove_item': '/{id}/remove_item',
'clear': '/{id}/clear',
}
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 a list by 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
def item_status(self, **kwargs):
"""
Check to see if a movie id is already added to a list.
Args:
movie_id: The id of the movie.
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 create_list(self, **kwargs):
"""
Create a new list.
A valid session id is required.
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('create_list')
kwargs.update({'session_id': self.session_id})
payload = {
'name': kwargs.pop('name', None),
'description': kwargs.pop('description', None),
}
if 'language' in kwargs:
payload['language'] = kwargs['language']
response = self._POST(path, kwargs, payload)
self._set_attrs_to_values(response)
return response
def add_item(self, **kwargs):
"""
Add new movies to a list that the user created.
A valid session id is required.
Args:
media_id: A movie id.
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):
"""
Delete movies from a list that the user created.
A valid session id is required.
Args:
media_id: A movie id.
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 clear_list(self, **kwargs):
"""
Clears all of the items within a list. This is an irreversible action
and should be treated with caution.
A valid session id is required.
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('clear')
kwargs.update({'session_id': self.session_id})
payload = {}
response = self._POST(path, kwargs, payload)
self._set_attrs_to_values(response)
return response
tmdbsimple-2.2.0/tmdbsimple/base.py 0000664 0000000 0000000 00000006217 13262565317 0017317 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-2018 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
self.base_uri = 'https://api.themoviedb.org'
self.base_uri += '/{version}'.format(version=API_VERSION)
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_series_id_season_number_path(self, key):
return self._get_path(key).format(series_id=self.series_id,
season_number=self.season_number)
def _get_series_id_season_number_episode_number_path(self, key):
return self._get_path(key).format(series_id=self.series_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)
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)
response = requests.request(
method, url, params=params,
data=json.dumps(payload) if payload else payload,
headers=self.headers)
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.2.0/tmdbsimple/changes.py 0000664 0000000 0000000 00000004231 13262565317 0020007 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-2018 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',
'person': 'person/changes',
'tv': 'tv/changes',
}
def movie(self, **kwargs):
"""
Get a list of movie ids that have been edited.
Args:
page: (optional) Minimum 1, maximum 1000.
start_date: (optional) Expected format is 'YYYY-MM-DD'.
end_date: (optional) Expected format is 'YYYY-MM-DD'.
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 person(self, **kwargs):
"""
Get a list of people ids that have been edited.
Args:
page: (optional) Minimum 1, maximum 1000.
start_date: (optional) Expected format is 'YYYY-MM-DD'.
end_date: (optional) Expected format is 'YYYY-MM-DD'.
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):
"""
Get a list of TV show ids that have been edited.
Args:
page: (optional) Minimum 1, maximum 1000.
start_date: (optional) Expected format is 'YYYY-MM-DD'.
end_date: (optional) Expected format is 'YYYY-MM-DD'.
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.2.0/tmdbsimple/configuration.py 0000664 0000000 0000000 00000004021 13262565317 0021243 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
"""
tmdbsimple.configuration
~~~~~~~~~~~~~~~~~~~~~~~~
This module implements the Configuration, Certifications, and Timezones
functionality of tmdbsimple.
Created by Celia Oakley on 2013-10-31.
:copyright: (c) 2013-2018 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': '',
}
def info(self, **kwargs):
"""
Get the system wide configuration info.
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
class Certifications(TMDB):
"""
Certifications functionality.
See: https://developers.themoviedb.org/3/certifications
"""
BASE_PATH = 'certification'
URLS = {
'movie_list': '/movie/list',
}
def list(self, **kwargs):
"""
Get the list of supported certifications for movies.
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
class Timezones(TMDB):
"""
Timezones functionality.
See: https://developers.themoviedb.org/3/timezones
"""
BASE_PATH = 'timezones'
URLS = {
'list': '/list',
}
def list(self, **kwargs):
"""
Get the list of supported timezones for the API methods that support
them.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('list')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
tmdbsimple-2.2.0/tmdbsimple/discover.py 0000664 0000000 0000000 00000016127 13262565317 0020224 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-2018 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.
Args:
page: (optional) Minimum 1, maximum 1000.
language: (optional) ISO 639-1 code.
sort_by: (optional) Available options are 'vote_average.desc',
'vote_average.asc', 'release_date.desc', 'release_date.asc'
'popularity.desc', 'popularity.asc'.
include_adult: (optional) Toggle the inclusion of adult titles.
Expected value is a boolean, True or False.
year: (optional) Filter the results release dates to matches that
include this value. Expected value is a year.
primary_release_year: (optional) Filter the results so that
only the primary release date year has
this value. Expected value is a year.
vote_count.gte or vote_count_gte: (optional) Only include movies
that are equal to, or have a vote count higher
than this value. Expected value is an integer.
vote_average.gte or vote_average_gte: (optional) Only include
movies that are equal to, or have a higher
average rating than this value. Expected value
is a float.
with_genres: (optional) Only include movies with the specified
genres. Expected value is an integer (the id of
a genre). Multiple values can be specified.
Comma separated indicates an 'AND' query, while
a pipe (|) separated value indicates an 'OR'.
release_date.gte or release_date_gte: (optional) The minimum
release to include. Expected format is
'YYYY-MM-DD'.
releaste_date.lte or release_date_lte: (optional) The maximum
release to include. Expected format is
'YYYY-MM-DD'.
certification_country: (optional) Only include movies with
certifications for a specific country. When
this value is specified, 'certification.lte'
is required. An ISO 3166-1 is expected.
certification.lte or certification_lte: (optional) Only include
movies with this certification and lower.
Expected value is a valid certification for
the specified 'certification_country'.
with_companies: (optional) Filter movies to include a specific
company. Expected value is an integer (the id
of a company). They can be comma separated
to indicate an 'AND' query.
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 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.
Args:
page: (optional) Minimum 1, maximum 1000.
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'
first_air_year: (optional) Filter the results release dates to
matches that include this value. Expected value
is a year.
vote_count.gte or vote_count_gte: (optional) Only include TV shows
that are equal to,
or have vote count higher than this value. Expected
value is an integer.
vote_average.gte or vote_average_gte: (optional) Only include TV
shows that are equal
to, or have a higher average rating than this
value. Expected value is a float.
with_genres: (optional) Only include TV shows with the specified
genres. Expected value is an integer (the id of a
genre). Multiple valued can be specified. Comma
separated indicates an 'AND' query, while a
pipe (|) separated value indicates an 'OR'.
with_networks: (optional) Filter TV shows to include a specific
network. Expected value is an integer (the id of a
network). They can be comma separated to indicate an
'AND' query.
first_air_date.gte or first_air_date_gte: (optional) The minimum
release to include.
Expected format is 'YYYY-MM-DD'.
first_air_date.lte or first_air_date_lte: (optional) The maximum
release to include.
Expected format is 'YYYY-MM-DD'.
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 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.2.0/tmdbsimple/find.py 0000664 0000000 0000000 00000002620 13262565317 0017317 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-2018 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):
"""
Search for objects in the database by an external id. For instance,
an IMDB ID. This will search all objects (movies, TV shows and people)
and return the results in a single response. TV season and TV episode
searches will be supported shortly.
The supported external sources for each object are as follows:
Movies: imdb_id
People: imdb_id, freebase_mid, freebase_id, tvrage_id
TV Series: imdb_id, freebase_mid, freebase_id, tvdb_id, tvrage_id
Args:
external_source: See lists above.
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
tmdbsimple-2.2.0/tmdbsimple/genres.py 0000664 0000000 0000000 00000004455 13262565317 0017672 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-2018 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',
}
def __init__(self, id=0):
super(Genres, self).__init__()
self.id = id
def movie_list(self, **kwargs):
"""
Get the list of Movie genres.
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 TV genres.
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
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.2.0/tmdbsimple/movies.py 0000664 0000000 0000000 00000043426 13262565317 0017712 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-2018 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}',
'alternative_titles': '/{id}/alternative_titles',
'credits': '/{id}/credits',
'external_ids': '/{id}/external_ids',
'images': '/{id}/images',
'keywords': '/{id}/keywords',
'release_dates': '/{id}/release_dates',
'releases': '/{id}/releases',
'videos': '/{id}/videos',
'translations': '/{id}/translations',
'similar_movies': '/{id}/similar_movies',
'reviews': '/{id}/reviews',
'lists': '/{id}/lists',
'changes': '/{id}/changes',
'latest': '/latest',
'upcoming': '/upcoming',
'now_playing': '/now_playing',
'popular': '/popular',
'top_rated': '/top_rated',
'account_states': '/{id}/account_states',
'rating': '/{id}/rating',
'recommendations': '/{id}/recommendations'
}
def __init__(self, id=0):
super(Movies, self).__init__()
self.id = id
def info(self, **kwargs):
"""
Get the basic movie information for a specific movie id.
Args:
language: (optional) ISO 639-1 code.
append_to_response: (optional) Comma separated, any movie method.
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_titles(self, **kwargs):
"""
Get the alternative titles for a specific movie id.
Args:
country: (optional) ISO 3166-1 code.
append_to_response: (optional) Comma separated, any movie method.
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 credits(self, **kwargs):
"""
Get the cast and crew information for a specific movie id.
Args:
append_to_response: (optional) Comma separated, any movie method.
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 external_ids(self, **kwargs):
"""
Get the external ids for a specific movie id.
Args:
language: (optional) ISO 639-1 code.
append_to_response: (optional) Comma separated, any movie method.
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 (posters and backdrops) for a specific movie id.
Args:
language: (optional) ISO 639-1 code.
append_to_response: (optional) Comma separated, any movie method.
include_image_language: (optional) Comma separated, a valid
ISO 69-1.
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):
"""
Get the plot keywords for a specific movie id.
Returns:
A dict respresentation 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 recommendations(self, **kwargs):
"""
Get a list of recommended movies for a movie.
Args:
language: (optional) ISO 639-1 code.
page: (optional) Minimum value of 1. Expected value is an integer.
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 release_dates(self, **kwargs):
"""
Get the release dates and certification for a specific movie id.
Args:
append_to_response: (optional) Comma separated, any movie method.
Returns:
A dict respresentation 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 releases(self, **kwargs):
"""
Get the release date and certification information by country for a
specific movie id.
Args:
append_to_response: (optional) Comma separated, any movie method.
Returns:
A dict respresentation 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
def videos(self, **kwargs):
"""
Get the videos (trailers, teasers, clips, etc...) for a
specific movie id.
Args:
append_to_response: (optional) Comma separated, any movie method.
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 translations(self, **kwargs):
"""
Get the translations for a specific movie id.
Args:
append_to_response: (optional) Comma separated, any movie method.
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 similar_movies(self, **kwargs):
"""
Get the similar movies for a specific movie id.
Args:
page: (optional) Minimum value of 1. Expected value is an integer.
language: (optional) ISO 639-1 code.
append_to_response: (optional) Comma separated, any movie method.
Returns:
A dict respresentation 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 reviews(self, **kwargs):
"""
Get the reviews for a particular movie id.
Args:
page: (optional) Minimum value of 1. Expected value is an integer.
language: (optional) ISO 639-1 code.
append_to_response: (optional) Comma separated, any movie method.
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 lists(self, **kwargs):
"""
Get the lists that the movie belongs to.
Args:
page: (optional) Minimum value of 1. Expected value is an integer.
language: (optional) ISO 639-1 code.
append_to_response: (optional) Comma separated, any movie method.
Returns:
A dict respresentation 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 changes(self, **kwargs):
"""
Get the changes for a specific movie id.
Changes are grouped by key, and ordered by date in descending order.
By default, only the last 24 hours of changes are returned. The
maximum number of days that can be returned in a single request is 14.
The language is present on fields that are translatable.
Args:
start_date: (optional) Expected format is 'YYYY-MM-DD'.
end_date: (optional) Expected format is 'YYYY-MM-DD'.
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 latest(self, **kwargs):
"""
Get the latest movie id.
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 upcoming(self, **kwargs):
"""
Get the list of upcoming movies. This list refreshes every day.
The maximum number of items this list will include is 100.
Args:
page: (optional) Minimum value of 1. Expected value is an integer.
language: (optional) ISO 639-1 code.
Returns:
A dict respresentation 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
def now_playing(self, **kwargs):
"""
Get the list of movies playing in theatres. This list refreshes
every day. The maximum number of items this list will include is 100.
Args:
page: (optional) Minimum value of 1. Expected value is an integer.
language: (optional) ISO 639-1 code.
Returns:
A dict respresentation 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 the list of popular movies on The Movie Database. This list
refreshes every day.
Args:
page: (optional) Minimum value of 1. Expected value is an integer.
language: (optional) ISO 639-1 code.
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 the list of top rated movies. By default, this list will only
include movies that have 10 or more votes. This list refreshes every
day.
Args:
page: (optional) Minimum value of 1. Expected value is an integer.
language: (optional) ISO 639-1 code.
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
def account_states(self, **kwargs):
"""
This method lets users get the status of whether or not the movie has
been rated or added to their favourite or watch lists. A valid session
id is required.
Args:
session_id: 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 rating(self, **kwargs):
"""
This method lets users rate a movie. A valid session id or guest
session id is required.
Args:
session_id: see Authentication.
guest_session_id: see Authentication.
value: Rating value.
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
class Collections(TMDB):
"""
Collections functionality.
See: https://developers.themoviedb.org/3/collections
"""
BASE_PATH = 'collection'
URLS = {
'info': '/{id}',
'images': '/{id}/images',
}
def __init__(self, id):
super(Collections, self).__init__()
self.id = id
def info(self, **kwargs):
"""
Get the basic collection information for a specific collection id.
You can get the ID needed for this method by making a /movie/{id}
request and paying attention to the belongs_to_collection hash.
Movie parts are not sorted in any particular order. If you would like
to sort them yourself you can use the provided release_date.
Args:
language: (optional) ISO 639-1 code.
append_to_response: (optional) Comma separated, any movie method.
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 images(self, **kwargs):
"""
Get all of the images for a particular collection by collection id.
Args:
language: (optional) ISO 639-1 code.
append_to_response: (optional) Comma separated, any movie method.
include_image_language: (optional) Comma separated, a valid
ISO 69-1.
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
class Companies(TMDB):
"""
Companies functionality.
See: https://developers.themoviedb.org/3/companies
"""
BASE_PATH = 'company'
URLS = {
'info': '/{id}',
'movies': '/{id}/movies',
}
def __init__(self, id=0):
super(Companies, self).__init__()
self.id = id
def info(self, **kwargs):
"""
This method is used to retrieve all of the basic information about a
company.
Args:
append_to_response: (optional) Comma separated, any movie method.
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 movies(self, **kwargs):
"""
Get the list of movies associated with a particular company.
Args:
page: (optional) Minimum value of 1. Expected value is an integer.
language: (optional) ISO 639-1 code.
append_to_response: (optional) Comma separated, any movie method.
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
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 basic information for a specific keyword 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
def movies(self, **kwargs):
"""
Get the list of movies for a particular keyword by id.
Args:
page: (optional) Minimum value of 1. Expected value is an integer.
language: (optional) ISO 639-1 code.
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
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 full details of a review by 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
tmdbsimple-2.2.0/tmdbsimple/people.py 0000664 0000000 0000000 00000016111 13262565317 0017663 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
"""
tmdbsimple.people
~~~~~~~~~~~~~~~~~
This module implements the People, Credits, and Jobs functionality
of tmdbsimple.
Created by Celia Oakley on 2013-10-31.
:copyright: (c) 2013-2018 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}',
'movie_credits': '/{id}/movie_credits',
'tv_credits': '/{id}/tv_credits',
'combined_credits': '/{id}/combined_credits',
'external_ids': '/{id}/external_ids',
'images': '/{id}/images',
'changes': '/{id}/changes',
'popular': '/popular',
'latest': '/latest',
}
def __init__(self, id=0):
super(People, self).__init__()
self.id = id
def info(self, **kwargs):
"""
Get the general person information for a specific id.
Args:
append_to_response: (optional) Comma separated, any person method.
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 movie_credits(self, **kwargs):
"""
Get the movie credits for a specific person id.
Args:
language: (optional) ISO 639-1 code.
append_to_response: (optional) Comma separated, any person method.
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 credits for a specific person id.
Args:
language: (optional) ISO 639-1 code.
append_to_response: (optional) Comma separated, any person method.
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 combined (movie and TV) credits for a specific person id.
To get the expanded details for each TV record, call the /credit method
with the provided credit_id. This will provide details about which
episode and/or season the credit is for.
Args:
language: (optional) ISO 639-1 code.
append_to_response: (optional) Comma separated, any person method.
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 specific person id.
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 specific person id.
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 changes(self, **kwargs):
"""
Get the changes for a specific person id.
Changes are grouped by key, and ordered by date in descending order.
By default, only the last 24 hours of changes are returned. The maximum
number of days that can be returned in a single request is 14. The
language is present on fields that are translatable.
Args:
start_date: (optional) Expected format is 'YYYY-MM-DD'.
end_date: (optional) Expected format is 'YYYY-MM-DD'.
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 popular(self, **kwargs):
"""
Get the list of popular people on The Movie Database. This list
refreshes every day.
Args:
page: (optional) Minimum 1, maximum 1000.
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 latest(self, **kwargs):
"""
Get the latest person id.
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
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 the detailed information about a particular credit record. This is
currently only supported with the new credit model found in TV. These
ids can be found from any TV credit response as well as the tv_credits
and combined_credits methods for people.
The episodes object returns a list of episodes and are generally going
to be guest stars. The season array will return a list of season
numbers. Season credits are credits that were marked with the
"add to every season" option in the editing interface and are
assumed to be "season regulars".
Args:
language: (optional) ISO 639-1 code.
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
class Jobs(TMDB):
"""
Jobs functionality.
See: https://developers.themoviedb.org/3/jobs
"""
BASE_PATH = 'job'
URLS = {
'list': '/list',
}
def list(self, **kwargs):
"""
Get a list of valid jobs.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('list')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
tmdbsimple-2.2.0/tmdbsimple/search.py 0000664 0000000 0000000 00000014214 13262565317 0017646 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-2018 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 = {
'movie': '/movie',
'collection': '/collection',
'tv': '/tv',
'person': '/person',
'company': '/company',
'keyword': '/keyword',
'multi': '/multi'
}
def movie(self, **kwargs):
"""
Search for movies by title.
Args:
query: CGI escpaed string.
page: (optional) Minimum value of 1. Expected value is an integer.
language: (optional) ISO 639-1 code.
include_adult: (optional) Toggle the inclusion of adult titles.
Expected value is True or False.
year: (optional) Filter the results release dates to matches that
include this value.
primary_release_year: (optional) Filter the results so that only
the primary release dates have this value.
search_type: (optional) By default, the search type is 'phrase'.
This is almost guaranteed the option you will want.
It's a great all purpose search type and by far the
most tuned for every day querying. For those wanting
more of an "autocomplete" type search, set this
option to 'ngram'.
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 collection(self, **kwargs):
"""
Search for collections by name.
Args:
query: CGI escpaed string.
page: (optional) Minimum value of 1. Expected value is an integer.
language: (optional) ISO 639-1 code.
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 tv(self, **kwargs):
"""
Search for TV shows by title.
Args:
query: CGI escpaed string.
page: (optional) Minimum value of 1. Expected value is an integer.
language: (optional) ISO 639-1 code.
first_air_date_year: (optional) Filter the results to only match
shows that have a air date with with value.
search_type: (optional) By default, the search type is 'phrase'.
This is almost guaranteed the option you will want.
It's a great all purpose search type and by far the
most tuned for every day querying. For those wanting
more of an "autocomplete" type search, set this
option to 'ngram'.
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):
"""
Search for people by name.
Args:
query: CGI escpaed string.
page: (optional) Minimum value of 1. Expected value is an integer.
include_adult: (optional) Toggle the inclusion of adult titles.
Expected value is True or False.
search_type: (optional) By default, the search type is 'phrase'.
This is almost guaranteed the option you will want.
It's a great all purpose search type and by far the
most tuned for every day querying. For those wanting
more of an "autocomplete" type search, set this
option to 'ngram'.
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 company(self, **kwargs):
"""
Search for companies by name.
Args:
query: CGI escpaed string.
page: (optional) Minimum value of 1. Expected value is an integer.
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 keyword(self, **kwargs):
"""
Search for keywords by name.
Args:
query: CGI escpaed string.
page: (optional) Minimum value of 1. Expected value is an integer.
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 multi(self, **kwargs):
"""
Search the movie, tv show and person collections with a single query.
Args:
query: CGI escpaed string.
page: (optional) Minimum value of 1. Expected value is an integer.
language: (optional) ISO 639-1 code.
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_path('multi')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
tmdbsimple-2.2.0/tmdbsimple/tv.py 0000664 0000000 0000000 00000042264 13262565317 0017040 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-2018 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}',
'alternative_titles': '/{id}/alternative_titles',
'content_ratings': '/{id}/content_ratings',
'credits': '/{id}/credits',
'external_ids': '/{id}/external_ids',
'images': '/{id}/images',
'rating': '/{id}/rating',
'similar': '/{id}/similar',
'recommendations': '/{id}/recommendations',
'translations': '/{id}/translations',
'videos': '/{id}/videos',
'latest': '/latest',
'on_the_air': '/on_the_air',
'airing_today': '/airing_today',
'top_rated': '/top_rated',
'popular': '/popular',
}
def __init__(self, id=0):
super(TV, self).__init__()
self.id = id
def info(self, **kwargs):
"""
Get the primary information about a TV series by id.
Args:
language: (optional) ISO 639 code.
append_to_response: (optional) Comma separated, any TV series
method.
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_titles(self, **kwargs):
"""
Get the alternative titles for a specific tv id.
Args:
language: (optional) ISO 3166-1 code.
append_to_response: (optional) Comma separated, any tv method.
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 content ratings for a TV Series.
Args:
language: (optional) ISO 639 code.
append_to_response: (optional) Comma separated, any collection
method.
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 cast & crew information about a TV series. Just like the
website, we pull this information from the last season of the series.
Args:
language: (optional) ISO 639 code.
append_to_response: (optional) Comma separated, any collection
method.
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 external_ids(self, **kwargs):
"""
Get the external ids that we have stored for a TV series.
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 (posters and backdrops) for a TV series.
Args:
language: (optional) ISO 639 code.
include_image_language: (optional) Comma separated, a valid
ISO 69-1.
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 rating(self, **kwargs):
"""
This method lets users rate a TV show. A valid session id or guest
session id is required.
Args:
session_id: see Authentication.
guest_session_id: see Authentication.
value: Rating value.
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 similar(self, **kwargs):
"""
Get the similar TV series for a specific TV series id.
Args:
page: (optional) Minimum value of 1. Expected value is an integer.
language: (optional) ISO 639-1 code.
append_to_response: (optional) Comma separated, any TV method.
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 recommendations(self, **kwargs):
"""
Get the recommendations for TV series for a specific TV series id.
Args:
page: (optional) Minimum value of 1. Expected value is an integer.
language: (optional) ISO 639-1 code.
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 translations(self, **kwargs):
"""
Get the list of translations that exist for a TV series. These
translations cascade down to the episode level.
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 series (trailers, opening
credits, etc...).
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 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 on_the_air(self, **kwargs):
"""
Get the list of TV 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:
page: (optional) Minimum 1, maximum 1000.
language: (optional) ISO 639 code.
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 airing_today(self, **kwargs):
"""
Get the list of TV shows that air today. Without a specified timezone,
this query defaults to EST (Eastern Time UTC-05:00).
Args:
page: (optional) Minimum 1, maximum 1000.
language: (optional) ISO 639 code.
timezone: (optional) Valid value from the list of timezones.
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 top_rated(self, **kwargs):
"""
Get the list of top rated TV shows. By default, this list will only
include TV shows that have 2 or more votes. This list refreshes every
day.
Args:
page: (optional) Minimum 1, maximum 1000.
language: (optional) ISO 639 code.
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
def popular(self, **kwargs):
"""
Get the list of popular TV shows. This list refreshes every day.
Args:
page: (optional) Minimum 1, maximum 1000.
language: (optional) ISO 639 code.
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 TV_Seasons(TMDB):
"""
TV Seasons functionality.
See: https://developers.themoviedb.org/3/tv-seasons
"""
BASE_PATH = 'tv/{series_id}/season/{season_number}'
URLS = {
'info': '',
'credits': '/credits',
'external_ids': '/external_ids',
'images': '/images',
'videos': '/videos',
}
def __init__(self, series_id, season_number):
super(TV_Seasons, self).__init__()
self.series_id = series_id
self.season_number = season_number
def info(self, **kwargs):
"""
Get the primary information about a TV season by its season number.
Args:
language: (optional) ISO 639 code.
append_to_response: (optional) Comma separated, any TV series
method.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_series_id_season_number_path('info')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def credits(self, **kwargs):
"""
Get the cast & crew credits for a TV season by season number.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_series_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 that we have stored for a TV season by season
number.
Args:
language: (optional) ISO 639 code.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_series_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 (posters) that we have stored for a TV season by season
number.
Args:
language: (optional) ISO 639 code.
include_image_language: (optional) Comma separated, a valid
ISO 69-1.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_series_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 (trailers, teasers,
etc...).
Args:
language: (optional) ISO 639 code.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_series_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/{series_id}/season/{season_number}/episode/{episode_number}'
URLS = {
'info': '',
'credits': '/credits',
'external_ids': '/external_ids',
'images': '/images',
'rating': '/rating',
'videos': '/videos',
}
def __init__(self, series_id, season_number, episode_number):
super(TV_Episodes, self).__init__()
self.series_id = series_id
self.season_number = season_number
self.episode_number = episode_number
def info(self, **kwargs):
"""
Get the primary information about a TV episode by combination of a
season and episode number.
Args:
language: (optional) ISO 639 code.
append_to_response: (optional) Comma separated, any TV series
method.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_series_id_season_number_episode_number_path('info')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def credits(self, **kwargs):
"""
Get the TV episode credits by combination of season and episode number.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_series_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 by combination of a season and
episode number.
Args:
language: (optional) ISO 639 code.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_series_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 (episode stills) for a TV episode by combination of a
season and episode number. Since episode stills don't have a language,
this call will always return all images.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_series_id_season_number_episode_number_path('images')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def rating(self, **kwargs):
"""
This method lets users rate a TV episode. A valid session id or guest
session id is required.
Args:
session_id: see Authentication.
guest_session_id: see Authentication.
value: Rating value.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_series_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 videos(self, **kwargs):
"""
Get the videos that have been added to a TV episode (teasers, clips,
etc...).
Args:
language: (optional) ISO 639 code.
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_series_id_season_number_episode_number_path('videos')
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}',
}
def __init__(self, id):
super(Networks, self).__init__()
self.id = id
def info(self, **kwargs):
"""
This method is used to retrieve the basic information about a TV
network. You can use this ID to search for TV shows with the discover.
At this time we don't have much but this will be fleshed out over time.
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