anna_s_archive_containers_aac

Anna’s Archive Containers (AAC)

Never return to Digital Rights Management (DRM)

Return instead to Anna's Archive, Calibre and De-DRM

Anna’s Archive Containers (AAC): standardizing releases from the world’s largest shadow library annas-blog.org, 2023-08-15

Anna’s Archive has become by far the largest shadow library in the world, and the only shadow library of its scale that is fully open-source and open-data. Below is a table from their Datasets page (slightly modified):

Source Size Mirrored by

Anna’s Archive

  • Sci-Hub - 86,614,441 files - 87.2 TB 99.957%
  • Z-Library - 13,769,031 files - 97.3 TB 99.91%

Total - Excluding duplicates - 111,081,811 files - 419.5 TB 97.998%

They accomplished this in three ways:

Mirroring existing open-data shadow libraries (like Sci-Hub and Library Genesis). Helping out shadow libraries that want to be more open, but didn’t have the time or resources to do so (like the Libgen comics collection). Scraping libraries that do not wish to share in bulk (like Z-Library). For (2) and (3) we now manage a considerable collection of torrents ourselves (100s of TBs). So far we have approached these collections as one-offs, meaning bespoke infrastructure and data organization for each collection. This adds significant overhead to each release, and makes it particularly hard to do more incremental releases.

That’s why we decided to standardize our releases. This is a technical blog post in which we’re introducing our standard: Anna’s Archive Containers.

Design goals Our primary use case is the distribution of files and associated metadata from different existing collections. Our most important considerations are:

Heterogeneous files and metadata, in as close to the original format as possible. Heterogeneous identifiers in the source libraries, or even lack of identifiers. Separate releases of metadata vs file data, or metadata-only releases (e.g. our ISBNdb release). Distribution through torrents, though with the possibility of other distribution methods (e.g. IPFS). Immutable records, since we should assume our torrents will live forever. Incremental releases / appendable releases. Machine-readable and writeable, conveniently and quickly, especially for our stack (Python, MySQL, ElasticSearch, Transmission, Debian, ext4). Somewhat easy human inspection, though this is secondary to machine readability. Easy to seed our collections with a standard rented seedbox. Binary data can be served directly by webservers like Nginx. Some non-goals:

We don’t care about files being easy to navigate manually on disk, or searchable without preprocessing. We don’t care about being directly compatible with existing library software. While it should be easy for anyone to seed our collection using torrents, we don’t expect the files to be usable without significant technical knowledge and commitment. Since Anna’s Archive is open source, we want to dogfood our format directly. When we refresh our search index, we only access publicly available paths, so that anyone who forks our library can get up and running quickly.

The standard Ultimately, we settled on a relatively simple standard. It’s fairly loose, non-normative, and a work in progress.

AAC. AAC (Anna’s Archive Container) is a single item consisting of metadata, and optionally binary data, both of which are immutable. It has a globally unique identifier, called AACID. Collection. Each AAC belongs to a collection, which by definition is a list of AACs that are semantically consistent. That means that if you make a significant change to the format of the metadata, then you have to create a new collection. “records” and “files” collections. By convention, it’s often convenient to release “records” and “files” as different collections, so they can be released at different schedules, e.g. based on scraping rates. A “record” is a metadata-only collection, containing information like book titles, authors, ISBNs, etc, while “files” are the collections that contain the actual files themselves (pdf, epub). AACID. The format of AACID is this: aacid__{collection}__{ISO 8601 timestamp}__{collection-specific ID}__{shortuuid}. For example, an actual AACID that we’re released is aacid__zlib3_records__20230808T014342Z__22433983__URsJNGy5CjokTsNT6hUmmj. {collection}: the collection name, which may contain ASCII letters, numbers, and underscores (but no double underscores). {ISO 8601 timestamp}: a short version of the ISO 8601, always in UTC, e.g. 20220723T194746Z. This number has to monotonically increase for every release, though its exact semantics can differ per collection. We suggest using the time of scraping or of generating the ID. {collection-specific ID}: a collection-specific identifier, if applicable, e.g. the Z-Library ID. May be omitted or truncated. Must be omitted or truncated if the AACID would otherwise exceed 150 characters. {shortuuid}: a UUID but compressed to ASCII, e.g. using base57. We currently use the shortuuid Python library. AACID range. Since AACIDs contain monotonically increasing timestamps, we can use that to denote ranges within a particular collection. We use this format: aacid__{collection}__{from_timestamp}–{to_timestamp}, where the timestamps are inclusive. This is consistent with ISO 8601 notation. Ranges are continuous, and may overlap, but in case of overlap must contain identical records as the one previously released in that collection (since AACs are immutable). Missing records are not allowed. Metadata file. A metadata file contains the metadata of a range of AACs, for one particular collection. These have the following properties: Filename must be an AACID range, prefixed with annas_archive_meta__ and followed by .jsonl.zstd. For example, one of our releases is called annas_archive_meta__aacid__zlib3_records__20230808T014342Z–20230808T023702Z.jsonl.zst. As indicated by the file extension, the file type is JSON Lines compressed with Zstandard. Each JSON object must contain the following fields at the top level: aacid, metadata, data_folder (optional). No other fields are allowed. metadata is arbitrary metadata, per the semantics of the collection. It must be semantically consistent within the collection. data_folder is optional, and is the name of binary data folder that contains the corresponding binary data. The filename of the corresponding binary data within that folder is the record’s AACID. The annas_archive_meta__ prefix may be adapted to the name of your institution, e.g. my_institute_meta__. Binary data folder. A folder with the binary data of a range of AACs, for one particular collection. These have the following properties: Directory name must be an AACID range, prefixed with annas_archive_data__, and no suffix. For example, one of our actual releases has a directory called annas_archive_data__aacid__zlib3_files__20230808T055130Z–20230808T055131Z. The directory must contain data files for all AACs within the specified range. Each data file must have its AACID as the filename (no extensions). It’s recommended to make these folders somewhat manageable in size, e.g. not larger than 100GB-1TB each, though this recommendation may change over time. Torrents. The metadata files and binary data folders may be bundled in torrents, with one torrent per metadata file, or one torrent per binary data folder. The torrents must have the original file/directory name plus a .torrent suffix as their filename. Example Let’s look at our recent Z-Library release as an example. It consists of two collections: “zlib3_records” and “zlib3_files”. This allows us to separately scrape and release metadata records from the actual book files. As such, we released two torrents with metadata files:

annas_archive_meta__aacid__zlib3_records__20230808T014342Z–20230808T023702Z.jsonl.zst.torrent annas_archive_meta__aacid__zlib3_files__20230808T051503Z–20230809T223215Z.jsonl.zst.torrent We also released a bunch of torrents with binary data folders, but only for the “zlib3_files” collection, 62 in total: annas_archive_data__aacid__zlib3_files__20230808T055130Z–20230808T055131Z.torrent annas_archive_data__aacid__zlib3_files__20230808T120246Z–20230808T120247Z.torrent … annas_archive_data__aacid__zlib3_files__20230809T204340Z–20230809T204341Z.torrent By running zstdcat annas_archive_meta__aacid__zlib3_records__20230808T014342Z–20230808T023702Z.jsonl.zst we can see what’s inside:

{“aacid”:“aacid__zlib3_records__20230808T014342Z__22430000__hnyiZz2K44Ur5SBAuAgpg8”,“metadata”:{“zlibrary_id”:22430000,“date_added”:“2022-08-24”,“date_modified”:“2023-04-05”,“extension”:“epub”,“filesize_reported”:483359,“md5_reported”:“21f19f95c4b969d06fe5860a98e29f0d”,“title”:“Els nens de la senyora Zlatin”,“author”:“Maria Lluïsa Amorós”,“publisher”:“ePubLibre”,“language”:“catalan”,“series”:“”,“volume”:“”,“edition”:“”,“year”:“2021”,“pages”:“”,“description”:“França, 1943. Un grup de nens jueus, procedents de diversos països europeus, arriben a França per escapar de la tragèdia que devasta Europa durant la Segona Guerra Mundial. Amb l’ocupació de França per part dels alemanys, les seves vides corren perill. La Sabine Zlatin, infermera de la Creu Roja, tindrà cura d’ells i els buscarà un indret on puguin refugiar-se fins a l’acabament de la guerra. El 18 de maig del 1943, amb el temor que algú els aturi, arriben a Villa Anne-Marie, un casalici blanc on els nens compartiran pors i l’enyorança dels pares, que van deixar enrere, però també gaudiran de la pau del lloc, dels jocs vora la gran font i dels contes que en Léon, un educador, els relata perquè la son els venci. I, sobretot, retrobaran el valor de l’amistat, del primer amor i de tenir cura els uns dels altres.Paral·lelament, l’Octavi Verdier, un jove periodista, escriu una novel·la sobre la presència nazi a la Barcelona dels anys quaranta, que contrasta amb la Barcelona sotmesa pel franquisme. Durant aquest procés de creació que l’obliga a investigar, descobrirà què s’amaga darrere la porta del despatx d’en Gustau Verdier, el seu avi, que el 1944 va venir de França i va comprar una fàbrica tèxtil a Terrassa. En la recerca anirà a parar a Villa Anne-Marie, a Izieu.”,“cover_path”:“/covers/books/21/f1/9f/21f19f95c4b969d06fe5860a98e29f0d.jpg”,“isbns”:[],“category_id”:“”}} In this case, it’s metadata of a French book, as reported by Z-Library. At the top-level we only have “aacid” and “metadata”, but no “data_folder”, since there is no corresponding binary data. The AACID contains “22430000” as the primary ID, which we can see is taken from “zlibrary_id”. We can expect other AACs in this collection to have the same structure.

Now let’s run zstdcat annas_archive_meta__aacid__zlib3_files__20230808T051503Z–20230809T223215Z.jsonl.zst:

{“aacid”:“aacid__zlib3_files__20230808T051503Z__22433983__NRgUGwTJYJpkQjTbz2jA3M”,“data_folder”:“annas_archive_data__aacid__zlib3_files__20230808T051503Z–20230808T051504Z”,“metadata”:{“zlibrary_id”:“22433983”,“md5”:“63332c8d6514aa6081d088de96ed1d4f”}} This is a much smaller AAC metadata, though the bulk of this AAC is located elsewhere in a binary file! After all, we have a “data_folder” this time, so we can expect the corresponding binary data to be located at annas_archive_data__aacid__zlib3_files__20230808T051503Z–20230808T051504Z/aacid__zlib3_files__20230808T051503Z__22433983__NRgUGwTJYJpkQjTbz2jA3M. The “metadata” contains the “zlibrary_id”, so we can easily associate it with the corresponding AAC in the “zlib_records” collection. We could’ve associated in a number of different ways, e.g. through AACID — the standard doesn’t prescribe that.

Note that it’s also not necessary for the “metadata” field to itself be JSON. It could be a string containing XML or any other data format. You could even store metadata information in the associated binary blob, e.g. if it’s a lot of data.

Conclusion With this standard, we can make releases more incrementally, and more easily add new data sources. We already have a few exciting releases in the pipeline!

We also hope it becomes easier for other shadow libraries to mirror our collections. After all, our goal is to preserve human knowledge and culture forever, so the more redundancy the better.

Snippet from Wikipedia: Anna's Archive

Anna's Archive is a search engine for shadow libraries. It was founded by the Pirate Library Mirror, a team of anonymous archivists, in direct response to law enforcement efforts to close down Z-Library in 2022. It describes itself as a project that aims to "catalog all the books in existence" and to "track humanity's progress toward making all these books easily available in digital form".

Anna's Archive mirrors Library Genesis, Open Library, Sci-Hub and Z-Library. Anna's Archive says that it does not host copyrighted materials and that it only indexes metadata that is already publicly available.

As of April 1, 2024, Anna's Archive includes 30,702,128 books and 99,901,919 papers.

Fair Use Sources

Shadow Libraries: Anna's Archive, Anna’s Archive Containers (AAC), Library Genesis, Sci-Hub, Z-Library, Open Library, DataHoarder, De-DRM, Digital Rights Management (DRM), Calibre, File Sharing, Freedom of Information, Open Data. (navbar_shadow_library - see also navbar_bibliography)

Bibliography: Books, De-DRM (Calibre and Anna's Archive Shadow Library), Publishers and Publications, WorldCat.org (ISBN), Amazon (ASIN), Apple Books-Kindle-eBooks. (navbar_bibliography - see also navbar_shadow_library, navbar_propaganda)


© 1994 - 2024 Cloud Monk Losang Jinpa or Fair Use. Disclaimers

SYI LU SENG E MU CHYWE YE. NAN. WEI LA YE. WEI LA YE. SA WA HE.


anna_s_archive_containers_aac.txt · Last modified: 2024/04/28 03:51 (external edit)