Package: beets-audible
Beets-audible: Organize Your Audiobook Collection With BeetsThis is a plugin that allows Beets to manage audiobook collections.It fetches audiobook metadata via the Audible andAudnex API. With this data, it ensures books have the correct tags and makes the collection ready to be served by Plex, Audiobookshelf or Booksonic.Motivationseanap's audiobook organization guidedescribes a workflow for adding tags to audiobooks and moving the files to the right folders.However, it relies on using Mp3tag, a gui tool which does not lend itself to automation. Mp3tag works only on Windows.This Beets plugin solves both problems.InstallationInstall via pip:pip install beets-audible beets-copyartifacts3(copyartifacts is optional but recommended). See the next section instead if you're running Beets in Docker (highly recommended as it makes it easier to maintain a separate Beets installation dedicated to audiobooks).Use a separate beets config and database for managing audiobooks. This is the recommended Beets config for this plugin:# add audible to the list of plugins# copyartifacts is optional but recommended if you're manually specifying metadata via metadata.yml, see the "Importing non-audible content" sectionplugins:audible copyartifacts edit fromfilename scrubdirectory:/audiobooks# Place books in their own folders to be compatible with Booksonic and Audiobookshelf serverspaths:# For books that belong to a series"albumtype:audiobookseries_name::.+series_position::.+":$albumartist/%ifdef{series_name}/%ifdef{series_position} - $album%aunique{}/$track - $title"albumtype:audiobookseries_name::.+":$albumartist/%ifdef{series_name}/$album%aunique{}/$track - $title# Stand-alone books"albumtype:audiobook":$albumartist/$album%aunique{}/$track - $titledefault:$albumartist/$album%aunique{}/$track - $titlesingleton:Non-Album/$artist - $titlecomp:Compilations/$album%aunique{}/$track - $titlealbumtype_soundtrack:Soundtracks/$album/$track $title# disables musicbrainz lookup, as it doesn't help for audiobooksmusicbrainz:enabled:noaudible:# if the number of files in the book is the same as the number of chapters from Audible,# attempt to match each file to an audible chaptermatch_chapters:truesource_weight:0.0# disable the source_weight penaltyfetch_art:true# whether to retrieve cover artinclude_narrator_in_artists:true# include author and narrator in artist tag. Or just authorwrite_description_file:true# output desc.txtwrite_reader_file:true# output reader.txtcopyartifacts:extensions:.yml# so that metadata.yml is copied, see belowscrub:auto:yes# optional, enabling this is personal preferenceRun thebeet --versioncommand and verify that the audible plugin appears in the list of plugins.With DockerCreate the following folder structure:beets
  config/
  scripts/
    install-deps.sh # see step 3
  docker-compose.yml # see step 2Save the following as the docker-compose file:---version:"3"services:beets:image:lscr.io/linuxserver/beets:latestcontainer_name:beetsenvironment:# Update as needed-PUID=1000-PGID=1000-TZ=Asia/Singaporevolumes:-./config:/config-./scripts:/config/custom-cont-init.d-/path/to/audiobooks:/audiobooks-/path/to/import/books/from:/inputrestart:unless-stoppedSave the following underscripts/install-deps.sh:#!/bin/bashecho"Installing dependencies..."# copyartifacts is optional but recommendedpipinstall--no-cache-dirbeets-audiblebeets-copyartifacts3Spin up the container:docker-compose up -dUpdate the config inconfig/config.yamlas described above.In the docker container, run thebeet --versioncommand and verify that the audible plugin appears in the list of plugins.UsageWhen importing audiobooks into Beets, ensure that the files for each book are in its own folder, even if the audiobook only consists of a single file. This is so that the files for a book are treated as an album by Beets. Avoid putting files from multiple books in the same folder.When ready, start the import by executing the following command in the container:beetimport/path/to/audiobooksThe following sources of information are used to search for book matches in order of preference:A file containing book info namedmetadata.yml(see below)Album and artist tagsIf tags are missing from the file, enabling the fromfilename plugin will attempt to deduce album and artist from file namesIf all else fails, use the folder name as the query stringIf you're not getting a match for a book, try the following:Check the tags on the files being imported. The album and artist tags should be set to the book title and author respectively.PressEwhen Beets prompts you about not being able to find a match. This prompts for the artist and album name. If the wrong book is being matched because there are other books with similar names on Audible, try using the audiobook's asin as the artist and title as the album.Specify the book's data by usingmetadata.ymlif it isn't on Audible (see the next section).The plugin gets chapter data of each book and tries to match them to the imported files if and only if the number of imported files is the same as the number of chapters from Audible. This can fail and cause inaccurate track assignments if the lengths of the files don't match Audible's chapter data. If this happens, set the config optionmatch_chapterstofalsetemporarily and try again, and remember to uncomment that line once done.Goodreads for original work first published dateThe plugin can search Goodreads to find the original publication date of the work the audiobook is based on by searching on the ASIN. To enable this option you need a Goodreads API key and you must set that key in the audible plugin configaudible:
     goodreads_apikey: [APIKEYHERE] #optionalIf you want this date used as the release date for the audiobook, you must setoriginal_dateto yes in your beets configImporting Non-Audible ContentThe plugin looks for a file calledmetadata.ymlin each book's folder during import. If this file is present, it exclusively uses the info in it for tagging and skips the Audible lookup.This is meant for importing audio content that isn't on Audible.Here's an example of whatmetadata.ymlshould look like:---# These are all required fieldstitle:The Lord of the Rings (BBC Dramatization)authors:["J.R.R.Tolkien","BrianSibley","MichaelBakewell"]narrators:-"IanHolm(asFrodo)"-"SirMichaelHordern(asGandalf)"-"RobertStephens(asAragorn)"-"JohnLeMesurier"description:|This audio set includes:The Fellowship of the Ring; The Two Towers;andThe Return of the King.Undertaking the adaptation of J.R.R. Tolkien's best-known work was an enormous task, but with its first broadcast on BBC Radio 4 on March 8, 1981, this dramatized tale of Middle Earth became an instant global classic. Thrilling dramatization by Brian Sibley and Michael Bakewell it boasts a truly outstanding cast including Ian Holm (as Frodo), Sir Michael Hordern (as Gandalf), Robert Stephens (as Aragorn), and John Le Mesurier. Tolkiens tale relates the perilous attempt by Frodo Baggins and company to defeat the evil Saruman and dispose of the Ruling Ring. Brian Sibley wrote the opening and closing narration for the character of Frodo, played by Ian Holm, who now stars as Bilbo in the feature films based onThe Lord of the Rings.genres:["fantasy"]releaseDate:2008-08-19publisher:BBC Audiobooks# optional fieldslanguage:English# defaults to "English" if not specifiedsubtitle:"somesubtitle"series:The Lord Of The RingsseriesPosition:"1-3"The copyartifacts plugin ensures thatmetadata.ymlis copied over during the import, as it gets left in the source folder otherwise.Folder StructureThe config above places books according to this folder structure, which can be changed by editing the path config.Terry Goodkind/
  Sword of Truth/
    1 - Wizards First Rule/
      cover.png
      desc.txt
      reader.txt
      wizards first rule.m4b
George Orwell/
  Animal Farm/
    Animal Farm.m4b
    cover.png
    desc.txt
    reader.txtDesc.txt and reader.txt contain the book description and narrator populated from Audible.Tags WrittenBeets-audible writes the following tags:ID3 TagAudible.com ValueTIT1(CONTENTGROUP)Series, Book #TALB(ALBUM)TitleTIT3(SUBTITLE)SubtitleTPE1(ARTIST)Author, NarratorTPE2(ALBUMARTIST)AuthorTCOM(COMPOSER)NarratorTCON(GENRE)Genre1/Genre2TDRCandTDRL(release date)audio publication dateCOMMordescfor m4b files (COMMENT)Publisher's SummaryTSOA(ALBUMSORT)If ALBUM only, then %Title%If ALBUM and SUBTITLE, then %Title% - %Subtitle%If Series, then %Series% %Series-part% - %Title%TPUB(PUBLISHER)PublisherASIN(ASIN)Amazon Standard Identification Numberstik(media type), m4b only2 (audiobook)shwm(show movement), m4b only1 if part of a seriesMVNM(MOVEMENTNAME)SeriesMVIN/MVIfor m4b files (MOVEMENT)Series Book #TXXX_SERIES(SERIES)SeriesTXXX_SERIES-PARTSeries positionKnown LimitationsAnything that would cause Beets to move data (e.g, if performing an update after changing the path format) only moves the audio files and cover, leaving desc.txt and reader.txt behind. They need to be moved manually. This is because Beets doesn't associate these files with the album in its database.Plex IntegrationIf the directory where Beets imports audiobooks to is also where you've set Plex to serve content from, you can enable theplexupdate pluginto notify Plex when new books are imported.