├── .gitignore ├── LICENSE ├── README.md ├── config ├── people.default.conf ├── rcm.default.conf └── words.conf └── rcm.py /.gitignore: -------------------------------------------------------------------------------- 1 | config/rcm.conf 2 | config/people.conf 3 | config/memory.dat 4 | output/ 5 | logs/ 6 | -------------------------------------------------------------------------------- /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 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Radarr Collection and People Manager 2 | 3 | A Python script for checking your [Radarr](https://radarr.video/) database against Collections and People's careers on [TMDB](https://www.themoviedb.org/). 4 | 5 | This downloads information directly from the Movie's TMDB page and Collections are strictly limited to sequels. For example, with [Dark Knight (2008)](https://www.themoviedb.org/movie/155-the-dark-knight) in my database, this will look at the attached [collection information](https://www.themoviedb.org/collection/263-the-dark-knight-collection?language=en-US), check the Radarr database for [Batman Begins (2005)](https://www.themoviedb.org/movie/272?language=en-US) and [The Dark Knight Rises (2012)](https://www.themoviedb.org/movie/49026?language=en-US) and can either automatically add any missing into the database or save as a list for manual browsing. 6 | 7 | People can also be monitored to automatically find missing Movies from their Acting, Writng, Directing, and / or Production credits as listed on their [TMDB page](https://www.themoviedb.org/person/138-quentin-tarantino?language=en-US). 8 | 9 | ___ 10 | # NOW UPDATED FOR RADARR API V3 11 | ___ 12 | **Jump to:** 13 | - [Setting up config files](https://github.com/RhinoRhys/radarr-collections#setting-up-the-configuration-files) 14 | - [Setting up People monitoring](https://github.com/RhinoRhys/radarr-collections#people-monitoring) 15 | - [Install and Run](https://github.com/RhinoRhys/radarr-collections#installation-and-running) 16 | - [Get in touch](https://github.com/RhinoRhys/radarr-collections#get-in-touch) 17 | 18 | ## Optional Features: 19 | - Automatically added into Radarr _or_ save results to text file. 20 | - Add Monitored _or_ Unmonitored. 21 | - Trigger search when added. 22 | - Follow People and grab everything with / by them. 23 | - People only mode - disable scanning collections. 24 | - Movie exclusions 25 | - Ignore missing movies, only check movies that have files. 26 | - Ignore unmonitored movies. 27 | - Blacklist of movies to reject. 28 | - Exclude movies on Radarr's exclusion list. 29 | - Exclude results by minimum ratings and votes. 30 | - Exclude unannounced / preproduction movies that have a release year 0 (on by default) 31 | 32 | ## Requirements: 33 | - Radarr 34 | - Your own TMDB API key. 35 | 36 | **Getting a TMDB API key:** TMDB offers free API keys to anyone with an account. Simply sign up and request a key via your account settings. 37 | 38 | ## Setting up the configuration files 39 | 40 | The config folder can be named and placed anywhere on your computer and the directory path must be specified when running the command. 41 | 42 | In the config folder, make a copy of `rcm.default.conf`, rename it `rcm.conf` and open it with any text editor. 43 | 44 | #### Radarr settings 45 | 46 | - **server** - Address used to access Radarr, usually only `host:port`. Can be `host:port/end`, `domain/end` or anything as needed for reverse proxied setups. 47 | - **api_key** - Can be found under Settings > General. 48 | - **ssl** [`True`|`False`] - Add `https://` instead of `http://` before the _server_ setting when putting the Radarr URL together. 49 | - **docker** [`True`|`False`] - Forces a linux style directory path for when running from Windows with Radarr in a Docker or on a remote linux machine. 50 | 51 | #### TMDB 52 | - **api_key** - Your TMDB API (v3) key. 53 | 54 | #### Adding 55 | Settings for automatic adding into Radarr. If using, the first time you run the script it is reccomended to have both set to False. This will find a lot of movies on the first run and having it autosearch all of these is a bad idea, having them unmonitored makes them easier to filter in Radarr. 56 | - **monitored** [`True`|`False`] - Add new movies monitored. 57 | - **autosearch** [`True`|`False`] - Automatically run a historical / backlog search when added. 58 | - **profile** is the TMDB ID number of a Movie in your database that will be used to copy the Profile and Root Path from when adding movies via People Monitoring and as a back-up for single scan mode if no movies in the collection are in the database. You need to find a movie in Radarr that has the root folder and profile that you want to copy and take the number from the end of the web address, `localhost:7878/movies/name-of-movie-#####`. The profile variable has to be a movie TMDB ID number, it cannot be the name of a movie. 59 | 60 | #### Output 61 | - **ignore_wanted** [`True`|`False`] - Only check movies with files. Ignore Wanted list. 62 | - **ignore_unmonitored** [`True`|`False`] - Only check monitored movies in Radarr. 63 | - **column** - Minimum width for first column in output files, I had to give it a number to make everything line up so it might as well be here. 64 | - **path** - Set folder where the two `output` and `logs` folders will be created. Default is to use the current working directory. 65 | 66 | #### Blacklist 67 | While checking for movie information, TMDB ratings and the number of votes that contributed were also included so can be used to reject poorly rated movies. If you only want movies after a certain year, movies before this can also be rejected. 68 | - **min_rating** - Scale from 0.0 to 10.0 69 | - **min_votes** - Minimum number of votes 70 | - **min_year** - Reject movies in collections by earliest release year. Does not apply to people monitoring. 71 | - **ignore_zero** - [`True`|`False`] - Ignore movies that have the year (0) 72 | 73 | There are a lot of bad sequels out there. To block a movie from being imported, simply find it on TMDB and grab the ID number from the web address `themoviebd.org/movie/#####-name-of-movie` and add it to the blacklist. Alternatively, running the script with automatic adding disabled will list the movie TMDB ID numbers in the results file. 74 | - **blacklist** - Comma separated list of movie TMDB ID numbers to ignore if missing from the database. For example, to ignore both other Batman movies and only keep the middle one, I would have: `blacklist = 272, 49026` 75 | 76 | ## People Monitoring 77 | 78 | Do you want everything by a certain Actor, Producer, Director or Writer? Grab their TMDB ID number from their [TMDB profile page](https://www.themoviedb.org/person/138-quentin-tarantino?language=en-US) web address `themoviebd.org/person/####-name-of-person` and using the template below, select which credits you would like to monitor. Should work with any of the separating headers on their profile page or [this list](https://www.themoviedb.org/talk/598c3a70925141080100e601). If monitoring 'Acting' credits, specific charcater names can be set to allow you to reject movies where they are credited as "Himself" or "Herself", if "Uncredited" appears in there, or if you wish to exclude any other role they are credited with. 79 | 80 | In the config folder, make a copy of `people.default.conf` and rename it `people.conf`. 81 | 82 | #### Setting up an individual to follow 83 | 84 | For each person you wish to follow you need to make a new section in `people.conf`. 85 | - **header** The section header should be their name inside [   ]. 86 | - **id** - The person's TMDB ID number. 87 | - **monitor** - Comma separated list of the roles you wish to follow for that person. 88 | - **reject** - Comma separated list of specific character names to reject from acting roles, or use "&blank" to reject empty information and "&name" to reject character names that are their real names. Can be anything but must match letter for letter. 89 | - **min_year** - Reject movies by earliest release year for this person only. 90 | 91 | Template: 92 | > [NAME]
93 | > id = TMDB ID
94 | > monitor = Acting, Directing, Production, Writing
95 | > reject = &blank, &name, Uncredited, Himself, Herself, Narrator
96 | > min_year = 0 97 | 98 | Example: 99 | > [Quentin Tarantino]
100 | > id = 138
101 | > monitor = Directing, Production, Writing
102 | > reject =
103 | > min_year = 0
104 | >
105 | > [Tom Cruise]
106 | > id = 500
107 | > monitor = Acting
108 | > reject = &blank, Uncredited, Himself, Ethan Hunt
109 | > min_year = 2000 110 | 111 | ## Installation and Running 112 | **Local** 113 | - Download and extract the zip or clone with git to a location of your choice. 114 | - You may name and place the config folder anywhere on the computer, the given command assumes the folder is still named `config` in the same folder as `rcm.py`. 115 | - In the config folder, make a copy of `rcm.default.conf` and rename it `rcm.conf`, edit `rcm.conf` for your values and optionally set up `people.conf`. 116 | - In Command Prompt or Terminal, navigate into the downloaded folder and run `python rcm.py ./config` to begin a scan with the default running options. Python v2 and v3 compatible. 117 | 118 | **Docker Container** 119 | - Container written and maintained by **Roxedus**, and is available [here](https://github.com/si0972/docker-containers/tree/master/alpine/radarr-collections). 120 | ``` 121 | docker create \ 122 | --name=radarr-collections \ 123 | -v :/config \ 124 | -e PGID= -e PUID= \ 125 | -e args=CHANGE_ME \ 126 | si0972/radarr-collections 127 | ``` 128 | The `args` enviroment variable refers to the [running options](https://github.com/RhinoRhys/radarr-collections#running-options). 129 | 130 | I know nothing about Docker myself so cannot assist with any related issues, please open issues about the container [here](https://github.com/si0972/docker-containers/issues/new). 131 | 132 | **Running Process**
133 | Running without any mode options will default to a **full update scan** after one **full initial scan** has completed. 134 | 135 | Movies added into Radarr automatically from; 136 | - Collection scans will use the same Profile and Root Folder Path for the whole collection. 137 | - People Monitoring will copy the Profile and Root Folder Path from the movie set in the varibale below. 138 | - Single scan mode will check if any of the collection are already in the database and copy that or copy the people monitoring default if none are found. 139 | 140 | ### Running options 141 | 142 | You are able to change the mode and output by running as `python rcm.py ./config [options]`.
143 | 144 | | Short | Long | Use | 145 | |---|---|---| 146 | | `-h` | `--help` | Displays this help. | 147 | | | **Conflicting** | **Mode options** | 148 | | `-f` | `--full` | Repeat full initial scan - recheck all movies. | 149 | | `-u` | `--up` | Reduced update scan - only check recently added items. | 150 | | `-p` | `--people` | People only mode - disable all collection scanning | 151 | | `-t ` | `--tmdbid ` | Single scan mode - check single TMDB ID for Collections. | 152 | | `-s ` | `--start ` | Specify start point - useful for big libraries if errors occur. (forces `-f`) | 153 | | | **Independant** | **Output options** | 154 | | `-q` | `--quiet` | Disables verbose logging in command line. Log file still created. | 155 | | `-n` | `--nolog` | Disables log file creation. Verbose logging still visible. | 156 | | `-e` | `--exclude` | Movies on Radarr's exclusion list will be ignored and won't be added to the datbase. | 157 | | `-c` | `--cache` | Disables automatic adding to Radarr, instead saves list of missing movies to text file. | 158 | 159 | 160 | Multiple options can be passed in, in any order. `python rcm.py ./config -c -n -f` would work for example. 161 | 162 | ### Scan Modes 163 | #### Full initial scan 164 | 165 | The first time the script is run, or when running with the `-f` option, every movie in your Radarr database will be checked for collections, then your monitored people if set up. After this complete scan, it will save a list of all the movie TMDB ID numbers in your Radarr database and all the Collection ID numbers discovered. 166 | 167 | #### Full update scan 168 | 169 | Running the script after this data is saved will perform an update scan, only checking movies that have been added to the Radarr database since and then rechecking the previously found collections and your monitored people for any new additions. If you delete any or all of the movies in a collection from Radarr without adding them to the blacklist, the update scan will still remember the collection and try to re-add the movies. The only way to remove an entire collection from memory is to re-run the initial scan. 170 | 171 | #### Reduced update scan 172 | 173 | As new movies don't come out very often, running with the `-u` options allows you to check collections for newly added movies in Radarr without rechecking the saved collections or your monitored people. This is an ideal scan mode to schedule at short intervals to keep all movies added into Radarr checked. 174 | 175 | #### Single scan 176 | 177 | When running with the `-t ` option, this will only run a collection check for that movie then stop. Designed for use with `ignore_wanted = true`, single scan mode can be set up as a post processing script in Radarr to automatically check collections as files are downloaded. 178 | 179 | #### People only scan 180 | 181 | If you do not wish to check your Radarr database against collection information and are only interested in searching people's careers, collection scanning can be skipped by running with the `-p` option. 182 | 183 | ### Common Problems 184 | 185 | > Traceback ..... ImportError: No module named XXXX 186 | - You do not have the 'requests' or 'configparser' Python module(s) installed. 187 | - unix `pip install requests configparser` 188 | - Windows `python -m pip install requests configparser` 189 | 190 | > Traceback ..... KeyError: XXX 191 | - Please update your config files to the latest version 192 | 193 | > Failed to add: [response code: 200] 194 | - This error occurs when the URL in the config is not accurate enough, usually due to missing the reverse proxy URL base. While the script has been able to read your database, the API is very specific when adding information. 195 | 196 | ### Scheduling 197 | 198 | To automate running a scan at set intervals, please use your inbuilt OS scheduling tool to run the command. Please be aware that once the **full initial scan** has run, the **full update scan** is unlikely to find new movies very often and that this script makes one API call to TMDB per movie, collection and person that it checks. While their network can probably handle it, it just seems like a waste to be repeatedly making thousands of data requests per run when new sequels are only announced every few years and it takes months of people's time to make or be in something. I personally have it set up with two scheduled tasks, one running the **Reduced update scan** every day to keep new additions to the database checked and the other running a **full update scan** only once a fortnight to sync all my monitored collections and people. 199 | 200 | ### Additional output files 201 | #### Caching mode 202 | 203 | When running with the `-c` option, no movies will be automatically added into Radarr. Instead, found\_date\_time.txt is the scan results file that lists the movies that have been found. It is not created if 0 movies are found. A comma separated list of all the TMDB ID numbers found is also added at the end of the file. This allows you to run the scan once to list everything you are missing, add all the movies from the list that you want, then run the scan a second time and use the new list to paste into your rcm.conf file in the blacklist. Be sure to check there is a comma between the end of what is already there and what you paste in.
204 | Example: 205 | > Total Movies Found: 2 206 | > 207 | > From Collections: 1 208 | > 209 | > The Dark Knight Collection TMDB ID: 272 Batman Begins (2005) 210 | > 211 | > From People: 1 212 | > 213 | > Quentin Tarantino - Directing - Director TMDB ID: 187 Sin City (2005) 214 | > 215 | > Blacklist entry for all movies: 216 | > 217 | > blacklist = 272, 187 218 | 219 | ## Get in touch 220 | 221 | - [Discord](https://discord.gg/nXcFvWX) 222 | - [Reddit](https://www.reddit.com/user/RhinoRhys) 223 | -------------------------------------------------------------------------------- /config/people.default.conf: -------------------------------------------------------------------------------- 1 | # People to follow 2 | # 3 | # 4 | # [<>] 5 | # id = <> 6 | # monitor = Acting, Directing, Production, Writing 7 | # reject = &blank, &name, Uncredited, Himself, Herself, Narrator 8 | # min_year = 0 9 | 10 | -------------------------------------------------------------------------------- /config/rcm.default.conf: -------------------------------------------------------------------------------- 1 | ## Radarr settings 2 | [radarr] 3 | # What you type in your browser to view Radarr 4 | server = localhost:7878 5 | # api key can be found under Settings > General 6 | api_key = 7 | # Use https:// instead of http:// 8 | ssl = false 9 | # Force correct file path separator when running Radarr in Docker and the script on Windows 10 | docker = false 11 | 12 | [tmdb] 13 | # API key for TMDB 14 | api_key = 15 | 16 | [adding] 17 | # Reccomended defaults below are False, you'll be suprised how many movies will be added on the first run! 18 | # Add new items monitored 19 | monitored = false 20 | # Automatically run a historical / backlog search when new items added 21 | autosearch = false 22 | # TMDB ID of a Movie in your database that will be used to copy the Profile and Root Path from when adding movies from People Monitoring 23 | profile = 24 | 25 | [results] 26 | # Only check movies with files. Ignore Wanted list. 27 | ignore_wanted = false 28 | # Only check monitored movies in Radarr. 29 | ignore_unmonitored = false 30 | # Minimum column width for output files 31 | column = 60 32 | # Directory to create logs and output folder in. Default is current working directory ./ 33 | # If using Roxedus' docker container, set to path = /config 34 | path = 35 | 36 | [blacklist] 37 | # Reject movies by TMDB ratings 38 | min_rating = 0 39 | min_votes = 0 40 | # Reject movies in collections by earliest release year 41 | min_year = 0 42 | # Reject movies with a release year of 0 43 | ignore_zero = true 44 | # Comma separated list of TMDB IDs to ignore if missing from database 45 | blacklist = 46 | 47 | -------------------------------------------------------------------------------- /config/words.conf: -------------------------------------------------------------------------------- 1 | # Library for written output 2 | # 3 | # To customise your logging and results files, feel free to change any of the text 4 | # Changing any of the {#} or ${word} variables WILL cause errors. 5 | 6 | [help] 7 | text = | python rcm.py ./config [options] 8 | | 9 | | Options: 10 | | 11 | | Short Long Use 12 | | 13 | | -h --help Displays this help. 14 | | 15 | | -Conflicting- 16 | | 17 | | -f --full Repeat initial scan - recheck all movies. 18 | | -u --up Reduced update scan - only check recently added items. 19 | | -p --people People only mode - disable all Collection scanning. 20 | | -t --tmdbid Single scan mode - check single TMDB ID for Collections. 21 | | -s --start Specify start point - useful for big libraries if errors occur. (forces -f) 22 | | 23 | | -Independant- 24 | | 25 | | -q --quiet Disables verbose logging in command line. Log file still created. 26 | | -n --nolog Disables log file creation - verbose logging still visible. 27 | | -c --cache Disables automatic adding to Radarr - instead saves list of missing movies to text file. 28 | | -e --exclude Honors Radarr list exclusions - will not add any results on the Radarr exclusion list. 29 | 30 | [text] 31 | # Open 32 | first = No previous data found - This must be your first time? 33 | name = Radarr Collection and People Manager by u/RhinoRhys 34 | hello = Welcome to ${name} 35 | dent = ---> 36 | bye = Thank You for using ${name} 37 | 38 | # Errors 39 | error = Error - 40 | exit = - Exiting 41 | opts = options not compatible 42 | 43 | people_update = ${error} people.conf has been updated. 44 | config_update = ${error} rcm.conf has been updated. 45 | words_update = ${error} words.conf has been updated. Please reload. 46 | 47 | start_err = ${error} Start point {0} greater that data length {1} ${exit} 48 | 49 | template_err = ${error} Profile template for People monitoring 50 | int_err = not recognised as a number ${exit} 51 | prof_err = TMDB ID not in database ${exit} 52 | 53 | tp_err = ${error} Single scan (-t) and People only scan (-p) ${opts}. Running single scan only. 54 | tu_err = ${error} Single scan (-t) and Reduced update scan (-u) ${opts}. Running single scan only. 55 | up_err = ${error} Reduced update scan (-u) and People only scan (-p) ${opts}. Running reduced update scan only. 56 | uf_err = ${error} Full initial scan (-f) and Reduced update scan (-u) ${opts} ${exit} 57 | 58 | exiting = ${exit} at item {1} 59 | 60 | # Modes 61 | run_mov_mon = {0} Unchecked Movies 62 | run_col_mon = {1} existing Collections 63 | run_per_mon = {2} monitored People 64 | 65 | single = Scanning: 66 | peeps = People only mode: Ignoring Collections 67 | 68 | full_scan = Running full scan: 69 | ${dent} ${run_mov_mon} 70 | ${dent} ${run_per_mon} 71 | 72 | quick_scan = Running quick check for new database items: 73 | ${dent} ${run_mov_mon} 74 | 75 | update_scan = Running update scan: 76 | ${dent} ${run_mov_mon} 77 | ${dent} ${run_col_mon} 78 | ${dent} ${run_per_mon} 79 | 80 | cache = Auto adding disabled: saving results to file 81 | start = Start point specified: skipping {0} items 82 | 83 | # API 84 | api_auth = Unauthorized - Please check your {0} API key 85 | api_wait = >>> Too many requests - waiting {0} seconds <<< 86 | api_misc = >>> Unplanned error from {0} API, return code: {1} - Retrying, attempt {2} <<< 87 | 88 | add_true = >>> {0}${dent} Added sucessfully 89 | add_fail = >>> {0}${dent} Failed to add [Response Code: {1}] 90 | 91 | api_retry = {0} API Error - Retry limit reached - ${exiting} 92 | offline = ${error} {0} offline ${exiting} 93 | retry_err = ${error} Too many failed attempts adding to Radarr - Switching to caching mode 94 | 95 | # Movies 96 | radarr = Radarr ID: {0} 97 | mov_info = {1} TMDB ID: {2}{3}{4} ({5}){6} 98 | 99 | stage_info = {0}{1}{2} (ID: {3}) 100 | other = ${stage_info}: {4} Movies in collection: 101 | person = ${stage_info}: Monitoring: {4} 102 | 103 | # Collection Check 104 | col_err = {0}Error - Not Found 105 | in_col = {0}In Collection 106 | no_col = {0}None 107 | 108 | file = {0}No File 109 | unmonitored = {0}Unmonitored 110 | checked = {0}Checked 111 | 112 | # Database Check 113 | in_data = >> ${radarr}${mov_info}In Database 114 | check_data = >> {0}${mov_info} 115 | reject = > Rejected: 116 | not_data = ${check_data}Adding to Wanted 117 | ignore = ${check_data}${reject} Blacklisted 118 | exclude = ${check_data}${reject} Radarr Exclude List 119 | rated = ${check_data}${reject} Rating Too Low 120 | early = ${check_data}${reject} Before {7} 121 | ignore_zero = ${check_data}${reject} 0 in Year 122 | found = {0}{1} TMDB ID: {2}{3}{4} ({5}) 123 | 124 | # People Check 125 | cast = >> Appeared in {0} Movies: 126 | crew = >> Credited for {0} on {1} Movies: 127 | 128 | # Results 129 | found_total = Total Movies Found: {0} 130 | found_cols = From Collections: {0} 131 | found_peep = From People: {0} 132 | added_total = Successfully added {0} movies to Radarr 133 | auto_cache = Too many errors adding to Radarr, found_{0}.txt has been saved in the output folder instead 134 | found_black = Blacklist entry for all movies: 135 | 136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /rcm.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | from encodings import utf_8 5 | import requests, datetime, sys, getopt, time, atexit, configparser 6 | from pathlib import Path, PurePosixPath 7 | 8 | for var in ['quiet', 'full', 'peeps', 'nolog', 'cache', 'single', 'quick', 'printtime', 'first', "exclude"]: 9 | exec("{} = False".format(var)) 10 | 11 | check_num = 0 # 0 12 | 13 | def get_dir(input_path): 14 | if not Path(input_path).is_absolute(): return Path.cwd() / input_path 15 | else: return Path(input_path) 16 | 17 | def fatal(error): 18 | global printtime 19 | printtime = False 20 | if quiet: print(error) 21 | log(error + u"\n") 22 | sys.exit(2) 23 | 24 | def nologfatal(error): 25 | global nolog, quiet 26 | quiet = False 27 | nolog = True 28 | fatal(error) 29 | 30 | # Output files 31 | 32 | def log(text): 33 | if printtime and text != "": pay = datetime.datetime.now().strftime("[%y-%m-%d %H:%M:%S] ") + text 34 | else: pay = text 35 | if not quiet: 36 | try: print(pay) 37 | except: print(pay.encode("utf-8", errors = 'replace')) 38 | if not nolog: 39 | f = open(Path.joinpath(output_path,'logs',"log_{}.txt".format(start_time)),'a+',encoding="utf_8") 40 | try: f.write(pay + u"\n") 41 | except: pass 42 | f.close() 43 | 44 | def whitespace(tmdbId, title, year, rad_id): 45 | w_id = " "*(10 - len(str(tmdbId))) 46 | w_title = " "*(title_top - len(title)) 47 | if year == 0: w_title += " "*3 48 | w_rad = " "*(rad_top - len(str(rad_id))) 49 | return w_rad, w_id, w_title 50 | 51 | def mov_info(index): 52 | global data 53 | if index >= len(data): 54 | data = api("Radarr") 55 | w_rad, w_id, w_title = whitespace(data[index]["tmdbId"], data[index]['title'], data[index]['year'], data[index]['id']) 56 | return data[index]['id'], w_rad, data[index]["tmdbId"], w_id, data[index]['title'], data[index]['year'], w_title 57 | 58 | def datadump(): 59 | global printtime, added 60 | if len(found_col)+len(found_per) != 0 and cache: 61 | if fails == 10: 62 | printtime = False 63 | log(words[u'text'][u'auto_cache'].format(start_time) + u"\n") 64 | found_col.sort() 65 | found_per.sort() 66 | g = open(Path.joinpath(output_path,'output','found_{0}.txt'.format(start_time)),'w+',encoding="utf_8") 67 | g.write(words[u'text'][u'name'] + u"\n\n") 68 | g.write(words[u'text'][u'found_total'].format(len(found_col) + len(found_per)) + u"\n\n") 69 | if len(found_col) != 0: 70 | g.write(words[u'text'][u'found_cols'].format(len(found_col)) + u"\n\n") 71 | for item in found_col: g.write(item + '\n') 72 | g.write(u"\n") 73 | if len(found_per) != 0: 74 | g.write(words[u'text'][u'found_peep'].format(len(found_per)) + u"\n\n") 75 | for item in found_per: g.write(item + "\n") 76 | g.write(u"\n") 77 | g.write(words[u'text'][u'found_black'] + u"\n\n") 78 | g.write(u"blacklist = {}".format(str(found_black).strip("[]"))) 79 | g.close() 80 | 81 | if check_num != 0: 82 | col_ids.sort() 83 | [tmdb_ids.remove(mov_id) for mov_id in wanted] 84 | [tmdb_ids.remove(mov_id) for mov_id in list(set(unmon)-set(wanted))] 85 | g = open(Path.joinpath(config_path,u'memory.dat'),'w+',encoding="utf_8") 86 | for text in (str(tmdb_ids),str(col_ids),str(wanted),str(unmon)): g.write(text + u"\n") 87 | g.close() 88 | 89 | printtime = False 90 | log(words[u'text'][u'found_total'].format(len(found_col) + len(found_per)) + u"\n") 91 | if added > 0: log(words[u'text'][u'added_total'].format(added) + u"\n") 92 | log(u"\n" + words[u'text'][u'bye']) 93 | 94 | # API Function 95 | 96 | def api(host, com = "get", args = None ): 97 | global printtime 98 | """ 99 | radarr: get & {} | lookup & {id:} | post & {**data} 100 | tmdb: get & com & {id} 101 | """ 102 | if host == "Radarr": 103 | url = radarr_url 104 | key = {"apikey": config[u'radarr'][u'api_key']} 105 | if com == "lookup": 106 | url += "/movie/lookup/tmdb" 107 | key.update({"tmdbid" : int(args)}) 108 | elif com == "post": 109 | url += "/movie" 110 | response = requests.post(url, json = args, headers={'Content-Type': 'application/json; charset=utf-8','x-api-key' : config[u'radarr'][u'api_key']}) 111 | return response.status_code 112 | elif com == "exclude": 113 | url +="/exclusions" 114 | elif com == "get": 115 | url+="/movie" 116 | elif host == "TMDB": 117 | key = {"api_key": config[u'tmdb'][u'api_key']} 118 | if com == "mov": endpoint = "movie" 119 | elif com == "col": endpoint = "collection" 120 | elif com == "per": 121 | endpoint = "person" 122 | key.update({"append_to_response" : "movie_credits"}) 123 | url = "https://api.themoviedb.org/3/{0}/{1}".format(endpoint, str(args)) 124 | 125 | good = False 126 | tries = 1 127 | while not good: 128 | response = requests.get(url, params = key ) 129 | response.content.decode("utf-8") 130 | code = response.status_code 131 | if code == 200: # GOOD 132 | good = True 133 | return response.json() ## EXIT 134 | elif code == 404: # MINOR 135 | good = True 136 | return code ## EXIT 137 | elif code == 429: # TOO FAST 138 | wait = int(response.headers["Retry-After"]) + 1 139 | if not quiet: print(words[u'text'][u'api_wait'].format(wait)) 140 | time.sleep(wait) ## LOOP 141 | elif code == 401: fatal(words[u'text'][u'api_auth'].format(host)) 142 | elif code in (502,503): fatal(u"\n" + words[u'text'][u'offline'].format(host, check_num)) 143 | else: # UNKNOWN 144 | if tries < 6: ## RETRY 145 | print(words[u'text'][u'api_misc'].format(host, code, tries)) 146 | time.sleep(5 + tries) 147 | tries += 1 ### LOOP 148 | else: 149 | printtime = False 150 | fatal(u"\n" + words[u'text'][u'api_retry'].format(host, check_num)) ## FATAL 151 | 152 | # Movie in Database Check & POST Function 153 | 154 | def database_check(id_check, white_name, json_in, input_data): 155 | global cache, fails, printtime, added 156 | if id_check in tmdb_ids: 157 | skip.append(id_check) 158 | log(words[u'text'][u'in_data'].format(*mov_info(tmdb_ids.index(id_check)))) 159 | else: 160 | lookup_json = api("Radarr", com = "lookup", args = id_check) 161 | w_rad, w_id, w_title = whitespace(id_check, lookup_json['title'], lookup_json['year'], "") 162 | payload = " "*11, w_rad, id_check, w_id, lookup_json['title'], lookup_json['year'], w_title 163 | # check for rejections 164 | if id_check in blacklist: log(words[u'text'][u'ignore'].format(*payload)) 165 | elif excludeList and id_check in excludeList: log(words[u'text'][u'exclude'].format(*payload)) 166 | elif lookup_json[u'ratings'][u'tmdb'][u'value'] < float(config[u'blacklist'][u'min_rating']) or lookup_json['ratings'][u'tmdb'][u'votes'] < int(config[u'blacklist'][u'min_votes']): log(words[u'text'][u'rated'].format(*payload)) 167 | elif stage != 3 and lookup_json[u'year'] < int(config[u'blacklist'][u'min_year']): log(words[u'text'][u'early'].format(*payload + (config[u'blacklist'][u'min_year'],))) 168 | elif stage == 3 and lookup_json[u'year'] < int(people[person][u'min_year']): log(words[u'text'][u'early'].format(*payload + (people[person][u'min_year'],))) 169 | elif lookup_json[u'year'] == 0 and 'true' in config[u'blacklist'][u'ignore_zero'].lower(): log(words[u'text'][u'ignore_zero'].format(*payload)) 170 | else: # add movie 171 | log(words[u'text'][u'not_data'].format(*payload)) 172 | if stage == 0: 173 | try: index = tmdb_ids.index(input_data) 174 | except: index = tmdb_ids.index(int(config[u"adding"][u"profile"])) 175 | elif stage == 1: index = input_data 176 | elif stage == 2: index = tmdb_ids.index(input_data) 177 | elif stage == 3: index = tmdb_ids.index(int(config[u'adding'][u'profile'])) 178 | folder = str(lookup_json[u"title"]).replace(":","") + " (" + str(lookup_json[u"year"]) + ")" 179 | if u'true' in config[u'radarr'][u'docker']: rootpath = str(PurePosixPath(data[index]['path']).parent) 180 | else: rootpath = str(Path(data[index]['path']).parent) 181 | post_data = lookup_json 182 | post_data.update({ 183 | u"id": 0, 184 | u"monitored" : "true" in config[u'adding'][u'monitored'].lower(), 185 | u"rootFolderPath" : rootpath, 186 | u"folder": folder, 187 | u"qualityProfileId": int(data[index][u'qualityProfileId']), 188 | u"minimumAvailability" : "released", 189 | u"tags": [], 190 | u"addOptions" : {u"searchForMovie" : "true" in config[u'adding'][u'autosearch'].lower()} 191 | }) 192 | 193 | white_cid = " "*(15 - len(str(post_data["tmdbId"]))) 194 | if stage == 3: name = json_in['name'] + input_data 195 | else: name = json_in['name'] 196 | payload = words[u'text'][u'found'].format(name, white_name, post_data[u'tmdbId'], white_cid, post_data['title'], post_data['year']) 197 | if stage in [0, 1, 2]: found_col.append(payload) 198 | elif stage == 3: found_per.append(payload) 199 | found_black.append(post_data[u'tmdbId']) 200 | if not cache: 201 | post = api("Radarr", com = "post", args = post_data) 202 | white_yn = " "*(rad_top + 10) 203 | if post == 201: 204 | log(words[u'text'][u'add_true'].format(white_yn)) 205 | tmdb_ids.append(post_data['tmdbId']) 206 | added += 1 207 | else: 208 | log(words[u'text'][u'add_fail'].format(white_yn, post)) 209 | fails += 1 210 | if fails == 10: 211 | cache = True 212 | printtime = False 213 | log(u"\n" + words[u'text'][u'retry_err'] + u"\n") 214 | printtime = True 215 | 216 | # Collection Parts Check Function 217 | 218 | def collection_check(col_id, tmdbId = None): 219 | if single: log("") 220 | col_json = api("TMDB", com = "col", args = col_id) 221 | if type(col_json) != dict: 222 | col_ids.remove(col_id) 223 | return 224 | if len(col_json['name']) < int(config[u'results'][u'column']): top_c = int(config[u'results'][u'column']) 225 | else: top_c = len(col_json['name']) + 5 226 | white_name = " "*(top_c - len(col_json['name'])) 227 | parts = [col['id'] for col in col_json['parts']] 228 | number = len(parts) 229 | if stage == 1: 230 | try: parts.remove(int(tmdbId)) 231 | except: pass 232 | log("") 233 | if stage in [0, 1]: payload = ">", " "*(1 + len(str(len(data)))), col_json['name'], col_id, number 234 | elif stage == 2: payload = str(check_num + 1) + ":", white_dex, col_json['name'], col_id, number 235 | if stage == 1: input_id = check_num 236 | elif stage in [0, 2]: 237 | source = list(set(parts).intersection(tmdb_ids)) 238 | if len(source) > 0: input_id = source[0] 239 | elif not cache: input_id = int(config[u'adding'][u'profile']) 240 | else: input_id = None 241 | log(words[u'text'][u'other'].format(*payload) + u"\n") 242 | for id_check in parts: database_check(id_check, white_name, col_json, input_id) 243 | if any([full, all([not full, tmdbId not in skip])]): log("") 244 | 245 | # Movie in Collection Check Function 246 | 247 | def tmdb_check(tmdbId): 248 | mov_json = api("TMDB", com = "mov", args = tmdbId) 249 | if mov_json == 404: log(words[u'text'][u'col_err'].format(logtext)) 250 | elif type(mov_json['belongs_to_collection']) != type(None): # Collection Found 251 | col_id = mov_json['belongs_to_collection'][u'id'] 252 | if col_id not in col_ids: col_ids.append(col_id) 253 | log(words[u'text'][u'in_col'].format(logtext)) 254 | collection_check(col_id, tmdbId) 255 | else: log(words[u'text'][u'no_col'].format(logtext)) 256 | 257 | # Person Credits Check Function 258 | 259 | def person_check(person): 260 | per_id = int(people[person][u'id']) 261 | per_json = api("TMDB", com = "per", args = per_id) 262 | 263 | if len(per_json[u'name']) + 20 < int(config[u'results'][u'column']): top_p = int(config[u'results'][u'column']) 264 | else: top_p = len(per_json[u'name']) + 25 265 | search = [role.strip().title() for role in people[person][u'monitor'].split(",")] 266 | reject = [role.strip().lower() for role in people[person][u'reject'].split(",")] 267 | if u'&name' in reject: reject.append(per_json[u'name'].lower()) 268 | payload = str(per_num + 1) + ":", white_dex, per_json['name'], per_id, ", ".join(search) 269 | log(words[u'text'][u'person'].format(*payload)) 270 | scan_hold = [] 271 | if len(list(set(search).intersection(['Cast','Acting']))) != 0: 272 | cast = [] 273 | for movie in per_json[u'movie_credits']['cast']: 274 | try: role = movie[u'character'].lower() 275 | except: 276 | movie[u'character'] = u'No Data' 277 | role = movie[u'character'].lower() 278 | for string in ["/","(",")"]: role = role.replace(string,",") 279 | role = role.split(",") 280 | role = [string.strip() for string in role] 281 | if not any([len(list(set(role).intersection(reject))) != 0, 282 | all(['&blank' in reject, 283 | movie[u'character'] == ""])]): 284 | cast.append(movie) 285 | log("") 286 | log(words[u'text'][u'cast'].format(len(cast))) 287 | log("") 288 | for movie in cast: 289 | scan_hold.append(movie['id']) 290 | white_name = " "*(top_p - len(per_json['name'] + " - Cast - " + movie[u'character'])) 291 | database_check(movie['id'], white_name, per_json, " - Cast - " + movie[u'character'].title()) 292 | roles = {} 293 | for movie in per_json[u'movie_credits']['crew']: 294 | if all([movie['department'].title() in search, \ 295 | movie['id'] not in scan_hold]): 296 | if movie['department'] not in roles.keys(): 297 | roles.update({movie['department'] : []}) 298 | roles[movie['department']].append([movie['id'],movie['job'].title()]) 299 | scan_hold.append(movie['id']) 300 | for role in roles.keys(): 301 | log("") 302 | log(words[u'text'][u'crew'].format(role, len(roles[role]))) 303 | log("") 304 | for tmdb_Id, job in roles[role]: 305 | white_name = " "*(top_p - len(per_json['name'] + " - " + role + " - " + job)) 306 | database_check(tmdb_Id, white_name, per_json, " - " + role + " - " + job) 307 | 308 | #%% Config Check 309 | if len(sys.argv) != 1 and sys.argv[1][0] != "-": config_path = get_dir(sys.argv[1]) 310 | else: nologfatal(u"\n" + u"Error - path to config folder must be given in command. eg: python rcm.py ./config") 311 | if not Path.exists(Path.joinpath(config_path, "rcm.conf")): nologfatal(u"\n" + "Error - {}/rcm.conf does not exist.".format(config_path)) 312 | 313 | #%% Configuration 314 | 315 | start_time = datetime.datetime.now().strftime("%y-%m-%d_%H-%M-%S") 316 | 317 | words = configparser.ConfigParser(interpolation=configparser.ExtendedInterpolation(),allow_no_value=True) 318 | words.read(Path.joinpath(config_path,u'words.conf')) 319 | config = configparser.ConfigParser(allow_no_value=True) 320 | config.read(Path.joinpath(config_path,u'rcm.conf')) 321 | people = configparser.ConfigParser(allow_no_value=True) 322 | people.read(Path.joinpath(config_path,u'people.conf')) 323 | 324 | if config[u'results'][u'path'] == "": config[u'results'][u'path'] = u"./" 325 | output_path = get_dir(config[u'results'][u'path']) 326 | 327 | for folder in ["logs","output"]: 328 | with Path.joinpath(output_path, folder) as fold: 329 | if not Path.exists(fold): Path.mkdir(fold) 330 | 331 | if __name__ == '__main__': 332 | try: 333 | opts, args = getopt.getopt(sys.argv[2:],"hqdfas:ncpt:ue",["help","quiet","down","full","start=","nolog","cache","people","tmdbid=","up","exclude"]) 334 | except getopt.GetoptError: 335 | print(u"\n" + u'Error in options\n') 336 | print(words[u'help'][u'text']) 337 | sys.exit() 338 | for opt, arg in opts: 339 | if opt in ("-h", "--help"): 340 | print(words[u'help'][u'text']) 341 | sys.exit() 342 | elif opt in ("-q", "--quiet"): quiet = True 343 | elif opt in ("-f", "--full"): full = True 344 | elif opt in ("-p", "--people"): peeps = True 345 | elif opt in ("-s", "--start"): check_num = int(arg) 346 | elif opt in ("-n", "--nolog"): nolog = True 347 | elif opt in ("-c", "--cache"): cache = True 348 | elif opt in ("-e", "--exclude"): exclude = True 349 | elif opt in ("-u", "--up"): quick = True 350 | elif opt in ("-t", "--tmdbid"): 351 | single = True 352 | single_id = int(arg) 353 | 354 | if check_num != 0: full = True 355 | 356 | skip, old_want, old_unmon, col_ids = [],[], [],[] 357 | 358 | with Path.joinpath(config_path, u'memory.dat') as file: 359 | if Path.exists(file): 360 | memory = open(Path.joinpath(config_path, u'memory.dat'), "r") 361 | memory = memory.readlines() 362 | 363 | if not full: 364 | skip = memory[0].strip('[]\n').split(',') 365 | skip = [int(mov_id) for mov_id in skip] 366 | try: 367 | old_want = memory[2].strip('[]\n').split(',') 368 | if old_want[0] != "": old_want = [int(mov_id) for mov_id in old_want] 369 | else: old_want = [] 370 | except: pass 371 | try: 372 | old_unmon = memory[3].strip('[]\n').split(',') 373 | if old_unmon[0] != "": old_unmon = [int(mov_id) for mov_id in old_unmon] 374 | else: old_unmon = [] 375 | except: pass 376 | 377 | if full and check_num == 0: col_ids = [] 378 | else: 379 | col_ids = memory[1].strip('[]\n').split(',') 380 | if col_ids[0] != "": col_ids = [int(col_id) for col_id in col_ids] 381 | else: col_ids = [] 382 | else: 383 | check_num = 0 384 | first = True 385 | full = True 386 | 387 | 388 | #%% Data grab 389 | 390 | if u'true' in config[u'radarr'][u'ssl'].lower(): radarr_url = u"https://" 391 | else: radarr_url = u"http://" 392 | radarr_url += u"{0}/api/v3".format(config[u'radarr'][u'server']) 393 | 394 | data = api("Radarr") 395 | tmdb_ids, wanted, unmon = [],[],[] 396 | for movie in data: 397 | tmdb_ids.append(movie["tmdbId"]) 398 | if u'true' in config[u'results'][u'ignore_wanted'].lower() and not movie['hasFile']: 399 | wanted.append(movie["tmdbId"]) 400 | if u'true' in config[u'results'][u'ignore_unmonitored'].lower() and not movie['monitored']: 401 | unmon.append(movie["tmdbId"]) 402 | 403 | if full: numbers = [len(data) - check_num] 404 | else: 405 | numbers = [max(0, len(data) - len(skip + old_want) - len(set(old_unmon) - set(old_want).intersection(old_unmon)) \ 406 | + len(set(old_unmon) - set(unmon) - set(wanted)) \ 407 | + len(set(old_want) - set(wanted) - set(unmon)))] 408 | numbers += [len(col_ids), len(people.sections())] 409 | 410 | blacklist = config[u'blacklist'][u'blacklist'].split(",") 411 | if blacklist[0] != "": blacklist = [int(mov_id) for mov_id in blacklist] 412 | 413 | excludeList = api("Radarr",com="exclude") 414 | if excludeList and len(excludeList) > 0: excludeList = [exclusion["tmdbId"] for exclusion in excludeList] 415 | 416 | title_top = max([len(movie["title"]) for movie in data]) + 2 417 | rad_top = len(str(data[-1]['id'])) + 1 418 | 419 | found_col, found_per, found_black, = [],[],[] 420 | fails = 0 421 | added = 0 422 | 423 | #%% Fatal Input Errors 424 | 425 | if full and quick: nologfatal(u"\n" + words[u'text'][u'uf_err']) 426 | if check_num > len(data): nologfatal(u"\n" + words[u'text'][u'start_err'].format(check_num, len(data))) 427 | if len(people.sections()) != 0: 428 | if not cache: 429 | try: int(config[u'adding'][u'profile']) 430 | except: nologfatal("{0} {1}".format(u"\n" + words[u'text'][u'template_err'], words[u'text'][u'int_err'])) 431 | if int(config[u'adding'][u'profile']) not in tmdb_ids: nologfatal(u"\n" + "{0} {1}".format(words[u'text'][u'template_err'], words[u'text'][u'prof_err'])) 432 | 433 | if u'added_total' not in words[u'text']: nologfatal(u"\n Error - Please download latest words.conf file") 434 | 435 | #%% Begin 436 | 437 | log(words[u'text'][u'hello'] + u"\n") 438 | if first: log(words[u'text'][u'first']) 439 | if cache: log(words[u'text'][u'cache']) 440 | if single: 441 | if peeps: 442 | log(words[u'text'][u'tp_err']) 443 | peeps = False 444 | if quick: 445 | log(words[u'text'][u'tu_err']) 446 | quick = False 447 | else: # Not single 448 | if peeps: 449 | if quick: 450 | log(words[u'text'][u'up_err']) 451 | peeps = False 452 | else: log(words[u'text'][u'peeps']) 453 | else: # not single not peeps 454 | if check_num != 0: log(words[u'text'][u'start'].format(check_num)) 455 | 456 | if any([single, peeps, quick, cache, first]): log("") 457 | 458 | if not peeps and not single: 459 | if full: log(words[u'text'][u'full_scan'].format(*numbers) + u"\n") 460 | elif quick: log(words[u'text'][u'quick_scan'].format(*numbers) + u"\n") 461 | else: log(words[u'text'][u'update_scan'].format(*numbers) + u"\n") 462 | 463 | atexit.register(datadump) 464 | 465 | #%% Single Scan Mode 466 | stage = 0 467 | if single: 468 | printtime = True 469 | check_num = 1 470 | lookup_json = api("Radarr", com = "lookup", args = single_id) 471 | w_rad, w_id, w_title = whitespace(single_id, lookup_json['title'], lookup_json['year'], "") 472 | payload = "", " "*(len(str(len(data))) + 13 + len(w_rad) - len(words[u'text'][u'single'])), single_id, w_id, lookup_json['title'], lookup_json['year'], w_title 473 | logtext = words[u'text'][u'single'] + words[u'text'][u'mov_info'].format(*payload) 474 | tmdb_check(single_id) 475 | log(u"") 476 | sys.exit() 477 | 478 | #%% Database Search Loop 479 | stage = 1 480 | if not peeps: 481 | if numbers[0] > 0: 482 | log(words[u'text'][u'run_mov_mon'].format(*numbers) + u":\n") 483 | printtime= True 484 | slice_num = check_num 485 | for movie in data[slice_num:]: 486 | white_dex = " "*(len(str(len(data))) + 1 - len(str(check_num + 1))) 487 | payload = mov_info(check_num) 488 | logtext = "{0}:{1}".format(check_num + 1, white_dex) + words[u'text'][u'radarr'].format(*payload) + words[u'text'][u'mov_info'].format(*payload) 489 | 490 | if movie["tmdbId"] in unmon: 491 | if movie["tmdbId"] not in old_unmon + old_want: log(words[u'text'][u'unmonitored'].format(logtext)) 492 | elif movie["tmdbId"] in wanted: 493 | if movie["tmdbId"] not in old_unmon + old_want: log(words[u'text'][u'file'].format(logtext)) 494 | elif movie["tmdbId"] in skip: 495 | if full or movie["tmdbId"] in old_unmon + old_want: log(words[u'text'][u'checked'].format(logtext)) # if id in list 496 | else: tmdb_check(movie["tmdbId"]) 497 | check_num += 1 498 | log("") 499 | if quick: sys.exit() 500 | 501 | #%% Collection Monitor Loop 502 | stage = 2 503 | if not peeps and not full: 504 | data = api("Radarr") 505 | printtime = False 506 | log(words[u'text'][u'run_col_mon'].format(*numbers) + u":\n") 507 | printtime= True 508 | for check_num, col_id in enumerate(col_ids): 509 | white_dex = " "*(len(str(len(data))) + 1 - len(str(check_num + 1))) 510 | collection_check(col_id) 511 | 512 | #%% Person Monitor Loop 513 | stage = 3 514 | if len(people.sections()) != 0: 515 | printtime = False 516 | log(words[u'text'][u'run_per_mon'].format(*numbers) + u":\n") 517 | printtime= True 518 | for per_num, person in enumerate(people.sections()): 519 | white_dex = " "*(len(str(len(data))) + 1 - len(str(per_num + 1))) 520 | person_check(person) 521 | log("") 522 | --------------------------------------------------------------------------------