├── .gitignore ├── .gitmodules ├── .vscode └── tasks.json ├── CREDITS ├── LICENSE ├── README.md ├── __init__.py ├── action.py ├── changelog.md ├── config.py ├── container_extended_metadata.py ├── images ├── dictionary.svg ├── ePub_logo_color.svg ├── epub_extended_metadata.svg ├── metadata.svg ├── plugin.png ├── user_profile.svg └── warning.png ├── marc_relators.py ├── plugin-import-name-epub_extended_metadata.txt ├── pyproject.toml ├── reader └── __init__.py ├── readme.bbcode ├── static ├── ePub_Extended_Metadata-reader.png └── ePub_Extended_Metadata.png ├── translations ├── default.pot └── fr.po └── writer └── __init__.py /.gitignore: -------------------------------------------------------------------------------- 1 | ## gitignore 2 | ## https://git-scm.com/docs/gitignore 3 | ## 4 | 5 | __pycache__/ 6 | .ruff_cache/ 7 | --*/ 8 | zz* 9 | *.lnk 10 | *.url 11 | *.mo 12 | .vscode/settings.json 13 | MobileRead_post.bbcode 14 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "common_utils"] 2 | path = common_utils 3 | url = https://github.com/un-pogaz/common_utils.git 4 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the tasks.json format 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "label": "build", 8 | "type": "shell", 9 | "command": "common_utils/.build/build.cmd", 10 | "group": { 11 | "kind": "build", 12 | "isDefault": true 13 | } 14 | }, 15 | { 16 | "label": "update_common_utils", 17 | "type": "shell", 18 | "command": "common_utils/.build/update_common_utils.cmd", 19 | "problemMatcher": [] 20 | }, 21 | { 22 | "label": "release", 23 | "type": "shell", 24 | "command": "common_utils/.build/release.cmd", 25 | "problemMatcher": [] 26 | }, 27 | { 28 | "label": "debug", 29 | "type": "shell", 30 | "command": "common_utils/.build/debug.cmd" 31 | } 32 | ] 33 | } -------------------------------------------------------------------------------- /CREDITS: -------------------------------------------------------------------------------- 1 | marc_relators.py 2 | 3 | The MARC Code associated name and decriptions are extracted from the https://github.com/Sigil-Ebook/Sigil code source (with minor edit) 4 | Some translation of the MARC Code are also based on the translation made for Sigil https://www.transifex.com/zdpo/sigil/dashboard/ (language: FR) 5 | -------------------------------------------------------------------------------- /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 | # ePub Extended Metadata 2 | [![MobileRead][mobileread-image]][mobileread-url] 3 | [![History][changelog-image]][changelog-url] 4 | [![License][license-image]][license-url] 5 | [![calibre Version][calibre-image]][calibre-url] 6 | [![Status][status-image]][status-image] 7 | 8 | 9 | *ePub Extended Metadata* is a plugin whose objective is to allow to read and write a wider range of ePub metadata according to the ePub standard. 10 | 11 | * Read and write contributors \ in columns (type names) 12 | 13 | Once the different metadata is set, you will be able to import or embed its advanced metadata in your ePub in one click. 14 | 15 | It is also possible to activate the automatic import/reading of its metadata when adding a book to your library. 16 | Also, it is possible to activate a automatic integration of them at the same time as the default Calibre Embed action, without having to specifically activate. 17 | Of course, other metadata not set in your plugin are kept. 18 | 19 | 20 | **Note:** 21 | 22 | 1. the setting of "ePub Extended Metadata" is done by *Library*. 23 | 2. "ePub Extended Metadata" came with 2 companion plugin "ePub Extended Metadata {Reader}" and "ePub Extended Metadata {Writer}" that are auto-installed, so do not be surprised to see them appear, it means the plugin has been properly installed. 24 | 3. The plugin use custom colums "Comma separated text, like tags", with the option "Contains names" checked to make the value separated by a Ampersand & (like Authors) 25 | 26 | 27 | **Credits:** 28 | 29 | * The MARC Code associated name and decriptions are extracted from the [Sigil](https://github.com/Sigil-Ebook/Sigil) code source (with minor edit) 30 | * Some translation of the MARC Code are also based on the translation made for [Sigil](https://www.transifex.com/zdpo/sigil/dashboard/) (language: FR) 31 | 32 | Idea lauch here: https://www.mobileread.com/forums/showthread.php?t=344482 33 | 34 | 35 | **Installation** 36 | 37 | Open *Preferences -> Plugins -> Get new plugins* and install the "ePub Extended Metadata" plugin. 38 | You may also download the attached zip file and install the plugin manually, then restart calibre as described in the [Introduction to plugins thread](https://www.mobileread.com/forums/showthread.php?t=118680") 39 | 40 | The plugin works for Calibre 5 and later. 41 | 42 | Page: [GitHub](https://github.com/un-pogaz/ePub-Extended-Metadata) | [MobileRead](https://www.mobileread.com/forums/showthread.php?t=345069) 43 | 44 | Note for those who wish to provide a translation:
45 | I am *French*! Although for obvious reasons, the default language of the plugin is English, keep in mind that already a translation. 46 | 47 | 48 |

49 | 50 | ![configuration dialog](https://raw.githubusercontent.com/un-pogaz/ePub-Extended-Metadata/main/static/ePub_Extended_Metadata.png) 51 | ![configuration dialog for metadata reader](https://raw.githubusercontent.com/un-pogaz/ePub-Extended-Metadata/main/static/ePub_Extended_Metadata-reader.png) 52 | 53 | 54 | [mobileread-url]: https://www.mobileread.com/forums/showthread.php?t=345069 55 | 56 | [changelog-image]: https://img.shields.io/badge/History-CHANGELOG-blue.svg 57 | [changelog-url]: changelog.md 58 | 59 | [license-image]: https://img.shields.io/badge/License-GPL-yellow.svg 60 | [license-url]: LICENSE 61 | 62 | [calibre-image]: https://img.shields.io/badge/calibre-5.00.0_and_above-green?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAllJREFUOMt1kz1MU1EUx3/3fZSP0lJLgVqRNqCDHxApAWcXF9O4oomDcXU06iIuLgxuTi4mrm7GRI2LiYOJ4ldAiBqxqSA2lEc/oNC+d991eI8HRnuGm3tzzv2d/znnXpEb5CHQDoCi8LigruHbrXOTs6Wl6qnkcPTd7SdvTvMfM/I1LgnhHYSgePHm9APheMAbV8e+mZoaR7BCCzMyEehNJXCky0bR2tJcdx7Nc+at0POjiQYokWkJABgcTlGv72AVLXRdQ9d0XKUob4uyF6aGWgE0gO36Jq7dBEBKl6Zt4zgO5bpe8uO6P768HGupACVRrvzHWdwMWbAFwHx96uy9u+UTc68WcmcuTCqljNzMFL80gCNDMfr6O0Eh9gOWq2YZsAFWGyNXYv3h6cLnyph0mllhMBGU8HVxleKKBQIFcKiv1y8HF1gG6NGXqqF2E8cGx3bQYSwA/Mxb1CrbQWYlwDT86iAPMGDMSYDIAcHGagUF4wEgnQ4Tj5t7AFehacLvssgDpPSFMGDH+kKUlssA2aCJ9a0GXV1GADBNA0e6u7g8gC4aaWBxMjc62tbeBpC6/oikBlCtNNmsNQKAbUtPvLf+8DcZJXgfTyYIxyLeCDWyGoAmFNWaDEYgpYNhmP49TwEQ6aT25a85Kx/QHVYkoq6fE1ylgnfhCrkLYDD0YW3/fQFZ7XsVXizAs3ko1Ij0J3pIpw5yOJkk3NHRefJ1egVoABw3nu4Ack8AWWM4yk7wnWHtd2k9Wiytt/kpLGbuuPcnRl27KRsDI/Fj6jxvhcBU8EkoZv8AURDxq1Vav0YAAAAASUVORK5CYII= 63 | [calibre-url]: https://www.calibre-ebook.com/ 64 | 65 | [status-image]: https://img.shields.io/badge/Status-Stable-green 66 | 67 | [mobileread-image]: https://img.shields.io/badge/MobileRead-Plugin%20Thread-blue?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAACJUlEQVQ4EZ3SX0hTYRjH8e+79DQcm5pGba0pQizrJhiMvJDwj3dR2SIoqK68CYouy24sb/TKbsuyC4kwG3gVBpUlqP1hBaUxiMp5aLZyzdn847E6+YQHDkNv+ty88PI8Px6e91XvJ5Nm9MU44t10GjuXplFV5qZIK6SyrARRHdgWAPbvqfT1A6jo8Buz73WcfAf3VnGqMczC4jKJbz9YWDJWzwxiIvkdMf41TQHrKE5P8XxgBP3lI0RraysiFKxAlA4NIRYNz/oBK3qcG7d7EEOrxbFYjFAohOjt7UX4/X5mYk9xlBe7yJf5mZMmcrkcg4ODuN1uLNlslubmZurq6tAcJv+W2DbwjHwNHgNjfo5IJILX68Uioe3t7RjGCq7tAQrYQG19E9UVXoRMMzY2Rk1NDcFgkM7OTq4/GEE42IBrs4adrut0dHSQTCYRiXSWrW4X6oOe0i9Hn/jJU79rpxQgJmcyzBu/sJMnbDtyAAVw/Npdk/9w78IJpVgjHyo385lEIo5Ir3hY/q3wObPYoblR5UEqyko43RhWCpupqwHzz2IO8Uqr5dKdCS6ePUkkME02FsXia+lHq2pQ9iVifHpsNQsOnzlPOBymu+8hpce6FTZLH4exFLBGOUuxM768pauri1QqRaBozpy9dQiLw1mCRWGTud9i2kfVfLvZ5CxmeXoCmc66850bVesGiIVYjzk7ehMjGceucMsO3PuO4mm6orD5CzQt1i+ddfLfAAAAAElFTkSuQmCC 68 | -------------------------------------------------------------------------------- /__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | __license__ = 'GPL v3' 4 | __copyright__ = '2021, un_pogaz ' 5 | 6 | 7 | try: 8 | load_translations() 9 | except NameError: 10 | pass # load_translations() added in calibre 1.9 11 | 12 | # The class that all Interface Action plugin wrappers must inherit from 13 | from calibre.customize import InterfaceActionBase 14 | 15 | 16 | class ePubExtendedMetadata(InterfaceActionBase): 17 | ''' 18 | This class is a simple wrapper that provides information about the actual 19 | plugin class. The actual interface plugin class is called InterfacePlugin 20 | and is defined in the ui.py file, as specified in the actual_plugin field 21 | below. 22 | 23 | The reason for having two classes is that it allows the command line 24 | calibre utilities to run without needing to load the GUI libraries. 25 | ''' 26 | name = 'ePub Extended Metadata' 27 | description = _("Read and write a wider range of metadata for ePub's files " 28 | "and associating them to columns in your libraries.") 29 | supported_platforms = ['windows', 'osx', 'linux'] 30 | author = 'un_pogaz' 31 | version = (0, 11, 4) 32 | minimum_calibre_version = (5, 0, 0) 33 | 34 | name_reader = name + ' {Reader}' 35 | name_writer = name + ' {Writer}' 36 | file_types = {'epub'} 37 | description_companion = '\n' +_('This is an companion (and embeded) plugin of "{:s}".').format(name) 38 | description_reader = _('Read a wider range of metadata from the ePub file.') + description_companion 39 | description_writer = _('Write a wider range of metadata in the ePub file.') + description_companion 40 | 41 | # This field defines the GUI plugin class that contains all the code 42 | # that actually does something. Its format is module_path:class_name 43 | # The specified class must be defined in the specified module. 44 | actual_plugin = __name__+'.action:ePubExtendedMetadataAction' 45 | 46 | def initialize(self): 47 | ''' 48 | Called once when calibre plugins are initialized. Plugins are 49 | re-initialized every time a new plugin is added. Also note that if the 50 | plugin is run in a worker process, such as for adding books, then the 51 | plugin will be initialized for every new worker process. 52 | 53 | Perform any plugin specific initialization here, such as extracting 54 | resources from the plugin ZIP file. The path to the ZIP file is 55 | available as ``self.plugin_path``. 56 | 57 | Note that ``self.site_customization`` is **not** available at this point. 58 | ''' 59 | 60 | from .reader import MetadataReader 61 | from .writer import MetadataWriter 62 | 63 | self.initialize_embedded_plugin(MetadataWriter, name=self.name_reader, description=self.description_reader) 64 | self.initialize_embedded_plugin(MetadataReader, name=self.name_writer, description=self.description_writer) 65 | 66 | def initialize_embedded_plugin(self, plugin, name: str=None, description: str=None): 67 | ''' 68 | A Calibre plugin can normally only contain one Plugin class. 69 | In our case, this would be the file type class. 70 | However, we want to load the GUI plugin, too, so we have to trick 71 | Calibre into believing that there's actually a 2nd plugin. 72 | ''' 73 | 74 | from calibre.customize.ui import _initialized_plugins, initialize_plugin 75 | 76 | for p in _initialized_plugins: 77 | if isinstance(p, plugin): 78 | return p 79 | 80 | plugin.name = name or str(plugin.__name__) 81 | plugin.description = description or self.description 82 | 83 | plugin.version = self.version 84 | plugin.minimum_calibre_version = self.minimum_calibre_version 85 | plugin.supported_platforms = self.supported_platforms 86 | plugin.author = self.author 87 | 88 | plugin.file_types = getattr(self, 'file_types', None) 89 | 90 | installation_type = getattr(self, 'installation_type', None) 91 | 92 | try: 93 | if installation_type is not None: 94 | p = initialize_plugin(plugin, self.plugin_path, installation_type) 95 | else: 96 | p = initialize_plugin(plugin, self.plugin_path) 97 | _initialized_plugins.append(p) 98 | return p 99 | except Exception as err: 100 | print(f'{self.name}: Error during the initialize of the embedded plugin "{plugin.name}":\n{err}\n') 101 | return None 102 | 103 | def is_customizable(self): 104 | ''' 105 | This method must return True to enable customization via 106 | Preferences->Plugins 107 | ''' 108 | return True 109 | 110 | def config_widget(self): 111 | ''' 112 | Implement this method and :meth:`save_settings` in your plugin to 113 | use a custom configuration dialog. 114 | 115 | This method, if implemented, must return a QWidget. The widget can have 116 | an optional method validate() that takes no arguments and is called 117 | immediately after the user clicks OK. Changes are applied if and only 118 | if the method returns True. 119 | 120 | If for some reason you cannot perform the configuration at this time, 121 | return a tuple of two strings (message, details), these will be 122 | displayed as a warning dialog to the user and the process will be 123 | aborted. 124 | 125 | The base class implementation of this method raises NotImplementedError 126 | so by default no user configuration is possible. 127 | ''' 128 | # It is important to put this import statement here rather than at the 129 | # top of the module as importing the config class will also cause the 130 | # GUI libraries to be loaded, which we do not want when using calibre 131 | # from the command line 132 | if self.actual_plugin_: 133 | from .config import ConfigWidget 134 | return ConfigWidget() 135 | 136 | def save_settings(self, config_widget): 137 | ''' 138 | Save the settings specified by the user with config_widget. 139 | 140 | :param config_widget: The widget returned by :meth:`config_widget`. 141 | ''' 142 | config_widget.save_settings() 143 | 144 | 145 | # For testing, run from command line with this: 146 | # calibre-debug -e __init__.py 147 | if __name__ == '__main__': 148 | from calibre.gui2 import Application 149 | from calibre.gui2.preferences import test_widget 150 | app = Application([]) 151 | test_widget('Advanced', 'Plugins') 152 | -------------------------------------------------------------------------------- /action.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | __license__ = 'GPL v3' 4 | __copyright__ = '2021, un_pogaz ' 5 | 6 | 7 | try: 8 | load_translations() 9 | except NameError: 10 | pass # load_translations() added in calibre 1.9 11 | 12 | import os.path 13 | from typing import Any, Dict, List 14 | 15 | try: 16 | from qt.core import QMenu, QToolButton 17 | except ImportError: 18 | from PyQt5.Qt import QMenu, QToolButton 19 | 20 | from calibre.gui2 import warning_dialog 21 | from calibre.gui2.actions import InterfaceAction 22 | 23 | from .common_utils import GUI, PLUGIN_NAME, debug_print, get_icon, has_restart_pending 24 | from .common_utils.dialogs import ProgressDialog, custom_exception_dialog 25 | from .common_utils.librarys import get_BookIds_selected 26 | from .common_utils.menus import create_menu_action_unique 27 | from .config import DYNAMIC, FIELD, ICON, KEY, plugin_check_enable_library, plugin_realy_enable 28 | from .container_extended_metadata import read_extended_metadata, write_extended_metadata 29 | 30 | 31 | class VALUE: 32 | EMBED = 'embed' 33 | IMPORT = 'import' 34 | 35 | 36 | class ePubExtendedMetadataAction(InterfaceAction): 37 | 38 | name = PLUGIN_NAME 39 | # Create our top-level menu/toolbar action (text, icon_path, tooltip, keyboard shortcut) 40 | action_spec = (PLUGIN_NAME, None, _('Edit the Extended Metadata of the ePub files'), None) 41 | popup_type = QToolButton.InstantPopup 42 | action_type = 'current' 43 | dont_add_to = frozenset(['context-menu-device']) 44 | 45 | def genesis(self): 46 | self.menu = QMenu(GUI) 47 | self.qaction.setMenu(self.menu) 48 | self.qaction.setIcon(get_icon(ICON.PLUGIN)) 49 | # self.qaction.triggered.connect(self.toolbar_triggered) 50 | self.rebuild_menus() 51 | 52 | def rebuild_menus(self): 53 | self.menu.clear() 54 | 55 | create_menu_action_unique(self, self.menu, _('&Embed Extended Metadata'), None, 56 | triggered=self.embed_extended_metadata, 57 | unique_name='&Embed Extended Metadata') 58 | self.menu.addSeparator() 59 | 60 | create_menu_action_unique(self, self.menu, _('&Import Extended Metadata'), None, 61 | triggered=self.import_extended_metadata, 62 | unique_name='&Import Extended Metadata') 63 | self.menu.addSeparator() 64 | 65 | ## TODO 66 | ## 67 | ## create_menu_action_unique(self, self.menu, _('&Bulk avanced editor'), None, 68 | ## triggered=self.edit_bulk_extended_metadata, 69 | ## unique_name='&Bulk avanced editor') 70 | ## 71 | ## create_menu_action_unique(self, self.menu, _('&Avanced editor, book by book'), None, 72 | ## triggered=self.edit_book_extended_metadata, 73 | ## unique_name='&Avanced editor, book by book') 74 | ## 75 | ## self.menu.addSeparator() 76 | 77 | create_menu_action_unique(self, self.menu, _('&Customize plugin…'), 'config.png', 78 | triggered=self.show_configuration, 79 | unique_name='&Customize plugin', 80 | shortcut=False) 81 | 82 | GUI.keyboard.finalize() 83 | 84 | def show_configuration(self): 85 | if not has_restart_pending(): 86 | self.interface_action_base_plugin.do_user_config(GUI) 87 | 88 | def library_changed(self, db): 89 | plugin_check_enable_library() 90 | 91 | def gui_layout_complete(self): 92 | ''' 93 | Called once per action when the layout of the main GUI is 94 | completed. If your action needs to make changes to the layout, they 95 | should be done here, rather than in :meth:`initialization_complete`. 96 | ''' 97 | plugin_check_enable_library() 98 | 99 | def shutting_down(self): 100 | ''' 101 | Called once per plugin when the main GUI is in the process of shutting 102 | down. Release any used resources, but try not to block the shutdown for 103 | long periods of time. 104 | 105 | :return: False to halt the shutdown. You are responsible for telling 106 | the user why the shutdown was halted. 107 | 108 | ''' 109 | plugin_realy_enable(KEY.AUTO_IMPORT) 110 | plugin_realy_enable(KEY.AUTO_EMBED) 111 | return True 112 | 113 | def toolbar_triggered(self): 114 | self.embed_extended_metadata() 115 | 116 | def embed_extended_metadata(self): 117 | self.run_extended_metadata({id:VALUE.EMBED for id in get_BookIds_selected(show_error=True)}) 118 | 119 | def import_extended_metadata(self): 120 | self.run_extended_metadata({id:VALUE.IMPORT for id in get_BookIds_selected(show_error=True)}) 121 | 122 | def edit_bulk_extended_metadata(self): 123 | debug_print('edit_bulk_extended_metadata') 124 | 125 | def edit_book_extended_metadata(self): 126 | debug_print('edit_book_extended_metadata') 127 | 128 | def run_extended_metadata(self, book_ids): 129 | ePubExtendedMetadataProgressDialog(book_ids) 130 | 131 | 132 | def apply_extended_metadata(miA, prefs, extended_metadata, keep_calibre=False, check_user_metadata={}) -> List[str]: 133 | field_change = [] 134 | 135 | if check_user_metadata: 136 | # check if the Metadata object accepts those added 137 | from calibre.ebooks.metadata import string_to_authors 138 | 139 | from .common_utils.columns import get_columns_from_dict 140 | miA_columns = get_columns_from_dict(miA.get_all_user_metadata(True)) 141 | for k,cc in check_user_metadata.items(): 142 | if not (cc.is_composite or cc.is_csp): 143 | if k not in miA_columns: 144 | if cc.is_multiple: 145 | cc.metadata['#value#'] = [] 146 | else: 147 | cc.metadata['#value#'] = None 148 | cc.metadata['#extra#'] = None 149 | miA.set_user_metadata(k, cc.metadata) 150 | else: 151 | mc = miA_columns[k] 152 | if cc.is_multiple and not mc.is_multiple: 153 | values = [] 154 | if cc.is_names: 155 | values = string_to_authors(mc.metadata['#value#']) 156 | elif mc.metadata['#value#']: 157 | values = mc.metadata['#value#'].split(cc.is_multiple.ui_to_list) 158 | 159 | cc.metadata['#value#'] = values 160 | cc.metadata['#extra#'] = None 161 | miA.set_user_metadata(k, cc.metadata) 162 | 163 | if not cc.is_multiple and mc.is_multiple: 164 | join = mc.is_multiple.list_to_ui or ', ' 165 | value = join.joint(mc.metadata['#value#']) 166 | 167 | cc.metadata['#value#'] = value 168 | cc.metadata['#extra#'] = None 169 | miA.set_user_metadata(k, cc.metadata) 170 | 171 | for data, field in prefs.items(): 172 | if data == KEY.CONTRIBUTORS: 173 | for role, field in prefs[KEY.CONTRIBUTORS].items(): 174 | if field != FIELD.AUTHOR.NAME and role in extended_metadata[KEY.CONTRIBUTORS]: 175 | new_value = extended_metadata[KEY.CONTRIBUTORS][role] 176 | old_value = miA.get(field) 177 | if not (old_value and keep_calibre): 178 | miA.set(field, new_value) 179 | field_change.append(field) 180 | if data == KEY.CREATORS: 181 | debug_print('KEY.CREATORS',KEY.CREATORS) 182 | 183 | return field_change 184 | 185 | 186 | def create_extended_metadata(miA, prefs) -> Dict[str, Any]: 187 | extended_metadata = {} 188 | for data, field in prefs.items(): 189 | if data == KEY.CONTRIBUTORS: 190 | extended_metadata[KEY.CONTRIBUTORS] = {} 191 | for role, field in prefs[KEY.CONTRIBUTORS].items(): 192 | extended_metadata[KEY.CONTRIBUTORS][role] = miA.get(field, default=[]) 193 | if data == KEY.CREATORS: 194 | debug_print('KEY.CREATORS',KEY.CREATORS) 195 | 196 | return extended_metadata 197 | 198 | 199 | class ePubExtendedMetadataProgressDialog(ProgressDialog): 200 | 201 | def setup_progress(self, **kvargs): 202 | # prefs 203 | self.prefs = KEY.get_current_prefs() 204 | 205 | # Count update 206 | self.no_epub_count = 0 207 | self.import_count = 0 208 | self.import_field_count = 0 209 | self.export_count = 0 210 | 211 | # Exception 212 | self.exception = None 213 | self.exception_unhandled = False 214 | self.exception_read = [] 215 | self.exception_write = [] 216 | 217 | def end_progress(self): 218 | 219 | # info debug 220 | debug_print(f'ePub Extended Metadata launched for {self.book_count} books.') 221 | 222 | if self.wasCanceled(): 223 | debug_print('ePub Extended Metadata Metadata was aborted.') 224 | elif self.exception_unhandled: 225 | debug_print('ePub Extended Metadata Metadata was interupted. An exception has occurred:') 226 | debug_print(self.exception) 227 | custom_exception_dialog(self.exception) 228 | 229 | if self.exception_read: 230 | lst = [] 231 | for id, book_info, e in self.exception_read: 232 | lst.append(f'Book {book_info} |> '+ e.__class__.__name__ +': '+ str(e)) 233 | det_msg= '\n'.join(lst) 234 | 235 | warning_dialog(GUI, _('Exceptions during the reading of Extended Metadata'), 236 | _('{:d} exceptions have occurred during the reading of Extended Metadata.\n' 237 | 'Some books may not have been updated.').format(len(self.exception_read)), 238 | det_msg='-- ePub Extended Metadata: reading exceptions --\n\n'+det_msg, 239 | show=True, show_copy_button=True, 240 | ) 241 | 242 | if self.exception_write: 243 | lst = [] 244 | for id, book_info, e in self.exception_write: 245 | lst.append(f'Book {book_info} |> '+ e.__class__.__name__ +': '+ str(e)) 246 | det_msg= '\n'.join(lst) 247 | 248 | warning_dialog(GUI, _('Exceptions during the writing of Extended Metadata'), 249 | _('{:d} exceptions have occurred during the writing of Extended Metadata.\n' 250 | 'Some books may not have been updated.').format(len(self.exception_write)), 251 | det_msg='-- ePub Extended Metadata: writing exceptions --\n\n'+det_msg, 252 | show=True, show_copy_button=True, 253 | ) 254 | 255 | if self.no_epub_count: 256 | debug_print(f"{self.no_epub_count} books didn't have an ePub format.") 257 | 258 | if self.import_count: 259 | debug_print( 260 | f'Extended Metadata read for {self.import_count} books' 261 | f'with a total of {self.import_field_count} fields modify.' 262 | ) 263 | else: 264 | debug_print('No Extended Metadata read from selected books.') 265 | 266 | if self.export_count: 267 | debug_print(f'Extended Metadata write for {self.export_count} books.') 268 | else: 269 | debug_print('No Extended Metadata write in selected books.') 270 | debug_print(f'ePub Extended Metadata execute in {self.time_execut:0.3f} seconds.', '\n') 271 | 272 | def job_progress(self): 273 | 274 | debug_print(f'Launch ePub Extended Metadata for {self.book_count} books.') 275 | debug_print(self.prefs) 276 | print() 277 | 278 | import_id = {} 279 | import_mi = {} 280 | 281 | export_id = [] 282 | no_epub_id = [] 283 | 284 | for book_id, extended_metadata in self.book_ids.items(): 285 | # update Progress 286 | num = self.increment() 287 | 288 | if self.wasCanceled(): 289 | return 290 | 291 | ### 292 | miA = self.dbAPI.get_metadata(book_id, get_cover=False, get_user_categories=False) 293 | 294 | # book_info = "title" (author & author) [book: num/book_count]{id: book_id} 295 | book_info = '"{title}" ({authors}) [book: {num}/{book_count}]{{id: {book_id}}}'.format( 296 | title=miA.get('title'), 297 | authors=' & '.join(miA.get('authors')), 298 | num=num, 299 | book_count=self.book_count, 300 | book_id=book_id, 301 | ) 302 | 303 | fmt = 'EPUB' 304 | path = self.dbAPI.format_abspath(book_id, fmt) 305 | 306 | if path: 307 | if extended_metadata == VALUE.IMPORT: 308 | if book_id not in import_mi: 309 | debug_print('Read ePub Extended Metadata for', book_info, '\n') 310 | extended_metadata = read_extended_metadata(path) 311 | # try: 312 | import_id[book_id] = apply_extended_metadata( 313 | miA, 314 | self.prefs, 315 | extended_metadata, 316 | keep_calibre=DYNAMIC[KEY.KEEP_CALIBRE_MANUAL], 317 | ) 318 | if import_id[book_id]: 319 | import_mi[book_id] = miA 320 | # except Exception as err: 321 | # # title (author & author) 322 | # book_info = '"{title}" ({authors})'.format( 323 | # title=miA.get('title'), authors=' & '.join(miA.get('authors')), 324 | # ) 325 | # self.exception_read.append( (id, book_info, err) ) 326 | else: 327 | debug_print('Write ePub Extended Metadata for', book_info, '\n') 328 | if extended_metadata == VALUE.EMBED: 329 | extended_metadata = create_extended_metadata(miA, self.prefs) 330 | 331 | # try: 332 | write_extended_metadata(path, extended_metadata) 333 | export_id.append(book_id) 334 | new_size = os.path.getsize(path) 335 | if new_size is not None: 336 | fname = self.dbAPI.fields['formats'].format_fname(book_id, fmt.upper()) 337 | max_size = self.dbAPI.fields['formats'].table.update_fmt( 338 | book_id, 339 | fmt.upper(), 340 | fname, 341 | new_size, 342 | self.dbAPI.backend, 343 | ) 344 | self.dbAPI.fields['size'].table.update_sizes({book_id:max_size}) 345 | 346 | # except Exception as err: 347 | # # title (author & author) 348 | # book_info = '"{title}" ({authors})'.format( 349 | # title=miA.get('title'), authors=' & '.join(miA.get('authors')), 350 | # ) 351 | # self.exception_write.append( (id, book_info, err) ) 352 | 353 | for id, miA in import_mi.items(): 354 | self.dbAPI.set_metadata(id, miA) 355 | 356 | self.no_epub_count = len(no_epub_id) 357 | self.export_count = len(export_id) 358 | self.import_count = len(import_id) 359 | self.import_field_count = 0 360 | for v in import_id.values(): 361 | self.import_field_count += len(v) 362 | 363 | lst_id = list(import_id.keys()) + export_id 364 | GUI.iactions['Edit Metadata'].refresh_gui(lst_id, covers_changed=False) 365 | 366 | 367 | #### 368 | # Enter the exotic zone 369 | # those of the integrated plugins that if you don't watch out, overide those of Calibre => no basic metadata. 370 | 371 | # get_metadata(stream, type) 372 | def read_metadata(stream, fmt, miA): 373 | # --------------- 374 | # Read Extended Metadata 375 | extended_metadata = read_extended_metadata(stream) 376 | apply_extended_metadata(miA, KEY.get_current_prefs(), extended_metadata, 377 | keep_calibre=DYNAMIC[KEY.KEEP_CALIBRE_AUTO], check_user_metadata=KEY.get_current_columns()) 378 | return miA 379 | 380 | 381 | # ePubExtendedMetadata.MetadataWriter 382 | # set_metadata(stream, mi, type) 383 | def write_metadata(stream, fmt, miA): 384 | import sys 385 | import traceback 386 | 387 | from calibre.customize.builtins import ActionEmbed 388 | 389 | # --------------- 390 | # Write Extended Metadata 391 | from calibre.customize.ui import find_plugin 392 | i, book_ids, pd, only_fmts, errors = find_plugin(ActionEmbed.name).actual_plugin_.job_data 393 | 394 | def report_error(mi, fmt, tb): 395 | miA.book_id = book_ids[i] 396 | errors.append((miA, fmt, tb)) 397 | 398 | try: 399 | extended_metadata = create_extended_metadata(miA, KEY.get_current_prefs()) 400 | write_extended_metadata(stream, extended_metadata) 401 | except: 402 | if report_error is None: 403 | debug_print( 404 | 'Failed to set extended metadata for the', fmt.upper(), 405 | 'format of:', getattr(miA, 'title', ''), 406 | file=sys.stderr, 407 | ) 408 | traceback.print_exc() 409 | else: 410 | report_error(miA, fmt.upper(), traceback.format_exc()) 411 | -------------------------------------------------------------------------------- /changelog.md: -------------------------------------------------------------------------------- 1 | # Changelog - ePub Extended Metadata 2 | 3 | ## [0.11.4] - 2024/07/29 4 | 5 | ### Bug fixes 6 | - Fix error for importing Authors-like values 7 | 8 | ## [0.11.3] - 2024/07/28 9 | 10 | ### Bug fixes 11 | - Fix only one book updated when import Extended Metadata 12 | 13 | ## [0.11.2] - 2024/02/19 14 | 15 | ### Bug fixes 16 | - Fix some untranslated string 17 | 18 | ## [0.11.1] - 2024/01/27 19 | 20 | ### Bug fixes 21 | - Fix wrong text display when customizing keyboard shortcut 22 | 23 | ## [0.11.0] - 2023/11/17 24 | 25 | ### Changed 26 | - Drop Python 2 / Calibre 4 compatibility, only Calibre 5 and above 27 | 28 | ## [0.10.2] - 2023/09/25 29 | 30 | ### Bug fixes 31 | - fix a python2 imcopatibility 32 | 33 | ## [0.10.1] - 2023/09/13 34 | 35 | ### Bug fixes 36 | - Don't update the config file when Calibre start 37 | 38 | ## [0.10.0] - 2023/08/31 39 | 40 | ### Bug fixes 41 | - fix duplicate contributor for ePub 2 42 | 43 | ## [0.9.0] - 2022/10/19 44 | 45 | ### Changed 46 | - Again, big rework of common_utils (use submodule) 47 | 48 | ## [0.8.1] - 2022/10/17 49 | 50 | ### Bug fixes 51 | - Fix a error when a user categorie exist in the library 52 | 53 | ## [0.8.0] - 2022/10/11 54 | 55 | ### Changed 56 | - Big rework of common_utils.py 57 | 58 | ## [0.7.2] - 2022/09/08 59 | 60 | ### Bug fixes 61 | - Icon not display when a theme colors is used 62 | 63 | ## [0.7.1] - 2022/08/16 64 | 65 | ### Bug fixes 66 | - Use literal in ePubExtendedMetadata class 67 | 68 | ## [0.7.0] - 2022/08/16 69 | 70 | ### Changed 71 | - Back to the embeded companion plugin, more stable 72 | 73 | ## [0.6.0] - 2022/02/11 74 | 75 | ### Changed 76 | - Moving the Metadata Reader & Writer into bundled plugins automatically installed in parallel with ePub Extended Metadata 77 | 78 | ## [0.5.0] - 2022/02/01 79 | 80 | ### First release 81 | - Beta public test 82 | -------------------------------------------------------------------------------- /config.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | __license__ = 'GPL v3' 4 | __copyright__ = '2021, un_pogaz ' 5 | 6 | 7 | try: 8 | load_translations() 9 | except NameError: 10 | pass # load_translations() added in calibre 1.9 11 | 12 | import copy 13 | from collections import OrderedDict 14 | from functools import partial 15 | 16 | try: 17 | from qt.core import ( 18 | QAbstractItemView, 19 | QCheckBox, 20 | QGridLayout, 21 | QHBoxLayout, 22 | QLabel, 23 | QPushButton, 24 | QScrollArea, 25 | QSizePolicy, 26 | QSpacerItem, 27 | Qt, 28 | QTableWidget, 29 | QTabWidget, 30 | QToolButton, 31 | QVBoxLayout, 32 | QWidget, 33 | ) 34 | except ImportError: 35 | from PyQt5.Qt import ( 36 | QAbstractItemView, 37 | QCheckBox, 38 | QGridLayout, 39 | QHBoxLayout, 40 | QLabel, 41 | QPushButton, 42 | QScrollArea, 43 | QSizePolicy, 44 | QSpacerItem, 45 | Qt, 46 | QTableWidget, 47 | QTabWidget, 48 | QToolButton, 49 | QVBoxLayout, 50 | QWidget, 51 | ) 52 | 53 | from calibre.gui2 import question_dialog, warning_dialog 54 | from calibre.library.field_metadata import FieldMetadata 55 | from calibre.utils.icu import strcmp 56 | 57 | from .common_utils import GUI, PREFS_dynamic, PREFS_library, debug_print, duplicate_entry, get_icon 58 | from .common_utils.dialogs import KeyboardConfigDialogButton, LibraryPrefsViewerDialogButton 59 | from .common_utils.widgets import CustomColumnComboBox, ImageTitleLayout, KeyValueComboBox, ReadOnlyTableWidgetItem 60 | from .marc_relators import CONTRIBUTORS_DESCRIPTION, CONTRIBUTORS_ROLES 61 | 62 | 63 | class ICON: 64 | PLUGIN = 'images/plugin.png' 65 | WARNING = 'images/warning.png' 66 | 67 | 68 | class FIELD: 69 | ''' 70 | contains the information to associate the data to a field 71 | ''' 72 | class AUTHOR: 73 | ROLE = 'aut' 74 | NAME = 'authors' 75 | LOCAL = FieldMetadata()._tb_cats['authors']['name'] 76 | COLUMN = f'{NAME} ({LOCAL})' 77 | 78 | 79 | class KEY: 80 | OPTION_CHAR = '_' 81 | AUTO_IMPORT = OPTION_CHAR + 'autoImport' 82 | AUTO_EMBED = OPTION_CHAR + 'autoEmbed' 83 | FIRST_CONFIG = OPTION_CHAR + 'firstConfig' 84 | LINK_AUTHOR = OPTION_CHAR + 'linkAuthors' 85 | CREATORS_AS_AUTHOR = OPTION_CHAR + 'creatorAsAuthors' 86 | 87 | KEEP_CALIBRE_MANUAL = OPTION_CHAR + 'keepCalibre_Manual' 88 | KEEP_CALIBRE_AUTO = OPTION_CHAR + 'keepCalibre_Auto' 89 | 90 | SHARED_COLUMNS = OPTION_CHAR + 'sharedColumns' 91 | 92 | CREATORS = 'creators' 93 | CONTRIBUTORS = 'contributors' 94 | 95 | # legacy ePub2 96 | COVERAGES = 'coverages' 97 | RELATIONS = 'relations' 98 | RIGHTS = 'rights' 99 | SOURCES = 'sources' 100 | TYPES = 'types' 101 | 102 | # ePub3 103 | SERIES = 'series' 104 | COLLECTIONS = 'collections' 105 | 106 | @staticmethod 107 | def find_plugin(key): 108 | from calibre.customize.ui import find_plugin 109 | 110 | from .common_utils import PLUGIN_CLASSE 111 | return find_plugin(PLUGIN_CLASSE.name_writer if key == KEY.AUTO_EMBED else PLUGIN_CLASSE.name_reader) 112 | 113 | @staticmethod 114 | def enable_plugin(key): 115 | from calibre.customize.ui import enable_plugin 116 | p = KEY.find_plugin(key) 117 | if p: 118 | enable_plugin(p.name) 119 | 120 | @staticmethod 121 | def disable_plugin(key): 122 | from calibre.customize.ui import disable_plugin 123 | p = KEY.find_plugin(key) 124 | if p: 125 | disable_plugin(p.name) 126 | 127 | @staticmethod 128 | def get_current_columns(): 129 | from .common_utils.columns import get_columns_from_dict 130 | return get_columns_from_dict(DYNAMIC[KEY.SHARED_COLUMNS]) 131 | 132 | @staticmethod 133 | def get_current_prefs(): 134 | prefs = DYNAMIC.copy() 135 | current_columns = KEY.get_current_columns().keys() 136 | link = DYNAMIC[KEY.LINK_AUTHOR] 137 | 138 | prefs = {k:v for k, v in prefs.items() if not k.startswith(KEY.OPTION_CHAR)} 139 | 140 | if KEY.CONTRIBUTORS not in prefs or not prefs[KEY.CONTRIBUTORS]: 141 | prefs[KEY.CONTRIBUTORS] = {} 142 | 143 | for k,v in copy.copy(prefs).items(): 144 | if k == KEY.CONTRIBUTORS: 145 | for k,v in copy.copy(prefs[KEY.CONTRIBUTORS]).items(): 146 | if not k or k not in CONTRIBUTORS_ROLES or not v or v not in current_columns: 147 | prefs[KEY.CONTRIBUTORS].pop(k, None) 148 | elif not v or v not in current_columns: 149 | prefs.pop(k, None) 150 | 151 | if link: 152 | prefs[KEY.CONTRIBUTORS][FIELD.AUTHOR.ROLE] = FIELD.AUTHOR.NAME 153 | return prefs 154 | 155 | @staticmethod 156 | def get_names(): 157 | from .common_utils.columns import get_names 158 | return get_names(True) 159 | 160 | @staticmethod 161 | def get_used_columns(): 162 | from .common_utils.columns import get_columns_where 163 | treated_column = [] 164 | treated_column.extend([v for k,v in PREFS.items() if not k.startswith(KEY.OPTION_CHAR) and isinstance(v, str)]) 165 | treated_column.extend([c for c in PREFS[KEY.CONTRIBUTORS].values() if isinstance(c, str)]) 166 | 167 | def predicate(column): 168 | return column.is_custom and column.name in treated_column 169 | 170 | return {v.name:v.metadata for v in get_columns_where(predicate=predicate).values()} 171 | 172 | 173 | PREFS = PREFS_library() 174 | PREFS.defaults[KEY.AUTO_IMPORT] = False 175 | PREFS.defaults[KEY.AUTO_EMBED] = False 176 | PREFS.defaults[KEY.LINK_AUTHOR] = False 177 | PREFS.defaults[KEY.CREATORS_AS_AUTHOR] = False 178 | PREFS.defaults[KEY.CONTRIBUTORS] = {} 179 | PREFS.defaults[KEY.FIRST_CONFIG] = True 180 | PREFS.defaults[KEY.KEEP_CALIBRE_MANUAL] = False 181 | PREFS.defaults[KEY.KEEP_CALIBRE_AUTO] = True 182 | 183 | DYNAMIC = PREFS_dynamic() 184 | DYNAMIC.defaults = copy.deepcopy(PREFS.defaults) 185 | DYNAMIC.defaults[KEY.SHARED_COLUMNS] = {} 186 | 187 | 188 | def plugin_check_enable_library(): 189 | if PREFS[KEY.AUTO_IMPORT]: 190 | KEY.enable_plugin(KEY.AUTO_IMPORT) 191 | else: 192 | KEY.disable_plugin(KEY.AUTO_IMPORT) 193 | 194 | if PREFS[KEY.AUTO_EMBED]: 195 | KEY.enable_plugin(KEY.AUTO_EMBED) 196 | else: 197 | KEY.disable_plugin(KEY.AUTO_EMBED) 198 | 199 | with DYNAMIC: 200 | DYNAMIC.update(PREFS.copy()) 201 | DYNAMIC[KEY.SHARED_COLUMNS] = KEY.get_used_columns() 202 | 203 | 204 | def plugin_realy_enable(key): 205 | from calibre.customize.ui import is_disabled 206 | p = KEY.find_plugin(key) 207 | if p: 208 | enable = not is_disabled(p) 209 | if PREFS[key] != enable: 210 | PREFS[key] = enable 211 | return enable 212 | else: 213 | return False 214 | 215 | 216 | class ConfigWidget(QWidget): 217 | def __init__(self): 218 | QWidget.__init__(self) 219 | 220 | layout = QVBoxLayout(self) 221 | self.setLayout(layout) 222 | 223 | title_layout = ImageTitleLayout(ICON.PLUGIN, _('ePub Extended Metadata options')) 224 | layout.addLayout(title_layout) 225 | 226 | tabs = QTabWidget(self) 227 | layout.addWidget(tabs) 228 | 229 | # Add a horizontal layout containing the table and the buttons next to it 230 | contributor_layout = QVBoxLayout() 231 | tab_contributor = QWidget() 232 | tab_contributor.setLayout(contributor_layout) 233 | 234 | contributor_table_layout = QHBoxLayout() 235 | contributor_layout.addLayout(contributor_table_layout) 236 | tabs.addTab(tab_contributor, _('Contributor')) 237 | 238 | # Create a table the user can edit the menu list 239 | self.table = ContributorTableWidget(PREFS[KEY.CONTRIBUTORS], self) 240 | contributor_table_layout.addWidget(self.table) 241 | 242 | # Add a vertical layout containing the the buttons to move ad/del etc. 243 | button_layout = QVBoxLayout() 244 | contributor_table_layout.addLayout(button_layout) 245 | add_button = QToolButton(self) 246 | add_button.setToolTip(_('Add a Column/Contributor pair')) 247 | add_button.setIcon(get_icon('plus.png')) 248 | 249 | button_layout.addWidget(add_button) 250 | button_layout.addItem(QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)) 251 | 252 | delete_button = QToolButton(self) 253 | delete_button.setToolTip(_('Delete Column/Contributor pair')) 254 | delete_button.setIcon(get_icon('minus.png')) 255 | button_layout.addWidget(delete_button) 256 | 257 | add_button.clicked.connect(self.table.add_row) 258 | delete_button.clicked.connect(self.table.delete_rows) 259 | 260 | contributor_option = QHBoxLayout() 261 | contributor_layout.addLayout(contributor_option) 262 | 263 | self.linkAuthors = QCheckBox(_('Embed "{:s}" column').format(FIELD.AUTHOR.COLUMN), self) 264 | self.linkAuthors.setToolTip( 265 | _('Embed the "{:s}" column as a Contributors metadata. ' 266 | 'This a write-only option, the import action will not change the Calibre {:s} column.').format( 267 | FIELD.AUTHOR.COLUMN, FIELD.AUTHOR.LOCAL, 268 | ) 269 | ) 270 | self.linkAuthors.setChecked(PREFS[KEY.LINK_AUTHOR]) 271 | contributor_option.addWidget(self.linkAuthors) 272 | 273 | # self.creatorsAsAuthors = QCheckBox(_('Import all Creators as authors'), self) 274 | # self.creatorsAsAuthors.setToolTip( 275 | # _('Import all Creators as {:s} in "{:s}" column.').format( 276 | # FIELD.AUTHOR.LOCAL, FIELD.AUTHOR.COLUMN 277 | # ) 278 | # ) 279 | # self.creatorsAsAuthors.setChecked(PREFS[KEY.CREATORS_AS_AUTHOR]) 280 | # contributor_option.addWidget(self.creatorsAsAuthors) 281 | 282 | contributor_option.addStretch(-1) 283 | 284 | # ePub 3 tab 285 | 286 | scroll_layout = QVBoxLayout() 287 | tab_epub3 = QWidget() 288 | tab_epub3.setLayout(scroll_layout) 289 | scrollable = QScrollArea() 290 | scrollable.setWidget(tab_epub3) 291 | scrollable.setWidgetResizable(True) 292 | tabs.addTab(scrollable, _('ePub3 metadata')) 293 | 294 | epub3_layout = QGridLayout() 295 | scroll_layout.addLayout(epub3_layout) 296 | epub3_layout.addWidget(QLabel('Work in progres', self), 0, 0, 1, 1) 297 | 298 | scroll_layout.addStretch(-1) 299 | 300 | # Global options 301 | option_layout = QHBoxLayout() 302 | layout.addLayout(option_layout) 303 | 304 | option_layout.insertStretch(-1) 305 | 306 | self.reader_button = QPushButton(_('Automatic import')) 307 | self.reader_button.setToolTip( 308 | _('Allows to automatically import the extended metadata when adding a new book to the library') 309 | ) 310 | button_plugin_initialized(self.reader_button, KEY.AUTO_IMPORT) 311 | option_layout.addWidget(self.reader_button) 312 | self.writer_button = QPushButton(_('Automatic embed')) 313 | self.writer_button.setToolTip( 314 | _('Allows to to automatically embed the extended metadata at the same time as the default Calibre action') 315 | ) 316 | button_plugin_initialized(self.writer_button, KEY.AUTO_EMBED) 317 | option_layout.addWidget(self.writer_button) 318 | 319 | # --- Keyboard shortcuts --- 320 | keyboard_layout = QHBoxLayout() 321 | layout.addLayout(keyboard_layout) 322 | keyboard_layout.addWidget(KeyboardConfigDialogButton(parent=self)) 323 | 324 | view_prefs_button = LibraryPrefsViewerDialogButton() 325 | view_prefs_button.library_prefs_changed.connect(self.library_prefs_changed) 326 | keyboard_layout.addWidget(view_prefs_button) 327 | 328 | keyboard_layout.insertStretch(-1) 329 | 330 | import_option = QPushButton(_('Edit import options')) 331 | if self.reader_button.isEnabled(): 332 | p = KEY.find_plugin(KEY.AUTO_IMPORT) 333 | import_option.clicked.connect(partial(p.do_user_config, self)) 334 | else: 335 | import_option.setEnabled(False) 336 | keyboard_layout.addWidget(import_option) 337 | 338 | def validate(self): 339 | valide = self.table.valide_contributors_columns() 340 | if not valide: 341 | warning_dialog(GUI, 342 | _('Duplicate values'), 343 | _("The current parameters contain duplicate values.\nYour changes can't be saved and have been cancelled."), 344 | show=True, show_copy_button=False, 345 | ) 346 | 347 | return valide 348 | 349 | def save_settings(self): 350 | with PREFS: 351 | PREFS[KEY.CONTRIBUTORS] = self.table.get_contributors_columns() 352 | PREFS[KEY.LINK_AUTHOR] = self.linkAuthors.checkState() == Qt.Checked 353 | # PREFS[KEY.CREATORS_AS_AUTHOR] = self.creatorsAsAuthors.checkState() == Qt.Checked 354 | PREFS[KEY.AUTO_IMPORT] = self.reader_button.pluginEnable 355 | PREFS[KEY.AUTO_EMBED] = self.writer_button.pluginEnable 356 | PREFS[KEY.FIRST_CONFIG] = False 357 | 358 | if PREFS[KEY.LINK_AUTHOR]: 359 | poped = PREFS[KEY.CONTRIBUTORS].pop(FIELD.AUTHOR.ROLE, None) 360 | if poped: 361 | PREFS[str(len(PREFS[KEY.CONTRIBUTORS])+1)] = poped 362 | 363 | debug_print('Save settings:', PREFS,'\n') 364 | plugin_check_enable_library() 365 | 366 | def library_prefs_changed(self): 367 | self.table.populate_table(PREFS[KEY.CONTRIBUTORS]) 368 | self.linkAuthors.setChecked(PREFS[KEY.LINK_AUTHOR]) 369 | plugin_check_enable_library() 370 | self.reader_button.pluginEnable = PREFS[KEY.AUTO_IMPORT] 371 | self.writer_button.pluginEnable = PREFS[KEY.AUTO_EMBED] 372 | button_plugin_icon(self.reader_button) 373 | button_plugin_icon(self.writer_button) 374 | 375 | 376 | def button_plugin_initialized(button, key): 377 | button.pluginEnable = plugin_realy_enable(key) 378 | if KEY.find_plugin(key): 379 | button.clicked.connect(partial(button_plugin_clicked, button, key)) 380 | button_plugin_icon(button) 381 | else: 382 | button.setIcon(get_icon(ICON.WARNING)) 383 | button.setEnabled(False) 384 | button.setToolTip(_('This feature has been incorrectly initialized. Restart Calibre to fix this.')) 385 | 386 | 387 | def button_plugin_clicked(button, key): 388 | button.pluginEnable = not button.pluginEnable 389 | button_plugin_icon(button) 390 | 391 | 392 | def button_plugin_icon(button): 393 | if button.pluginEnable: 394 | button.setIcon(get_icon('dot_green.png')) 395 | else: 396 | button.setIcon(get_icon('dot_red.png')) 397 | 398 | 399 | COL_COLUMNS = [_('Contributor type'), _('Column'), ''] 400 | 401 | 402 | class ContributorTableWidget(QTableWidget): 403 | _columnContrib = 0 404 | _columnColumn = 1 405 | _columnSpace = 2 406 | 407 | def __init__(self, contributors_pair_list=None, *args): 408 | QTableWidget.__init__(self, *args) 409 | self.setAlternatingRowColors(True) 410 | self.setSelectionBehavior(QAbstractItemView.SelectRows) 411 | self.setSortingEnabled(False) 412 | self.setMinimumSize(600, 0) 413 | self.populate_table(contributors_pair_list) 414 | 415 | def populate_table(self, contributors_pair_list=None): 416 | self.clear() 417 | self.setColumnCount(len(COL_COLUMNS)) 418 | self.setHorizontalHeaderLabels(COL_COLUMNS) 419 | self.verticalHeader().setDefaultSectionSize(24) 420 | 421 | contributors_pair_list = contributors_pair_list or {} 422 | 423 | if PREFS[KEY.FIRST_CONFIG] and not contributors_pair_list: 424 | columns = KEY.get_names() 425 | for role in CONTRIBUTORS_ROLES: 426 | for column in columns: 427 | if strcmp('#'+role, column) == 0: 428 | contributors_pair_list[role] = column 429 | 430 | self.setRowCount(len(contributors_pair_list)) 431 | for row, contributors_pair in enumerate(contributors_pair_list.items(), 0): 432 | self.populate_table_row(row, contributors_pair) 433 | 434 | self.selectRow(0) 435 | 436 | def populate_table_row(self, row, contributors_pair): 437 | self.blockSignals(True) 438 | 439 | contributors_pair = contributors_pair or ('','') 440 | self.setCellWidget(row, self._columnContrib, ContributorsComboBox(contributors_pair[0], self)) 441 | self.setCellWidget(row, self._columnColumn, DuplicColumnComboBox(contributors_pair[1], self)) 442 | self.setItem(row, self._columnSpace, ReadOnlyTableWidgetItem('')) 443 | 444 | self.resizeColumnsToContents() 445 | self.blockSignals(False) 446 | 447 | def add_row(self): 448 | self.setFocus() 449 | # We will insert a blank row below the currently selected row 450 | row = self.currentRow() + 1 451 | self.insertRow(row) 452 | self.populate_table_row(row, None) 453 | self.select_and_scroll_to_row(row) 454 | 455 | def delete_rows(self): 456 | self.setFocus() 457 | rows = self.selectionModel().selectedRows() 458 | if len(rows) == 0: 459 | return 460 | message = _('Are you sure you want to delete this Column/Contributor pair?') 461 | if len(rows) > 1: 462 | message = _('Are you sure you want to delete the selected {:d} Column/Contributor pairs?').format(len(rows)) 463 | if not question_dialog(self, _('Are you sure?'), message, show_copy_button=False): 464 | return 465 | first_sel_row = self.currentRow() 466 | for selrow in reversed(rows): 467 | self.removeRow(selrow.row()) 468 | if first_sel_row < self.rowCount(): 469 | self.select_and_scroll_to_row(first_sel_row) 470 | elif self.rowCount() > 0: 471 | self.select_and_scroll_to_row(first_sel_row - 1) 472 | 473 | def select_and_scroll_to_row(self, row): 474 | self.selectRow(row) 475 | self.scrollToItem(self.currentItem()) 476 | 477 | def _duplicate_entrys(self, column): 478 | de = duplicate_entry([self.cellWidget(row, column).currentText() for row in range(self.rowCount())]) 479 | if '' in de: 480 | de.remove('') 481 | return de 482 | 483 | def valide_contributors_columns(self): 484 | aa = self._duplicate_entrys(self._columnContrib) 485 | cc = self._duplicate_entrys(self._columnColumn) 486 | return not (aa or cc) 487 | 488 | def get_contributors_columns(self): 489 | contributors_columns = {} 490 | for row in range(self.rowCount()): 491 | k = self.cellWidget(row, self._columnContrib).selected_key() 492 | v = self.cellWidget(row, self._columnColumn).selected_name() 493 | 494 | if k or v: 495 | contributors_columns[k if k else str(row)] = v if v else '' 496 | 497 | return contributors_columns 498 | 499 | 500 | class ContributorsComboBox(KeyValueComboBox): 501 | def __init__(self, selected_contributors, table): 502 | KeyValueComboBox.__init__(self, 503 | CONTRIBUTORS_ROLES, 504 | selected_contributors, 505 | CONTRIBUTORS_DESCRIPTION, 506 | parent=table, 507 | ) 508 | self.table = table 509 | self.currentIndexChanged.connect(self.test_contributors_changed) 510 | 511 | def wheelEvent(self, event): 512 | # Disable the mouse wheel on top of the combo box changing selection as plays havoc in a grid 513 | event.ignore() 514 | 515 | def test_contributors_changed(self, val): 516 | de = self.table._duplicate_entrys(self.table._columnContrib) 517 | if de and de.count(self.currentText()): 518 | warning_dialog(self, _('Duplicate Contributors type'), 519 | _('A Contributor was duplicated!\n' 520 | 'Change the settings so that each contributor is present only once, ' 521 | 'otherwise the settings can not be saved.\n\nDuplicate type:') 522 | + '\n' + '\n'.join(de), 523 | show=True, show_copy_button=False) 524 | 525 | 526 | class DuplicColumnComboBox(CustomColumnComboBox): 527 | 528 | def __init__(self, selected_column, table): 529 | CustomColumnComboBox.__init__(self, KEY.get_names(), selected_column, parent=table) 530 | self.table = table 531 | self.currentIndexChanged.connect(self.test_column_changed) 532 | 533 | def wheelEvent(self, event): 534 | # Disable the mouse wheel on top of the combo box changing selection as plays havoc in a grid 535 | event.ignore() 536 | 537 | def test_column_changed(self, val): 538 | de = self.table._duplicate_entrys(self.table._columnColumn) 539 | if de and de.count(self.currentText()): 540 | warning_dialog(self, _('Duplicate Custom column'), 541 | _('A Custom column was duplicated!\n' 542 | 'Change the settings so that each Custom column is present only once, ' 543 | 'otherwise the settings can not be saved.\n\nDuplicate column:') 544 | + '\n' + '\n'.join(de), 545 | show=True, show_copy_button=False) 546 | 547 | 548 | OPTION_MANUAL = OrderedDict([ 549 | (True, _('Keep Calibre metadata, fill only the empty fields')), 550 | (False, _('Overwrites Calibre metadata, considers that the book always reason')) 551 | ]) 552 | 553 | OPTION_AUTO = OrderedDict([ 554 | (True, _('Keep Calibre embed metadata that could exist in the book')), 555 | (False, _('Overwrites Calibre embed metadata, give priority to original metadata')) 556 | ]) 557 | 558 | 559 | class ConfigReaderWidget(QWidget): 560 | def __init__(self): 561 | QWidget.__init__(self) 562 | 563 | layout = QVBoxLayout(self) 564 | self.setLayout(layout) 565 | 566 | title_layout = ImageTitleLayout(ICON.PLUGIN, _('ePub Extended Metadata import options')) 567 | layout.addLayout(title_layout) 568 | head = QLabel(_('Set here the specifics options to read and automatic addition of metadata.')) 569 | head.setWordWrap(True) 570 | layout.addWidget(head) 571 | 572 | conflict = QLabel(_('Choose the behavior to adopt in case of conflict between the metadata read ' 573 | 'by ePub Extended Metadata and the one already recorded by Calibre.') 574 | ) 575 | conflict.setWordWrap(True) 576 | layout.addWidget(conflict) 577 | 578 | layout.addWidget(QLabel('')) 579 | 580 | importManual_Label = QLabel(_('When importing manually:')) 581 | importManual_ToolTip = _('The manual import is executed by clicking on "Import Extended Metadata" ' 582 | "in the menu of 'ePub Extended Metadata'") 583 | importManual_Label.setToolTip(importManual_ToolTip) 584 | layout.addWidget(importManual_Label) 585 | self.importManual = KeyValueComboBox(OPTION_MANUAL, PREFS[KEY.KEEP_CALIBRE_MANUAL], parent=self) 586 | self.importManual.setToolTip(importManual_ToolTip) 587 | layout.addWidget(self.importManual) 588 | 589 | importAuto_Label = QLabel(_('During automatic import:')) 590 | importAuto_ToolTip = _('The auto import is executed when Calibre add a book to the library') 591 | importAuto_Label.setToolTip(importAuto_ToolTip) 592 | layout.addWidget(importAuto_Label) 593 | self.importAuto = KeyValueComboBox(OPTION_AUTO, PREFS[KEY.KEEP_CALIBRE_AUTO], parent=self) 594 | self.importAuto.setToolTip(importAuto_ToolTip) 595 | layout.addWidget(self.importAuto) 596 | 597 | layout.insertStretch(-1) 598 | 599 | def save_settings(self): 600 | prefs = {} 601 | prefs[KEY.KEEP_CALIBRE_AUTO] = self.importAuto.selected_key() 602 | prefs[KEY.KEEP_CALIBRE_MANUAL] = self.importManual.selected_key() 603 | 604 | PREFS.update(prefs) 605 | debug_print('Save settings of import:', prefs,'\n') 606 | plugin_check_enable_library() 607 | -------------------------------------------------------------------------------- /container_extended_metadata.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | __license__ = 'GPL v3' 4 | __copyright__ = '2021, un_pogaz ' 5 | 6 | 7 | try: 8 | load_translations() 9 | except NameError: 10 | pass # load_translations() added in calibre 1.9 11 | 12 | import os 13 | 14 | from lxml import etree 15 | 16 | from calibre.ebooks.metadata import author_to_author_sort, string_to_authors 17 | from calibre.ebooks.metadata.epub import EPubException, get_zip_reader 18 | from calibre.ebooks.metadata.opf2 import OPF 19 | from calibre.ebooks.metadata.utils import pretty_print_opf 20 | from calibre.utils.zipfile import ZIP_DEFLATED, ZipFile, safe_replace 21 | 22 | from .common_utils import debug_print 23 | from .config import KEY 24 | 25 | NS_OCF = 'urn:oasis:names:tc:opendocument:xmlns:container' 26 | NS_OPF = 'http://www.idpf.org/2007/opf' 27 | NS_DC = 'http://purl.org/dc/elements/1.1/' 28 | NS_NCX = 'http://www.daisy.org/z3986/2005/ncx/' 29 | 30 | NAMESPACES={'opf':NS_OPF, 'dc':NS_DC, 'ocf':NS_OCF, 'ncx':NS_NCX} 31 | 32 | 33 | class ParseError(ValueError): 34 | def __init__(self, name, err): 35 | self.name = name 36 | self.err = err 37 | ValueError.__init__(self, f'Failed to parse: {name} with error: {err}') 38 | 39 | 40 | class OPFException(EPubException): 41 | pass 42 | 43 | 44 | class OPFParseError(OPFException, ParseError): 45 | def __init__(self, name, err): 46 | ValueError.__init__(self, name, err) 47 | 48 | 49 | class ContainerExtendedMetadata: 50 | ''' 51 | epub can be a file path or a stream 52 | ''' 53 | def __init__(self, epub, read_only=False): 54 | # Load ZIP 55 | self.ZIP = None 56 | self.reader = None 57 | self._opf = None 58 | 59 | self.ZIP = ZipFile(epub, mode='r' if read_only else 'a', compression=ZIP_DEFLATED) 60 | self.reader = get_zip_reader(self.ZIP.fp, root=os.getcwd()) 61 | self._opf = self.reader.opf 62 | 63 | import math 64 | d, i = math.modf(self.opf.package_version) 65 | self._version = (int(i), int(d)) 66 | 67 | self._metadata = self.opf.metadata 68 | 69 | @property 70 | def opf(self): 71 | return self._opf 72 | 73 | @property 74 | def metadata(self): 75 | return self._metadata 76 | 77 | @property 78 | def version(self): 79 | return self._version 80 | 81 | def __enter__(self): 82 | return self 83 | 84 | def save_opf(self): 85 | pretty_print_opf(self.opf.root) 86 | xml_opf = etree.tostring(self.opf.root, encoding='UTF-8', pretty_print=True) 87 | 88 | if self.reader: 89 | if isinstance(xml_opf, bytes): 90 | safe_replace(self.ZIP.fp, self.reader.container[OPF.MIMETYPE], xml_opf) 91 | else: 92 | safe_replace(self.ZIP.fp, self.reader.container[OPF.MIMETYPE], xml_opf.encode('utf-8')) 93 | 94 | def __exit__(self, type, value, traceback): 95 | self.close() 96 | 97 | def __del__(self): 98 | self.close() 99 | 100 | def close(self): 101 | self.ZIP.close() 102 | 103 | 104 | def read_extended_metadata(epub): 105 | ''' 106 | epub/opf can be a file path or a stream 107 | ''' 108 | extended_metadata = {} 109 | 110 | # Use a "stream" to read the OPF without any extracting 111 | with ContainerExtendedMetadata(epub, read_only=True) as container: 112 | extended_metadata = _read_extended_metadata(container) 113 | 114 | return extended_metadata 115 | 116 | 117 | def write_extended_metadata(epub, extended_metadata): 118 | ''' 119 | epub/opf can be a file path or a stream 120 | ''' 121 | debug_print('write_extended_metadata()') 122 | debug_print('extended_metadata:', extended_metadata) 123 | 124 | # Use a "stream" to read the OPF without any extracting 125 | with ContainerExtendedMetadata(epub, read_only=False) as container: 126 | _write_extended_metadata(container, extended_metadata) 127 | container.save_opf() 128 | 129 | 130 | def _read_extended_metadata(container): 131 | extended_metadata = {} 132 | extended_metadata[KEY.CREATORS] = creators = [] 133 | extended_metadata[KEY.CONTRIBUTORS] = contributors = {} 134 | 135 | extended_metadata[KEY.SERIES] = {} 136 | 137 | extended_metadata[KEY.SERIES] = {} 138 | 139 | extended_metadata[KEY.COLLECTIONS] = {} 140 | if not container.opf: 141 | return extended_metadata 142 | 143 | if container.version[0] == 2: 144 | for child in container.metadata.xpath('dc:creator', namespaces=NAMESPACES): 145 | tbl = child.xpath('@opf:role', namespaces=NAMESPACES) 146 | role = tbl[0] if tbl else 'aut' 147 | 148 | authors = string_to_authors(child.text) 149 | 150 | if len(authors) == 1: 151 | tbl = child.xpath('@opf:file-as', namespaces=NAMESPACES) 152 | author_sort = tbl[0] if tbl else author_to_author_sort(authors[0]) 153 | creators.append((authors[0], role, author_sort)) 154 | else: 155 | for author in authors: 156 | creators.append((author, role, author_to_author_sort(author))) 157 | 158 | for child in container.metadata.xpath('dc:contributor', namespaces=NAMESPACES): 159 | tbl = child.xpath('@opf:role', namespaces=NAMESPACES) 160 | role = tbl[0] if tbl else 'oth' 161 | if role not in contributors: 162 | contributors[role] = [] 163 | for author in string_to_authors(child.text): 164 | contributors[role].append(author) 165 | 166 | if container.version[0] == 3: 167 | for contrib in container.metadata.xpath('dc:contributor[@id]', namespaces=NAMESPACES): 168 | id = contrib.attrib['id'] 169 | xpath = f'opf:meta[@refines="#{id}" and @property="role" and @scheme="marc:relators"]' 170 | roles = container.metadata.xpath(xpath, namespaces=NAMESPACES) 171 | 172 | role = 'oth' 173 | if roles: 174 | role = roles[-1].text 175 | 176 | if role not in contributors: 177 | contributors[role] = [] 178 | 179 | for author in string_to_authors(contrib.text): 180 | contributors[role].append(author) 181 | 182 | role = 'oth' 183 | for contrib in container.metadata.xpath('dc:contributor[not(@id)]', namespaces=NAMESPACES): 184 | if role not in contributors: 185 | contributors[role] = [] 186 | 187 | for author in string_to_authors(contrib.text): 188 | contributors[role].append(author) 189 | 190 | # extended_metadata 191 | 192 | debug_print('extended_metadata:', extended_metadata) 193 | 194 | return extended_metadata 195 | 196 | 197 | def _write_extended_metadata(container, extended_metadata): 198 | if not container.opf: 199 | return False 200 | 201 | # merge old extended metadata and the new 202 | epub_extended_metadata = _read_extended_metadata(container) 203 | 204 | for data, value in extended_metadata.items(): 205 | if data == KEY.CONTRIBUTORS: 206 | for role, value in extended_metadata[KEY.CONTRIBUTORS].items(): 207 | epub_extended_metadata[KEY.CONTRIBUTORS][role] = value 208 | else: 209 | epub_extended_metadata[data] = value 210 | 211 | if container.version[0] == 2: 212 | creator = container.metadata.xpath('dc:creator', namespaces=NAMESPACES) 213 | idx = container.metadata.index(creator[-1])+1 214 | 215 | for role in sorted(epub_extended_metadata[KEY.CONTRIBUTORS].keys()): 216 | for meta in container.metadata.xpath(f'dc:contributor[@opf:role="{role}"]', namespaces=NAMESPACES): 217 | container.metadata.remove(meta) 218 | for contrib in epub_extended_metadata[KEY.CONTRIBUTORS][role]: 219 | element = etree.Element(etree.QName(NS_DC, 'contributor')) 220 | element.text = contrib 221 | element.attrib[etree.QName(NS_OPF, 'role')] = role 222 | element.attrib[etree.QName(NS_OPF, 'file-as')] = author_to_author_sort(contrib) 223 | container.metadata.insert(idx, element) 224 | idx = idx+1 225 | 226 | if container.version[0] == 3: 227 | creator = container.metadata.xpath('dc:creator', namespaces=NAMESPACES) 228 | idx = container.metadata.index(creator[-1])+1 229 | 230 | for contrib in container.metadata.xpath('dc:contributor', namespaces=NAMESPACES): 231 | id_s = contrib.attrib.get('id', None) 232 | if id_s: 233 | # remove all marc code 234 | xpath = f'opf:meta[@refines="#{id_s}" and @property="role" and @scheme="marc:relators"]' 235 | for meta in container.metadata.xpath(xpath, namespaces=NAMESPACES): 236 | container.metadata.remove(meta) 237 | # if the contributor has others meta linked (except "file-as") 238 | xpath = f'opf:meta[@refines="#{id_s}" and not(@property="file-as")]' 239 | if not container.metadata.xpath(xpath, namespaces=NAMESPACES): 240 | # coutain if the contributor has no others meta linked (or only "file-as"), del the contributor 241 | container.metadata.remove(contrib) 242 | # and del the "file-as" 243 | for meta in container.metadata.xpath(f'opf:meta[@refines="#{id_s}"]', namespaces=NAMESPACES): 244 | container.metadata.remove(meta) 245 | else: 246 | # remove contributor without id 247 | container.metadata.remove(contrib) 248 | 249 | role_id = {} 250 | 251 | for role in sorted(epub_extended_metadata[KEY.CONTRIBUTORS].keys()): 252 | id_n = (len(role_id[role]) if role in role_id else 0) + 1 253 | 254 | for contrib in epub_extended_metadata[KEY.CONTRIBUTORS][role]: 255 | element = etree.Element(etree.QName(NS_DC, 'contributor')) 256 | element.text = contrib 257 | id_s = role+f'{id_n:02d}' 258 | element.attrib['id'] = id_s 259 | container.metadata.insert(idx, element) 260 | idx = idx+1 261 | 262 | if role not in role_id: 263 | role_id[role] = [] 264 | role_id[role].append(id_s) 265 | 266 | file = etree.Element('meta') 267 | file.text = author_to_author_sort(contrib) 268 | file.attrib['refines'] = '#'+id_s 269 | file.attrib['property'] = 'file-as' 270 | container.metadata.insert(idx, file) 271 | idx = idx+1 272 | 273 | id_n = id_n+1 274 | 275 | for role in sorted(role_id.keys()): 276 | for id_s in role_id[role]: 277 | meta = etree.Element('meta') 278 | meta.text = role 279 | meta.attrib['refines'] = '#'+id_s 280 | meta.attrib['property'] = 'role' 281 | meta.attrib['scheme'] = 'marc:relators' 282 | container.metadata.insert(idx, meta) 283 | idx = idx+1 284 | -------------------------------------------------------------------------------- /images/dictionary.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 28 | 29 | 48 | 51 | 52 | 54 | 55 | 57 | image/svg+xml 58 | 60 | 61 | 62 | 63 | Kovid Goyal 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 78 | 79 | 81 | 83 | 85 | 87 | 89 | 91 | 93 | 94 | 95 | 96 | 101 | 107 | 113 | 121 | 125 | 129 | 133 | 137 | 138 | 139 | 140 | -------------------------------------------------------------------------------- /images/ePub_logo_color.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 11 | 14 | 16 | 20 | 21 | 25 | 26 | -------------------------------------------------------------------------------- /images/epub_extended_metadata.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 26 | 27 | 49 | 52 | 53 | 55 | 56 | 58 | image/svg+xml 59 | 61 | 62 | 63 | 64 | Kovid Goyal 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 79 | 80 | 82 | 84 | 86 | 88 | 90 | 92 | 94 | 95 | 96 | 97 | 101 | 125 | 130 | 134 | 139 | 144 | 149 | 154 | 159 | 160 | 161 | 162 | -------------------------------------------------------------------------------- /images/metadata.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 41 | 43 | 44 | 46 | image/svg+xml 47 | 49 | 50 | 51 | 52 | Kovid Goyal 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 67 | 68 | 70 | 72 | 74 | 76 | 78 | 80 | 82 | 83 | 84 | 85 | 89 | 91 | 96 | 101 | 106 | 111 | 116 | 117 | 118 | 119 | -------------------------------------------------------------------------------- /images/plugin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/un-pogaz/ePub-Extended-Metadata/a9507f53f0ddc68d437e7c5d27d9dc46871c4df4/images/plugin.png -------------------------------------------------------------------------------- /images/user_profile.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 20 | 22 | 33 | 36 | 40 | 44 | 45 | 55 | 58 | 62 | 66 | 67 | 77 | 87 | 88 | 107 | 109 | 110 | 112 | image/svg+xml 113 | 115 | 116 | 117 | 118 | Kovid Goyal 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 133 | 134 | 136 | 138 | 140 | 142 | 144 | 146 | 148 | 149 | 150 | 151 | 156 | 162 | 169 | 174 | 179 | 185 | 191 | 197 | 198 | 199 | -------------------------------------------------------------------------------- /images/warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/un-pogaz/ePub-Extended-Metadata/a9507f53f0ddc68d437e7c5d27d9dc46871c4df4/images/warning.png -------------------------------------------------------------------------------- /marc_relators.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | __license__ = 'GPL v3' 4 | __copyright__ = '2021, un_pogaz ' 5 | 6 | 7 | try: 8 | load_translations() 9 | except NameError: 10 | pass # load_translations() added in calibre 1.9 11 | 12 | from collections import OrderedDict 13 | 14 | # The following MARC Code associated name and decriptions are extracted from the https://github.com/Sigil-Ebook/Sigil code source (with minor edit) 15 | # Some translation are also based on the work done for Sigil, see CREDITS file 16 | 17 | # For the authoritiative relator list and descriptive definitions see http://www.loc.gov/marc/relators/ 18 | 19 | t = _('//// MARC CONTRIBUTORS ROLES') 20 | # https://www.loc.gov/marc/relators/relacode.html 21 | CONTRIBUTORS_ROLES = OrderedDict([ 22 | ('', ''), 23 | ('abr', _('Abridger')), 24 | ('act', _('Actor')), 25 | ('adp', _('Adapter')), 26 | ('anl', _('Analyst')), 27 | ('anm', _('Animator')), 28 | ('ann', _('Annotator')), 29 | ('apl', _('Appellant')), 30 | ('ape', _('Appellee')), 31 | ('app', _('Applicant')), 32 | ('arc', _('Architect')), 33 | ('arr', _('Arranger')), 34 | ('acp', _('Art copyist')), 35 | ('adi', _('Art director')), 36 | ('art', _('Artist')), 37 | ('ard', _('Artistic director')), 38 | ('asg', _('Assignee')), 39 | ('asn', _('Associated name')), 40 | ('att', _('Attributed name')), 41 | ('auc', _('Auctioneer')), 42 | ('aut', _('Author')), 43 | ('aqt', _('Author in quotations or text extracts')), 44 | ('aft', _('Author of afterword, colophon, etc.')), 45 | ('aud', _('Author of dialog')), 46 | ('aui', _('Author of introduction, etc.')), 47 | ('aus', _('Author of screenplay, etc.')), 48 | ('ato', _('Autographer')), 49 | ('ant', _('Bibliographic antecedent')), 50 | ('bnd', _('Binder')), 51 | ('bdd', _('Binding designer')), 52 | ('blw', _('Blurb writer')), 53 | ('bkd', _('Book designer')), 54 | ('bkp', _('Book producer')), 55 | ('bjd', _('Bookjacket designer')), 56 | ('bpd', _('Bookplate designer')), 57 | ('bsl', _('Bookseller')), 58 | ('brl', _('Braille embosser')), 59 | ('brd', _('Broadcaster')), 60 | ('cll', _('Calligrapher')), 61 | ('ctg', _('Cartographer')), 62 | ('cas', _('Caster')), 63 | ('cns', _('Censor')), 64 | ('chr', _('Choreographer')), 65 | ('cng', _('Cinematographer')), 66 | ('cli', _('Client')), 67 | ('cor', _('Collection registrar')), 68 | ('col', _('Collector')), 69 | ('clt', _('Collotyper')), 70 | ('clr', _('Colorist')), 71 | ('cmm', _('Commentator')), 72 | ('cwt', _('Commentator for written text')), 73 | ('com', _('Compiler')), 74 | ('cpl', _('Complainant')), 75 | ('cpt', _('Complainant-appellant')), 76 | ('cpe', _('Complainant-appellee')), 77 | ('cmp', _('Composer')), 78 | ('cmt', _('Compositor')), 79 | ('ccp', _('Conceptor')), 80 | ('cnd', _('Conductor')), 81 | ('con', _('Conservator')), 82 | ('csl', _('Consultant')), 83 | ('csp', _('Consultant to a project')), 84 | ('cos', _('Contestant')), 85 | ('cot', _('Contestant-appellant')), 86 | ('coe', _('Contestant-appellee')), 87 | ('cts', _('Contestee')), 88 | ('ctt', _('Contestee-appellant')), 89 | ('cte', _('Contestee-appellee')), 90 | ('ctr', _('Contractor')), 91 | ('ctb', _('Contributor')), 92 | ('cpc', _('Copyright claimant')), 93 | ('cph', _('Copyright holder')), 94 | ('crr', _('Corrector')), 95 | ('crp', _('Correspondent')), 96 | ('cst', _('Costume designer')), 97 | ('cou', _('Court governed')), 98 | ('crt', _('Court reporter')), 99 | ('cov', _('Cover designer')), 100 | ('cre', _('Creator')), 101 | ('cur', _('Curator of an exhibition')), 102 | ('dnc', _('Dancer')), 103 | ('dtc', _('Data contributor')), 104 | ('dtm', _('Data manager')), 105 | ('dte', _('Dedicatee')), 106 | ('dto', _('Dedicator')), 107 | ('dfd', _('Defendant')), 108 | ('dft', _('Defendant-appellant')), 109 | ('dfe', _('Defendant-appellee')), 110 | ('dgg', _('Degree grantor')), 111 | ('dln', _('Delineator')), 112 | ('dpc', _('Depicted')), 113 | ('dpt', _('Depositor')), 114 | ('dsr', _('Designer')), 115 | ('drt', _('Director')), 116 | ('dis', _('Dissertant')), 117 | ('dbp', _('Distribution place')), 118 | ('dst', _('Distributor')), 119 | ('dnr', _('Donor')), 120 | ('drm', _('Draftsman')), 121 | ('dub', _('Dubious author')), 122 | ('edt', _('Editor')), 123 | ('edc', _('Editor of compilation')), 124 | ('edm', _('Editor of moving image work')), 125 | ('elg', _('Electrician')), 126 | ('elt', _('Electrotyper')), 127 | ('eng', _('Engineer')), 128 | ('egr', _('Engraver')), 129 | ('etr', _('Etcher')), 130 | ('evp', _('Event place')), 131 | ('exp', _('Expert')), 132 | ('fac', _('Facsimilist')), 133 | ('fld', _('Field director')), 134 | ('fmd', _('Film director')), 135 | ('fds', _('Film distributor')), 136 | ('flm', _('Film editor')), 137 | ('fmp', _('Film producer')), 138 | ('fmk', _('Filmmaker')), 139 | ('fpy', _('First party')), 140 | ('frg', _('Forger')), 141 | ('fmo', _('Former owner')), 142 | ('fnd', _('Funder')), 143 | ('gis', _('Geographic information specialist')), 144 | ('hnr', _('Honoree')), 145 | ('hst', _('Host')), 146 | ('his', _('Host institution')), 147 | ('ilu', _('Illuminator')), 148 | ('ill', _('Illustrator')), 149 | ('ins', _('Inscriber')), 150 | ('itr', _('Instrumentalist')), 151 | ('ive', _('Interviewee')), 152 | ('ivr', _('Interviewer')), 153 | ('inv', _('Inventor')), 154 | ('isb', _('Issuing body')), 155 | ('jud', _('Judge')), 156 | ('jug', _('Jurisdiction governed')), 157 | ('lbr', _('Laboratory')), 158 | ('ldr', _('Laboratory director')), 159 | ('lsa', _('Landscape architect')), 160 | ('led', _('Lead')), 161 | ('len', _('Lender')), 162 | ('lil', _('Libelant')), 163 | ('lit', _('Libelant-appellant')), 164 | ('lie', _('Libelant-appellee')), 165 | ('lel', _('Libelee')), 166 | ('let', _('Libelee-appellant')), 167 | ('lee', _('Libelee-appellee')), 168 | ('lbt', _('Librettist')), 169 | ('lse', _('Licensee')), 170 | ('lso', _('Licensor')), 171 | ('lgd', _('Lighting designer')), 172 | ('ltg', _('Lithographer')), 173 | ('lyr', _('Lyricist')), 174 | ('mfp', _('Manufacture place')), 175 | ('mfr', _('Manufacturer')), 176 | ('mrb', _('Marbler')), 177 | ('mrk', _('Markup editor')), 178 | ('med', _('Medium')), 179 | ('mdc', _('Metadata contact')), 180 | ('mte', _('Metal-engraver')), 181 | ('mtk', _('Minute taker')), 182 | ('mod', _('Moderator')), 183 | ('mon', _('Monitor')), 184 | ('mcp', _('Music copyist')), 185 | ('msd', _('Musical director')), 186 | ('mus', _('Musician')), 187 | ('nrt', _('Narrator')), 188 | ('osp', _('Onscreen presenter')), 189 | ('opn', _('Opponent')), 190 | ('orm', _('Organizer of meeting')), 191 | ('org', _('Originator')), 192 | ('oth', _('Other')), 193 | ('own', _('Owner')), 194 | ('pan', _('Panelist')), 195 | ('ppm', _('Papermaker')), 196 | ('pta', _('Patent applicant')), 197 | ('pth', _('Patent holder')), 198 | ('pat', _('Patron')), 199 | ('prf', _('Performer')), 200 | ('pma', _('Permitting agency')), 201 | ('pht', _('Photographer')), 202 | ('ptf', _('Plaintiff')), 203 | ('ptt', _('Plaintiff-appellant')), 204 | ('pte', _('Plaintiff-appellee')), 205 | ('plt', _('Platemaker')), 206 | ('pra', _('Praeses')), 207 | ('pre', _('Presenter')), 208 | ('prt', _('Printer')), 209 | ('pop', _('Printer of plates')), 210 | ('prm', _('Printmaker')), 211 | ('prc', _('Process contact')), 212 | ('pro', _('Producer')), 213 | ('prn', _('Production company')), 214 | ('prs', _('Production designer')), 215 | ('pmn', _('Production manager')), 216 | ('prd', _('Production personnel')), 217 | ('prp', _('Production place')), 218 | ('prg', _('Programmer')), 219 | ('pdr', _('Project director')), 220 | ('pfr', _('Proofreader')), 221 | ('prv', _('Provider')), 222 | ('pup', _('Publication place')), 223 | ('pbl', _('Publisher')), 224 | ('pbd', _('Publishing director')), 225 | ('ppt', _('Puppeteer')), 226 | ('rdd', _('Radio director')), 227 | ('rpc', _('Radio producer')), 228 | ('rcp', _('Recipient')), 229 | ('rce', _('Recording engineer')), 230 | ('rce', _('Recording engineer')), 231 | ('red', _('Redactor')), 232 | ('ren', _('Renderer')), 233 | ('rpt', _('Reporter')), 234 | ('rps', _('Repository')), 235 | ('rth', _('Research team head')), 236 | ('rtm', _('Research team member')), 237 | ('res', _('Researcher')), 238 | ('rsp', _('Respondent')), 239 | ('rst', _('Respondent-appellant')), 240 | ('rse', _('Respondent-appellee')), 241 | ('rpy', _('Responsible party')), 242 | ('rsg', _('Restager')), 243 | ('rsr', _('Restorationist')), 244 | ('rev', _('Reviewer')), 245 | ('rbr', _('Rubricator')), 246 | ('sce', _('Scenarist')), 247 | ('sad', _('Scientific advisor')), 248 | ('scr', _('Scribe')), 249 | ('scl', _('Sculptor')), 250 | ('spy', _('Second party')), 251 | ('sec', _('Secretary')), 252 | ('sll', _('Seller')), 253 | ('std', _('Set designer')), 254 | ('stg', _('Setting')), 255 | ('sgn', _('Signer')), 256 | ('sng', _('Singer')), 257 | ('sds', _('Sound designer')), 258 | ('spk', _('Speaker')), 259 | ('spn', _('Sponsor')), 260 | ('sgd', _('Stage director')), 261 | ('stm', _('Stage manager')), 262 | ('stn', _('Standards body')), 263 | ('str', _('Stereotyper')), 264 | ('stl', _('Storyteller')), 265 | ('sht', _('Supporting host')), 266 | ('srv', _('Surveyor')), 267 | ('tch', _('Teacher')), 268 | ('tcd', _('Technical director')), 269 | ('tld', _('Television director')), 270 | ('tlp', _('Television producer')), 271 | ('ths', _('Thesis advisor')), 272 | ('trc', _('Transcriber')), 273 | ('trl', _('Translator')), 274 | ('tyd', _('Type designer')), 275 | ('tyg', _('Typographer')), 276 | ('uvp', _('University place')), 277 | ('vdg', _('Videographer')), 278 | ('vac', _('Voice actor')), 279 | ('wit', _('Witness')), 280 | ('wde', _('Wood-engraver')), 281 | ('wdc', _('Woodcutter')), 282 | ('wam', _('Writer of accompanying material')), 283 | ('wac', _('Writer of added commentary')), 284 | ('wal', _('Writer of added lyrics')), 285 | ('wat', _('Writer of added text')), 286 | ('win', _('Writer of introduction')), 287 | ('wpr', _('Writer of preface')), 288 | ('wst', _('Writer of supplementary textual content')), 289 | ]) 290 | 291 | t = _('//// MARC CONTRIBUTORS DESCRIPTION') 292 | # https://www.loc.gov/marc/relators/relaterm.html 293 | CONTRIBUTORS_DESCRIPTION = OrderedDict([ 294 | ('abr' , _('A person, family, or organization contributing to a resource by shortening or condensing the original work but leaving the nature and content of the original work substantially unchanged. For substantial modifications that result in the creation of a new work, see Author.')), 295 | ('act' , _('Use for a person or organization who principally exhibits acting skills in a musical or dramatic presentation or entertainment.')), 296 | ('adp' , _('Use for a person or organization who 1) reworks a musical composition, usually for a different medium, or 2) rewrites novels or stories for motion pictures or other audiovisual medium.')), 297 | ('anl' , _('Use for a person or organization that reviews, examines and interprets data or information in a specific area.')), 298 | ('anm' , _('Use for a person or organization who draws the two-dimensional figures, manipulates the three dimensional objects and/or also programs the computer to move objects and images for the purpose of animated film processing. Animation cameras, stands, celluloid screens, transparencies and inks are some of the tools of the animator.')), 299 | ('ann' , _('Use for a person who writes manuscript annotations on a printed item.')), 300 | ('apl' , _("A person or organization who appeals a lower court's decision.")), 301 | ('ape' , _('A person or organization against whom an appeal is taken.')), 302 | ('app' , _('Use for a person or organization responsible for the submission of an application or who is named as eligible for the results of the processing of the application (e.g., bestowing of rights, reward, title, position).')), 303 | ('arc' , _('Use for a person or organization who designs structures or oversees their construction.')), 304 | ('arr' , _('Use for a person or organization who transcribes a musical composition, usually for a different medium from that of the original; in an arrangement the musical substance remains essentially unchanged.')), 305 | ('acp' , _('Use for a person (e.g., a painter or sculptor) who makes copies of works of visual art.')), 306 | ('adi' , _('A person contributing to a motion picture or television production by overseeing the artists and craftspeople who build the sets.')), 307 | ('art' , _('Use for a person (e.g., a painter) or organization who conceives, and perhaps also implements, an original graphic design or work of art, if specific codes (e.g., [egr], [etr]) are not desired. For book illustrators, prefer Illustrator [ill].')), 308 | ('ard' , _('Use for a person responsible for controlling the development of the artistic style of an entire production, including the choice of works to be presented and selection of senior production staff.')), 309 | ('asg' , _('Use for a person or organization to whom a license for printing or publishing has been transferred.')), 310 | ('asn' , _('Use for a person or organization associated with or found in an item or collection, which cannot be determined to be that of a Former owner [fmo] or other designated relator indicative of provenance.')), 311 | ('att' , _('Use for an author, artist, etc., relating him/her to a work for which there is or once was substantial authority for designating that person as author, creator, etc. of the work.')), 312 | ('auc' , _('Use for a person or organization in charge of the estimation and public auctioning of goods, particularly books, artistic works, etc.')), 313 | ('aut' , _('Use for a person or organization chiefly responsible for the intellectual or artistic content of a work, usually printed text. This term may also be used when more than one person or body bears such responsibility.')), 314 | ('aqt' , _('Use for a person or organization whose work is largely quoted or extracted in works to which he or she did not contribute directly. Such quotations are found particularly in exhibition catalogs, collections of photographs, etc.')), 315 | ('aft' , _('Use for a person or organization responsible for an afterword, postface, colophon, etc. but who is not the chief author of a work.')), 316 | ('aud' , _('Use for a person or organization responsible for the dialog or spoken commentary for a screenplay or sound recording.')), 317 | ('aui' , _('Use for a person or organization responsible for an introduction, preface, foreword, or other critical introductory matter, but who is not the chief author.')), 318 | ('aus' , _('Use for a person or organization responsible for a motion picture screenplay, dialog, spoken commentary, etc.')), 319 | ('ato' , _('A person whose manuscript signature appears on an item.')), 320 | ('ant' , _('Use for a person or organization responsible for a work upon which the work represented by the catalog record is based. This may be appropriate for adaptations, sequels, continuations, indexes, etc.')), 321 | ('bnd' , _('Use for a person or organization responsible for the binding of printed or manuscript materials.')), 322 | ('bdd' , _('Use for a person or organization responsible for the binding design of a book, including the type of binding, the type of materials used, and any decorative aspects of the binding.')), 323 | ('blw' , _('A person or organization responsible for writing a commendation or testimonial for a work, which appears on or within the publication itself, frequently on the back or dust jacket of print publications or on advertising material for all media.')), 324 | ('bkd' , _('Use for a person or organization responsible for the entire graphic design of a book, including arrangement of type and illustration, choice of materials, and process used.')), 325 | ('bkp' , _('Use for a person or organization responsible for the production of books and other print media, if specific codes (e.g., [bkd], [egr], [tyd], [prt]) are not desired.')), 326 | ('bjd' , _('Use for a person or organization responsible for the design of flexible covers designed for or published with a book, including the type of materials used, and any decorative aspects of the bookjacket.')), 327 | ('bpd' , _("Use for a person or organization responsible for the design of a book owner's identification label that is most commonly pasted to the inside front cover of a book.")), 328 | ('bsl' , _('Use for a person or organization who makes books and other bibliographic materials available for purchase. Interest in the materials is primarily lucrative.')), 329 | ('brl' , _('A person, family, or organization involved in manufacturing a resource by embossing Braille cells using a stylus, special embossing printer, or other device.')), 330 | ('brd' , _('A person, family, or organization involved in broadcasting a resource to an audience via radio, television, webcast, etc.')), 331 | ('cll' , _('Use for a person or organization who writes in an artistic hand, usually as a copyist and or engrosser.')), 332 | ('ctg' , _('Use for a person or organization responsible for the creation of maps and other cartographic materials.')), 333 | ('cas' , _('A person, family, or organization involved in manufacturing a resource by pouring a liquid or molten substance into a mold and leaving it to solidify to take the shape of the mold.')), 334 | ('cns' , _('Use for a censor, bowdlerizer, expurgator, etc., official or private.')), 335 | ('chr' , _('Use for a person or organization who composes or arranges dances or other movements (e.g., "master of swords") for a musical or dramatic presentation or entertainment.')), 336 | ('cng' , _('Use for a person or organization who is in charge of the images captured for a motion picture film. The cinematographer works under the supervision of a director, and may also be referred to as director of photography. Do not confuse with videographer.')), 337 | ('cli' , _('Use for a person or organization for whom another person or organization is acting.')), 338 | ('cor' , _('A curator who lists or inventories the items in an aggregate work such as a collection of items or works.')), 339 | ('col' , _('Use for a person or organization who has brought together material from various sources that has been arranged, described, and cataloged as a collection. A collector is neither the creator of the material nor a person to whom manuscripts in the collection may have been addressed.')), 340 | ('clt' , _('Use for a person or organization responsible for the production of photographic prints from film or other colloid that has ink-receptive and ink-repellent surfaces.')), 341 | ('clr' , _('A person or organization responsible for applying color to drawings, prints, photographs, maps, moving images, etc.')), 342 | ('cmm' , _('Use for a person or organization who provides interpretation, analysis, or a discussion of the subject matter on a recording, motion picture, or other audiovisual medium.')), 343 | ('cwt' , _('Use for a person or organization responsible for the commentary or explanatory notes about a text. For the writer of manuscript annotations in a printed book, use Annotator [ann].')), 344 | ('com' , _('Use for a person or organization who produces a work or publication by selecting and putting together material from the works of various persons or bodies.')), 345 | ('cpl' , _('Use for the party who applies to the courts for redress, usually in an equity proceeding.')), 346 | ('cpt' , _('Use for a complainant who takes an appeal from one court or jurisdiction to another to reverse the judgment, usually in an equity proceeding.')), 347 | ('cpe' , _('Use for a complainant against whom an appeal is taken from one court or jurisdiction to another to reverse the judgment, usually in an equity proceeding.')), 348 | ('cmp' , _('Use for a person or organization who creates a musical work, usually a piece of music in manuscript or printed form.')), 349 | ('cmt' , _('Use for a person or organization responsible for the creation of metal slug, or molds made of other materials, used to produce the text and images in printed matter.')), 350 | ('ccp' , _('Use for a person or organization responsible for the original idea on which a work is based, this includes the scientific author of an audio-visual item and the conceptor of an advertisement.')), 351 | ('cnd' , _('Use for a person who directs a performing group (orchestra, chorus, opera, etc.) in a musical or dramatic presentation or entertainment.')), 352 | ('con' , _('A person or organization responsible for documenting, preserving, or treating printed or manuscript material, works of art, artifacts, or other media.')), 353 | ('csl' , _('Use for a person or organization relevant to a resource, who is called upon for professional advice or services in a specialized field of knowledge or training.')), 354 | ('csp' , _('Use for a person or organization relevant to a resource, who is engaged specifically to provide an intellectual overview of a strategic or operational task and by analysis, specification, or instruction, to create or propose a cost-effective course of action or solution.')), 355 | ('cos' , _('Use for the party who opposes, resists, or disputes, in a court of law, a claim, decision, result, etc.')), 356 | ('cot' , _('Use for a contestant who takes an appeal from one court of law or jurisdiction to another to reverse the judgment.')), 357 | ('coe' , _('Use for a contestant against whom an appeal is taken from one court of law or jurisdiction to another to reverse the judgment.')), 358 | ('cts' , _('Use for the party defending a claim, decision, result, etc. being opposed, resisted, or disputed in a court of law.')), 359 | ('ctt' , _('Use for a contestee who takes an appeal from one court or jurisdiction to another to reverse the judgment.')), 360 | ('cte' , _('Use for a contestee against whom an appeal is taken from one court or jurisdiction to another to reverse the judgment.')), 361 | ('ctr' , _('Use for a person or organization relevant to a resource, who enters into a contract with another person or organization to perform a specific task.')), 362 | ('ctb' , _('Use for a person or organization one whose work has been contributed to a larger work, such as an anthology, serial publication, or other compilation of individual works. Do not use if the sole function in relation to a work is as author, editor, compiler or translator.')), 363 | ('cpc' , _('Use for a person or organization listed as a copyright owner at the time of registration. Copyright can be granted or later transferred to another person or organization, at which time the claimant becomes the copyright holder.')), 364 | ('cph' , _('Use for a person or organization to whom copy and legal rights have been granted or transferred for the intellectual content of a work. The copyright holder, although not necessarily the creator of the work, usually has the exclusive right to benefit financially from the sale and use of the work to which the associated copyright protection applies.')), 365 | ('crr' , _('Use for a person or organization who is a corrector of manuscripts, such as the scriptorium official who corrected the work of a scribe. For printed matter, use Proofreader.')), 366 | ('crp' , _('Use for a person or organization who was either the writer or recipient of a letter or other communication.')), 367 | ('cst' , _('Use for a person or organization who designs or makes costumes, fixes hair, etc., for a musical or dramatic presentation or entertainment.')), 368 | ('cou' , _('A court governed by court rules, regardless of their official nature (e.g., laws, administrative regulations.)')), 369 | ('crt' , _("A person, family, or organization contributing to a resource by preparing a court's opinions for publication.")), 370 | ('cov' , _('Use for a person or organization responsible for the graphic design of a book cover, album cover, slipcase, box, container, etc. For a person or organization responsible for the graphic design of an entire book, use Book designer; for book jackets, use Bookjacket designer.')), 371 | ('cre' , _('Use for a person or organization responsible for the intellectual or artistic content of a work.')), 372 | ('cur' , _('Use for a person or organization responsible for conceiving and organizing an exhibition.')), 373 | ('dnc' , _('Use for a person or organization who principally exhibits dancing skills in a musical or dramatic presentation or entertainment.')), 374 | ('dtc' , _('Use for a person or organization that submits data for inclusion in a database or other collection of data.')), 375 | ('dtm' , _('Use for a person or organization responsible for managing databases or other data sources.')), 376 | ('dte' , _('Use for a person or organization to whom a book, manuscript, etc., is dedicated (not the recipient of a gift).')), 377 | ('dto' , _('Use for the author of a dedication, which may be a formal statement or in epistolary or verse form.')), 378 | ('dfd' , _('Use for the party defending or denying allegations made in a suit and against whom relief or recovery is sought in the courts, usually in a legal action.')), 379 | ('dft' , _('Use for a defendant who takes an appeal from one court or jurisdiction to another to reverse the judgment, usually in a legal action.')), 380 | ('dfe' , _('Use for a defendant against whom an appeal is taken from one court or jurisdiction to another to reverse the judgment, usually in a legal action.')), 381 | ('dgg' , _('Use for the organization granting a degree for which the thesis or dissertation described was presented.')), 382 | ('dln' , _("Use for a person or organization executing technical drawings from others' designs.")), 383 | ('dpc' , _('Use for an entity depicted or portrayed in a work, particularly in a work of art.')), 384 | ('dpt' , _('Use for a person or organization placing material in the physical custody of a library or repository without transferring the legal title.')), 385 | ('dsr' , _('Use for a person or organization responsible for the design if more specific codes (e.g., [bkd], [tyd]) are not desired.')), 386 | ('drt' , _('Use for a person or organization who is responsible for the general management of a work or who supervises the production of a performance for stage, screen, or sound recording.')), 387 | ('dis' , _('Use for a person who presents a thesis for a university or higher-level educational degree.')), 388 | ('dbp' , _('A place from which a resource, e.g., a serial, is distributed.')), 389 | ('dst' , _('Use for a person or organization that has exclusive or shared marketing rights for an item.')), 390 | ('dnr' , _('Use for a person or organization who is the donor of a book, manuscript, etc., to its present owner. Donors to previous owners are designated as Former owner [fmo] or Inscriber [ins].')), 391 | ('drm' , _('Use for a person or organization who prepares artistic or technical drawings.')), 392 | ('dub' , _('Use for a person or organization to which authorship has been dubiously or incorrectly ascribed.')), 393 | ('edt' , _('Use for a person or organization who prepares for publication a work not primarily his/her own, such as by elucidating text, adding introductory or other critical matter, or technically directing an editorial staff.')), 394 | ('edc' , _('A person, family, or organization contributing to a collective or aggregate work by selecting and putting together works, or parts of works, by one or more creators. For compilations of data, information, etc., that result in new works, see compiler.')), 395 | ('edm' , _('A person, family, or organization responsible for assembling, arranging, and trimming film, video, or other moving image formats, including both visual and audio aspects.')), 396 | ('elg' , _('Use for a person responsible for setting up a lighting rig and focusing the lights for a production, and running the lighting at a performance.')), 397 | ('elt' , _('Use for a person or organization who creates a duplicate printing surface by pressure molding and electrodepositing of metal that is then backed up with lead for printing.')), 398 | ('eng' , _('Use for a person or organization that is responsible for technical planning and design, particularly with construction.')), 399 | ('egr' , _('Use for a person or organization who cuts letters, figures, etc. on a surface, such as a wooden or metal plate, for printing.')), 400 | ('etr' , _('Use for a person or organization who produces text or images for printing by subjecting metal, glass, or some other surface to acid or the corrosive action of some other substance.')), 401 | ('evp' , _('A place where an event such as a conference or a concert took place.')), 402 | ('exp' , _('Use for a person or organization in charge of the description and appraisal of the value of goods, particularly rare items, works of art, etc.')), 403 | ('fac' , _('Use for a person or organization that executed the facsimile.')), 404 | ('fld' , _('Use for a person or organization that manages or supervises the work done to collect raw data or do research in an actual setting or environment (typically applies to the natural and social sciences).')), 405 | ('fmd' , _('A director responsible for the general management and supervision of a filmed performance.')), 406 | ('fds' , _('A person, family, or organization involved in distributing a moving image resource to theatres or other distribution channels.')), 407 | ('flm' , _('Use for a person or organization who is an editor of a motion picture film. This term is used regardless of the medium upon which the motion picture is produced or manufactured (e.g., acetate film, video tape).')), 408 | ('fmp' , _('A producer responsible for most of the business aspects of a film.')), 409 | ('fmk' , _('A person, family or organization responsible for creating an independent or personal film. A filmmaker is individually responsible for the conception and execution of all aspects of the film.')), 410 | ('fpy' , _('Use for a person or organization who is identified as the only party or the party of the first part. In the case of transfer of right, this is the assignor, transferor, licensor, grantor, etc. Multiple parties can be named jointly as the first party.')), 411 | ('frg' , _('Use for a person or organization who makes or imitates something of value or importance, especially with the intent to defraud.')), 412 | ('fmo' , _('Use for a person or organization who owned an item at any time in the past. Includes those to whom the material was once presented. A person or organization giving the item to the present owner is designated as Donor [dnr].')), 413 | ('fnd' , _('Use for a person or organization that furnished financial support for the production of the work.')), 414 | ('gis' , _('Use for a person responsible for geographic information system (GIS) development and integration with global positioning system data.')), 415 | ('hnr' , _('Use for a person or organization in memory or honor of whom a book, manuscript, etc. is donated.')), 416 | ('hst' , _('Use for a person who is invited or regularly leads a program (often broadcast) that includes other guests, performers, etc. (e.g., talk show host).')), 417 | ('his' , _('An organization hosting the event, exhibit, conference, etc., which gave rise to a resource, but having little or no responsibility for the content of the resource.')), 418 | ('ilu' , _('Use for a person or organization responsible for the decoration of a work (especially manuscript material) with precious metals or color, usually with elaborate designs and motifs.')), 419 | ('ill' , _('Use for a person or organization who conceives, and perhaps also implements, a design or illustration, usually to accompany a written text.')), 420 | ('ins' , _('Use for a person who has written a statement of dedication or gift.')), 421 | ('itr' , _('Use for a person or organization who principally plays an instrument in a musical or dramatic presentation or entertainment.')), 422 | ('ive' , _('Use for a person or organization who is interviewed at a consultation or meeting, usually by a reporter, pollster, or some other information gathering agent.')), 423 | ('ivr' , _('Use for a person or organization who acts as a reporter, pollster, or other information gathering agent in a consultation or meeting involving one or more individuals.')), 424 | ('inv' , _('Use for a person or organization who first produces a particular useful item, or develops a new process for obtaining a known item or result.')), 425 | ('isb' , _('A person, family or organization issuing a work, such as an official organ of the body.')), 426 | ('jud' , _('A person who hears and decides on legal matters in court.')), 427 | ('jug' , _('A jurisdiction governed by a law, regulation, etc., that was enacted by another jurisdiction.')), 428 | ('lbr' , _('Use for an institution that provides scientific analyses of material samples.')), 429 | ('ldr' , _('Use for a person or organization that manages or supervises work done in a controlled setting or environment.')), 430 | ('lsa' , _('Use for a person or organization whose work involves coordinating the arrangement of existing and proposed land features and structures.')), 431 | ('led' , _('Use to indicate that a person or organization takes primary responsibility for a particular activity or endeavor. Use with another relator term or code to show the greater importance this person or organization has regarding that particular role. If more than one relator is assigned to a heading, use the Lead relator only if it applies to all the relators.')), 432 | ('len' , _('Use for a person or organization permitting the temporary use of a book, manuscript, etc., such as for photocopying or microfilming.')), 433 | ('lil' , _('Use for the party who files a libel in an ecclesiastical or admiralty case.')), 434 | ('lit' , _('Use for a libelant who takes an appeal from one ecclesiastical court or admiralty to another to reverse the judgment.')), 435 | ('lie' , _('Use for a libelant against whom an appeal is taken from one ecclesiastical court or admiralty to another to reverse the judgment.')), 436 | ('lel' , _('Use for a party against whom a libel has been filed in an ecclesiastical court or admiralty.')), 437 | ('let' , _('Use for a libelee who takes an appeal from one ecclesiastical court or admiralty to another to reverse the judgment.')), 438 | ('lee' , _('Use for a libelee against whom an appeal is taken from one ecclesiastical court or admiralty to another to reverse the judgment.')), 439 | ('lbt' , _('Use for a person or organization who is a writer of the text of an opera, oratorio, etc.')), 440 | ('lse' , _('Use for a person or organization who is an original recipient of the right to print or publish.')), 441 | ('lso' , _('Use for person or organization who is a signer of the license, imprimatur, etc.')), 442 | ('lgd' , _('Use for a person or organization who designs the lighting scheme for a theatrical presentation, entertainment, motion picture, etc.')), 443 | ('ltg' , _('Use for a person or organization who prepares the stone or plate for lithographic printing, including a graphic artist creating a design directly on the surface from which printing will be done.')), 444 | ('lyr' , _('Use for a person or organization who is the a writer of the text of a song.')), 445 | ('mfp' , _('The place of manufacture (e.g., printing, duplicating, casting, etc.) of a resource in a published form.')), 446 | ('mfr' , _('Use for a person or organization that makes an artifactual work (an object made or modified by one or more persons). Examples of artifactual works include vases, cannons or pieces of furniture.')), 447 | ('mrb' , _('The entity responsible for marbling paper, cloth, leather, etc. used in construction of a resource.')), 448 | ('mrk' , _('Use for a person or organization performing the coding of SGML, HTML, or XML markup of metadata, text, etc.')), 449 | ('med' , _('A person held to be a channel of communication between the earthly world and a different world.')), 450 | ('mdc' , _('Use for a person or organization primarily responsible for compiling and maintaining the original description of a metadata set (e.g., geospatial metadata set).')), 451 | ('mte' , _('Use for a person or organization responsible for decorations, illustrations, letters, etc. cut on a metal surface for printing or decoration.')), 452 | ('mtk' , _('A person, family, or organization responsible for recording the minutes of a meeting.')), 453 | ('mod' , _('Use for a person who leads a program (often broadcast) where topics are discussed, usually with participation of experts in fields related to the discussion.')), 454 | ('mon' , _('Use for a person or organization that supervises compliance with the contract and is responsible for the report and controls its distribution. Sometimes referred to as the grantee, or controlling agency.')), 455 | ('mcp' , _('Use for a person who transcribes or copies musical notation.')), 456 | ('msd' , _('Use for a person responsible for basic music decisions about a production, including coordinating the work of the composer, the sound editor, and sound mixers, selecting musicians, and organizing and/or conducting sound for rehearsals and performances.')), 457 | ('mus' , _('Use for a person or organization who performs music or contributes to the musical content of a work when it is not possible or desirable to identify the function more precisely.')), 458 | ('nrt' , _('Use for a person who is a speaker relating the particulars of an act, occurrence, or course of events.')), 459 | ('osp' , _('A performer contributing to an expression of a work by appearing on screen in nonfiction moving image materials or introductions to fiction moving image materials to provide contextual or background information. Use when another term (e.g., Narrator, Host) is either not applicable or not desired.')), 460 | ('opn' , _('Use for a person or organization responsible for opposing a thesis or dissertation.')), 461 | ('orm' , _('Use for a person or organization responsible for organizing a meeting for which an item is the report or proceedings.')), 462 | ('org' , _('Use for a person or organization performing the work, i.e., the name of a person or organization associated with the intellectual content of the work. This category does not include the publisher or personal affiliation, or sponsor except where it is also the corporate author.')), 463 | ('oth' , _('Use for relator codes from other lists which have no equivalent in the MARC list or for terms which have not been assigned a code.')), 464 | ('own' , _('Use for a person or organization that currently owns an item or collection.')), 465 | ('pan' , _('A performer contributing to a resource by participating in a program (often broadcast) where topics are discussed, usually with participation of experts in fields related to the discussion.')), 466 | ('ppm' , _('Use for a person or organization responsible for the production of paper, usually from wood, cloth, or other fibrous material.')), 467 | ('pta' , _('Use for a person or organization that applied for a patent.')), 468 | ('pth' , _('Use for a person or organization that was granted the patent referred to by the item.')), 469 | ('pat' , _('Use for a person or organization responsible for commissioning a work. Usually a patron uses his or her means or influence to support the work of artists, writers, etc. This includes those who commission and pay for individual works.')), 470 | ('prf' , _('Use for a person or organization who exhibits musical or acting skills in a musical or dramatic presentation or entertainment, if specific codes for those functions ([act], [dnc], [itr], [voc], etc.) are not used. If specific codes are used, [prf] is used for a person whose principal skill is not known or specified.')), 471 | ('pma' , _('Use for an authority (usually a government agency) that issues permits under which work is accomplished.')), 472 | ('pht' , _('Use for a person or organization responsible for taking photographs, whether they are used in their original form or as reproductions.')), 473 | ('ptf' , _('Use for the party who complains or sues in court in a personal action, usually in a legal proceeding.')), 474 | ('ptt' , _('Use for a plaintiff who takes an appeal from one court or jurisdiction to another to reverse the judgment, usually in a legal proceeding.')), 475 | ('pte' , _('Use for a plaintiff against whom an appeal is taken from one court or jurisdiction to another to reverse the judgment, usually in a legal proceeding.')), 476 | ('plt' , _('Use for a person or organization responsible for the production of plates, usually for the production of printed images and/or text.')), 477 | ('pra' , _('A person who is the faculty moderator of an academic disputation, normally proposing a thesis and participating in the ensuing disputation.')), 478 | ('pre' , _("A person or organization mentioned in an 'X presents' credit for moving image materials and who is associated with production, finance, or distribution in some way. A vanity credit; in early years, normally the head of a studio.")), 479 | ('prt' , _('Use for a person or organization who prints texts, whether from type or plates.')), 480 | ('pop' , _('Use for a person or organization who prints illustrations from plates.')), 481 | ('prm' , _('Use for a person or organization who makes a relief, intaglio, or planographic printing surface.')), 482 | ('prc' , _('Use for a person or organization primarily responsible for performing or initiating a process, such as is done with the collection of metadata sets.')), 483 | ('pro' , _('Use for a person or organization responsible for the making of a motion picture, including business aspects, management of the productions, and the commercial success of the work.')), 484 | ('prn' , _('An organization that is responsible for financial, technical, and organizational management of a production for stage, screen, audio recording, television, webcast, etc.')), 485 | ('prs' , _('A person or organization responsible for designing the overall visual appearance of a moving image production.')), 486 | ('pmn' , _('Use for a person responsible for all technical and business matters in a production.')), 487 | ('prd' , _('Use for a person or organization associated with the production (props, lighting, special effects, etc.) of a musical or dramatic presentation or entertainment.')), 488 | ('prp' , _('The place of production (e.g., inscription, fabrication, construction, etc.) of a resource in an unpublished form.')), 489 | ('prg' , _('Use for a person or organization responsible for the creation and/or maintenance of computer program design documents, source code, and machine-executable digital files and supporting documentation.')), 490 | ('pdr' , _('Use for a person or organization with primary responsibility for all essential aspects of a project, or that manages a very large project that demands senior level responsibility, or that has overall responsibility for managing projects, or provides overall direction to a project manager.')), 491 | ('pfr' , _('Use for a person who corrects printed matter. For manuscripts, use Corrector [crr].')), 492 | ('prv' , _('A person or organization who produces, publishes, manufactures, or distributes a resource if specific codes are not desired (e.g. [mfr], [pbl].)')), 493 | ('pup' , _('The place where a resource is published.')), 494 | ('pbl' , _('Use for a person or organization that makes printed matter, often text, but also printed music, artwork, etc. available to the public.')), 495 | ('pbd' , _('Use for a person or organization who presides over the elaboration of a collective work to ensure its coherence or continuity. This includes editors-in-chief, literary editors, editors of series, etc.')), 496 | ('ppt' , _('Use for a person or organization who manipulates, controls, or directs puppets or marionettes in a musical or dramatic presentation or entertainment.')), 497 | ('rdd' , _('A director responsible for the general management and supervision of a radio program.')), 498 | ('rpc' , _('A producer responsible for most of the business aspects of a radio program.')), 499 | ('rcp' , _('Use for a person or organization to whom correspondence is addressed.')), 500 | ('rce' , _('Use for a person or organization who supervises the technical aspects of a sound or video recording session.')), 501 | ('rce' , _('A person contributing to a resource by supervising the technical aspects of a sound or video recording session.')), 502 | ('red' , _('Use for a person or organization who writes or develops the framework for an item without being intellectually responsible for its content.')), 503 | ('ren' , _('Use for a person or organization who prepares drawings of architectural designs (i.e., renderings) in accurate, representational perspective to show what the project will look like when completed.')), 504 | ('rpt' , _('Use for a person or organization who writes or presents reports of news or current events on air or in print.')), 505 | ('rps' , _('Use for an agency that hosts data or material culture objects and provides services to promote long term, consistent and shared use of those data or objects.')), 506 | ('rth' , _('Use for a person who directed or managed a research project.')), 507 | ('rtm' , _('Use for a person who participated in a research project but whose role did not involve direction or management of it.')), 508 | ('res' , _('Use for a person or organization responsible for performing research.')), 509 | ('rsp' , _('Use for the party who makes an answer to the courts pursuant to an application for redress, usually in an equity proceeding.')), 510 | ('rst' , _('Use for a respondent who takes an appeal from one court or jurisdiction to another to reverse the judgment, usually in an equity proceeding.')), 511 | ('rse' , _('Use for a respondent against whom an appeal is taken from one court or jurisdiction to another to reverse the judgment, usually in an equity proceeding.')), 512 | ('rpy' , _('Use for a person or organization legally responsible for the content of the published material.')), 513 | ('rsg' , _('Use for a person or organization, other than the original choreographer or director, responsible for restaging a choreographic or dramatic work and who contributes minimal new content.')), 514 | ('rsr' , _('A person, family, or organization responsible for the set of technical, editorial, and intellectual procedures aimed at compensating for the degradation of an item by bringing it back to a state as close as possible to its original condition.')), 515 | ('rev' , _('Use for a person or organization responsible for the review of a book, motion picture, performance, etc.')), 516 | ('rbr' , _('Use for a person or organization responsible for parts of a work, often headings or opening parts of a manuscript, that appear in a distinctive color, usually red.')), 517 | ('sce' , _('Use for a person or organization who is the author of a motion picture screenplay.')), 518 | ('sad' , _('Use for a person or organization who brings scientific, pedagogical, or historical competence to the conception and realization on a work, particularly in the case of audio-visual items.')), 519 | ('scr' , _('Use for a person who is an amanuensis and for a writer of manuscripts proper. For a person who makes pen-facsimiles, use Facsimilist [fac].')), 520 | ('scl' , _('Use for a person or organization who models or carves figures that are three-dimensional representations.')), 521 | ('spy' , _('Use for a person or organization who is identified as the party of the second part. In the case of transfer of right, this is the assignee, transferee, licensee, grantee, etc. Multiple parties can be named jointly as the second party.')), 522 | ('sec' , _('Use for a person or organization who is a recorder, redactor, or other person responsible for expressing the views of a organization.')), 523 | ('sll' , _('A former owner of an item who sold that item to another owner.')), 524 | ('std' , _('Use for a person or organization who translates the rough sketches of the art director into actual architectural structures for a theatrical presentation, entertainment, motion picture, etc. Set designers draw the detailed guides and specifications for building the set.')), 525 | ('stg' , _('An entity in which the activity or plot of a work takes place, e.g. a geographic place, a time period, a building, an event.')), 526 | ('sgn' , _('Use for a person whose signature appears without a presentation or other statement indicative of provenance. When there is a presentation statement, use Inscriber [ins].')), 527 | ('sng' , _('Use for a person or organization who uses his/her/their voice with or without instrumental accompaniment to produce music. A performance may or may not include actual words.')), 528 | ('sds' , _('Use for a person who produces and reproduces the sound score (both live and recorded), the installation of microphones, the setting of sound levels, and the coordination of sources of sound for a production.')), 529 | ('spk' , _('Use for a person who participates in a program (often broadcast) and makes a formalized contribution or presentation generally prepared in advance.')), 530 | ('spn' , _('Use for a person or organization that issued a contract or under the auspices of which a work has been written, printed, published, etc.')), 531 | ('sgd' , _('A person or organization contributing to a stage resource through the overall management and supervision of a performance.')), 532 | ('stm' , _('Use for a person who is in charge of everything that occurs on a performance stage, and who acts as chief of all crews and assistant to a director during rehearsals.')), 533 | ('stn' , _('Use for an organization responsible for the development or enforcement of a standard.')), 534 | ('str' , _('Use for a person or organization who creates a new plate for printing by molding or copying another printing surface.')), 535 | ('stl' , _('Use for a person relaying a story with creative and/or theatrical interpretation.')), 536 | ('sht' , _('Use for a person or organization that supports (by allocating facilities, staff, or other resources) a project, program, meeting, event, data objects, material culture objects, or other entities capable of support.')), 537 | ('srv' , _('Use for a person or organization who does measurements of tracts of land, etc. to determine location, forms, and boundaries.')), 538 | ('tch' , _('Use for a person who, in the context of a resource, gives instruction in an intellectual subject or demonstrates while teaching physical skills.')), 539 | ('tcd' , _('Use for a person who is ultimately in charge of scenery, props, lights and sound for a production.')), 540 | ('tld' , _('A director responsible for the general management and supervision of a television program.')), 541 | ('tlp' , _('A producer responsible for most of the business aspects of a television program.')), 542 | ('ths' , _('Use for a person under whose supervision a degree candidate develops and presents a thesis, mémoire, or text of a dissertation.')), 543 | ('trc' , _('Use for a person who prepares a handwritten or typewritten copy from original material, including from dictated or orally recorded material. For makers of pen-facsimiles, use Facsimilist [fac].')), 544 | ('trl' , _('Use for a person or organization who renders a text from one language into another, or from an older form of a language into the modern form.')), 545 | ('tyd' , _('Use for a person or organization who designed the type face used in a particular item.')), 546 | ('tyg' , _('Use for a person or organization primarily responsible for choice and arrangement of type used in an item. If the typographer is also responsible for other aspects of the graphic design of a book (e.g., Book designer [bkd]), codes for both functions may be needed.')), 547 | ('uvp' , _('A place where a university that is associated with a resource is located, for example, a university where an academic dissertation or thesis was presented.')), 548 | ('vdg' , _('Use for a person or organization in charge of a video production, e.g. the video recording of a stage production as opposed to a commercial motion picture. The videographer may be the camera operator or may supervise one or more camera operators. Do not confuse with cinematographer.')), 549 | ('vac' , _('An actor contributing to a resource by providing the voice for characters in radio and audio productions and for animated characters in moving image works, as well as by providing voice overs in radio and television commercials, dubbed resources, etc.')), 550 | ('wit' , _('Use for a person who verifies the truthfulness of an event or action.')), 551 | ('wde' , _('Use for a person or organization who makes prints by cutting the image in relief on the end-grain of a wood block.')), 552 | ('wdc' , _('Use for a person or organization who makes prints by cutting the image in relief on the plank side of a wood block.')), 553 | ('wam' , _('Use for a person or organization who writes significant material which accompanies a sound recording or other audiovisual material.')), 554 | ('wac' , _('A person, family, or organization contributing to an expression of a work by providing an interpretation or critical explanation of the original work.')), 555 | ('wal' , _('A writer of words added to an expression of a musical work. For lyric writing in collaboration with a composer to form an original work, see lyricist.')), 556 | ('wat' , _('A person, family, or organization contributing to a non-textual resource by providing text for the non-textual work (e.g., writing captions for photographs, descriptions of maps.)')), 557 | ('win' , _('A person, family, or organization contributing to a resource by providing an introduction to the original work.')), 558 | ('wpr' , _('A person, family, or organization contributing to a resource by providing a preface to the original work.')), 559 | ('wst' , _('A person, family, or organization contributing to a resource by providing supplementary textual content (e.g., an introduction, a preface) to the original work.')), 560 | ]) 561 | -------------------------------------------------------------------------------- /plugin-import-name-epub_extended_metadata.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [project] 2 | name = "ePub Extended Metadata" 3 | requires-python = ">=3.8" 4 | 5 | [tool.ruff] 6 | exclude = ["common_utils/"] 7 | line-length = 120 8 | target-version = "py38" 9 | builtins = ['_', 'I', 'P'] 10 | preview = true 11 | 12 | [tool.ruff.lint] 13 | explicit-preview-rules = true 14 | ignore = [ 15 | 'E741', 'E402', 'E722', 'W293', 16 | 'UP012', 'UP030', 'UP032', 'C413', 'C420', 'PIE790', 'ISC003', 17 | 'RUF001', 'RUF002', 'RUF003', 'RUF005', 'RUF012', 'RUF013', 'RUF015', 'RUF100', 18 | 'F841', # because in preview, unused tuple unpacking variable that not use dummy syntax (prefix '_' underscore) 19 | # raise error 'unused-variable', sigh (https://github.com/astral-sh/ruff/issues/8884) 20 | ] 21 | select = [ 22 | 'E', 'F', 'I', 'W', 'INT', 23 | 'Q', 'UP', 'YTT', 'C4', 'COM818', 'PIE', 'RET501', 'ISC', 24 | 'RUF', # nota: RUF can flag many unsolicited errors 25 | # preview rules 26 | 'RUF051', 'RUF056', # useless dict operation 27 | 'RUF055', # unnecessary regex 28 | 'RUF039', # always use raw-string for regex 29 | 'E302', 'E303', 'E304', 'E305', 'W391', # blank-line standard 30 | 'E111', 'E112', 'E113', 'E117', # code indentation 31 | 'E114', 'E115', 'E116', 'E261', 'E262', 'E265', # comment formating 32 | 'E201', 'E202', 'E211', 'E251', 'E275', # + partial: 'E203', 'E222', 'E241', 'E271', 'E272' # various whitespace 33 | ] 34 | unfixable = ['ISC001'] 35 | 36 | [tool.ruff.lint.per-file-ignores] 37 | "marc_relators.py" = ['E501'] 38 | 39 | [tool.ruff.format] 40 | quote-style = 'single' 41 | 42 | [tool.ruff.lint.isort] 43 | detect-same-package = true 44 | known-first-party = ["calibre", "calibre_extensions", "calibre_plugins", "polyglot"] 45 | known-third-party = ["qt"] 46 | relative-imports-order = "closest-to-furthest" 47 | split-on-trailing-comma = false 48 | section-order = ["__python__", "future", "standard-library", "third-party", "first-party", "local-folder"] 49 | 50 | [tool.ruff.lint.isort.sections] 51 | "__python__" = ["__python__"] 52 | 53 | [tool.ruff.lint.flake8-comprehensions] 54 | allow-dict-calls-with-keyword-arguments = true 55 | 56 | [tool.ruff.lint.flake8-quotes] 57 | avoid-escape = true 58 | docstring-quotes = 'single' 59 | inline-quotes = 'single' 60 | multiline-quotes = 'single' 61 | -------------------------------------------------------------------------------- /reader/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | __license__ = 'GPL v3' 4 | __copyright__ = '2021, un_pogaz ' 5 | 6 | 7 | # The class that all Interface Action plugin wrappers must inherit from 8 | from calibre.customize import MetadataReaderPlugin 9 | 10 | 11 | class MetadataReader(MetadataReaderPlugin): 12 | ''' 13 | A plugin that implements reading metadata from a set of file types. 14 | ''' 15 | # plugin attributs are set during the initialization in ePubExtendedMetadata 16 | 17 | def get_metadata(self, stream, type): 18 | ''' 19 | Return metadata for the file represented by stream (a file like object 20 | that supports reading). Raise an exception when there is an error 21 | with the input data. 22 | 23 | :param type: The type of file. Guaranteed to be one of the entries 24 | in :attr:`file_types`. 25 | :return: A :class:`calibre.ebooks.metadata.book.Metadata` object 26 | ''' 27 | from calibre.customize.builtins import EPUBMetadataReader 28 | from calibre.customize.ui import find_plugin, quick_metadata 29 | 30 | from ..common_utils import get_plugin_attribut 31 | 32 | # Use the Calibre EPUBMetadataReader 33 | if hasattr(stream, 'seek'): 34 | stream.seek(0) 35 | calibre_reader = find_plugin(EPUBMetadataReader.name) 36 | calibre_reader.quick = quick_metadata.quick 37 | mi = calibre_reader.get_metadata(stream, type) 38 | 39 | if find_plugin(get_plugin_attribut('name')): 40 | if hasattr(stream, 'seek'): 41 | stream.seek(0) 42 | from ..action import read_metadata 43 | return read_metadata(stream, type, mi) 44 | else: 45 | return mi 46 | 47 | def is_customizable(self): 48 | ''' 49 | This method must return True to enable customization via 50 | Preferences->Plugins 51 | ''' 52 | return True 53 | 54 | def config_widget(self): 55 | from ..config import ConfigReaderWidget 56 | return ConfigReaderWidget() 57 | 58 | def save_settings(self, config_widget): 59 | config_widget.save_settings() 60 | -------------------------------------------------------------------------------- /readme.bbcode: -------------------------------------------------------------------------------- 1 | [I]ePub Extended Metadata[/I] is a plugin whose objective is to allow to read and write a wider range of ePub metadata according to the ePub standard. 2 | 3 | [LIST] 4 | [*]Read and write contributors in columns (type names) 5 | [/LIST] 6 | 7 | Once the different metadata is set, you will be able to import or embed its advanced metadata in your ePub in one click. 8 | 9 | It is also possible to activate the automatic import/reading of its metadata when adding a book to your library. 10 | Also, it is possible to activate a automatic integration of them at the same time as the default Calibre Embed action, without having to specifically activate. 11 | Of course, other metadata not set in your plugin are kept. 12 | 13 | [B]Note:[/B] 14 | [LIST=1] 15 | [*]the setting of "ePub Extended Metadata" is done by [I]Library[/I]. 16 | [*]"ePub Extended Metadata" came with 2 companion plugin "ePub Extended Metadata {Reader}" and "ePub Extended Metadata {Writer}" that are auto-installed, so do not be surprised to see them appear, it means the plugin has been properly installed. 17 | [*]The plugin use customs colums "Comma separated text, like tags", with the option "Contains names" checked to make the value separated by a Ampersand & (like Authors). 18 | [/LIST] 19 | 20 | [B]Credits:[/B] 21 | [LIST] 22 | [*]The MARC Code associated name and decriptions are extracted from the [url="https://github.com/Sigil-Ebook/Sigil"]Sigil[/url] code source (with minor edit) 23 | [*]Some translation of the MARC Code are also based on the translation made for [url="https://www.transifex.com/zdpo/sigil/dashboard/"]Sigil[/url] (language: FR) 24 | [/LIST] 25 | 26 | [B]Installation[/B] 27 | Open [I]Preferences -> Plugins -> Get new plugins[/I] and install the "ePub Extended Metadata" plugin. 28 | You may also download the attached zip file and install the plugin manually, then restart calibre as described in the [URL="https://www.mobileread.com/forums/showthread.php?t=118680"]Introduction to plugins thread[/URL] 29 | 30 | The plugin works for Calibre 5 and later. 31 | 32 | Page: [URL=https://github.com/un-pogaz/ePub-Extended-Metadata]GitHub[/URL] | [URL=https://www.mobileread.com/forums/showthread.php?t=345069]MobileRead[/URL] 33 | 34 | [U]Note for those who wish to provide a translation:[/U] 35 | I am [I]French[/I]! Although for obvious reasons, the default language of the plugin is English, keep in mind that already a translation. 36 | -------------------------------------------------------------------------------- /static/ePub_Extended_Metadata-reader.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/un-pogaz/ePub-Extended-Metadata/a9507f53f0ddc68d437e7c5d27d9dc46871c4df4/static/ePub_Extended_Metadata-reader.png -------------------------------------------------------------------------------- /static/ePub_Extended_Metadata.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/un-pogaz/ePub-Extended-Metadata/a9507f53f0ddc68d437e7c5d27d9dc46871c4df4/static/ePub_Extended_Metadata.png -------------------------------------------------------------------------------- /writer/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | __license__ = 'GPL v3' 4 | __copyright__ = '2021, un_pogaz ' 5 | 6 | 7 | # The class that all Interface Action plugin wrappers must inherit from 8 | from calibre.customize import MetadataWriterPlugin 9 | 10 | 11 | class MetadataWriter(MetadataWriterPlugin): 12 | ''' 13 | A plugin that implements reading metadata from a set of file types. 14 | ''' 15 | # plugin attributs are set during the initialization in ePubExtendedMetadata 16 | 17 | def set_metadata(self, stream, mi, type): 18 | ''' 19 | Set metadata for the file represented by stream (a file like object 20 | that supports reading). Raise an exception when there is an error 21 | with the input data. 22 | 23 | :param type: The type of file. Guaranteed to be one of the entries 24 | in :attr:`file_types`. 25 | :param mi: A :class:`calibre.ebooks.metadata.book.Metadata` object 26 | ''' 27 | from calibre.customize.builtins import EPUBMetadataWriter 28 | from calibre.customize.ui import apply_null_metadata, config, find_plugin, force_identifiers 29 | 30 | from ..common_utils import get_plugin_attribut 31 | 32 | # Use the Calibre EPUBMetadataWriter 33 | if hasattr(stream, 'seek'): 34 | stream.seek(0) 35 | calibre_writer = find_plugin(EPUBMetadataWriter.name) 36 | calibre_writer.apply_null = apply_null_metadata.apply_null 37 | calibre_writer.force_identifiers = force_identifiers.force_identifiers 38 | calibre_writer.site_customization = config['plugin_customization'].get(calibre_writer.name, '') 39 | calibre_writer.set_metadata(stream, mi, type) 40 | 41 | if find_plugin(get_plugin_attribut('name')): 42 | if hasattr(stream, 'seek'): 43 | stream.seek(0) 44 | from ..action import write_metadata 45 | write_metadata(stream, type, mi) 46 | 47 | def is_customizable(self): 48 | ''' 49 | This method must return True to enable customization via 50 | Preferences->Plugins 51 | ''' 52 | return True 53 | 54 | def config_widget(self): 55 | from calibre.customize.ui import find_plugin 56 | 57 | from ..common_utils import get_plugin_attribut 58 | return find_plugin(get_plugin_attribut('name')).config_widget() 59 | 60 | def save_settings(self, config_widget): 61 | config_widget.save_settings() 62 | --------------------------------------------------------------------------------