├── .gitignore
├── LICENSE
├── LICENSE.txt
├── MANIFEST.in
├── README.md
├── README.txt
├── setup.py
├── tests
└── yify_test.py
└── torrentmediasearcher
├── __init__.py
├── examples
└── examples.py
└── providers
├── __init__.py
├── base_api.py
├── eztv_api.py
├── torrentproject_api.py
└── yify_api.py
/.gitignore:
--------------------------------------------------------------------------------
1 | *.py[cod]
2 |
3 | .idea/
4 | Thumbs.db
5 | *.log
6 | *.ini
7 |
8 | build/
9 | dist/
10 | MANIFEST
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Lesser General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 | {description}
294 | Copyright (C) {year} {fullname}
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License along
307 | with this program; if not, write to the Free Software Foundation, Inc.,
308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309 |
310 | Also add information on how to contact you by electronic and paper mail.
311 |
312 | If the program is interactive, make it output a short notice like this
313 | when it starts in an interactive mode:
314 |
315 | Gnomovision version 69, Copyright (C) year name of author
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 | This is free software, and you are welcome to redistribute it
318 | under certain conditions; type `show c' for details.
319 |
320 | The hypothetical commands `show w' and `show c' should show the appropriate
321 | parts of the General Public License. Of course, the commands you use may
322 | be called something other than `show w' and `show c'; they could even be
323 | mouse-clicks or menu items--whatever suits your program.
324 |
325 | You should also get your employer (if you work as a programmer) or your
326 | school, if any, to sign a "copyright disclaimer" for the program, if
327 | necessary. Here is a sample; alter the names:
328 |
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
331 |
332 | {signature of Ty Coon}, 1 April 1989
333 | Ty Coon, President of Vice
334 |
335 | This General Public License does not permit incorporating your program into
336 | proprietary programs. If your program is a subroutine library, you may
337 | consider it more useful to permit linking proprietary applications with the
338 | library. If this is what you want to do, use the GNU Lesser General
339 | Public License instead of this License.
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Lesser General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 | {description}
294 | Copyright (C) {year} {fullname}
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License along
307 | with this program; if not, write to the Free Software Foundation, Inc.,
308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309 |
310 | Also add information on how to contact you by electronic and paper mail.
311 |
312 | If the program is interactive, make it output a short notice like this
313 | when it starts in an interactive mode:
314 |
315 | Gnomovision version 69, Copyright (C) year name of author
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 | This is free software, and you are welcome to redistribute it
318 | under certain conditions; type `show c' for details.
319 |
320 | The hypothetical commands `show w' and `show c' should show the appropriate
321 | parts of the General Public License. Of course, the commands you use may
322 | be called something other than `show w' and `show c'; they could even be
323 | mouse-clicks or menu items--whatever suits your program.
324 |
325 | You should also get your employer (if you work as a programmer) or your
326 | school, if any, to sign a "copyright disclaimer" for the program, if
327 | necessary. Here is a sample; alter the names:
328 |
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
331 |
332 | {signature of Ty Coon}, 1 April 1989
333 | Ty Coon, President of Vice
334 |
335 | This General Public License does not permit incorporating your program into
336 | proprietary programs. If your program is a subroutine library, you may
337 | consider it more useful to permit linking proprietary applications with the
338 | library. If this is what you want to do, use the GNU Lesser General
339 | Public License instead of this License.
--------------------------------------------------------------------------------
/MANIFEST.in:
--------------------------------------------------------------------------------
1 | include *.txt
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | TorrentMediaSearcher
2 | ====================
3 |
4 | Fetches magnet links from various torrent providers.
5 |
6 | Allows specifying a movie or show name, season, episode and returns (if available) magnet links to the content of the requested quality.
7 | Torrents with the most seeds are prioritized. Works with threads and a function can be specified to send the results to.
8 |
9 | ### Features
10 | - Very easy to use
11 | - Provides exceptions
12 |
13 | ### Torrent providers
14 | - EZTV (tv)
15 | - TorrentProject (tv/movies)
16 | - YIFY (movies)
17 | - More can be requested
18 |
19 | ### Usage
20 | For usage examples, see:
21 |
22 | torrentmediasearcher/examples/examples.py
23 |
24 | ### Installation
25 | Windows users can run the .exe installer
26 |
27 | Everyone can run:
28 |
29 | python setup.py install
30 |
31 | ### Dependencies
32 | - requests
33 | - beautifulsoup4
34 | - simplejson
35 |
--------------------------------------------------------------------------------
/README.txt:
--------------------------------------------------------------------------------
1 | TorrentMediaSearcher
2 | ====================
3 |
4 | Fetches magnet links from various torrent providers.
5 |
6 | Allows specifying a movie or show name, season, episode and returns (if available) magnet links to the content of the requested quality.
7 | Torrents with the most seeds are prioritized. Works with threads and a function can be specified to send the results to.
8 |
9 | Features
10 | =============
11 |
12 | - Very easy to use
13 |
14 | - Returns a magnet link from the specified provider and lists seeds (if provider shows seeds)
15 |
16 | - Provides exceptions
17 |
18 | Torrent providers
19 | =============
20 |
21 | - EZTV (tv)
22 |
23 | - TorrentProject (tv/movies)
24 |
25 | - YIFY (movies)
26 |
27 | - More can be requested
28 |
29 | Usage
30 | =============
31 |
32 | For usage examples, see:
33 |
34 | https://github.com/Christilut/TorrentMediaSearcher/blob/master/torrentmediasearcher/examples/examples.py
35 |
36 | Installation
37 | =============
38 |
39 | Windows users can run the .exe installer
40 |
41 | Everyone can run:
42 |
43 | python setup.py install
44 |
45 | Dependencies
46 | =============
47 |
48 | - requests
49 |
50 | - beautifulsoup4
51 |
52 | - simplejson
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | from distutils.core import setup
2 |
3 | setup(
4 | name = 'TorrentMediaSearcher',
5 | packages = ['torrentmediasearcher', 'torrentmediasearcher.providers'],
6 | version = '1.0.3',
7 | description = 'Fetches TV and movie magnet links from various torrent providers',
8 | author = 'Christiaan Maks',
9 | author_email = 'christiaanmaks@mylittlesky.net',
10 | url = 'https://github.com/Christilut/TorrentMediaSearcher',
11 | keywords = ['torrent', 'magnet', 'eztv', 'yify', 'tv', 'movie'],
12 | classifiers = [
13 | 'Programming Language :: Python :: 2',
14 | 'Programming Language :: Python :: 3',
15 | 'Development Status :: 4 - Beta',
16 | 'Intended Audience :: Developers',
17 | 'Environment :: Other Environment',
18 | 'License :: OSI Approved :: GNU General Public License v2 (GPLv2)',
19 | 'Operating System :: OS Independent',
20 | 'Topic :: Software Development :: Libraries :: Python Modules',
21 | 'Topic :: Communications :: File Sharing',
22 | ],
23 | )
24 |
--------------------------------------------------------------------------------
/tests/yify_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 |
3 | from torrentmediasearcher.providers.yify_api import YIFYAPI
4 |
5 |
6 | class YIFYTest(unittest.TestCase):
7 |
8 | def test_create_query(self):
9 | """
10 | _create_query should return a string with the movie title seperated by %20 instead of spaces and add the year if it is supplied
11 | """
12 |
13 | movie = 'iron man 3'
14 | year = 2013
15 | quality = '1080p'
16 |
17 | yify = YIFYAPI(None)
18 |
19 | query = yify._create_query(movie=movie, year=year)
20 |
21 | self.assertTrue(query.startswith('keywords='))
22 | self.assertFalse(' ' in query)
23 |
24 | split_movie = movie.split(' ')
25 |
26 | for term in split_movie:
27 | self.assertTrue(term in query)
28 |
29 | def test_get_json(self):
30 | """
31 | _get_json should return a valid json or raise a LookupError incase of network issues
32 | """
33 | pass
34 |
35 | def test_get_magnet_movie(self):
36 | """
37 | _get_magnet_movie should return a dict() with magnet and seeds key or raise an exception: MovieNotFound, QualityNotFound, LookupError
38 | """
39 |
40 | movie = 'iron man 3'
41 | year = 2013
42 | quality = '1080p'
43 |
44 | yify = YIFYAPI(None)
45 | yify._wanted_movie = movie
46 |
47 | query = yify._create_query(movie=movie, year=year)
48 |
49 | result = yify._get_magnet_movie(query=query, quality=quality, year=year)
50 |
51 | self.assertTrue('seeds' in result.keys())
52 | self.assertTrue('magnet' in result.keys())
53 | self.assertEqual(2, len(result))
54 |
55 | self.assertTrue(result['magnet'].startswith('magnet:?'))
56 | self.assertGreaterEqual(int(result['seeds']), 0)
57 |
58 |
59 |
60 |
61 | if __name__ == "__main__":
62 | unittest.main()
63 |
--------------------------------------------------------------------------------
/torrentmediasearcher/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = "Christiaan Maks (christiaanmaks@mylittlesky.net)"
2 | __version__ = "1.0"
3 | __copyright__ = "Copyright (c) 2014 Christiaan Maks"
4 | __license__ = "GPLv2"
5 |
6 | __all__ = ['TorrentMediaSearcher']
7 |
8 | from .providers.eztv_api import EZTVAPI
9 | from .providers.torrentproject_api import TorrentProjectAPI
10 | from .providers.yify_api import YIFYAPI
11 |
12 |
13 | class TorrentMediaSearcher():
14 |
15 | _PROVIDERS = {
16 | 'eztv' : EZTVAPI,
17 | 'torrentproject' : TorrentProjectAPI,
18 | 'yify' : YIFYAPI,
19 | }
20 |
21 | @staticmethod
22 | def _print_results(results):
23 | for n in results:
24 | print(repr(n), ':', results[n])
25 |
26 | @staticmethod
27 | def request_movie_magnet(provider, movie, year=None, quality=None, callback=None):
28 | if provider in TorrentMediaSearcher._PROVIDERS:
29 | provider_class = TorrentMediaSearcher._PROVIDERS[provider]
30 | else:
31 | raise ValueError('No valid search provider selected, choose from: ' + str(TorrentMediaSearcher._PROVIDERS.keys()))
32 |
33 | if year is not None and 1000 > year > 9999:
34 | raise ValueError('Invalid year input, please use the yyyy format or do not use the year parameter (results will be less accurate)')
35 |
36 | if callback is None:
37 | print('No callback function specified, only printing results')
38 | callback = TorrentMediaSearcher._print_results
39 |
40 | search = provider_class(callback=callback)
41 | search.create_movie_request(movie=movie, year=year, quality=quality)
42 |
43 | @staticmethod
44 | def request_tv_magnet(provider, show, season, episode, quality=None, callback=None):
45 | if provider in TorrentMediaSearcher._PROVIDERS:
46 | provider_class = TorrentMediaSearcher._PROVIDERS[provider]
47 | else:
48 | raise ValueError('No valid search provider selected, choose from: ' + str(TorrentMediaSearcher._PROVIDERS.keys()))
49 |
50 | if callback is None:
51 | print('No callback function specified, only printing results')
52 | callback = TorrentMediaSearcher._print_results
53 |
54 | search = provider_class(callback=callback)
55 | search.create_tvshow_request(show=show, season=season, episode=episode, quality=quality)
56 |
57 |
--------------------------------------------------------------------------------
/torrentmediasearcher/examples/examples.py:
--------------------------------------------------------------------------------
1 | from torrentmediasearcher import TorrentMediaSearcher
2 | from torrentmediasearcher.providers.base_api import MovieNotFound, EpisodeNotFound, ShowNotFound, QualityNotFound
3 |
4 |
5 | def on_finished(results):
6 | for n in results:
7 | print(repr(n), ':', results[n])
8 |
9 |
10 | def test_tv():
11 | try:
12 | TorrentMediaSearcher().request_tv_magnet(provider='eztv', show='big bang theory', season=1, episode=10, quality='normal', callback=on_finished)
13 | except EpisodeNotFound as e:
14 | print(e)
15 | except ShowNotFound as e:
16 | print(e)
17 | except QualityNotFound as e:
18 | print(e)
19 |
20 |
21 | def test_movie():
22 | try:
23 | TorrentMediaSearcher().request_movie_magnet(provider='yify', movie='iron man', year=2008, quality='1080p', callback=on_finished)
24 | except MovieNotFound as e:
25 | print(e)
26 | except QualityNotFound as e:
27 | print(e)
28 |
29 |
30 | import threading
31 | threading.Thread(target=test_movie).start() # Create the request in a thread, so it does not block the main thread
32 |
33 | print('Waiting for results...')
--------------------------------------------------------------------------------
/torrentmediasearcher/providers/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Christilut/TorrentMediaSearcher/2c25a4072d3a6965abcb86299ace6fd8f1b369f2/torrentmediasearcher/providers/__init__.py
--------------------------------------------------------------------------------
/torrentmediasearcher/providers/base_api.py:
--------------------------------------------------------------------------------
1 | import re
2 |
3 |
4 | class BaseAPI():
5 |
6 | _URL = None
7 |
8 | _QUALITY_SPECIFIERS = {
9 | 'normal tv' : 'HDTV',
10 | 'normal movie' : 'XVID',
11 | 'hd' : '720p',
12 | 'fullhd' : '1080p',
13 | }
14 |
15 | _TV_INDEX_SPECIFIERS = [
16 | r'S(\d+)E(\d+)', # Regex for S??E??
17 | r'(\D+\d{2})x(\d{2}\D+)', # Regex for ??x?? and makes sure before and after are no numbers or it could match a resolution (1024x768)
18 | ]
19 |
20 | _wanted_movie = None
21 | _wanted_year = None
22 | _wanted_show = None
23 | _wanted_season = None
24 | _wanted_episode = None
25 | _wanted_quality = None
26 |
27 |
28 | def __init__(self, callback):
29 | self.callback = callback
30 |
31 | if self._URL is None:
32 | raise ValueError('URL has not been set')
33 |
34 | def create_tvshow_request(self, show, season, episode, quality):
35 | self._wanted_show = show
36 | self._wanted_season = season
37 | self._wanted_episode = episode
38 |
39 | # Check if quality string is correct
40 | if quality == 'normal': quality = self._QUALITY_SPECIFIERS['normal tv']
41 | elif quality not in self._QUALITY_SPECIFIERS.keys() and quality not in self._QUALITY_SPECIFIERS.values():
42 | raise ValueError('Invalid quality selected')
43 |
44 | for n in self._QUALITY_SPECIFIERS: # Change quality types into the search string
45 | if quality == n: quality = self._QUALITY_SPECIFIERS[n]
46 |
47 | self._wanted_quality = quality
48 | results = self._query_tvshow(show=self._wanted_show, season=self._wanted_season, episode=self._wanted_episode, quality=quality)
49 | self.callback(results)
50 |
51 | def create_movie_request(self, movie, year, quality):
52 | self._wanted_movie = movie
53 | self._wanted_year = year
54 |
55 | # Check if quality string is correct
56 | if quality == 'normal': quality = self._QUALITY_SPECIFIERS['normal movie']
57 | elif quality not in self._QUALITY_SPECIFIERS.keys() and quality not in self._QUALITY_SPECIFIERS.values() and quality is not None:
58 | raise ValueError('Invalid quality selected')
59 |
60 | for n in self._QUALITY_SPECIFIERS: # Change quality types into the search string
61 | if quality == n: quality = self._QUALITY_SPECIFIERS[n]
62 |
63 | self._wanted_quality = quality
64 | results = self._query_movie(movie=movie, year=year, quality=quality)
65 | self.callback(results)
66 |
67 | def _query_tvshow(self, show, season, episode):
68 | raise NotImplementedError('This method must be implemented')
69 |
70 | def _query_movie(self, movie):
71 | raise NotImplementedError('This method must be implemented')
72 |
73 | def _contains(self, title, container):
74 | for c in container:
75 | if re.search(c, title, re.IGNORECASE) is not None: # If found
76 | return True
77 | return False
78 |
79 | def _contains_unwanted_quality_specifier(self, title, wanted_quality):
80 | for q in self._QUALITY_SPECIFIERS:
81 | if self._QUALITY_SPECIFIERS[q] == wanted_quality: continue # Don't check the wanted quality
82 | if re.search(self._QUALITY_SPECIFIERS[q], title, re.IGNORECASE) is not None: # If found
83 | return True
84 | return False
85 |
86 | """
87 | Exceptions
88 | """
89 |
90 |
91 | class ProviderException(Exception):
92 |
93 | def __init__(self, message=None, errors=None):
94 |
95 | Exception.__init__(self, message)
96 | self.errors = errors
97 |
98 |
99 | class ShowNotFound(ProviderException):
100 | """
101 | Raised when the specified show is not found
102 | """
103 |
104 |
105 | class EpisodeNotFound(ProviderException):
106 | """
107 | Raised when the specified episode is not found
108 | """
109 |
110 |
111 | class QualityNotFound(ProviderException):
112 | """
113 | Raised when the specified quality is not found
114 | """
115 |
116 |
117 | class MovieNotFound(ProviderException):
118 | """
119 | Raised when the specified movie is not found
120 | """
121 |
--------------------------------------------------------------------------------
/torrentmediasearcher/providers/eztv_api.py:
--------------------------------------------------------------------------------
1 | import re
2 | import requests
3 | from bs4 import BeautifulSoup
4 |
5 | from .base_api import BaseAPI, QualityNotFound, ShowNotFound, EpisodeNotFound
6 |
7 |
8 | class EZTVAPI(BaseAPI):
9 |
10 | _URL = "http://eztv.it"
11 |
12 | def _query_tvshow(self, show, season, episode, quality):
13 | show_id = self._get_show_id(show=show)
14 |
15 | result = self._get_magnet_tv(show_id=show_id, show=show, season=season, episode=episode, quality=quality)
16 |
17 | if len(result) == 0: # No quality of any kind was found, most likely the episode does not exist.
18 | raise EpisodeNotFound('Could not find episode ' + str(episode) + ' of season ' + str(season) + ' of ' + show)
19 |
20 | return result
21 |
22 | def _query_movie(self, *args):
23 | raise RuntimeError('Movies are not supported in the EZTV provider')
24 |
25 | def _get_show_id(self, show):
26 | # all strings are in lowercase
27 | show = show.lower()
28 | terms = show.split(' ')
29 |
30 | try:
31 | req = requests.get(self._URL, timeout=5)
32 | except requests.ConnectionError:
33 | raise LookupError('Could not reach host')
34 |
35 | soup = BeautifulSoup(req.content, 'html.parser')
36 |
37 | tv_shows = str(
38 | soup('select', {'name': 'SearchString'})).split('')
39 | for tv_show in tv_shows:
40 | tv_show = tv_show.lower()
41 | if all(x in tv_show for x in terms):
42 | show_id = re.search(r"\d+", tv_show).group()
43 | break
44 | else:
45 | raise ShowNotFound()
46 |
47 | return show_id
48 |
49 |
50 | def _get_magnet_tv(self, show_id, show, season, episode, quality):
51 |
52 | show_url = self._URL + '/shows/' + show_id + '/'
53 |
54 | try:
55 | req = requests.get(show_url, timeout=5)
56 | except requests.ConnectionError:
57 | raise LookupError('Could not reach host')
58 |
59 | soup = BeautifulSoup(req.content, 'html.parser')
60 |
61 | episodes = soup.find_all(class_='epinfo')
62 |
63 | wanted_episode = None
64 |
65 | for e in episodes:
66 | if re.search(show, e.text, re.IGNORECASE) is None: continue # Skip if text does not contain show name
67 | if re.search(quality, e.text, re.IGNORECASE) is None: continue # Skip if text does not contain wanted quality
68 |
69 | for s in self._TV_INDEX_SPECIFIERS:
70 | regex_result = re.search(s, e.text, re.IGNORECASE)
71 | if regex_result is not None:
72 | if int(regex_result.group(1)) == season and int(regex_result.group(2)) == episode:
73 | wanted_episode = e
74 | break
75 |
76 | if wanted_episode is not None:
77 | break
78 |
79 | if wanted_episode is None:
80 | raise QualityNotFound('Could not find anything matching the quality: ' + quality)
81 |
82 | return {'magnet': wanted_episode.parent.next_sibling.next_sibling.find(class_='magnet').get('href'), 'seeds': 'unknown'} # EZTV does not shows seeds
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/torrentmediasearcher/providers/torrentproject_api.py:
--------------------------------------------------------------------------------
1 | import re
2 | import simplejson
3 | from bs4 import BeautifulSoup
4 | import requests
5 |
6 | try: # For python 2/3 compatibility
7 | import urllib.request as urllib2
8 | except ImportError:
9 | import urllib2
10 |
11 | from .base_api import BaseAPI, ShowNotFound, EpisodeNotFound, QualityNotFound, MovieNotFound
12 |
13 |
14 | class TorrentProjectAPI(BaseAPI):
15 |
16 | _URL = 'http://torrentproject.com/'
17 |
18 | _LANGUAGES = [ # Common language keywords found in torrents, so we can filter them. Sorry, only English supported for now.
19 | 'GERMAN',
20 | 'FRENCH',
21 | 'DUTCH',
22 | 'NL',
23 | 'ITALIAN',
24 | 'SPANISH',
25 | 'LATINO',
26 | 'RUS',
27 | 'HEBREW',
28 | ]
29 |
30 | _UNWANTED_MOVIE_KEYWORDS = [ # Torrents with these keywords found will be ignored (unless the keyword is in the movie title)
31 | 'TRILOGY',
32 | 'DUOLOGY',
33 | ]
34 |
35 | _UNWANTED_TV_KEYWORDS = [
36 | 'SEASON',
37 | 'COMPLETE',
38 | ]
39 |
40 | def _query_tvshow(self, show, season, episode, quality):
41 | query_string = show.replace(' ', '+')
42 | specifier = 's%02d' % season + 'e%02d' % episode
43 |
44 | query = query_string + '+' + specifier
45 |
46 | # Before searching with specified quality, do a search without, to see if the show exists
47 | if self._get_json(query=query_string)['total_found'] == '0':
48 | raise ShowNotFound('No results were found for show: ' + show)
49 |
50 | result = self._get_magnet_tv(query=query, quality=quality)
51 |
52 | if len(result) == 0: # No quality of any kind was found, most likely the episode does not exist. # TODO never used?
53 | raise EpisodeNotFound('Could not find episode ' + str(episode) + ' of season ' + str(season) + ' of ' + show)
54 |
55 | return result
56 |
57 | def _query_movie(self, movie, year, quality):
58 | query = movie.replace(' ', '+')
59 | if year is not None: query += '+' + str(year)
60 |
61 | # Before searching with specified quality, do a search without, to see if the movie exists
62 | if self._get_json(query=query, quality=quality)['total_found'] == '0':
63 | raise MovieNotFound('No results found for movie: ' + movie)
64 |
65 | search_terms = self._wanted_movie.split(' ') # Get the words in the movie
66 | for s in search_terms:
67 | for lan in self._LANGUAGES: # This removes languages that are in the search terms. Otherwise movies with search terms equal to a langauge would always be skipped
68 | if re.match(s, lan, re.IGNORECASE):
69 | self._LANGUAGES.remove(lan)
70 |
71 | result = self._get_magnet_movie(query=query, quality=quality)
72 |
73 | if len(result) == 0: # No quality of any kind was found, most likely the movie does not exist.
74 | raise MovieNotFound('No results found for movie: ' + self._wanted_movie)
75 |
76 | return result
77 |
78 | def _get_json(self, query, quality):
79 | if quality is not None: # Allow None so a search can be performed without any quality string
80 | query += '+' + quality
81 |
82 | try:
83 | req = urllib2.Request(self._URL + '?s=' + query + '&out=json')
84 | except requests.ConnectionError:
85 | raise LookupError('Could not reach host')
86 |
87 | f = urllib2.build_opener().open(req)
88 |
89 | json = simplejson.load(f)
90 | return json
91 |
92 | def _get_magnet(self, torrent_hash):
93 | torrent_url = self._URL + torrent_hash
94 |
95 | try:
96 | req = requests.get(torrent_url)
97 | except requests.ConnectionError:
98 | raise LookupError('Could not reach host')
99 |
100 | soup = BeautifulSoup(req.text, 'html.parser')
101 |
102 | magnet = soup.find(name='a', text=re.compile('Magnet Link'))
103 |
104 | if magnet is None:
105 | raise ValueError('Could not find the magnet link, did the website change?')
106 |
107 | return magnet.get('href')
108 |
109 | def _get_magnet_tv(self, query, quality):
110 | """ Returns the URL to a torrent/magnet link of specified quality or raise error if not found """
111 |
112 | json = self._get_json(query, quality)
113 |
114 | best = None
115 | num_seeds = 0
116 | num_leechs = 0
117 |
118 | for n in json:
119 | entry = json[n]
120 |
121 | if n == 'total_found': continue # TorrentProject adds a total_found that we must ignore
122 |
123 | title = entry['title']
124 |
125 | # Perform some checks
126 | if entry['category'] != 'tv': continue # Ignore anything that is not from the TV category
127 | if self._contains(title=title, container=self._UNWANTED_TV_KEYWORDS): continue # Ignore torrents with invalid keywords (such as Season or Complete)
128 |
129 | for s in self._TV_INDEX_SPECIFIERS:
130 | regex_result = re.search(s, entry['title'], re.IGNORECASE)
131 | if regex_result is not None:
132 | if int(regex_result.group(1)) == self._wanted_season and int(regex_result.group(2)) == self._wanted_episode:
133 | if entry['seeds'] > num_seeds or (entry['seeds'] == num_seeds and entry['leechs'] > num_leechs): # Take link with most seeds, if the same amount, take the one with most leechs
134 | best = entry
135 | num_seeds = entry['seeds']
136 | num_leechs = entry['leechs']
137 |
138 | if best is None:
139 | raise QualityNotFound()
140 |
141 | return {'magnet': self._get_magnet(torrent_hash=best['torrent_hash']), 'seeds': best['seeds'] }
142 |
143 | def _get_magnet_movie(self, query, quality):
144 | """ Returns the URL to a torrent/magnet link of specified quality or raise error if not found """
145 |
146 | json = self._get_json(query=query, quality=quality)
147 |
148 | movie = self._wanted_movie
149 | terms_removed = re.findall(r'-\w+', self._wanted_movie, re.IGNORECASE) # Terms such -foo should be ignored when searching the titles
150 | for t in terms_removed: movie = movie.replace(t, '')
151 |
152 | movie = movie.strip() # Remove start and trailing whitespaces
153 | movie_regex = movie.replace(' ', '\D?') # e.g. Movie?Name?5
154 |
155 | if quality is None: quality = ''
156 |
157 | best = None
158 | num_seeds = 0
159 | num_leechs = 0
160 |
161 | for n in json:
162 | entry = json[n]
163 |
164 | if n == 'total_found': continue # TorrentProject adds a total_found that we must ignore
165 |
166 | title = entry['title']
167 |
168 | # Perform some checks
169 | if self._contains(title=title, container=self._LANGUAGES): continue # Check if movie title contains language terms that we dont want
170 | if self._contains(title=title, container=self._TV_INDEX_SPECIFIERS): continue # Check if the torrent is really a movie and not a tv show
171 | if re.search(quality, title, re.IGNORECASE) is None: continue # Check that the quality string is in the title
172 | if self._contains_unwanted_quality_specifier(title=title, wanted_quality=quality): continue # Skip files that contains wrong quality identifiers
173 | if self._contains(title=title, container=self._UNWANTED_MOVIE_KEYWORDS): continue # Check the title for unwanted keywords
174 | if re.search(movie_regex, title, re.IGNORECASE) is None: continue # The movie name was not found in the title, wrong search result so ignore it
175 |
176 | if entry['seeds'] > num_seeds or (entry['seeds'] == num_seeds and entry['leechs'] > num_leechs): # Take link with most seeds, if the same amount, take the one with most leechs
177 | best = entry
178 | num_seeds = entry['seeds']
179 | num_leechs = entry['leechs']
180 |
181 | if best is None:
182 | raise QualityNotFound('Could not find anything matching the quality: ' + quality)
183 |
184 | return {'magnet': self._get_magnet(torrent_hash=best['torrent_hash']), 'seeds': best['seeds'] }
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
--------------------------------------------------------------------------------
/torrentmediasearcher/providers/yify_api.py:
--------------------------------------------------------------------------------
1 | import simplejson
2 | import requests
3 |
4 | try: # For python 2/3 compatibility
5 | import urllib.request as urllib2
6 | except ImportError:
7 | import urllib2
8 |
9 | from .base_api import BaseAPI, MovieNotFound, QualityNotFound
10 |
11 |
12 | class YIFYAPI(BaseAPI):
13 |
14 | _URL = 'http://yts.re/api/'
15 |
16 |
17 | def _query_movie(self, movie, year, quality):
18 | query = self._create_query(movie=movie, year=year)
19 |
20 | result = self._get_magnet_movie(query=query, quality=quality, year=year)
21 |
22 | return result
23 |
24 | def _create_query(self, movie, year):
25 | query = 'keywords=' + movie.replace(' ', '%20')
26 | if year is not None: query += '%20' + str(year)
27 |
28 | return query
29 |
30 | def _get_json(self, query):
31 | try:
32 | req = urllib2.Request(self._URL + 'list.json?' + query)
33 | except requests.ConnectionError:
34 | raise LookupError('Could not reach host')
35 |
36 | f = urllib2.build_opener().open(req)
37 |
38 | json = simplejson.load(f)
39 |
40 | return json
41 |
42 | def _get_magnet_movie(self, query, quality, year):
43 | json = self._get_json(query=query)
44 | if 'error' in json:
45 | if json['error'] == 'No movies found':
46 | raise MovieNotFound('No results found for movie: ' + self._wanted_movie)
47 |
48 | movie = None
49 | movielist = json['MovieList']
50 |
51 | for n in range(0, json['MovieCount']):
52 | if quality is not None and movielist[n]['Quality'] != quality:
53 | continue
54 |
55 | if year is not None and movielist[n]['MovieYear'] != str(year): # Skip if year is incorrect
56 | continue
57 |
58 | movie = movielist[n]
59 | break
60 |
61 | if movie is None:
62 | raise QualityNotFound('Could not find anything matching the quality: ' + str(quality))
63 |
64 | return { 'magnet': movie['TorrentMagnetUrl'], 'seeds': movie['TorrentSeeds'] }
--------------------------------------------------------------------------------