### Get Language Dictionary Source: https://context7.com/davide-romanini/comicapi/llms.txt Retrieves a dictionary mapping ISO language codes to their full names. Useful for displaying language information. ```python lang_dict = getLanguageDict() print(lang_dict['en']) # "English" print(lang_dict['ja']) # "Japanese" ``` -------------------------------- ### Get Recursive File List Source: https://context7.com/davide-romanini/comicapi/llms.txt Recursively find all files within specified directories that match given extensions. Requires `utils.get_recursive_filelist`. ```python from utils import ( get_recursive_filelist ) # Get all comic files recursively from directories paths = ['/comics/marvel', '/comics/dc'] all_files = get_recursive_filelist(paths) comic_files = [f for f in all_files if f.endswith(('.cbz', '.cbr', '.pdf'))] print(f"Found {len(comic_files)} comic files") ``` -------------------------------- ### Get Language Name from ISO Code Source: https://context7.com/davide-romanini/comicapi/llms.txt Converts an ISO language code (e.g., 'fr') into its corresponding full language name (e.g., 'French'). ```python language_name = getLanguageFromISO('fr') print(language_name) # "French" ``` -------------------------------- ### Handle Complex Issue Numbers Source: https://context7.com/davide-romanini/comicapi/llms.txt Handle complex issue number formats including decimals, negative numbers, and letter suffixes using the IssueString class. Provides methods to get the issue number as a string, float, or integer. ```python from issuestring import IssueString # Parse various issue number formats issue_numbers = ["12", "12.1", "0", "-1", "5AU", "100-2", "½", "1½"] for issue in issue_numbers: iss = IssueString(issue) print(f"Issue: '{issue}'") print(f" As String: {iss.asString()}") print(f" As String (padded 3): {iss.asString(pad=3)}") print(f" As Float: {iss.asFloat()}") print(f" As Int: {iss.asInt()}") print() # Comparison and sorting issues = [IssueString("12"), IssueString("1"), IssueString("2"), IssueString("12.1")] sorted_issues = sorted(issues, key=lambda x: x.asFloat() or 0) print("Sorted:", [i.asString() for i in sorted_issues]) # Output: ['1', '2', '12', '12.1'] ``` -------------------------------- ### Initialize and Inspect ComicArchive Source: https://context7.com/davide-romanini/comicapi/llms.txt Demonstrates how to open a comic archive, detect its type (ZIP/CBZ, RAR/CBR, PDF), verify if it's a valid comic, and retrieve basic information like page count and page names. Ensure a default cover image path is provided. ```python from comicarchive import ComicArchive, MetaDataStyle # Open a comic archive (ZIP/CBZ, RAR/CBR, or PDF) comic = ComicArchive('/path/to/comic.cbz', default_image_path='/path/to/nocover.png') # Check archive type if comic.isZip(): print("This is a ZIP/CBZ archive") elif comic.isRar(): print("This is a RAR/CBR archive") elif comic.isPdf(): print("This is a PDF file") # Verify it's a valid comic archive if comic.seemsToBeAComicArchive(): print(f"Page count: {comic.getNumberOfPages()}") # Get list of page names pages = comic.getPageNameList() print(f"First page: {pages[0]}") # Read a specific page as binary image data cover_data = comic.getPage(0) with open('cover.jpg', 'wb') as f: f.write(cover_data) ``` -------------------------------- ### Initialize GenericMetadata Object Source: https://context7.com/davide-romanini/comicapi/llms.txt Demonstrates the basic instantiation of the `GenericMetadata` class, which serves as an internal container for comic metadata, supporting fields from various tagging schemes. ```python from genericmetadata import GenericMetadata, PageType # Create new metadata object md = GenericMetadata() ``` -------------------------------- ### Create CoMet XML from Metadata Source: https://context7.com/davide-romanini/comicapi/llms.txt Use `stringFromMetadata` to convert a `GenericMetadata` object into a CoMet XML string. Requires `comet.CoMet` and `genericmetadata.GenericMetadata`. ```python from comet import CoMet from genericmetadata import GenericMetadata comet = CoMet() md = GenericMetadata() md.series = "Fables" md.title = "Legends in Exile" md.issue = "1" md.publisher = "DC Comics/Vertigo" md.year = 2002 md.month = 7 md.addCredit("Bill Willingham", "Writer") md.addCredit("Lan Medina", "Penciller") md.characters = "Bigby Wolf, Snow White, Prince Charming" xml_output = comet.stringFromMetadata(md) print(xml_output) ``` -------------------------------- ### Find Executable in PATH Source: https://context7.com/davide-romanini/comicapi/llms.txt Searches the system's PATH environment variable for a specified executable. Returns the full path if found, otherwise None. ```python rar_path = which('rar') if rar_path: print(f"RAR found at: {rar_path}") ``` -------------------------------- ### Write Comic Metadata in Various Formats Source: https://context7.com/davide-romanini/comicapi/llms.txt Illustrates how to create and write metadata to comic archives using the `GenericMetadata` object. Supports writing in ComicRack (CIX) and ComicBookInfo (CBI) formats. Note that RAR archives require an external RAR executable for writing. ```python from comicarchive import ComicArchive, MetaDataStyle from genericmetadata import GenericMetadata comic = ComicArchive('/path/to/comic.cbz', default_image_path='/path/to/nocover.png') # Check if archive is writable if comic.isWritable(): # Create new metadata metadata = GenericMetadata() metadata.series = "Amazing Spider-Man" metadata.issue = "129" metadata.title = "The Punisher Strikes Twice" metadata.publisher = "Marvel Comics" metadata.year = 1974 metadata.month = 2 metadata.genre = "Superhero" metadata.language = "en" # Add credits metadata.addCredit("Gerry Conway", "Writer") metadata.addCredit("Ross Andru", "Penciller") metadata.addCredit("Frank Giacoia", "Inker") metadata.addCredit("Dave Hunt", "Inker") # Add tags metadata.tags = ["Spider-Man", "Punisher", "First Appearance"] # Write in ComicRack format (ComicInfo.xml) success = comic.writeMetadata(metadata, MetaDataStyle.CIX) print(f"Write CIX success: {success}") # Or write in ComicBookInfo format (JSON in archive comment) success = comic.writeMetadata(metadata, MetaDataStyle.CBI) print(f"Write CBI success: {success}") ``` -------------------------------- ### Read and Write CoMet External Files Source: https://context7.com/davide-romanini/comicapi/llms.txt Use `writeToExternalFile` and `readFromExternalFile` to manage CoMet XML metadata in external files. Requires `comet.CoMet` and `genericmetadata.GenericMetadata`. ```python from comet import CoMet from genericmetadata import GenericMetadata comet = CoMet() md = GenericMetadata() md.series = "Fables" md.title = "Legends in Exile" md.issue = "1" md.publisher = "DC Comics/Vertigo" md.year = 2002 md.month = 7 md.addCredit("Bill Willingham", "Writer") md.addCredit("Lan Medina", "Penciller") md.characters = "Bigby Wolf, Snow White, Prince Charming" # Read/write external files comet.writeToExternalFile("CoMet.xml", md) metadata = comet.readFromExternalFile("CoMet.xml") ``` -------------------------------- ### Export RAR Archive to ZIP Source: https://context7.com/davide-romanini/comicapi/llms.txt Convert a RAR comic archive to ZIP format using `exportAsZip`. Specify paths for the RAR executable and a default cover image. Requires `comicarchive.ComicArchive` and `comicarchive.MetaDataStyle`. ```python from comicarchive import ComicArchive, MetaDataStyle # Export a RAR archive as a ZIP file rar_comic = ComicArchive('/path/to/comic.cbr', rar_exe_path='/usr/bin/rar', default_image_path='/path/to/nocover.png') if rar_comic.isRar(): # Export to ZIP format success = rar_comic.exportAsZip('/path/to/comic.cbz') print(f"Export success: {success}") # The exported ZIP will contain all images and preserve the archive comment ``` -------------------------------- ### RARProcessFile Source: https://github.com/davide-romanini/comicapi/blob/master/UnRAR2/UnRARDLL/unrardll.txt Performs actions on the current file in an archive and advances to the next file. Supports extraction, testing, or skipping files. ```APIDOC ## RARProcessFile ### Description Performs action and moves the current position in the archive to the next file. Extract or test the current file from the archive opened in RAR_OM_EXTRACT mode. If the mode RAR_OM_LIST is set, then a call to this function will simply skip the archive position to the next file. ### Method int PASCAL ### Endpoint N/A (This is a function call, not an HTTP endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **hArcData** (HANDLE) - Required - Archive handle obtained from RAROpenArchive. - **Operation** (int) - Required - File operation type. Possible values: RAR_SKIP, RAR_TEST, RAR_EXTRACT. - **DestPath** (char *) - Optional - Destination directory for extracted files. If NULL, extracts to the current directory. Meaningful only if DestName is NULL. - **DestName** (char *) - Optional - Full path and name for the extracted file. Overrides DestPath and default name if not NULL. Note: Both DestPath and DestName must be in OEM encoding. ### Return values - **0** - Success - **ERAR_BAD_DATA** - File CRC error - **ERAR_BAD_ARCHIVE** - Volume is not valid RAR archive - **ERAR_UNKNOWN_FORMAT** - Unknown archive format - **ERAR_EOPEN** - Volume open error - **ERAR_ECREATE** - File create error - **ERAR_ECLOSE** - File close error - **ERAR_EREAD** - Read error - **ERAR_EWRITE** - Write error ### Request Example None (This is a C function call) ### Response #### Success Response (0) Indicates successful completion of the operation. #### Response Example None (Return value is an integer code) ``` -------------------------------- ### Read Comic Metadata with Different Styles Source: https://context7.com/davide-romanini/comicapi/llms.txt Shows how to check for the presence of different metadata styles (ComicInfo.xml, ComicBookInfo JSON, CoMet XML) within a comic archive and read metadata using the preferred available style. Accesses common metadata fields and credits. ```python from comicarchive import ComicArchive, MetaDataStyle comic = ComicArchive('/path/to/comic.cbz', default_image_path='/path/to/nocover.png') # Check which metadata styles are present has_cix = comic.hasCIX() # ComicRack's ComicInfo.xml has_cbi = comic.hasCBI() # ComicBookInfo JSON in archive comment has_comet = comic.hasCoMet() # CoMet XML format print(f"Has ComicInfo.xml: {has_cix}") print(f"Has ComicBookInfo: {has_cbi}") print(f"Has CoMet: {has_comet}") # Read metadata using preferred style if has_cix: metadata = comic.readMetadata(MetaDataStyle.CIX) elif has_cbi: metadata = comic.readMetadata(MetaDataStyle.CBI) elif has_comet: metadata = comic.readMetadata(MetaDataStyle.COMET) # Access metadata fields print(f"Series: {metadata.series}") print(f"Issue: {metadata.issue}") print(f"Title: {metadata.title}") print(f"Publisher: {metadata.publisher}") print(f"Year: {metadata.year}") print(f"Month: {metadata.month}") print(f"Page Count: {metadata.pageCount}") # Access credits for credit in metadata.credits: role = credit['role'] person = credit['person'] primary = credit.get('primary', False) print(f"{role}: {person} {'[Primary]' if primary else ''}") ``` -------------------------------- ### Parse CoMet XML String Source: https://context7.com/davide-romanini/comicapi/llms.txt Use `metadataFromString` to parse CoMet XML strings into metadata objects. Requires `comet.CoMet` and `genericmetadata.GenericMetadata`. ```python from comet import CoMet from genericmetadata import GenericMetadata comet = CoMet() # Parse CoMet XML string xml_string = """ The Long Halloween Batman 1 1 A mysterious killer is murdering people on holidays. DC Comics 1996-12 Jeph Loeb Tim Sale Crime Batman James Gordon Harvey Dent """ metadata = comet.metadataFromString(xml_string) print(f"Series: {metadata.series}") print(f"Issue: {metadata.issue}") print(f"Characters: {metadata.characters}") print(f"Year: {metadata.year}, Month: {metadata.month}") ``` -------------------------------- ### RARGetDllVersion Source: https://github.com/davide-romanini/comicapi/blob/master/UnRAR2/UnRARDLL/unrardll.txt Retrieves the API version of the UnRAR.dll. ```APIDOC ## void PASCAL RARGetDllVersion() ### Description Returns API version. ### Parameters None. ### Return values Returns an integer value denoting UnRAR.dll API version, which is also defined in unrar.h as RAR_DLL_VERSION. API version number is incremented only in case of noticeable changes in UnRAR.dll API. Do not confuse it with version of UnRAR.dll stored in DLL resources, which is incremented with every DLL rebuild. If RARGetDllVersion() returns a value lower than UnRAR.dll which your application was designed for, it may indicate that DLL version is too old and it will fail to provide all necessary functions to your application. This function is absent in old versions of UnRAR.dll, so it is safer to use LoadLibrary and GetProcAddress to access this function. ``` -------------------------------- ### RARSetCallback Source: https://github.com/davide-romanini/comicapi/blob/master/UnRAR2/UnRARDLL/unrardll.txt Sets a user-defined callback function to process Unrar events during archive operations. ```APIDOC ## RARSetCallback ### Description Set a user-defined callback function to process Unrar events. ### Method void PASCAL ### Endpoint N/A (This is a function call, not an HTTP endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **hArcData** (HANDLE) - Required - Archive handle obtained from RAROpenArchive. - **CallbackProc** (int PASCAL (*CallbackProc)(UINT msg, LPARAM UserData, LPARAM P1, LPARAM P2)) - Required - Pointer to a user-defined callback function. - **UserData** (LPARAM) - Optional - User-defined value passed to RARSetCallback. ### Callback Function Parameters - **msg** (UINT) - Type of event. Possible values include UCM_CHANGEVOLUME. - **UserData** (LPARAM) - User-defined value passed to RARSetCallback. - **P1** (LPARAM) - Event-dependent parameter. For UCM_CHANGEVOLUME, points to the zero-terminated name of the next volume. - **P2** (LPARAM) - Event-dependent parameter. For UCM_CHANGEVOLUME, indicates the function call mode (e.g., RAR_VOL_ASK). ### Return values None (This function is void) ### Request Example None (This is a C function call) ### Response None ``` -------------------------------- ### Read and Write ComicInfo.xml Source: https://context7.com/davide-romanini/comicapi/llms.txt Read and write ComicRack's ComicInfo.xml metadata format using the ComicInfoXml class. Supports parsing XML from a string and converting metadata objects back to XML strings. ```python from comicinfoxml import ComicInfoXml from genericmetadata import GenericMetadata cix = ComicInfoXml() # Parse ComicInfo.xml from string xml_string = """ Watchmen 1 At Midnight, All the Agents... 1986 9 Alan Moore Dave Gibbons DC Comics Superhero 32 """ metadata = cix.metadataFromString(xml_string) print(f"Series: {metadata.series}") print(f"Issue: {metadata.issue}") print(f"Writer: {[c['person'] for c in metadata.credits if c['role'] == 'Writer']}") # Convert metadata back to XML string md = GenericMetadata() md.series = "Sandman" md.issue = "1" md.title = "Sleep of the Just" md.publisher = "DC Comics/Vertigo" md.addCredit("Neil Gaiman", "Writer") md.addCredit("Sam Kieth", "Penciller") md.addCredit("Mike Dringenberg", "Inker") xml_output = cix.stringFromMetadata(md) print(xml_output) # Write to external file cix.writeToExternalFile("ComicInfo.xml", md) # Read from external file metadata = cix.readFromExternalFile("ComicInfo.xml") ``` -------------------------------- ### RARProcessFileW Source: https://github.com/davide-romanini/comicapi/blob/master/UnRAR2/UnRARDLL/unrardll.txt Unicode version of RARProcessFile, accepting wide character strings for destination paths. ```APIDOC ## RARProcessFileW ### Description Unicode version of RARProcessFile. It uses Unicode DestPath and DestName parameters, other parameters and return values are the same as in RARProcessFile. ### Method int PASCAL ### Endpoint N/A (This is a function call, not an HTTP endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **hArcData** (HANDLE) - Required - Archive handle obtained from RAROpenArchive. - **Operation** (int) - Required - File operation type. Possible values: RAR_SKIP, RAR_TEST, RAR_EXTRACT. - **DestPath** (wchar_t *) - Optional - Destination directory for extracted files (Unicode). If NULL, extracts to the current directory. Meaningful only if DestName is NULL. - **DestName** (wchar_t *) - Optional - Full path and name for the extracted file (Unicode). Overrides DestPath and default name if not NULL. ### Return values - **0** - Success - **ERAR_BAD_DATA** - File CRC error - **ERAR_BAD_ARCHIVE** - Volume is not valid RAR archive - **ERAR_UNKNOWN_FORMAT** - Unknown archive format - **ERAR_EOPEN** - Volume open error - **ERAR_ECREATE** - File create error - **ERAR_ECLOSE** - File close error - **ERAR_EREAD** - Read error - **ERAR_EWRITE** - Write error ### Request Example None (This is a C function call) ### Response #### Success Response (0) Indicates successful completion of the operation. #### Response Example None (Return value is an integer code) ``` -------------------------------- ### RAROpenArchive Source: https://github.com/davide-romanini/comicapi/blob/master/UnRAR2/UnRARDLL/unrardll.txt Opens a RAR archive and allocates memory structures for file extraction or listing. ```APIDOC ## RAROpenArchive ### Description Opens a RAR archive and allocates memory structures. This function can be used to list archive contents or to prepare for file extraction. ### Method `PASCAL` ### Endpoint `HANDLE PASCAL RAROpenArchive(struct RAROpenArchiveData *ArchiveData)` ### Parameters #### Input Parameters - **ArchiveData** (struct RAROpenArchiveData*) - Points to a `RAROpenArchiveData` structure containing archive details and open mode. #### `struct RAROpenArchiveData` Fields - **ArcName** (char*) - Zero-terminated string containing the archive name. - **OpenMode** (UINT) - Specifies the mode for opening the archive: - `RAR_OM_LIST`: Open for reading file headers only. - `RAR_OM_EXTRACT`: Open for testing and extracting files. - `RAR_OM_LIST_INCSPLIT`: Open for reading file headers, including those from split volumes. - **CmtBuf** (char*) - Buffer for archive comments. If NULL, comments are not read. - **CmtBufSize** (UINT) - Size of the buffer for archive comments. #### Output Parameters (within `ArchiveData`) - **OpenResult** (UINT) - Indicates the result of the open operation: - `0`: Success - `ERAR_NO_MEMORY`: Not enough memory. - `ERAR_BAD_DATA`: Archive header is broken. - `ERAR_BAD_ARCHIVE`: File is not a valid RAR archive. - `ERAR_UNKNOWN_FORMAT`: Unknown encryption used for headers. - `ERAR_EOPEN`: File open error. - **CmtSize** (UINT) - Size of comments actually read into the buffer. - **CmtState** (UINT) - State of comment extraction: - `0`: Comments not present. - `1`: Comments read completely. - `ERAR_NO_MEMORY`: Not enough memory for comments. - `ERAR_BAD_DATA`: Broken comment. - `ERAR_UNKNOWN_FORMAT`: Unknown comment format. - `ERAR_SMALL_BUF`: Buffer too small. ### Return values - Returns a `HANDLE` to the archive data on success. - Returns `NULL` in case of an error. ``` -------------------------------- ### UnRAR.dll Callback Functions Source: https://github.com/davide-romanini/comicapi/blob/master/UnRAR2/UnRARDLL/unrardll.txt Details on callback functions used by UnRAR.dll for notifications and data processing. ```APIDOC ## Callback Function Types ### RAR_VOL_NOTIFY **Description:** Called when a required volume is successfully opened. This is a notification call and volume name modification is not allowed. The function should return a positive value to continue or -1 to terminate the operation. ### UCM_PROCESSDATA **Description:** Processes unpacked data. It may be used to read a file while it is being extracted or tested without actually extracting the file to disk. Return a positive value to continue the process or -1 to cancel the archive operation. **Parameters:** - **P1** (unsigned char *) - Address pointing to the unpacked data. Function may refer to the data but must not change it. - **P2** (int) - Size of the unpacked data. It is guaranteed only that the size will not exceed the maximum dictionary size (4 Mb in RAR 3.0). ### UCM_NEEDPASSWORD **Description:** The DLL needs a password to process the archive. This message must be processed if you wish to be able to handle archives with encrypted file names. It can also be used as a replacement of RARSetPassword function even for usual encrypted files with non-encrypted names. **Parameters:** - **P1** (char *) - Address pointing to the buffer for a password. You need to copy a password here. - **P2** (int) - Size of the password buffer. ### UserData **Description:** User data passed to the callback function. Other functions of UnRAR.dll should not be called from the callback function. ``` -------------------------------- ### RARSetPassword Source: https://github.com/davide-romanini/comicapi/blob/master/UnRAR2/UnRARDLL/unrardll.txt Sets a password to decrypt files within an archive. ```APIDOC ## void PASCAL RARSetPassword(HANDLE hArcData, char *Password) ### Description Set a password to decrypt files. ### Parameters - **hArcData** (HANDLE) - This parameter should contain the archive handle obtained from the RAROpenArchive function call. - **Password** (char *) - It should point to a string containing a zero-terminated password. ### Return values None ``` -------------------------------- ### RARReadHeaderEx Source: https://github.com/davide-romanini/comicapi/blob/master/UnRAR2/UnRARDLL/unrardll.txt Similar to RARReadHeader, but uses RARHeaderDataEx structure, containing information about Unicode file names and 64-bit file sizes. ```APIDOC ## RARReadHeaderEx ### Description Similar to RARReadHeader, but uses RARHeaderDataEx structure, containing information about Unicode file names and 64 bit file sizes. ### Parameters #### Path Parameters - **hArcData** (HANDLE) - Required - This parameter should contain the archive handle obtained from the RAROpenArchive function call. - **HeaderData** (struct RARHeaderDataEx *) - Required - It should point to RARHeaderDataEx structure. ### Request Body ```c struct RARHeaderDataEx { char ArcName[1024]; wchar_t ArcNameW[1024]; char FileName[1024]; wchar_t FileNameW[1024]; unsigned int Flags; unsigned int PackSize; unsigned int PackSizeHigh; unsigned int UnpSize; unsigned int UnpSizeHigh; unsigned int HostOS; unsigned int FileCRC; unsigned int FileTime; }; ``` ### Structure Fields - **ArcName** (char[1024]) - Output parameter for the archive name. - **ArcNameW** (wchar_t[1024]) - Output parameter for the archive name in Unicode. - **FileName** (char[1024]) - Output parameter for the file name in OEM encoding. - **FileNameW** (wchar_t[1024]) - Output parameter for the file name in Unicode. - **Flags** (unsigned int) - File flags. - **PackSize** (unsigned int) - Lower 32 bits of packed file size. - **PackSizeHigh** (unsigned int) - Higher 32 bits of packed file size. - **UnpSize** (unsigned int) - Lower 32 bits of unpacked file size. - **UnpSizeHigh** (unsigned int) - Higher 32 bits of unpacked file size. - **HostOS** (unsigned int) - Operating system used for archiving. - **FileCRC** (unsigned int) - Unpacked file CRC. - **FileTime** (unsigned int) - Date and time in standard MS DOS format. ``` -------------------------------- ### Parse and Validate ComicBookInfo JSON Source: https://context7.com/davide-romanini/comicapi/llms.txt Use `metadataFromString` to parse JSON strings into metadata objects and `validateString` to check for valid ComicBookInfo data. Requires `json` and `comicapi.comicbookinfo`. ```python import json from comicapi import comicbookinfo as cbi json_string = json.dumps({ "appID": "ComicTagger/1.0.0", "lastModified": "2024-01-15", "ComicBookInfo/1.0": { "series": "Saga", "issue": "1", "title": "Chapter One", "publisher": "Image Comics", "publicationYear": 2012, "publicationMonth": 3, "genre": "Science Fiction, Fantasy", "language": "English", "credits": [ {"person": "Brian K. Vaughan", "role": "Writer"}, {"person": "Fiona Staples", "role": "Artist"} ], "tags": ["Saga", "Image", "Science Fiction"] } }) metadata = cbi.metadataFromString(json_string) print(f"Series: {metadata.series}") print(f"Year: {metadata.year}") print(f"Tags: {metadata.tags}") # Validate a string contains proper CBI data is_valid = cbi.validateString(json_string) print(f"Valid CBI: {is_valid}") ``` -------------------------------- ### Convert List to String Source: https://context7.com/davide-romanini/comicapi/llms.txt Join elements of a list into a comma-separated string. Requires `utils.listToString`. ```python from utils import ( listToString ) # Convert list to comma-separated string characters = ["Batman", "Robin", "Batgirl", "Nightwing"] char_string = listToString(characters) print(char_string) # "Batman, Robin, Batgirl, Nightwing" ``` -------------------------------- ### Convert Metadata to JSON String Source: https://context7.com/davide-romanini/comicapi/llms.txt Use `stringFromMetadata` to convert a `GenericMetadata` object into a JSON string. Requires `comicapi.comicbookinfo` and `genericmetadata`. ```python from comicapi import comicbookinfo as cbi from genericmetadata import GenericMetadata # Convert metadata to JSON string md = GenericMetadata() md.series = "East of West" md.issue = "1" md.publisher = "Image Comics" md.year = 2013 md.addCredit("Jonathan Hickman", "Writer") md.addCredit("Nick Dragotta", "Artist") json_output = cbi.stringFromMetadata(md) print(json_output) ``` -------------------------------- ### Write Metadata to External JSON File Source: https://context7.com/davide-romanini/comicapi/llms.txt Use `writeToExternalFile` to save `GenericMetadata` to a JSON file. Requires `comicapi.comicbookinfo`. ```python from comicapi import comicbookinfo as cbi from genericmetadata import GenericMetadata # Write to external file md = GenericMetadata() md.series = "East of West" md.issue = "1" md.publisher = "Image Comics" md.year = 2013 md.addCredit("Jonathan Hickman", "Writer") md.addCredit("Nick Dragotta", "Artist") cbi.writeToExternalFile("metadata.json", md) ``` -------------------------------- ### Set Basic Comic Metadata Source: https://context7.com/davide-romanini/comicapi/llms.txt Set basic comic metadata attributes such as series, issue, title, volume, publisher, and publication date. Also includes setting genre, language, country, maturity rating, and content flags. ```python md.series = "Batman" md.issue = "404" md.title = "Batman: Year One Part 1" md.volume = 1 md.issueCount = 4 md.publisher = "DC Comics" md.imprint = "DC" # Publication date md.year = 1987 md.month = 2 md.day = 1 # Content information md.genre = "Superhero, Crime" md.language = "en" # ISO 639-1 code md.country = "US" md.maturityRating = "Teen" md.blackAndWhite = False md.manga = None # or "YesAndRightToLeft" for manga # Story information md.storyArc = "Year One" md.seriesGroup = "Batman" md.comments = "Frank Miller's reimagining of Batman's origin." md.notes = "Part 1 of 4" # Characters and teams md.characters = "Batman, James Gordon, Catwoman" md.teams = "Gotham City Police Department" md.locations = "Gotham City" # Credits with primary flag md.addCredit("Frank Miller", "Writer", primary=True) md.addCredit("David Mazzucchelli", "Penciller", primary=True) md.addCredit("Richmond Lewis", "Colorist") # Page information md.setDefaultPageList(24) # Creates default page list md.pages[0]['Type'] = PageType.FrontCover md.pages[23]['Type'] = PageType.BackCover # Overlay metadata from another source other_md = GenericMetadata() other_md.webLink = "https://comicvine.gamespot.com/batman-404" other_md.criticalRating = 5 md.overlay(other_md) # Non-None values from other_md overwrite md print(md) # Pretty-printed metadata output ``` -------------------------------- ### RAROpenArchiveEx Source: https://github.com/davide-romanini/comicapi/blob/master/UnRAR2/UnRARDLL/unrardll.txt An extended version of RAROpenArchive that supports Unicode archive names and provides additional information about archive flags. ```APIDOC ## RAROpenArchiveEx ### Description Similar to `RAROpenArchive`, but uses `RAROpenArchiveDataEx` structure, allowing for Unicode archive names and returning information about archive flags. ### Method `PASCAL` ### Endpoint `HANDLE PASCAL RAROpenArchiveEx(struct RAROpenArchiveDataEx *ArchiveData)` ### Parameters #### Input Parameters - **ArchiveData** (struct RAROpenArchiveDataEx*) - Points to a `RAROpenArchiveDataEx` structure. #### `struct RAROpenArchiveDataEx` Fields - **ArcName** (char*) - Zero-terminated string containing the archive name (ANSI). - **ArcNameW** (wchar_t*) - Zero-terminated Unicode string containing the archive name. Can be NULL if not specified. - **OpenMode** (unsigned int) - Specifies the mode for opening the archive (same as `RAROpenArchive`). - **CmtBuf** (char*) - Buffer for archive comments. If NULL, comments are not read. - **CmtBufSize** (unsigned int) - Size of the buffer for archive comments. - **Reserved** (unsigned int[32]) - Reserved for future use. Must be zero. #### Output Parameters (within `ArchiveData`) - **OpenResult** (unsigned int) - Indicates the result of the open operation (same values as `RAROpenArchive`). - **CmtSize** (unsigned int) - Size of comments actually read into the buffer. - **CmtState** (unsigned int) - State of comment extraction (same values as `RAROpenArchive`). - **Flags** (unsigned int) - Combination of bit flags indicating archive properties: - `0x0001`: Volume attribute (archive volume). - `0x0002`: Archive comment present. - `0x0004`: Archive lock attribute. - `0x0008`: Solid attribute (solid archive). - `0x0010`: New volume naming scheme ('volname.partN.rar'). - `0x0020`: Authenticity information present. - `0x0040`: Recovery record present. - `0x0080`: Block headers are encrypted. - `0x0100`: First volume (RAR 3.0 and later). ### Return values - Returns a `HANDLE` to the archive data on success. - Returns `NULL` in case of an error. ``` -------------------------------- ### Validate CoMet Data Source: https://context7.com/davide-romanini/comicapi/llms.txt Use `validateString` to check if an XML string conforms to the CoMet schema. Requires `comet.CoMet`. ```python from comet import CoMet comet = CoMet() xml_string = """ The Long Halloween Batman 1 1 A mysterious killer is murdering people on holidays. DC Comics 1996-12 Jeph Loeb Tim Sale Crime Batman James Gordon Harvey Dent """ # Validate CoMet data is_valid = comet.validateString(xml_string) print(f"Valid CoMet: {is_valid}") ``` -------------------------------- ### Generate Unique Filename Source: https://context7.com/davide-romanini/comicapi/llms.txt This utility function generates a unique filename by appending a number in parentheses if the original file already exists. Useful for preventing overwrites. ```python filename = unique_file('/path/to/comic.cbz') # Returns '/path/to/comic (1).cbz' if original exists ``` -------------------------------- ### Handle ComicBookInfo JSON Source: https://context7.com/davide-romanini/comicapi/llms.txt Read and write ComicBookInfo JSON format, which stores metadata in the ZIP archive comment. This class is used to interact with this specific metadata format. ```python from comicbookinfo import ComicBookInfo from genericmetadata import GenericMetadata import json cbi = ComicBookInfo() ``` -------------------------------- ### RARReadHeader Source: https://github.com/davide-romanini/comicapi/blob/master/UnRAR2/UnRARDLL/unrardll.txt Reads the header information for a file within a RAR archive. ```APIDOC ## RARReadHeader ### Description Read header of file in archive. ### Parameters #### Path Parameters - **hArcData** (HANDLE) - Required - This parameter should contain the archive handle obtained from the RAROpenArchive function call. - **HeaderData** (struct RARHeaderData *) - Required - It should point to RARHeaderData structure. ### Request Body ```c struct RARHeaderData { char ArcName[260]; char FileName[260]; UINT Flags; UINT PackSize; UINT UnpSize; UINT HostOS; UINT FileCRC; UINT FileTime; UINT UnpVer; UINT Method; UINT FileAttr; char *CmtBuf; UINT CmtBufSize; UINT CmtSize; UINT CmtState; }; ``` ### Structure Fields - **ArcName** (char[260]) - Output parameter which contains a zero terminated string of the current archive name. May be used to determine the current volume name. - **FileName** (char[260]) - Output parameter which contains a zero terminated string of the file name in OEM (DOS) encoding. - **Flags** (UINT) - Output parameter which contains file flags: - 0x01 - file continued from previous volume - 0x02 - file continued on next volume - 0x04 - file encrypted with password - 0x08 - file comment present - 0x10 - compression of previous files is used (solid flag) - bits 7 6 5 - dictionary size (64 Kb to 4096 KB) - 1 1 1 - file is directory - Other bits are reserved. - **PackSize** (UINT) - Output parameter means packed file size or size of the file part if file was split between volumes. - **UnpSize** (UINT) - Output parameter - unpacked file size. - **HostOS** (UINT) - Output parameter - operating system used for archiving (0 - MS DOS, 1 - OS/2, 2 - Win32, 3 - Unix). - **FileCRC** (UINT) - Output parameter which contains unpacked file CRC. In case of file parts split between volumes only the last part contains the correct CRC and it is accessible only in RAR_OM_LIST_INCSPLIT listing mode. - **FileTime** (UINT) - Output parameter - contains date and time in standard MS DOS format. - **UnpVer** (UINT) - Output parameter - RAR version needed to extract file. It is encoded as 10 * Major version + minor version. - **Method** (UINT) - Output parameter - packing method. - **FileAttr** (UINT) - Output parameter - file attributes. - **CmtBuf** (char *) - Input parameter which should point to the buffer for file comments. Maximum comment size is limited to 64Kb. Comment text is a zero terminated string in OEM encoding. If the comment text is larger than the buffer size, the comment text will be truncated. If CmtBuf is set to NULL, comments will not be read. - **CmtBufSize** (UINT) - Input parameter which should contain size of buffer for archive comments. - **CmtSize** (UINT) - Output parameter containing size of comments actually read into the buffer, should not exceed CmtBufSize. - **CmtState** (UINT) - Output parameter. ### Return values - **0** - Success - **ERAR_END_ARCHIVE** - End of archive - **ERAR_BAD_DATA** - File header broken ``` -------------------------------- ### RARCloseArchive Source: https://github.com/davide-romanini/comicapi/blob/master/UnRAR2/UnRARDLL/unrardll.txt Closes a previously opened RAR archive and frees allocated memory structures. ```APIDOC ## RARCloseArchive ### Description Closes a RAR archive handle and frees all associated memory structures. This function should be called after all operations on the archive are completed. ### Method `PASCAL` ### Endpoint `int PASCAL RARCloseArchive(HANDLE hArcData)` ### Parameters #### Input Parameters - **hArcData** (HANDLE) - The handle to the RAR archive returned by `RAROpenArchive` or `RAROpenArchiveEx`. ### Return values - Returns `0` on success. - Returns a non-zero error code on failure (specific error codes are not detailed in the provided text). ``` -------------------------------- ### Parse Comic Filenames Source: https://context7.com/davide-romanini/comicapi/llms.txt Parse comic metadata from filenames using the FileNameParser class. Extracts series name, issue number, volume, year, and other information from common naming conventions. ```python from filenameparser import FileNameParser # Parse various filename formats filenames = [ "Amazing Spider-Man #129 (1974).cbz", "Batman - Year One 01 (of 04) (1987).cbr", "X-Men Vol.2 #1 (1991).cbz", "Saga 001 (2012) (Digital).cbz", "The Walking Dead #100 Variant Cover (2012).cbz", ] for filename in filenames: parser = FileNameParser() parser.parseFilename(filename) print(f"Filename: {filename}") print(f" Series: {parser.series}") print(f" Issue: {parser.issue}") print(f" Volume: {parser.volume}") print(f" Year: {parser.year}") print(f" Issue Count: {parser.issue_count}") print(f" Remainder: {parser.remainder}") print() # Output: # Filename: Amazing Spider-Man #129 (1974).cbz # Series: Amazing Spider-Man # Issue: 129 # Volume: # Year: 1974 # Issue Count: # Remainder: ``` -------------------------------- ### Parse Metadata from Filename Source: https://context7.com/davide-romanini/comicapi/llms.txt Extract comic metadata (series, issue, year) from a filename when no embedded metadata exists. Use `metadataFromFilename` and optionally `writeMetadata`. Requires `comicarchive.ComicArchive` and `comicarchive.MetaDataStyle`. ```python from comicarchive import ComicArchive, MetaDataStyle # Parse metadata from filename when no embedded metadata exists comic = ComicArchive('/path/to/Batman #404 (1987).cbz', default_image_path='/path/to/nocover.png') if not comic.hasMetadata(MetaDataStyle.CIX): # Extract metadata from the filename filename_md = comic.metadataFromFilename() print(f"Parsed series: {filename_md.series}") print(f"Parsed issue: {filename_md.issue}") print(f"Parsed year: {filename_md.year}") # Optionally write the parsed metadata to the archive if comic.isWritable(): comic.writeMetadata(filename_md, MetaDataStyle.CIX) ``` -------------------------------- ### RARCloseArchive Source: https://github.com/davide-romanini/comicapi/blob/master/UnRAR2/UnRARDLL/unrardll.txt Closes a RAR archive and releases allocated memory. This function should be called after all archive processing is completed, regardless of whether errors occurred. ```APIDOC ## RARCloseArchive ### Description Close RAR archive and release allocated memory. It must be called when archive processing is finished, even if the archive processing was stopped due to an error. ### Parameters #### Path Parameters - **hArcData** (HANDLE) - Required - This parameter should contain the archive handle obtained from the RAROpenArchive function call. ### Return values - **0** - Success - **ERAR_ECLOSE** - Archive close error ``` -------------------------------- ### Remove Articles from Title Source: https://context7.com/davide-romanini/comicapi/llms.txt Use this function to remove common articles ('the', 'a', 'an') from a title string for search and comparison purposes. It returns the cleaned string. ```python title = "The Amazing Spider-Man" cleaned = removearticles(title) print(cleaned) # "amazing spider man" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.