Overview
TheAudiobook class represents an audiobook retrieved from LibriVox via the Archive.org API. It contains metadata such as title, author, description, ratings, and more.
Properties
The title of the audiobook
The unique identifier for the audiobook (Archive.org identifier)
A text description of the audiobook
The total runtime of the audiobook
The author or creator of the audiobook
The publication or upload date
The number of times the audiobook has been downloaded
A list of subject tags or categories for the audiobook. Filters out generic tags like “librivox”, “audiobooks”, and “audiobook”
The total size of the audiobook in bytes
The average user rating for the audiobook
The number of reviews the audiobook has received
URL to the audiobook cover image. Constructed from Archive.org’s image service using the identifier
The language code of the audiobook (e.g., “en” for English)
The source of the audiobook (typically “librivox”)
Constructors
Audiobook.empty()
Creates an empty audiobook instance with default values.Audiobook.fromJson(Map jsonAudiobook)
Creates anAudiobook instance from a JSON map retrieved from the Archive.org API.
Parameters:
A map containing audiobook data from the Archive.org API response
identifier→idtitle→titleruntime→totalTimecreator→author(defaults to “Unknown”)date→date(parsed to DateTime)downloads→downloadssubject→subject(filtered)item_size→sizeavg_rating→ratingnum_reviews→reviewsdescription→descriptionlanguage→language(defaults to “en”)
Audiobook.fromMap
Creates anAudiobook instance from a map (typically used for local storage retrieval).
Parameters:
A map containing audiobook data in the internal format (Map<dynamic, dynamic>)
Methods
toMap()
Converts the audiobook to a map suitable for storage. Returns:Map<dynamic, dynamic>
toJson()
Converts the audiobook to a JSON-serializable map. Returns:Map<String, dynamic>
copyWith
Creates a copy of the audiobook with optionally updated fields. Parameters:Updated title
Updated identifier
Updated description
Updated total time
Updated author
Updated date
Updated download count
Updated subject list
Updated size
Updated rating
Updated review count
Updated cover image URL
Updated language code
Updated origin
Audiobook
Static Methods
fromJsonArray(List jsonAudiobook)
Converts a list of JSON objects into a list ofAudiobook instances. Filters out invalid entries (thumbs, librivox creators, null titles).
Parameters:
A list of JSON maps from the API response
List<Audiobook>