Class-reference#

ecmbBook#

class ecmblib.ecmb_book.ecmbBook(book_type: BOOK_TYPE, language: LANGUAGE_CODE, uid: str, width: int, height: int)#

The main class to genererate *.ecmb - files

Note:

  • the title is mandatory, so please call book.metadata.set_title(‘My Title’)

  • the width and height “should” be the size of the images. It not exact, coz when I was building fan-translated Mangas, all images had a different size and aspect-ratio, but the aspect-ratio is enterly important for the validator to validate the correct placement of double-page-images. (Formula: id_double = (img_width / img_height) > (book_width / book_height * 1.5))

  • chapters with an uneven page-count are supported, also double-pages on an uneven page and uneven page-count of the book … of course you will get a warning

  • All functions in the library will raise an ecmbException on invalid values!

Parameters:
  • book_type (BOOK_TYPE) – the book-type defines the reading-direction of the book

  • language (str) – language of the content (ISO 639-1 language-code)

  • uid (str) – unique-id of the book (minlength: 16, maxlength:255)

  • width (int) – approximately width of the images

  • height (int) – approximately height of the images

property metadata: ecmbMetaData#

You can add the book’s meta-data like title, genres, … to ecmbMetaData

Return type:

ecmbMetaData

property original: ecmbMetaDataOriginal#

alias for ecmbMetaData.original

If the book was (fan-) translated you can add the information for the original book to ecmbMetaDataOriginal.

Return type:

ecmbMetaDataOriginal

property based_on: ecmbMetaDataBasedOn#

alias for ecmbMetaData.based_on

If the book based on eg. a light-novel and you want to give that credit, you can add the information to ecmbMetaDataBasedOn

Return type:

ecmbMetaDataBasedOn

property content: ecmbContent#

Add folders and images to ecmbContent

Return type:

ecmbContent

property navigation: ecmbNavigation#

Add Chapters, Headlines or Links to ecmbNavigation

Return type:

ecmbNavigation

write(file_name: str, warnings: bool | Callable = True, demo_mode: bool = False) None#
Parameters:
  • file_name (str) –

  • warnings (bool | Callable, optional) – defines if warnings should be printed to the console or not or alternatively use a callback-function myfunc(msg)

  • demo_mode (bool, optional) – in demo-mode the generated file will be automaticaly unszipped

Meta-Data#

ecmbMetaData#

class ecmblib.lib.ecmb_metadata.ecmbMetaData#

Here you can add the book’s main meta-data.

If the book was (fan-) translated you can add the information for the original book to ecmbMetaDataOriginal. Its reccomended to add the authors to the original book, and leave them empty here at main meta-data.

Note:

  • the title is mandatory

property original: ecmbMetaDataOriginal#

If the book was (fan-) translated you can add the information for the original book to ecmbMetaDataOriginal. Its reccomended to add the authors to the original book, and leave them empty here at main meta-data.

Return type:

ecmbMetaDataOriginal

property based_on: ecmbMetaDataBasedOn#

If the book based on eg. a light-novel and you want to give that credit, you can add the information to ecmbMetaDataBasedOn

Return type:

ecmbMetaDataBasedOn

set_title(title: str) None#
Parameters:

title (str) – the title of the book

set_volume(volume: int) None#
Parameters:

volume (int) – if its a series of books you should set the volume-number

set_summary(summary: str) None#
Parameters:

summary (str) – the book’s summary in the book’s language

set_pages(pages: int) None#
Parameters:

pages (str) – the book’s page-count

set_notes(notes: str) None#
Parameters:

notes (str) – personal notes you would like to add

add_editor(name: str, role: EDITOR_ROLE, href: str = None) None#

If it’s an (fan-)translated book you can add the editor-credits here

Parameters:
  • name (str) – the name of the editor

  • role (EDITOR_ROLE) – the role of the editor

  • href (str, optional) – the homepage of the editor

add_genre(genre: str) None#
Parameters:

genre (str) – add the genre in the book’s language

add_content_warning(content_warning: CONTENT_WARNING) None#

Use content-based warnings for using safe-guard if necessary

Parameters:

content_warning (CONTENT_WARNING) – content-based warning

add_author(name: str, role: AUTHOR_ROLE = AUTHOR_ROLE.AUTHOR, href: str = None) None#
Parameters:
  • name (str) – the name of the author

  • role (AUTHOR_ROLE, optional) – the role of the author

  • href (str, optional) – the homepage of the author

set_isbn(isbn: str) None#
Parameters:

isbn (str) – isbn-10 or isbn-13

set_publishdate(publishdate: str) None#
Parameters:

publishdate (str) – the publishe-date of the book (YYYY-MM-DD or YYYY)

set_publisher(publisher: str, href: str = None) None#
Parameters:
  • publisher (str) – the name of the publisher

  • href (str, optional) – the homepage of the publisher

ecmbMetaDataOriginal#

class ecmblib.lib.ecmb_metadata_original.ecmbMetaDataOriginal#

If the book was (fan-) translated you can place the data of the original book here. Its reccomended to add the authors here and leave the authors at the main meta-data empty

Note:

  • if you add any original book’s metadata the title is mandatory

set_language(language: LANGUAGE_CODE) None#
Parameters:

language (str) – the language of the book

set_title(title: str) None#
Parameters:

title (str) – the title of the book

add_author(name: str, role: AUTHOR_ROLE = AUTHOR_ROLE.AUTHOR, href: str = None) None#
Parameters:
  • name (str) – the name of the author

  • role (AUTHOR_ROLE, optional) – the role of the author

  • href (str, optional) – the homepage of the author

set_isbn(isbn: str) None#
Parameters:

isbn (str) – isbn-10 or isbn-13

set_publishdate(publishdate: str) None#
Parameters:

publishdate (str) – the publishe-date of the book (YYYY-MM-DD or YYYY)

set_publisher(publisher: str, href: str = None) None#
Parameters:
  • publisher (str) – the name of the publisher

  • href (str, optional) – the homepage of the publisher

ecmbMetaDataBasedOn#

class ecmblib.lib.ecmb_metadata_based_on.ecmbMetaDataBasedOn#

If the book based on eg. a light-novel and you want to give that credit, you can place the information here.

Note:

  • if you add any to this, the title is mandatory

set_type(book_type: BASED_ON_TYPE) None#
Parameters:

book_type (BASED_ON_TYPE) –

add_author(name: str, role: AUTHOR_ROLE = AUTHOR_ROLE.AUTHOR, href: str = None) None#
Parameters:
  • name (str) – the name of the author

  • role (AUTHOR_ROLE, optional) – the role of the author

  • href (str, optional) – the homepage of the author

set_isbn(isbn: str) None#
Parameters:

isbn (str) – isbn-10 or isbn-13

set_language(language: LANGUAGE_CODE) None#
Parameters:

language (str) – the language of the book

set_publishdate(publishdate: str) None#
Parameters:

publishdate (str) – the publishe-date of the book (YYYY-MM-DD or YYYY)

set_publisher(publisher: str, href: str = None) None#
Parameters:
  • publisher (str) – the name of the publisher

  • href (str, optional) – the homepage of the publisher

set_title(title: str) None#
Parameters:

title (str) – the title of the book

Content#

ecmbContent#

class ecmblib.lib.ecmb_content.ecmbContent(book_obj)#

This is the root-node of the book’s contents.

If you want to use chapters (and subchapters) in navigation you have to organize the images in folders, coz a chapter points to a folder. You can add images directly to the root as well for example the introduction, table of contents, spacer-images between the chapters, …

set_cover_front(src: str | BytesIO) None#
Parameters:

src (str | BytesIO) – the front-cover of the book

set_cover_rear(src: str | BytesIO) None#
Parameters:

src (str | BytesIO) – the rear-cover of the book

add_folder(uid_or_folder: str | ecmbContentFolder = None) ecmbContentFolder#

Adds/creates an (sub-)folder. If you want to use chapters (and subchapters) in navigation you have to organize the images in folders, coz a chapter points to a folder.

Note:

  • because the class will generate internal names no name is necesary

  • provide a unique-id if you want to access this folder easily later at navigation

Parameters:

uid_or_folder (str | ecmbContentFolder, optional) – an unique-id or a previously created ecmbContentFolder

Return type:

ecmbContentFolder

add_image(src_or_image: str | BytesIO | ecmbContentImage, unique_id: str = None) ecmbContentImage#

Adds/creates an image

Note:

  • provide a unique-id if you want to access this image easily later at navigation

  • if you add a previously created ecmbContentImage all other parameters are ignored

Parameters:
  • src_or_image (str | BytesIO | ecmbContentImage) – an image (single-page or double-page) or a previously created ecmbContentImage

  • unique_id (str, optional) – provide a unique-id if you want to access this image easily later at navigation

Return type:

ecmbContentImage

ecmbContentFolder#

class ecmblib.lib.ecmb_content_folder.ecmbContentFolder(book_obj, unique_id: str = None)#

If you want to use chapters (and subchapters) in navigation you have to organize the images in folders, coz a chapter points to a folder.

Note:

  • because the class will generate internal names no name is necesary

  • provide a unique-id if you want to access this folder easily later at navigation

Parameters:
  • book_obj (ecmbBook) –

  • unique_id (str, optional) – provide a unique-id if you want to access this folder easily later at navigation

add_folder(uid_or_folder: str | ecmbContentFolder = None) ecmbContentFolder#

Adds/creates an (sub-)folder. If you want to use chapters (and subchapters) in navigation you have to organize the images in folders, coz a chapter points to a folder.

Note:

  • because the class will generate internal names no name is necesary

  • provide a unique-id if you want to access this folder easily later at navigation

Parameters:

uid_or_folder (str | ecmbContentFolder, optional) – an unique-id or a previously created ecmbContentFolder

Return type:

ecmbContentFolder

add_image(src_or_image: str | BytesIO | ecmbContentImage, unique_id: str = None) ecmbContentImage#

Adds/creates an image

Note:

  • provide a unique-id if you want to access this image easily later at navigation

  • if you add a previously created ecmbContentImage all other parameters are ignored

Parameters:
  • src_or_image (str | BytesIO | ecmbContentImage) – an image (single-page or double-page) or a previously created ecmbContentImage

  • unique_id (str, optional) – provide a unique-id if you want to access this image easily later at navigation

Return type:

ecmbContentImage

get_unique_id() str#
Returns:

returns the unique-id of the object

Return type:

str

ecmbContentImage#

class ecmblib.lib.ecmb_content_image.ecmbContentImage(book_obj, src: str | BytesIO, unique_id: str = None)#
Note:

  • provide a unique-id if you want to access this image easily later at navigation

Parameters:
  • book_obj (ecmbBook) –

  • src (str | BytesIO) – an image (single-page or double-page)

  • unique_id (str, optional) – provide a unique-id if you want to access this image easily later at navigation

get_unique_id() str#
Returns:

returns the unique-id of the object

Return type:

str

Misc#

Enums#

class ecmblib.lib.ecmb_enums.ALLOWED_IMAGE_EXTENTIONS(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)#
  • JPG = ‘jpg’

  • JPEG = ‘jpeg’

  • PNG = ‘png’

  • WEBP = ‘webp’

class ecmblib.lib.ecmb_enums.BOOK_TYPE(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)#
  • MANGA = ‘manga’

  • COMIC = ‘comic’

class ecmblib.lib.ecmb_enums.BASED_ON_TYPE(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)#
  • NOVEL = ‘Novel’

  • LIGHTNOVEL = ‘Lightnovel’

  • MANGA = ‘Manga’

  • COMIC = ‘Comic’

  • ANIME = ‘Anime’

  • GAME = ‘Game’

  • OTHER =’Other’

class ecmblib.lib.ecmb_enums.AUTHOR_ROLE(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)#
  • AUTHOR = ‘Author’

  • COAUTHOR = ‘Co-Author’

  • STORY = ‘Story’

  • ART = ‘Art’

  • COLORIST = ‘Colorist’

  • COVERARTIST = ‘CoverArtist’

class ecmblib.lib.ecmb_enums.EDITOR_ROLE(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)#
  • TRANSLATOR = ‘Translator’

  • SCANNER = ‘Scanner’

class ecmblib.lib.ecmb_enums.CONTENT_WARNING(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)#
  • ADULT = ‘Adult’

  • MATURE_THEMES = ‘Mature Themes’

  • NUDITY = ‘Nudity’

  • SEXUAL_CONTENT = ‘Sexual Content’

  • EXPLICIT_SEX = ‘Explict Sex’

  • HENTAI = ‘Hentai’

  • PROSTITUTION = ‘Prostitution’

  • INCEST = ‘Incest’

  • VIOLENCE = ‘Violence’

  • EXPLICIT_VIOLENCE = ‘Explicit Violence’

  • TERRORISM = ‘Terrorism’

  • EMOTIONAL_ABUSE= ‘Emotional Abuse’

  • SEXUAL_ABUSE = ‘Sexual Abuse’

  • PHYSICAL_ABUSE = ‘Physical Abuse’

  • DOMESTIC_ABUSE = ‘Domestic Abuse’

  • SELF_HARM = ‘Self-Harm’

  • SUICIDE = ‘Suicide’

  • DRUGS = ‘Drugs’

class ecmblib.lib.ecmb_enums.TARGET_SIDE(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)#
  • AUTO = ‘auto’

  • LEFT = ‘left’

  • RIGHT = ‘right’

class ecmblib.lib.ecmb_enums.LANGUAGE_CODE(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)#
  • Afar = ‘aa’

  • Abkhaz = ‘ab’

  • Avestan = ‘ae’

  • Afrikaans = ‘af’

  • Akan = ‘ak’

  • Amharic = ‘am’

  • Aragonese = ‘an’

  • Arabic = ‘ar’

  • Assamese = ‘as’

  • Avaric = ‘av’

  • Aymara = ‘ay’

  • Azerbaijani = ‘az’

  • Bashkir = ‘ba’

  • Belarusian = ‘be’

  • Bulgarian = ‘bg’

  • Bislama = ‘bi’

  • Bambara = ‘bm’

  • Bengali = ‘bn’

  • Tibetan = ‘bo’

  • Breton = ‘br’

  • Bosnian = ‘bs’

  • Catalan = ‘ca’

  • Chechen = ‘ce’

  • Chamorro = ‘ch’

  • Corsican = ‘co’

  • Cree = ‘cr’

  • Czech = ‘cs’

  • Old_Church_Slavonic = ‘cu’

  • Chuvash = ‘cv’

  • Welsh = ‘cy’

  • Danish = ‘da’

  • German = ‘de’

  • Divehi = ‘dv’

  • Dzongkha = ‘dz’

  • Ewe = ‘ee’

  • Greek = ‘el’

  • English = ‘en’

  • Esperanto = ‘eo’

  • Spanish = ‘es’

  • Estonian = ‘et’

  • Basque = ‘eu’

  • Persian = ‘fa’

  • Fula = ‘ff’

  • Finnish = ‘fi’

  • Fijian = ‘fj’

  • Faroese = ‘fo’

  • French = ‘fr’

  • Western_Frisian = ‘fy’

  • Irish = ‘ga’

  • Scottish_Gaelic = ‘gd’

  • Galician = ‘gl’

  • Guaraní = ‘gn’

  • Gujarati = ‘gu’

  • Manx = ‘gv’

  • Hausa = ‘ha’

  • Hebrew = ‘he’

  • Hindi = ‘hi’

  • Hiri_Motu = ‘ho’

  • Croatian = ‘hr’

  • Haitian = ‘ht’

  • Hungarian = ‘hu’

  • Armenian = ‘hy’

  • Herero = ‘hz’

  • Interlingua = ‘ia’

  • Indonesian = ‘id’

  • Interlingue = ‘ie’

  • Igbo = ‘ig’

  • Nuosu = ‘ii’

  • Inupiaq = ‘ik’

  • Ido = ‘io’

  • Icelandic = ‘is’

  • Italian = ‘it’

  • Inuktitut = ‘iu’

  • Japanese = ‘ja’

  • Javanese = ‘jv’

  • Georgian = ‘ka’

  • Kongo = ‘kg’

  • Kikuyu = ‘ki’

  • Kwanyama = ‘kj’

  • Kazakh = ‘kk’

  • Kalaallisut = ‘kl’

  • Khmer = ‘km’

  • Kannada = ‘kn’

  • Korean = ‘ko’

  • Kanuri = ‘kr’

  • Kashmiri = ‘ks’

  • Kurdish = ‘ku’

  • Komi = ‘kv’

  • Cornish = ‘kw’

  • Kyrgyz = ‘ky’

  • Latin = ‘la’

  • Luxembourgish = ‘lb’

  • Ganda = ‘lg’

  • Limburgish = ‘li’

  • Lingala = ‘ln’

  • Lao = ‘lo’

  • Lithuanian = ‘lt’

  • Luba_Katanga = ‘lu’

  • Latvian = ‘lv’

  • Malagasy = ‘mg’

  • Marshallese = ‘mh’

  • Māori = ‘mi’

  • Macedonian = ‘mk’

  • Malayalam = ‘ml’

  • Mongolian = ‘mn’

  • Marathi = ‘mr’

  • Malay = ‘ms’

  • Maltese = ‘mt’

  • Burmese = ‘my’

  • Nauru = ‘na’

  • Norwegian_Bokmål = ‘nb’

  • Northern_Ndebele = ‘nd’

  • Nepali = ‘ne’

  • Ndonga = ‘ng’

  • Dutch = ‘nl’

  • Norwegian_Nynorsk = ‘nn’

  • Norwegian = ‘no’

  • Southern_Ndebele = ‘nr’

  • Navajo = ‘nv’

  • Chichewa = ‘ny’

  • Occitan = ‘oc’

  • Ojibwe = ‘oj’

  • Oromo = ‘om’

  • Oriya = ‘or’

  • Ossetian = ‘os’

  • Panjabi = ‘pa’

  • Pāli = ‘pi’

  • Polish = ‘pl’

  • Pashto = ‘ps’

  • Portuguese = ‘pt’

  • Quechua = ‘qu’

  • Romansh = ‘rm’

  • Kirundi = ‘rn’

  • Romanian = ‘ro’

  • Russian = ‘ru’

  • Kinyarwanda = ‘rw’

  • Sanskrit = ‘sa’

  • Sardinian = ‘sc’

  • Sindhi = ‘sd’

  • Northern_Sami = ‘se’

  • Sango = ‘sg’

  • Sinhala = ‘si’

  • Slovak = ‘sk’

  • Slovenian = ‘sl’

  • Samoan = ‘sm’

  • Shona = ‘sn’

  • Somali = ‘so’

  • Albanian = ‘sq’

  • Serbian = ‘sr’

  • Swati = ‘ss’

  • Southern_Sotho = ‘st’

  • Sundanese = ‘su’

  • Swedish = ‘sv’

  • Swahili = ‘sw’

  • Tamil = ‘ta’

  • Telugu = ‘te’

  • Tajik = ‘tg’

  • Thai = ‘th’

  • Tigrinya = ‘ti’

  • Turkmen = ‘tk’

  • Tagalog = ‘tl’

  • Tswana = ‘tn’

  • Tonga = ‘to’

  • Turkish = ‘tr’

  • Tsonga = ‘ts’

  • Tatar = ‘tt’

  • Twi = ‘tw’

  • Tahitian = ‘ty’

  • Uyghur = ‘ug’

  • Ukrainian = ‘uk’

  • Urdu = ‘ur’

  • Uzbek = ‘uz’

  • Venda = ‘ve’

  • Vietnamese = ‘vi’

  • Volapük = ‘vo’

  • Walloon = ‘wa’

  • Wolof = ‘wo’

  • Xhosa = ‘xh’

  • Yiddish = ‘yi’

  • Yoruba = ‘yo’

  • Zhuang = ‘za’

  • Chinese = ‘zh’

  • Zulu = ‘zu’