lanraragi_api.enhanced package¶
Submodules¶
lanraragi_api.enhanced.script module¶
- lanraragi_api.enhanced.script.remove_all_categories(api: LANraragiAPI)¶
Remove every archive from every category, then delete the categories.
For every category, all the archives it contains are removed from it. After that, all the categories are removed.
- Parameters:
api – LANraragiAPI instance used to read and modify the categories.
Note
Every category of the server is deleted. Removing the archives from a category does not delete the archives themselves. The number of removed archives and categories is printed.
- lanraragi_api.enhanced.script.subfolders_to_artists(api: LANraragiAPI, dirname: str)¶
Set the artist tag of archives to the name of their parent folder.
Walks through
dirnameand, for every archive that has no artist tag yet, sets its artist tag to the name of the subfolder holding it. Archives that already have an artist tag are skipped.This function is similar to Subfolders to Categories, but has better performance.
- Parameters:
api – LANraragiAPI instance used to read and update the archives.
dirname – Content folder whose subfolders give the artist tags.
Note
This function modifies archive metadata on the server. Archives are looked up by title, and the archive ID is computed from the file only when several archives share the same title. A summary of the skipped and updated archives is printed.
lanraragi_api.enhanced.server_side module¶
- exception lanraragi_api.enhanced.server_side.ArchiveFileError¶
Bases:
ExceptionRaised when an archive file cannot be accessed on disk.
- lanraragi_api.enhanced.server_side.compute_id(file_path: str) str¶
Compute the archive ID of a file the same way the server does.
The ID of an archive is determined only by the archive itself, so it can be computed on the client side as well.
- Parameters:
file_path – Path of the archive file.
- Returns:
Hexadecimal SHA-1 digest of the first 512 KB of the file.
- Return type:
str
- Raises:
ArchiveFileError – If
file_pathis not a file, or if the file cannot be opened or read.
Note
The algorithm matches the server side implementation in
LANraragi/lib/LANraragi/Utils/Database.pm.
- lanraragi_api.enhanced.server_side.is_archive(file_name: str)¶
Check whether a file name has a supported archive extension.
- Parameters:
file_name – File name to test.
- Returns:
- True if the name ends with
zip,rar,7z,tar, tar.gz,lzma,xz,cbz,cbr,cb7,cbt,pdforepub, compared case-insensitively. False otherwise.
- True if the name ends with
- Return type:
bool
Note
The list of extensions matches the server side implementation in
LANraragi/lib/LANraragi/Utils/Generic.pm.