├── .gitignore
├── LICENSE
├── README.md
├── idp
├── __init__.py
├── parser
│ ├── __init__.py
│ ├── actorsparser.py
│ ├── actressesparser.py
│ ├── baseparser.py
│ ├── directorsparser.py
│ ├── genresparser.py
│ ├── moviesparser.py
│ ├── parsinghelper.py
│ ├── plotparser.py
│ ├── ratingsparser.py
│ └── triviaparser.py
├── settings.py.example
└── utils
│ ├── __init__.py
│ ├── dbscripthelper.py
│ ├── decorators.py
│ ├── filehandler.py
│ ├── freebaseagent.py
│ ├── listdownloader.py
│ ├── loggerinitializer.py
│ ├── regexhelper.py
│ └── test
│ ├── __init__.py
│ └── filehandler_test.py
├── imdb_parse_path.txt
├── imdbparser.py
└── samples
├── movies.list
└── movies.list.gz
/.gitignore:
--------------------------------------------------------------------------------
1 | *.py[cod]
2 |
3 | # C extensions
4 | *.so
5 |
6 | # Packages
7 | *.egg
8 | *.egg-info
9 | dist
10 | build
11 | eggs
12 | parts
13 | bin
14 | var
15 | sdist
16 | develop-eggs
17 | .installed.cfg
18 | lib
19 | lib64
20 |
21 | # Installer logs
22 | pip-log.txt
23 |
24 | # Unit test / coverage reports
25 | .coverage
26 | .tox
27 | nosetests.xml
28 |
29 | # Translations
30 | *.mo
31 |
32 | # Mr Developer
33 | .mr.developer.cfg
34 | .project
35 | .pydevproject
36 |
37 | #Temp files
38 | *~
39 | *.tmp
40 |
41 | #swap files of vim
42 | *.swp
43 |
44 | #dont commit settings file
45 | idp/settings.py
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | imdb-data-parser
2 | ================
3 |
4 | Parses the IMDB dumps into CSV and Relational Database insert queries
5 | Uses IMDB dumps from: http://www.imdb.com/interfaces
6 |
7 | imdb-data-parser is a free software licensed by GPLv3.
8 |
9 |
10 | Requirements
11 | ================
12 | * Python 3.x
13 |
14 | Configuring
15 | ================
16 | All configuration data stays at `idp/settings.py.example`
17 |
18 | You need to copy this file as `settings.py` and edit this file before running the project
19 |
20 | cd idp
21 | cp settings.py.example settings.py
22 | your_favourite_editor settings.py
23 |
24 | You also need to have dump files at `INPUT_DIR` and you can download dump files from one of the FTP addresses on http://www.imdb.com/interfaces.
25 |
26 | Besides that you can make `imdb-data-parser` dowload dumps for you by giving `-u` argument:
27 |
28 | ~/imdb-data-parser$ ./imdbparser.py -u
29 |
30 | Executing
31 | ---------
32 |
33 | ~/imdb-data-parser$ ./imdbparser.py
34 |
35 | You can use -h parameter to see list of optional arguments
36 |
37 | ~/imdb-data-parser$ ./imdbparser.py -h
38 |
39 | SQL Dumps
40 | ---------
41 | You can use mode parameter to create SQL dumps
42 |
43 | ~/imdb-data-parser$ ./imdbparser.py -h
44 |
45 | Default configuration of MySQL doesn't allow insert data more than 16MB. You need to change your mysql max_allowed_packet size to insert sql dumps.
46 |
47 | max_allowed_packet = 256M
48 |
49 | Our movies data includes series, videos, tv shows for now. You can exclude them by this command:
50 |
51 | grep -v '("\\"' movies.list.sql | grep -v '\\(VG\\)' | grep -v "\\(TV\\)" | grep -v "{" | grep -v "????" | grep -v "(V\\\)" > movies.sql
52 |
53 | Note: SQL dumps tested with only mysql.
54 |
--------------------------------------------------------------------------------
/idp/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dedeler/imdb-data-parser/20671ab98e2065bbe0a32aef0402776934a2863b/idp/__init__.py
--------------------------------------------------------------------------------
/idp/parser/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dedeler/imdb-data-parser/20671ab98e2065bbe0a32aef0402776934a2863b/idp/parser/__init__.py
--------------------------------------------------------------------------------
/idp/parser/actorsparser.py:
--------------------------------------------------------------------------------
1 | """
2 | This file is part of imdb-data-parser.
3 |
4 | imdb-data-parser is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | imdb-data-parser is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with imdb-data-parser. If not, see .
16 | """
17 |
18 | from .baseparser import *
19 |
20 |
21 | class ActorsParser(BaseParser):
22 | """
23 | RegExp: /(.*?)\t+((.*? \(\S{4,}\)) ?(\(\S+\))? ?(?!\{\{SUSPENDED\}\})(\{(.*?) ?(\(\S+?\))?\})? ?(\{\{SUSPENDED\}\})?)\s*(\(.*?\))?\s*(\(.*\))?\s*(\[.*\])?\s*(<.*>)?$/gm
24 | pattern: (.*?)\t+((.*? \(\S{4,}\)) ?(\(\S+\))? ?(?!\{\{SUSPENDED\}\})(\{(.*?) ?(\(\S+?\))?\})? ?(\{\{SUSPENDED\}\})?)\s*(\(.*?\))?\s*(\(.*\))?\s*(\[.*\])?\s*(<.*>)?$
25 | flags: gm
26 | 12 capturing groups:
27 | group 1: (.*?) surname, name
28 | group 2: #TITLE (UNIQUE KEY)
29 | group 3: (.*? \(\S{4,}\)) movie name + year
30 | group 4: (\(\S+\)) type ex:(TV)
31 | group 5: (\{(.*?) ?(\(\S+?\))?\}) series info ex: {Ally Abroad (#3.1)}
32 | group 6: (.*?) episode name ex: Ally Abroad
33 | group 7: (\(\S+?\)) episode number ex: (#3.1)
34 | group 8: (\{\{SUSPENDED\}\}) is suspended?
35 | group 9: (\(.*?\)) info 1
36 | group 10: (\(.*\)) info 2
37 | group 11: (\[.*\]) role
38 | group 12: ()
39 | """
40 |
41 | # properties
42 | base_matcher_pattern = '(.*?)\t+((.*? \(\S{4,}\)) ?(\(\S+\))? ?(?!\{\{SUSPENDED\}\})(\{(.*?) ?(\(\S+?\))?\})? ?(\{\{SUSPENDED\}\})?)\s*(\(.*?\))?\s*(\(.*\))?\s*(\[.*\])?\s*(<.*>)?$'
43 | input_file_name = "actors.list"
44 | number_of_lines_to_be_skipped = 239
45 | db_table_info = {
46 | 'tablename' : 'actors',
47 | 'columns' : [
48 | {'colname' : 'name', 'colinfo' : DbScriptHelper.keywords['string'] + '(127)'},
49 | {'colname' : 'surname', 'colinfo' : DbScriptHelper.keywords['string'] + '(127)'},
50 | {'colname' : 'title', 'colinfo' : DbScriptHelper.keywords['string'] + '(255) NOT NULL'},
51 | {'colname' : 'info_1', 'colinfo' : DbScriptHelper.keywords['string'] + '(127)'},
52 | {'colname' : 'info_2', 'colinfo' : DbScriptHelper.keywords['string'] + '(127)'},
53 | {'colname' : 'role', 'colinfo' : DbScriptHelper.keywords['string'] + '(127)'}
54 | ],
55 | 'constraints' : 'PRIMARY KEY(title)'
56 | }
57 | end_of_dump_delimiter = ""
58 |
59 | name = ""
60 | surname = ""
61 |
62 | def __init__(self, preferences_map):
63 | super(ActorsParser, self).__init__(preferences_map)
64 | self.first_one = True
65 |
66 | def parse_into_tsv(self, matcher):
67 | is_match = matcher.match(self.base_matcher_pattern)
68 |
69 | if(is_match):
70 | if(len(matcher.group(1).strip()) > 0):
71 | namelist = matcher.group(1).split(', ')
72 | if(len(namelist) == 2):
73 | self.name = namelist[1]
74 | self.surname = namelist[0]
75 | else:
76 | self.name = namelist[0]
77 | self.surname = ""
78 |
79 | self.tsv_file.write(self.name + self.seperator + self.surname + self.seperator + self.concat_regex_groups([2,9,10,11], None, matcher) + "\n")
80 | elif(len(matcher.get_last_string()) == 1):
81 | pass
82 | else:
83 | logging.critical("This line is fucked up: " + matcher.get_last_string())
84 | self.fucked_up_count += 1
85 |
86 | def parse_into_db(self, matcher):
87 | is_match = matcher.match(self.base_matcher_pattern)
88 |
89 | if(is_match):
90 | if(len(matcher.group(1).strip()) > 0):
91 | namelist = matcher.group(1).split(', ')
92 | if(len(namelist) == 2):
93 | self.name = namelist[1]
94 | self.surname = namelist[0]
95 | else:
96 | self.name = namelist[0]
97 | self.surname = ""
98 |
99 | if(self.first_one):
100 | self.sql_file.write("(\"" + self.name + "\", \"" + self.surname + "\", " + self.concat_regex_groups([2,9,10,11], [2,3,4,5], matcher) + ")")
101 | self.first_one = False;
102 | else:
103 | self.sql_file.write(",\n(\"" + self.name + "\", \"" + self.surname + "\", " + self.concat_regex_groups([2,9,10,11], [2,3,4,5], matcher) + ")")
104 |
105 | elif(len(matcher.get_last_string()) == 1):
106 | pass
107 | else:
108 | logging.critical("This line is fucked up: " + matcher.get_last_string())
109 | self.fucked_up_count += 1
110 |
--------------------------------------------------------------------------------
/idp/parser/actressesparser.py:
--------------------------------------------------------------------------------
1 | """
2 | This file is part of imdb-data-parser.
3 |
4 | imdb-data-parser is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | imdb-data-parser is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with imdb-data-parser. If not, see .
16 | """
17 |
18 | from .baseparser import *
19 |
20 |
21 | class ActressesParser(BaseParser):
22 | """
23 | RegExp: /(.*?)\t+((.*? \(\S{4,}\)) ?(\(\S+\))? ?(?!\{\{SUSPENDED\}\})(\{(.*?) ?(\(\S+?\))?\})? ?(\{\{SUSPENDED\}\})?)\s*(\(.*?\))?\s*(\(.*\))?\s*(\[.*\])?\s*(<.*>)?$/gm
24 | pattern: (.*?)\t+((.*? \(\S{4,}\)) ?(\(\S+\))? ?(?!\{\{SUSPENDED\}\})(\{(.*?) ?(\(\S+?\))?\})? ?(\{\{SUSPENDED\}\})?)\s*(\(.*?\))?\s*(\(.*\))?\s*(\[.*\])?\s*(<.*>)?$
25 | flags: gm
26 | 12 capturing groups:
27 | group 1: (.*?) surname, name
28 | group 2: #TITLE (UNIQUE KEY)
29 | group 3: (.*? \(\S{4,}\)) movie name + year
30 | group 4: (\(\S+\)) type ex:(TV)
31 | group 5: (\{(.*?) ?(\(\S+?\))?\}) series info ex: {Ally Abroad (#3.1)}
32 | group 6: (.*?) episode name ex: Ally Abroad
33 | group 7: (\(\S+?\)) episode number ex: (#3.1)
34 | group 8: (\{\{SUSPENDED\}\}) is suspended?
35 | group 9: (\(.*?\)) info 1
36 | group 10: (\(.*\)) info 2
37 | group 11: (\[.*\]) role
38 | group 12: ()
39 | """
40 |
41 | # properties
42 | base_matcher_pattern = '(.*?)\t+((.*? \(\S{4,}\)) ?(\(\S+\))? ?(?!\{\{SUSPENDED\}\})(\{(.*?) ?(\(\S+?\))?\})? ?(\{\{SUSPENDED\}\})?)\s*(\(.*?\))?\s*(\(.*\))?\s*(\[.*\])?\s*(<.*>)?$'
43 | input_file_name = "actresses.list"
44 | number_of_lines_to_be_skipped = 241
45 | db_table_info = {
46 | 'tablename' : 'actresses',
47 | 'columns' : [
48 | {'colname' : 'name', 'colinfo' : DbScriptHelper.keywords['string'] + '(127)'},
49 | {'colname' : 'surname', 'colinfo' : DbScriptHelper.keywords['string'] + '(127)'},
50 | {'colname' : 'title', 'colinfo' : DbScriptHelper.keywords['string'] + '(255) NOT NULL'},
51 | {'colname' : 'info_1', 'colinfo' : DbScriptHelper.keywords['string'] + '(127)'},
52 | {'colname' : 'info_2', 'colinfo' : DbScriptHelper.keywords['string'] + '(127)'},
53 | {'colname' : 'role', 'colinfo' : DbScriptHelper.keywords['string'] + '(127)'}
54 | ],
55 | 'constraints' : 'PRIMARY KEY(title)'
56 | }
57 | end_of_dump_delimiter = ""
58 |
59 | name = ""
60 | surname = ""
61 |
62 | def __init__(self, preferences_map):
63 | super(ActressesParser, self).__init__(preferences_map)
64 | self.first_one = True
65 |
66 | def parse_into_tsv(self, matcher):
67 | is_match = matcher.match(self.base_matcher_pattern)
68 |
69 | if(is_match):
70 | if(len(matcher.group(1).strip()) > 0):
71 | namelist = matcher.group(1).split(', ')
72 | if(len(namelist) == 2):
73 | self.name = namelist[1]
74 | self.surname = namelist[0]
75 | else:
76 | self.name = namelist[0]
77 | self.surname = ""
78 |
79 | self.tsv_file.write(self.name + self.seperator + self.surname + self.seperator + self.concat_regex_groups([2,9,10,11], None, matcher) + "\n")
80 | elif(len(matcher.get_last_string()) == 1):
81 | pass
82 | else:
83 | logging.critical("This line is fucked up: " + matcher.get_last_string())
84 | self.fucked_up_count += 1
85 |
86 | def parse_into_db(self, matcher):
87 | is_match = matcher.match(self.base_matcher_pattern)
88 |
89 | if(is_match):
90 | if(len(matcher.group(1).strip()) > 0):
91 | namelist = matcher.group(1).split(', ')
92 | if(len(namelist) == 2):
93 | self.name = namelist[1]
94 | self.surname = namelist[0]
95 | else:
96 | self.name = namelist[0]
97 | self.surname = ""
98 |
99 | if(self.first_one):
100 | self.sql_file.write("(\"" + self.name + "\", \"" + self.surname + "\", " + self.concat_regex_groups([2,9,10,11], [2,3,4,5], matcher) + ")")
101 | self.first_one = False;
102 | else:
103 | self.sql_file.write(",\n(\"" + self.name + "\", \"" + self.surname + "\", " + self.concat_regex_groups([2,9,10,11], [2,3,4,5], matcher) + ")")
104 |
105 | elif(len(matcher.get_last_string()) == 1):
106 | pass
107 | else:
108 | logging.critical("This line is fucked up: " + matcher.get_last_string())
109 | self.fucked_up_count += 1
110 |
--------------------------------------------------------------------------------
/idp/parser/baseparser.py:
--------------------------------------------------------------------------------
1 | """
2 | This file is part of imdb-data-parser.
3 |
4 | imdb-data-parser is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | imdb-data-parser is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with imdb-data-parser. If not, see .
16 | """
17 |
18 | import re
19 | import logging
20 | from abc import *
21 | from ..utils.filehandler import FileHandler
22 | from ..utils.regexhelper import RegExHelper
23 | from ..utils.decorators import duration_logged
24 | from ..utils.dbscripthelper import DbScriptHelper
25 |
26 |
27 | class BaseParser(metaclass=ABCMeta):
28 | """
29 | Base class for all parser classes
30 |
31 | This class holds common methods for all parser classes and
32 | must be implemented by any Parser class
33 |
34 | Implementing classes' responsibilities are as follows:
35 | * Implement parse_into_tsv function
36 | * Implement parse_into_db function
37 | * Calculate fuckedUpCount and store in self.fuckedUpCount
38 | * Define following properties:
39 | - baseMatcherPattern
40 | - inputFileName
41 | - numberOfLinesToBeSkipped
42 | - scripts
43 | """
44 |
45 | seperator = "\t" #TODO: get from settings
46 |
47 | def __init__(self, preferences_map):
48 | self.mode = preferences_map['mode']
49 | self.filehandler = FileHandler(self.input_file_name, preferences_map)
50 | self.input_file = self.filehandler.get_input_file()
51 |
52 | if (self.mode == "TSV"):
53 | self.tsv_file = self.filehandler.get_tsv_file()
54 | elif (self.mode == "SQL"):
55 | self.sql_file = self.filehandler.get_sql_file()
56 | self.scripthelper = DbScriptHelper(self.db_table_info)
57 | self.sql_file.write(self.scripthelper.scripts['drop'])
58 | self.sql_file.write(self.scripthelper.scripts['create'])
59 | self.sql_file.write(self.scripthelper.scripts['insert'])
60 |
61 | @abstractmethod
62 | def parse_into_tsv(self, matcher):
63 | raise NotImplemented
64 |
65 | @abstractmethod
66 | def parse_into_db(self, matcher):
67 | raise NotImplemented
68 |
69 | @duration_logged
70 | def start_processing(self):
71 | '''
72 | Actual parsing and generation of scripts (tsv & sql) are done here.
73 | '''
74 |
75 | self.fucked_up_count = 0
76 | counter = 0
77 | number_of_processed_lines = 0
78 |
79 | for line in self.input_file : #assuming the file is opened in the subclass before here
80 | if(number_of_processed_lines >= self.number_of_lines_to_be_skipped):
81 | #end of data
82 | if(self.end_of_dump_delimiter != "" and self.end_of_dump_delimiter in line):
83 | break
84 |
85 | matcher = RegExHelper(line)
86 |
87 | if(self.mode == "TSV"):
88 | '''
89 | give the matcher directly to implementing class
90 | and let it decide what to do when regEx is matched and unmatched
91 | '''
92 | self.parse_into_tsv(matcher)
93 | elif(self.mode == "SQL"):
94 | self.parse_into_db(matcher)
95 | else:
96 | raise NotImplemented("Mode: " + self.mode)
97 |
98 | number_of_processed_lines += 1
99 |
100 | #print("Processed lines: %d\r" % (number_of_processed_lines), end="")
101 |
102 | self.input_file.close()
103 |
104 | if(self.mode == "SQL"):
105 | self.sql_file.write(";\n COMMIT;")
106 | self.sql_file.close()
107 |
108 | if 'outputFile' in locals():
109 | self.output_file.flush()
110 | self.output_file.close()
111 |
112 | # fuckedUpCount is calculated in implementing class
113 | logging.info("Finished with " + str(self.fucked_up_count) + " fucked up line")
114 |
115 | def concat_regex_groups(self, group_list, col_list, matcher):
116 | ret_val = ""
117 | if col_list == None:
118 | ret_val = self.seperator.join('%s' % (matcher.group(i)) for i in group_list)
119 | else:
120 | for i in range(len(group_list)):
121 | if DbScriptHelper.keywords['string'] in self.db_table_info['columns'][col_list[i]]['colinfo']:
122 | ret_val += "\"" + re.escape(matcher.group(group_list[i])) + "\", "
123 | else:
124 | ret_val += matcher.group(group_list[i]) + ", "
125 | ret_val = ret_val[:-2]
126 | return ret_val
127 |
128 | ##### Below methods force associated properties to be defined in any derived class #####
129 |
130 | @abstractproperty
131 | def base_matcher_pattern(self):
132 | raise NotImplemented
133 |
134 | @abstractproperty
135 | def input_file_name(self):
136 | raise NotImplemented
137 |
138 | @abstractproperty
139 | def number_of_lines_to_be_skipped(self):
140 | raise NotImplemented
141 |
142 | @abstractproperty
143 | def db_table_info(self):
144 | raise NotImplemented
145 |
146 | @abstractproperty
147 | def end_of_dump_delimiter(self):
148 | raise NotImplemented
149 |
--------------------------------------------------------------------------------
/idp/parser/directorsparser.py:
--------------------------------------------------------------------------------
1 | """
2 | This file is part of imdb-data-parser.
3 |
4 | imdb-data-parser is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | imdb-data-parser is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with imdb-data-parser. If not, see .
16 | """
17 |
18 | from .baseparser import *
19 |
20 |
21 | class DirectorsParser(BaseParser):
22 | """
23 | RegExp: /(.*?)\t+((.*? \(\S{4,}\)) ?(\(\S+\))? ?(?!\{\{SUSPENDED\}\})(\{(.*?) ?(\(\S+?\))?\})? ?(\{\{SUSPENDED\}\})?)\s*(\(.*\)|EDIT)?\s*(<.*>)?$/gm
24 | pattern: (.*?)\t+((.*? \(\S{4,}\)) ?(\(\S+\))? ?(?!\{\{SUSPENDED\}\})(\{(.*?) ?(\(\S+?\))?\})? ?(\{\{SUSPENDED\}\})?)\s*(\(.*\)|EDIT)?\s*(<.*>)?$
25 | flags: gm
26 | 10 capturing groups:
27 | group 1: (.*?) surname, name
28 | group 2: #TITLE (UNIQUE KEY)
29 | group 3: (.*? \(\S{4,}\)) movie name + year
30 | group 4: (\(\S+\)) type ex:(TV)
31 | group 5: (\{(.*?) ?(\(\S+?\))?\}) series info ex: {Ally Abroad (#3.1)}
32 | group 6: (.*?) episode name ex: Ally Abroad
33 | group 7: (\(\S+?\)) episode number ex: (#3.1)
34 | group 8: (\{\{SUSPENDED\}\}) is suspended?
35 | group 9: (\(.*\)) info
36 | group 10: ()
37 | """
38 |
39 | # properties
40 | base_matcher_pattern = '(.*?)\t+((.*? \(\S{4,}\)) ?(\(\S+\))? ?(?!\{\{SUSPENDED\}\})(\{(.*?) ?(\(\S+?\))?\})? ?(\{\{SUSPENDED\}\})?)\s*(\(.*\)|EDIT)?\s*(<.*>)?$'
41 | input_file_name = "directors.list"
42 | number_of_lines_to_be_skipped = 235
43 | db_table_info = {
44 | 'tablename' : 'directors',
45 | 'columns' : [
46 | {'colname' : 'name', 'colinfo' : DbScriptHelper.keywords['string'] + '(127)'},
47 | {'colname' : 'surname', 'colinfo' : DbScriptHelper.keywords['string'] + '(127)'},
48 | {'colname' : 'title', 'colinfo' : DbScriptHelper.keywords['string'] + '(255) NOT NULL'},
49 | {'colname' : 'info', 'colinfo' : DbScriptHelper.keywords['string'] + '(127)'}
50 | ],
51 | 'constraints' : 'PRIMARY KEY(title)'
52 | }
53 | end_of_dump_delimiter = ""
54 |
55 | name = ""
56 | surname = ""
57 |
58 | def __init__(self, preferences_map):
59 | super(DirectorsParser, self).__init__(preferences_map)
60 | self.first_one = True
61 |
62 | def parse_into_tsv(self, matcher):
63 | is_match = matcher.match(self.base_matcher_pattern)
64 |
65 | if(is_match):
66 | if(len(matcher.group(1).strip()) > 0):
67 | namelist = matcher.group(1).split(', ')
68 | if(len(namelist) == 2):
69 | self.name = namelist[1]
70 | self.surname = namelist[0]
71 | else:
72 | self.name = namelist[0]
73 | self.surname = ""
74 |
75 | self.tsv_file.write(self.name + self.seperator + self.surname + self.seperator + self.concat_regex_groups([2,9], None, matcher) + "\n")
76 | elif(len(matcher.get_last_string()) == 1):
77 | pass
78 | else:
79 | logging.critical("This line is fucked up: " + matcher.get_last_string())
80 | self.fucked_up_count += 1
81 |
82 | def parse_into_db(self, matcher):
83 | is_match = matcher.match(self.base_matcher_pattern)
84 |
85 | if(is_match):
86 | if(len(matcher.group(1).strip()) > 0):
87 | namelist = matcher.group(1).split(', ')
88 | if(len(namelist) == 2):
89 | self.name = namelist[1]
90 | self.surname = namelist[0]
91 | else:
92 | self.name = namelist[0]
93 | self.surname = ""
94 |
95 | if(self.first_one):
96 | self.sql_file.write("(\"" + self.name + "\", \"" + self.surname + "\", " + self.concat_regex_groups([2,9], [2,3], matcher) + ")")
97 | self.first_one = False;
98 | else:
99 | self.sql_file.write(",\n(\"" + self.name + "\", \"" + self.surname + "\", " + self.concat_regex_groups([2,9], [2,3], matcher) + ")")
100 |
101 | elif(len(matcher.get_last_string()) == 1):
102 | pass
103 | else:
104 | logging.critical("This line is fucked up: " + matcher.get_last_string())
105 | self.fucked_up_count += 1
106 |
--------------------------------------------------------------------------------
/idp/parser/genresparser.py:
--------------------------------------------------------------------------------
1 | """
2 | This file is part of imdb-data-parser.
3 |
4 | imdb-data-parser is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | imdb-data-parser is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with imdb-data-parser. If not, see .
16 | """
17 |
18 | from .baseparser import *
19 |
20 |
21 | class GenresParser(BaseParser):
22 | """
23 | RegExp: /((.*? \(\S{4,}\)) ?(\(\S+\))? ?(?!\{\{SUSPENDED\}\})(\{(.*?) ?(\(\S+?\))?\})? ?(\{\{SUSPENDED\}\})?)\t+(.*)$/gm
24 | pattern: ((.*? \(\S{4,}\)) ?(\(\S+\))? ?(?!\{\{SUSPENDED\}\})(\{(.*?) ?(\(\S+?\))?\})? ?(\{\{SUSPENDED\}\})?)\t+(.*)$
25 | flags: gm
26 | 8 capturing groups:
27 | group 1: #TITLE (UNIQUE KEY)
28 | group 2: (.*? \(\S{4,}\)) movie name + year
29 | group 3: (\(\S+\)) type ex:(TV)
30 | group 4: (\{(.*?) ?(\(\S+?\))?\}) series info ex: {Ally Abroad (#3.1)}
31 | group 5: (.*?) episode name ex: Ally Abroad
32 | group 6: ((\(\S+?\)) episode number ex: (#3.1)
33 | group 7: (\{\{SUSPENDED\}\}) is suspended?
34 | group 8: (.*) genre
35 | """
36 |
37 | # properties
38 | base_matcher_pattern = "((.*? \(\S{4,}\)) ?(\(\S+\))? ?(?!\{\{SUSPENDED\}\})(\{(.*?) ?(\(\S+?\))?\})? ?(\{\{SUSPENDED\}\})?)\t+(.*)$"
39 | input_file_name = "genres.list"
40 | number_of_lines_to_be_skipped = 378
41 | db_table_info = {
42 | 'tablename' : 'genres',
43 | 'columns' : [
44 | {'colname' : 'title', 'colinfo' : DbScriptHelper.keywords['string'] + '(255) NOT NULL'},
45 | {'colname' : 'genre', 'colinfo' : DbScriptHelper.keywords['string'] + '(127)'}
46 | ],
47 | 'constraints' : 'PRIMARY KEY(title)'
48 | }
49 | end_of_dump_delimiter = ""
50 |
51 | def __init__(self, preferences_map):
52 | super(GenresParser, self).__init__(preferences_map)
53 | self.first_one = True
54 |
55 | def parse_into_tsv(self, matcher):
56 | is_match = matcher.match(self.base_matcher_pattern)
57 |
58 | if(is_match):
59 | self.tsv_file.write(self.concat_regex_groups([1,8], None, matcher) + "\n")
60 | else:
61 | logging.critical("This line is fucked up: " + matcher.get_last_string())
62 | self.fucked_up_count += 1
63 |
64 | def parse_into_db(self, matcher):
65 | is_match = matcher.match(self.base_matcher_pattern)
66 |
67 | if(is_match):
68 | if(self.first_one):
69 | self.sql_file.write("(" + self.concat_regex_groups([1,8], [0,1], matcher) + ")")
70 | self.first_one = False;
71 | else:
72 | self.sql_file.write(",\n(" + self.concat_regex_groups([1,8], [0,1], matcher) + ")")
73 | else:
74 | logging.critical("This line is fucked up: " + matcher.get_last_string())
75 | self.fucked_up_count += 1
76 |
--------------------------------------------------------------------------------
/idp/parser/moviesparser.py:
--------------------------------------------------------------------------------
1 | """
2 | This file is part of imdb-data-parser.
3 |
4 | imdb-data-parser is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | imdb-data-parser is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with imdb-data-parser. If not, see .
16 | """
17 |
18 | from .baseparser import *
19 |
20 |
21 | class MoviesParser(BaseParser):
22 | """
23 | Parses movies.list dump
24 |
25 | RegExp: /((.*? \(\S{4,}\)) ?(\(\S+\))? ?(?!\{\{SUSPENDED\}\})(\{(.*?) ?(\(\S+?\))?\})? ?(\{\{SUSPENDED\}\})?)\t+(.*)$/gm
26 | pattern: ((.*? \(\S{4,}\)) ?(\(\S+\))? ?(?!\{\{SUSPENDED\}\})(\{(.*?) ?(\(\S+?\))?\})? ?(\{\{SUSPENDED\}\})?)\t+(.*)$
27 | flags: gm
28 | 8 capturing groups:
29 | group 1: #TITLE (UNIQUE KEY)
30 | group 2: (.*? \(\S{4,}\)) movie name + year
31 | group 3: (\(\S+\)) type ex:(TV)
32 | group 4: (\{(.*?) ?(\(\S+?\))?\}) series info ex: {Ally Abroad (#3.1)}
33 | group 5: (.*?) episode name ex: Ally Abroad
34 | group 6: ((\(\S+?\)) episode number ex: (#3.1)
35 | group 7: (\{\{SUSPENDED\}\}) is suspended?
36 | group 8: (.*) year
37 | """
38 |
39 | # properties
40 | base_matcher_pattern = "((.*? \(\S{4,}\)) ?(\(\S+\))? ?(?!\{\{SUSPENDED\}\})(\{(.*?) ?(\(\S+?\))?\})? ?(\{\{SUSPENDED\}\})?)\t+(.*)$"
41 | input_file_name = "movies.list"
42 | #FIXME: zafer: I think using a static number is critical for us. If imdb sends a new file with first 10 line fucked then we're also fucked
43 | number_of_lines_to_be_skipped = 15
44 | db_table_info = {
45 | 'tablename' : 'movies',
46 | 'columns' : [
47 | {'colname' : 'title', 'colinfo' : DbScriptHelper.keywords['string'] + '(255) NOT NULL'},
48 | {'colname' : 'full_name', 'colinfo' : DbScriptHelper.keywords['string'] + '(127)'},
49 | {'colname' : 'type', 'colinfo' : DbScriptHelper.keywords['string'] + '(20)'},
50 | {'colname' : 'ep_name', 'colinfo' : DbScriptHelper.keywords['string'] + '(127)'},
51 | {'colname' : 'ep_num', 'colinfo' : DbScriptHelper.keywords['string'] + '(20)'},
52 | {'colname' : 'suspended', 'colinfo' : DbScriptHelper.keywords['string'] + '(20)'},
53 | {'colname' : 'year', 'colinfo' : DbScriptHelper.keywords['string'] + '(20)'}
54 | ],
55 | 'constraints' : 'PRIMARY KEY(title)'
56 | }
57 | end_of_dump_delimiter = "--------------------------------------------------------------------------------"
58 |
59 | def __init__(self, preferences_map):
60 | super(MoviesParser, self).__init__(preferences_map)
61 | self.first_one = True
62 |
63 | def parse_into_tsv(self, matcher):
64 | is_match = matcher.match(self.base_matcher_pattern)
65 |
66 | if(is_match):
67 | self.tsv_file.write(self.concat_regex_groups([1,2,3,5,6,7,8], None, matcher) + "\n")
68 | else:
69 | logging.critical("This line is fucked up: " + matcher.get_last_string())
70 | self.fucked_up_count += 1
71 |
72 | def parse_into_db(self, matcher):
73 | is_match = matcher.match(self.base_matcher_pattern)
74 |
75 | if(is_match):
76 | if(self.first_one):
77 | self.sql_file.write("(" + self.concat_regex_groups([1,2,3,5,6,7,8], [0,1,2,3,4,5,6], matcher) + ")")
78 | self.first_one = False;
79 | else:
80 | self.sql_file.write(",\n(" + self.concat_regex_groups([1,2,3,5,6,7,8], [0,1,2,3,4,5,6], matcher) + ")")
81 | else:
82 | logging.critical("This line is fucked up: " + matcher.get_last_string())
83 | self.fucked_up_count += 1
84 |
--------------------------------------------------------------------------------
/idp/parser/parsinghelper.py:
--------------------------------------------------------------------------------
1 | """
2 | This file is part of imdb-data-parser.
3 |
4 | imdb-data-parser is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | imdb-data-parser is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with imdb-data-parser. If not, see .
16 | """
17 |
18 | import logging
19 | import traceback
20 | from idp import settings
21 |
22 |
23 | class ParsingHelper(object):
24 | """
25 | ParsingHelper manages parsing order
26 | """
27 |
28 | @staticmethod
29 | def parse_one(item, preferences_map):
30 |
31 | def get_parser_class_for(item_name):
32 | """
33 | Thanks to http://stackoverflow.com/a/452981
34 | """
35 | kls = "idp.parser." + item_name + "parser." + item_name.title() + "Parser"
36 | parts = kls.split('.')
37 | module = ".".join(parts[:-1])
38 | m = __import__( module )
39 | for comp in parts[1:]:
40 | m = getattr(m, comp)
41 | return m
42 |
43 | try:
44 | ParserClass = get_parser_class_for(item)
45 | except Exception as e:
46 | logging.error("No parser found for: " + item + "\n\tException is: " + str(e))
47 | return 1
48 | logging.info("___________________")
49 | logging.info("Parsing " + item + "...")
50 | parser = ParserClass(preferences_map)
51 | try:
52 | parser.start_processing()
53 | except Exception as e:
54 | logging.error("Exception occured while parsing item: " + item + "\n\tException is: " + str(e))
55 | traceback.print_exc()
56 | logging.info("Parsing finished for item: " + item)
57 |
58 | @staticmethod
59 | def parse_all(preferences_map):
60 | for item in settings.LISTS:
61 | ParsingHelper.parse_one(item, preferences_map)
62 | logging.info("All parsing finished.")
63 |
64 | if __name__ == "__main__":
65 | """
66 | For debugging purposes
67 | """
68 | print("Parsing only one file for debugging purposes...")
69 | preferences_map = {
70 | "mode":"TSV",
71 | "inputDir": "../../samples/imdb_lists/",
72 | "outputDir": "../../samples/idp_files/"
73 | }
74 | ParsingHelper.parse_one("movies", preferences_map)
75 |
--------------------------------------------------------------------------------
/idp/parser/plotparser.py:
--------------------------------------------------------------------------------
1 | """
2 | This file is part of imdb-data-parser.
3 |
4 | imdb-data-parser is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | imdb-data-parser is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with imdb-data-parser. If not, see .
16 | """
17 |
18 | from .baseparser import *
19 |
20 |
21 | class PlotParser(BaseParser):
22 | """
23 | RegExp: /(.+?): (.*)/g
24 | pattern: (.+?): (.*)
25 | flags: g
26 | 2 capturing groups:
27 | group 1: (.+?) type of the line
28 | group 2: (.*) if the line-type is PL then this line is plot, not the whole but one line of it
29 | if the line-type is MV then this line is movie
30 | """
31 |
32 | # properties
33 | base_matcher_pattern = "(.+?): (.*)"
34 | input_file_name = "plot.list"
35 | number_of_lines_to_be_skipped = 15
36 | db_table_info = {
37 | 'tablename' : 'plot',
38 | 'columns' : [
39 | {'colname' : 'title', 'colinfo' : DbScriptHelper.keywords['string'] + '(255) NOT NULL'},
40 | {'colname' : 'plot', 'colinfo' : DbScriptHelper.keywords['string'] + '(4000)'}
41 | ],
42 | 'constraints' : 'PRIMARY KEY(title)'
43 | }
44 | end_of_dump_delimiter = ""
45 |
46 | def __init__(self, preferences_map):
47 | super(PlotParser, self).__init__(preferences_map)
48 | self.first_one = True
49 |
50 | # specific to this class
51 | self.title = ""
52 | self.plot = ""
53 |
54 | def parse_into_tsv(self, matcher):
55 | is_match = matcher.match(self.base_matcher_pattern)
56 |
57 | if(is_match):
58 | if(matcher.group(1) == "MV"): #Title
59 | if(self.title != ""):
60 | self.tsv_file.write(self.title + self.seperator + self.plot + "\n")
61 |
62 | self.plot = ""
63 | self.title = matcher.group(2)
64 |
65 | elif(matcher.group(1) == "PL"): #Descriptive text
66 | self.plot += matcher.group(2)
67 | elif(matcher.group(1) == "BY"):
68 | pass
69 | else:
70 | logging.critical("Unhandled abbreviation: " + matcher.group(1) + " in " + line)
71 | #else:
72 | #just ignore this part, useless lines
73 |
74 | """
75 | FIXME: this parsing misses the last entry
76 | need to execute following just after looping the input file's lines:
77 | # Covers the last item
78 | outputFile.write(title + self.seperator + plot + "\n")
79 |
80 | consider writing to the file in "BY:" condition
81 | """
82 |
83 | def parse_into_db(self, matcher):
84 | is_match = matcher.match(self.base_matcher_pattern)
85 |
86 | if(is_match):
87 | if(matcher.group(1) == "MV"): #Title
88 | if(self.title != ""):
89 | if(self.first_one):
90 | self.sql_file.write("(\"" + self.title + "\", \"" + self.plot + "\")")
91 | self.first_one = False;
92 | else:
93 | self.sql_file.write(",\n(\"" + self.title + "\", \"" + self.plot + "\")")
94 |
95 | self.plot = ""
96 | self.title = matcher.group(2)
97 |
98 | elif(matcher.group(1) == "PL"): #Descriptive text
99 | self.plot += matcher.group(2)
100 | elif(matcher.group(1) == "BY"):
101 | pass
102 | else:
103 | logging.critical("Unhandled abbreviation: " + matcher.group(1) + " in " + line)
104 |
--------------------------------------------------------------------------------
/idp/parser/ratingsparser.py:
--------------------------------------------------------------------------------
1 | """
2 | This file is part of imdb-data-parser.
3 |
4 | imdb-data-parser is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | imdb-data-parser is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with imdb-data-parser. If not, see .
16 | """
17 |
18 | from .baseparser import *
19 |
20 |
21 | class RatingsParser(BaseParser):
22 | """
23 | RegExp: /\s*(\S*)\s*(\S*)\s*(\S*)\s*((.*? \(\S{4,}\)) ?(\(\S+\))? ?(?!\{\{SUSPENDED\}\})(\{(.*?) ?(\(\S+?\))?\})? ?(\{\{SUSPENDED\}\})?)$/gm
24 | pattern: \s*(\S*)\s*(\S*)\s*(\S*)\s*((.*? \(\S{4,}\)) ?(\(\S+\))? ?(?!\{\{SUSPENDED\}\})(\{(.*?) ?(\(\S+?\))?\})? ?(\{\{SUSPENDED\}\})?)$
25 | flags: gm
26 | 10 capturing groups:
27 | group 1: (\S*) distribution
28 | group 2: (\S*) votes
29 | group 3: (\S*) rank
30 | group 4: #TITLE (UNIQUE KEY)
31 | group 5: (.*? \(\S{4,}\)) movie name + year
32 | group 6: (\(.+\)) type ex:(TV)
33 | group 7: (\{(.*?)\s?(\(.+?\))\}) series info ex: {Ally Abroad (#3.1)}
34 | group 8: (.*?) episode name ex: Ally Abroad
35 | group 9: (\(.+?\)) episode number ex: (#3.1)
36 | group 10: (\{\{SUSPENDED\}\}) is suspended?
37 | """
38 |
39 | # properties
40 | base_matcher_pattern = "\s*(\S*)\s*(\S*)\s*(\S*)\s*((.*? \(\S{4,}\)) ?(\(\S+\))? ?(?!\{\{SUSPENDED\}\})(\{(.*?) ?(\(\S+?\))?\})? ?(\{\{SUSPENDED\}\})?)$"
41 | input_file_name = "ratings.list"
42 | number_of_lines_to_be_skipped = 28
43 | db_table_info = {
44 | 'tablename' : 'ratings',
45 | 'columns' : [
46 | {'colname' : 'distribution', 'colinfo' : DbScriptHelper.keywords['string'] + '(127) NOT NULL'},
47 | {'colname' : 'votes', 'colinfo' : DbScriptHelper.keywords['string'] + '(127)'},
48 | {'colname' : 'rank', 'colinfo' : DbScriptHelper.keywords['string'] + '(127)'},
49 | {'colname' : 'title', 'colinfo' : DbScriptHelper.keywords['string'] + '(255) NOT NULL'}
50 | ],
51 | 'constraints' : 'PRIMARY KEY(title)'
52 | }
53 | end_of_dump_delimiter = ""
54 |
55 | def __init__(self, preferences_map):
56 | super(RatingsParser, self).__init__(preferences_map)
57 | self.first_one = True
58 |
59 | def parse_into_tsv(self, matcher):
60 | is_match = matcher.match(self.base_matcher_pattern)
61 |
62 | if(is_match):
63 | self.tsv_file.write(self.concat_regex_groups([1,2,3,4], None, matcher) + "\n")
64 | else:
65 | logging.critical("This line is fucked up: " + matcher.get_last_string())
66 | self.fucked_up_count += 1
67 |
68 | def parse_into_db(self, matcher):
69 | is_match = matcher.match(self.base_matcher_pattern)
70 |
71 | if(is_match):
72 | if(self.first_one):
73 | self.sql_file.write("(" + self.concat_regex_groups([1,2,3,4], [0,1,2,3], matcher) + ")")
74 | self.first_one = False;
75 | else:
76 | self.sql_file.write(",\n(" + self.concat_regex_groups([1,2,3,4], [0,1,2,3], matcher) + ")")
77 | else:
78 | logging.critical("This line is fucked up: " + matcher.get_last_string())
79 | self.fucked_up_count += 1
80 |
--------------------------------------------------------------------------------
/idp/parser/triviaparser.py:
--------------------------------------------------------------------------------
1 | """
2 | This file is part of imdb-data-parser.
3 |
4 | imdb-data-parser is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | imdb-data-parser is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with imdb-data-parser. If not, see .
16 | """
17 |
18 | from .baseparser import *
19 |
20 |
21 | class TriviaParser(BaseParser):
22 | """
23 | RegExp: /((.+?) (.*))|\n/g
24 | pattern: ((.+?) (.*))|\n
25 | flags: g
26 | 2 capturing groups:
27 | group 1: (.+?) type of the line
28 | group 2: (.*) if the line-type is - then this line is plot, not the whole but one line of it
29 | if the line-type is # then this line is movie
30 | """
31 |
32 | # properties
33 | base_matcher_pattern = "((.+?) (.*))|\n"
34 | input_file_name = "trivia.list"
35 | number_of_lines_to_be_skipped = 15
36 | db_table_info = {
37 | 'tablename' : 'trivia',
38 | 'columns' : [
39 | {
40 | 'colname' : '',
41 | 'colinfo' : DbScriptHelper.keywords['string'] + '(255) NOT NULL'
42 | }
43 | ],
44 | 'constraints' : ''
45 | }
46 | end_of_dump_delimiter = ""
47 |
48 | title = ""
49 | trivia = ""
50 |
51 | def __init__(self, preferences_map):
52 | super(TriviaParser, self).__init__(preferences_map)
53 | self.first_one = True
54 |
55 | def parse_into_tsv(self, matcher):
56 | is_match = matcher.match(self.base_matcher_pattern)
57 |
58 | if(is_match):
59 | if(matcher.group(2) == "#"): #Title
60 | self.title = matcher.group(3)
61 | elif(matcher.group(2) == "-"): #Descriptive text
62 | self.trivia = matcher.group(3)
63 | elif(matcher.group(2) == " "):
64 | self.trivia += ' ' + matcher.group(3)
65 | else:
66 | self.tsv_file.write(self.title + self.seperator + self.trivia + "\n")
67 | else:
68 | logging.critical("This line is fucked up: " + matcher.get_last_string())
69 | self.fucked_up_count += 1
70 |
71 | def parse_into_db(self, matcher):
72 | #TODO
73 | pass
74 |
--------------------------------------------------------------------------------
/idp/settings.py.example:
--------------------------------------------------------------------------------
1 | """
2 | This file is part of imdb-data-parser.
3 |
4 | imdb-data-parser is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | imdb-data-parser is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with imdb-data-parser. If not, see .
16 | """
17 |
18 | INPUT_DIR = "/path/to/lists/files/"
19 | OUTPUT_DIR = "/path/to/tsv/outputs/"
20 |
21 | INTERFACES_SERVER = "ftp.fu-berlin.de"
22 | INTERFACES_DIRECTORY = "pub/misc/movies/database/"
23 | #alternative servers:
24 | #ftp://ftp.funet.fi/pub/mirrors/ftp.imdb.com/pub/
25 | #ftp://ftp.sunet.se/pub/tv+movies/imdb/
26 |
27 | LISTS = [
28 | "directors",
29 | "genres",
30 | "movies",
31 | "plot",
32 | "actors",
33 | "actresses",
34 | "aka-names",
35 | "aka-titles",
36 | "ratings"
37 | ]
38 |
--------------------------------------------------------------------------------
/idp/utils/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dedeler/imdb-data-parser/20671ab98e2065bbe0a32aef0402776934a2863b/idp/utils/__init__.py
--------------------------------------------------------------------------------
/idp/utils/dbscripthelper.py:
--------------------------------------------------------------------------------
1 | """
2 | This file is part of imdb-data-parser.
3 |
4 | imdb-data-parser is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | imdb-data-parser is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with imdb-data-parser. If not, see .
16 | """
17 |
18 | import os
19 |
20 |
21 | class DbScriptHelper(object):
22 | keywords = {
23 | 'string': "VARCHAR",
24 | 'number': "NUMERIC",
25 | 'date': "DATE"
26 | }
27 |
28 | scripts = {
29 | 'drop': "DROP TABLE ",
30 | 'create': "CREATE TABLE ",
31 | 'insert': "INSERT INTO "
32 | }
33 |
34 | def __init__(self, db_table_info):
35 | self.scripts = {
36 | 'drop': "DROP TABLE ",
37 | 'create': "CREATE TABLE ",
38 | 'insert': "INSERT INTO "
39 | }
40 | self.scripts['drop'] += db_table_info['tablename'] + ";" + os.linesep
41 | self.scripts['create'] += db_table_info['tablename'] + "(" + ', '.join(filter(None, (', '.join('%s %s' % (col['colname'], col['colinfo']) for col in db_table_info['columns']), db_table_info['constraints']))) + ") CHARACTER SET utf8 COLLATE utf8_bin;" + os.linesep
42 | self.scripts['insert'] += db_table_info['tablename'] + "(" + ', '.join(col['colname'] for col in db_table_info['columns']) + ") VALUES" + os.linesep
--------------------------------------------------------------------------------
/idp/utils/decorators.py:
--------------------------------------------------------------------------------
1 | """
2 | This file is part of imdb-data-parser.
3 |
4 | imdb-data-parser is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | imdb-data-parser is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with imdb-data-parser. If not, see .
16 | """
17 |
18 | import datetime
19 | import logging
20 |
21 |
22 | def duration_logged(func):
23 | '''
24 | As the name suggests, calculates the execution duration of the function which is annotated by this decorator
25 | '''
26 | def inner(*args, **kwargs):
27 | start_time = datetime.datetime.now()
28 | ret_val = func(*args, **kwargs)
29 | end_time = datetime.datetime.now()
30 | duration = (end_time - start_time).total_seconds() #difference of 2 datetime is a timedelta
31 | logging.info("Parsing took " + str(duration) + " seconds")
32 | return ret_val
33 | return inner
--------------------------------------------------------------------------------
/idp/utils/filehandler.py:
--------------------------------------------------------------------------------
1 | """
2 | This file is part of imdb-data-parser.
3 |
4 | imdb-data-parser is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | imdb-data-parser is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with imdb-data-parser. If not, see .
16 | """
17 |
18 | import gzip
19 | import os.path
20 | import logging
21 | from ..settings import *
22 |
23 |
24 | class FileHandler(object):
25 | def __init__(self, list_name, preferences_map):
26 | self.list_name = list_name
27 | self.preferences_map = preferences_map
28 |
29 | def full_path(self):
30 | return os.path.join(self.preferences_map['input_dir'], self.list_name)
31 |
32 | def tsv_path(self):
33 | return os.path.join(self.preferences_map['output_dir'], self.list_name) + ".tsv"
34 |
35 | def sql_path(self):
36 | return os.path.join(self.preferences_map['output_dir'], self.list_name) + ".sql"
37 |
38 | def get_input_file(self):
39 | full_file_path = self.full_path()
40 | logging.info("Trying to find file: %s", full_file_path)
41 | if os.path.isfile(full_file_path):
42 | logging.info("File found: %s", full_file_path)
43 | return open(full_file_path, "r", encoding='iso-8859-1')
44 |
45 | logging.error("File cannot be found: %s", full_file_path)
46 |
47 | logging.info("Trying to find file: %s", full_file_path + ".gz")
48 | if os.path.isfile(full_file_path + ".gz"):
49 | logging.info("File found: %s", full_file_path + ".gz")
50 | if extract(full_file_path + ".gz") == 0:
51 | return open(full_file_path, "r", encoding='iso-8859-1')
52 | else:
53 | raise RuntimeError("Unknown error occured")
54 |
55 | logging.error("File cannot be found: %s", full_file_path + ".gz")
56 |
57 | raise RuntimeError("FileNotFoundError: %s", full_file_path)
58 |
59 | #this part removed until python 3.3 becomes available for ubuntu LTS and debian
60 | #
61 | # print("Trying to find file:", full_file_path)
62 | # if os.path.isfile(full_file_path):
63 | # print("File found:", full_file_path)
64 | # return gzip.open(full_file_path, 'rt')
65 | # print("File cannot be found:", full_file_path)
66 |
67 | def get_tsv_file(self):
68 | return open(self.tsv_path(), "w", encoding='utf-8')
69 |
70 | def get_sql_file(self):
71 | return open(self.sql_path(), "w", encoding='utf-8')
72 |
73 | def extract(gzip_path):
74 | try:
75 | logging.info("Started to extract list: %s", gzip_path)
76 | with gzip.open(gzip_path, "rb") as f:
77 | file_content = f.read()
78 | list_file = open(gzip_path[:-3], "wb")
79 | list_file.write(file_content)
80 | list_file.close()
81 | logging.info(gzip_path + " list extracted successfully")
82 | except Exception as e:
83 | logging.error("Error when extracting list: " + gzip_path + "\n\t" + str(e))
84 | return 1
85 | return 0
86 |
87 | def get_full_path(filename, isCompressed = False):
88 | """
89 | constructs a full path for a dump file in the INPUT_DIR
90 | filename should be without '.list'
91 | """
92 | if(isCompressed):
93 | return os.path.join(INPUT_DIR, filename) + ".gz"
94 | else:
95 | return os.path.join(INPUT_DIR, filename)
--------------------------------------------------------------------------------
/idp/utils/freebaseagent.py:
--------------------------------------------------------------------------------
1 | """
2 | This file is part of imdb-data-parser.
3 |
4 | imdb-data-parser is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | imdb-data-parser is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with imdb-data-parser. If not, see .
16 | """
17 |
18 | import json
19 | import urllib
20 |
21 |
22 | class FreebaseAgent(object):
23 | """Helper class to retrieve IMDb ids from freebase.
24 |
25 | Currently only supports movies. TV series support will
26 | hopefully be added if need arises.
27 | """
28 |
29 | def __init__(self):
30 | super(FreebaseAgent, self).__init__()
31 | self.API_KEY = 'YOUR-API-KEY-GOES-HERE' #TODO read these values from config
32 | self.topic_service_url = 'https://www.googleapis.com/freebase/v1/topic'
33 | self.search_service_url = 'https://www.googleapis.com/freebase/v1/search'
34 |
35 | def get_imdb_id(self, movie_name):
36 | """Returns the IMDb id of a movie, given its title.
37 |
38 | The returned title is the one with the highest
39 | freebase confidence score.
40 |
41 | Returns None if no such movie exists in freebase.
42 | """
43 | mid = self.get_topic_id(movie_name)
44 | topic = self.get_topic(mid)
45 | return topic
46 |
47 | def get_topic_id(self, name, entity_type='/film/film'):
48 | """Gets the topic id (aka mid, freebase id) of a title.
49 | """
50 | params = {
51 | 'query': name,
52 | 'type': entity_type,
53 | 'limit': 1
54 | }
55 | url = self.search_service_url + '?' + urllib.urlencode(params)
56 | response = json.loads(urllib.urlopen(url).read())
57 |
58 | for result in response.get('result'):
59 | mid = result.get('mid', None)
60 | return mid
61 | return None
62 |
63 | def get_topic(self, mid):
64 | """Gets the IMDb id of a freebase topic. Returns None if no
65 | such thing exists.
66 | """
67 | params = {
68 | 'filter': '/type/object/key'
69 | }
70 | url = self.topic_service_url + mid + '?' + urllib.urlencode(params)
71 | topic = json.loads(urllib.urlopen(url).read())
72 |
73 | for property in topic['property']:
74 | for value in topic['property'][property]['values']:
75 | if value['text'].startswith('/authority/imdb/title'):
76 | return value['text'].split('/')[-1]
77 |
78 |
79 | if __name__ == "__main__":
80 | import argparse
81 |
82 | parser = argparse.ArgumentParser(description="Retrieve imdb id from freebase.")
83 | parser.add_argument('movieName', help='The name of the movie')
84 | args = parser.parse_args()
85 |
86 | agent = FreebaseAgent()
87 | mid = agent.getTopicId(args.movieName)
88 | print 'freebase topic id (mid) is', mid
89 | topic = agent.getTopic(mid)
90 | print 'imdb id is', topic, 'so the url is http://www.imdb.com/title/'+topic
91 | print agent.getImdbId(args.movieName)
--------------------------------------------------------------------------------
/idp/utils/listdownloader.py:
--------------------------------------------------------------------------------
1 | """
2 | This file is part of imdb-data-parser.
3 |
4 | imdb-data-parser is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | imdb-data-parser is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with imdb-data-parser. If not, see .
16 | """
17 |
18 | import gzip
19 | import logging
20 | import os
21 | from ftplib import FTP
22 | from .filehandler import FileHandler
23 | from ..settings import *
24 |
25 |
26 | def download():
27 | logging.info("Lists will downloaded from server:" + INTERFACES_SERVER)
28 |
29 | ftp = FTP(INTERFACES_SERVER)
30 | ftp.login()
31 |
32 | download_count = 0
33 |
34 | for list_item in LISTS:
35 | try:
36 | logging.info("Started to download list:" + list_item)
37 | r = ftp.retrbinary("RETR " + INTERFACES_DIRECTORY + list_item + ".list.gz", open(os.path.join(INPUT_DIR, list_item + ".list.gz"), "wb").write)
38 | logging.info(list_item + "list downloaded successfully")
39 | download_count = download_count + 1
40 | FileHandler.extract(FileHandler.get_full_path(list_item + ".list", True))
41 | except Exception as e:
42 | logging.error("There is a problem when downloading list " + list_item + "\n\t" + str(e))
43 |
44 | logging.info(str(download_count) + " lists are downloaded")
45 | ftp.quit()
46 |
--------------------------------------------------------------------------------
/idp/utils/loggerinitializer.py:
--------------------------------------------------------------------------------
1 | """
2 | This file is part of imdb-data-parser.
3 |
4 | imdb-data-parser is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | imdb-data-parser is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with imdb-data-parser. If not, see .
16 | """
17 |
18 | import logging
19 | import os.path
20 |
21 |
22 | def initialize_logger(preferences_map):
23 | logger = logging.getLogger()
24 | logger.setLevel(logging.INFO)
25 |
26 | # create console handler and set level to info
27 | ch = logging.StreamHandler()
28 | ch.setLevel(logging.INFO)
29 | formatter = logging.Formatter("%(levelname)s - %(message)s")
30 | ch.setFormatter(formatter)
31 | logger.addHandler(ch)
32 |
33 | # create error file handler and set level to error
34 | ch = logging.FileHandler(os.path.join(preferences_map['output_dir'], "imdbparserError.log"),"w", encoding=None, delay="true")
35 | ch.setLevel(logging.ERROR)
36 | formatter = logging.Formatter("%(levelname)s - %(message)s")
37 | ch.setFormatter(formatter)
38 | logger.addHandler(ch)
39 |
40 | # create info file handler and set level to info
41 | ch = logging.FileHandler(os.path.join(preferences_map['output_dir'], "imdbparserAll.log"),"w")
42 | ch.setLevel(logging.INFO)
43 | formatter = logging.Formatter("%(levelname)s - %(message)s")
44 | ch.setFormatter(formatter)
45 | logger.addHandler(ch)
--------------------------------------------------------------------------------
/idp/utils/regexhelper.py:
--------------------------------------------------------------------------------
1 | """
2 | This file is part of imdb-data-parser.
3 |
4 | imdb-data-parser is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | imdb-data-parser is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with imdb-data-parser. If not, see .
16 | """
17 |
18 | import re
19 |
20 |
21 | class RegExHelper(object):
22 | def __init__(self, matchstring):
23 | self.matchstring = matchstring
24 |
25 | def match(self,regexp):
26 | self.rematch = re.match(regexp, self.matchstring)
27 | return bool(self.rematch)
28 |
29 | def group(self,i):
30 | if self.rematch.group(i) is None:
31 | return ""
32 | else:
33 | return self.rematch.group(i)
34 |
35 | def get_last_string(self):
36 | """
37 | returns the last string that is examined
38 | """
39 | return self.matchstring
--------------------------------------------------------------------------------
/idp/utils/test/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dedeler/imdb-data-parser/20671ab98e2065bbe0a32aef0402776934a2863b/idp/utils/test/__init__.py
--------------------------------------------------------------------------------
/idp/utils/test/filehandler_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from ..filehandler import *
3 | from ... import settings
4 |
5 | class FileHandlerTests(unittest.TestCase):
6 | def setUp(self):
7 | self.list = 'movies'
8 |
9 | def test_get_full_path(self):
10 | self.assertEqual(get_full_path(self.list), settings.INPUT_DIR+self.list)
11 |
12 |
13 | if __name__ == '__main__':
14 | unittest.main()
15 |
--------------------------------------------------------------------------------
/imdb_parse_path.txt:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of imdb-data-parser.
3 |
4 | imdb-data-parser is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | imdb-data-parser is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with imdb-data-parser. If not, see .
16 | */
17 |
18 |
19 |
20 | /********************************************************************************
21 | * *
22 | * -> optional *
23 | * #TITLE = name (year) }/> *
24 | * *
25 | ********************************************************************************/
26 |
27 | movies -> #TITLE Year
28 |
29 | ratings -> Dist.Num Votes Rank #TITLE
30 |
31 | genres -> #TITLE Genre
32 |
33 | language -> #TITLE Language
34 |
35 | run-time -> #TITLE time
36 |
37 | aka-title -> #TITLE
38 | (aka #TITLE)
39 | .....................
40 | .....................\n\n
41 |
42 | countries -> #TITLE Country
43 |
44 | taglines -> # #TITLE
45 | TagLine
46 | .......
47 | .......\n\n
48 |
49 | plot -> --------------------------
50 | MV: #TITLE
51 |
52 | PL: PlotLine1
53 | PL: PlotLine2
54 | PL: .........
55 |
56 | BY: By\n\n
57 |
58 | trivia -> # #TITLE
59 | - trivia1
60 | ...........
61 | ...........
62 |
63 | - trivia2
64 | ...........
65 | ...........\n\n
66 |
67 | directors -> Lastname, Firstname #TITLE
68 | #TITLE \n\n
69 |
70 | actors -> Lastname, Firstname #TITLE />
71 | #TITLE />
72 |
73 | actress -> Lastname, Firstname #TITLE />
74 | #TITLE />
75 |
--------------------------------------------------------------------------------
/imdbparser.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 |
3 | """
4 | This file is part of imdb-data-parser.
5 |
6 | imdb-data-parser is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | imdb-data-parser is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with imdb-data-parser. If not, see .
18 | """
19 |
20 | """
21 | Dealing with ": No such file or directory" error:
22 | http://stackoverflow.com/a/8735625/878361
23 | """
24 |
25 | import sys
26 | import argparse
27 | import datetime
28 | from idp.utils.loggerinitializer import *
29 | from idp.parser.parsinghelper import ParsingHelper
30 | from idp.settings import *
31 |
32 |
33 | # check python version
34 | if sys.version_info.major != 3:
35 | sys.exit("Error: wrong version! You need to install python3 to run this application properly.")
36 |
37 | parser = argparse.ArgumentParser(description="an IMDB data parser")
38 | parser.add_argument('-m', '--mode', help='Parsing mode, defines output of parsing process. Default: TSV', choices=['TSV', 'SQL'])
39 | parser.add_argument('-i', '--input_dir', help='source directory of interface lists')
40 | parser.add_argument('-o', '--output_dir', help='destination directory for outputs')
41 | parser.add_argument('-u', '--update_lists', action='store_true', help='downloads lists from server')
42 |
43 | args = parser.parse_args()
44 |
45 | # preparing preferences map
46 | if args.mode:
47 | mode = args.mode
48 | else: #default
49 | mode = "TSV"
50 |
51 | if args.input_dir:
52 | input_dir = args.input_dir
53 | else:
54 | input_dir = INPUT_DIR
55 |
56 | postfix = datetime.datetime.now().strftime("%Y-%m-%d_%H%M%S") + '_ImdbParserOutput'
57 | if args.input_dir:
58 | output_dir = os.path.join(args.output_dir, postfix)
59 | else:
60 | output_dir = os.path.join(OUTPUT_DIR, postfix)
61 |
62 | if not os.path.exists(output_dir):
63 | os.makedirs(output_dir)
64 |
65 | preferences_map = {
66 | "mode":mode,
67 | "input_dir": input_dir,
68 | "output_dir": output_dir
69 | }
70 |
71 | initialize_logger(preferences_map)
72 |
73 | logging.info("mode:%s", mode)
74 | logging.info("input_dir:%s", input_dir)
75 | logging.info("output_dir:%s", output_dir)
76 | logging.info("update_lists:%s", args.update_lists)
77 |
78 | if args.update_lists:
79 | from idp.utils import listdownloader
80 | logging.info("Downloading IMDB dumps, this may take a while depending on your connection speed")
81 | listdownloader.download()
82 |
83 | logging.info("Parsing, please wait. This may take very long time...")
84 |
85 | ParsingHelper.parse_all(preferences_map)
86 |
87 | logging.info("Check out output folder: %s", output_dir)
88 | print ("All done, enjoy ;)") #don't print this via logger, this is part of the program
89 |
--------------------------------------------------------------------------------
/samples/movies.list:
--------------------------------------------------------------------------------
1 | dummy
2 | dummy
3 | dummy
4 | dummy
5 | dummy
6 | dummy
7 | dummy
8 | dummy
9 | dummy
10 | dummy
11 | dummy
12 | dummy
13 | dummy
14 | dummy
15 | dummy
16 | "$9.99" (2003) {Winter Wonderland (#3.1)} 2005
17 | "$weepstake$" (1979) 1979-????
18 | "$weepstake$" (1979) {(#1.1)} 1979
19 | "' Horse Trials '" (2011) 2011-????
20 | "'80s Videos: A to Z" (2009) 2009-????
21 | "'Allo 'Allo!" (1982) 1982-1992
22 | "'Allo 'Allo!" (1982) {A Bun in the Oven (#8.0)} 1991
23 | "'Til Death" (2006) {(#3.22)} {{SUSPENDED}} ????
24 | "'Til Death" (2006) {Ally Abroad (#4.22)} 2010
25 | Anno 2006 (2007) (TV) 2007
26 | Anno 2008 - 15 let TV Nova (2009) (TV) 2009
27 | Anno 2009 (2010) (TV) 2010
28 | Anno 2020 - I gladiatori del futuro (1984) 1984
29 | Anno 2033 (1973) 1973
30 | Anno 2070 (2011) (VG) 2011
31 | Anno 79: La distruzione di Ercolano (1962) 1962
32 | Anno domini (1991) 1991
33 | Anniversary (1992) (V) 1992
34 | Anniversary (2002) {{SUSPENDED}} 2002
35 | Apocalypse (2011) (V) {{SUSPENDED}} 2011
36 | "'Allo 'Allo!" (1982) {A Bun in the Oven (#8.0)} {{SUSPENDED}} 1991
--------------------------------------------------------------------------------
/samples/movies.list.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dedeler/imdb-data-parser/20671ab98e2065bbe0a32aef0402776934a2863b/samples/movies.list.gz
--------------------------------------------------------------------------------