mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-05-30 23:40:40 +02:00
[Enhancement] Embed metadata in audio files & scan OPF file metadata #74
Closed
opened 2026-04-24 22:57:42 +02:00 by adam
·
21 comments
No Branch/Tag Specified
master
book_tags_genres_dedupe
episode_download_fallback
Issue-4540-SortBy-StartedDate-and-FinishedDate
episode_meta_tagging
fix_authorize_race_condition
redirect_transcode_requests
progress_updated_sort
fix_ereader_socket_event
fix_change_empty_root_password
fix_podcast_session_track_index
fix_set_token
session_modal_user
localize_durations
fix_oidc_create_user
jwt_auth_refactor
fix_scanner_deleting_single_file_books
fix_mediaprogress_updatedat_2
experimental_next_client
podcast_episode_duration
episode-timestamps-clickable
book_author_secondary_sort_title
podcast_useragents
pathexists_user_access
fix_pathexists_join
book_author_secondary_sort
clean_duplicate_mediaprogress
sanitize_html_description
trix_prevent_attachments
check_path_api_fix
fix_mediaprogress_updatedat
increase_express_json_limit
fix_dockerfile_nunicode
search_episodes
audiobook_tools_update
episode_secondary_sorts
hls_stream_url_update
new_session_track_endpoint
audiobook_tools_enhancements
watcher_rescans_update
player_track_tooltip
fix_exclude_prefixes_crash
socket_item_events
fix_podcast_episode_scanner_promise
new_stats_controller
count_cache_for_userpermissions
parsing-opf-v3
validate_migration_files
fix-quick-match-all-crash
fix-chapter-end-sleep-timer
stringify_sequelize_query
remove-col-ambiguity
fix_next_prev_edit_description
details_trim_whitespace
fix_content_url_basepath
fix_logger_fatal
progress_bar_visibility
batch-edit-populate-map-details
feed_generator_updates
bookmark-modal-updates
migrate-library-item-in-scanner
migrate-new-library-items
migrate-podcasts-new-library-item-2
migrate-podcasts-new-library-item
fix-remove-episode-from-playlist
playback-session-use-new-library-item
refactor-library-item
fix-heatmap-caption
feed-episodes-upsert
share-media-player-media-session-api
remove-old-playlist
remove_old_collection_object
plugin-implementation-demo
feed_migration
refactor-feeds-from-item
fix_remove_authors_no_books
v2.17.3-fk-constraints-migration
migrations-first-upgrade
sqlite_2
feature/nuxt-target-server
waveform
sqlite
playlists
video
v2.35.1
v2.35.0
v2.34.0
v2.33.2
v2.33.1
v2.33.0
v2.32.1
v2.32.0
v2.31.0
v2.30.0
v2.29.0
v2.28.0
v2.27.0
v2.26.3
v2.26.2
v2.26.1
v2.26.0
v2.25.1
v2.25.0
v2.24.0
v2.23.0
v2.22.0
v2.21.0
v2.20.0
v2.19.5
v2.19.4
v2.19.3
v2.19.2
v2.19.1
v2.19.0
v2.18.1
v2.18.0
v2.17.7
v2.17.6
v2.17.5
v2.17.4
v2.17.3
v2.17.2
v2.17.1
v2.17.0
v2.16.2
v2.16.1
v2.16.0
v2.15.1
v2.15.0
v2.14.0
v2.13.4
v2.13.3
v2.13.2
v2.13.1
v2.13.0
v2.12.3
v2.12.2
v2.12.1
v2.12.0
v2.11.0
v2.10.1
v2.10.0
v2.9.0
v2.8.1
v2.8.0
v2.7.2
v2.7.1
v2.7.0
v2.6.0
v2.5.0
v2.4.4
v2.4.3
v2.4.2
v2.4.1
v2.4.0
v2.3.5
v2.3.4
v2.3.3
v2.3.2
v2.3.1
v2.3.0
v2.2.23
v2.2.22
v2.2.21
v2.2.20
v2.2.19
v2.2.18
v2.2.17
v2.2.16
v2.2.15
v2.2.14
v2.2.13
v2.2.12
v2.2.11
v2.2.10
v2.2.9
v2.2.8
v2.2.7
v2.2.6
v2.2.5
v2.2.4
v2.2.3
v2.2.2
v2.2.1
v2.2.0
v2.1.5
v2.1.4
v2.1.3
v2.1.2
v2.1.1
v2.1.0
v2.0.24
v2.0.23
v2.0.22
v2.0.21
v2.0.20
v2.0.19
v2.0.18
v2.0.17
v2.0.16
v2.0.15
v2.0.14
v2.0.13
v2.0.12
v2.0.11
v2.0.10
v2.0.9
v2.0.8
v2.0.7
v2.0.6
v2.0.5
v2.0.4
v2.0.3
v2.0.2
v2.0.1
v1.7.2
v1.7.1
v1.7.0
v1.6.0
v1.5.5
v1.5.0
v1.4.11
v1.4.9
v1.4.7
v1.4.6
v1.4.4
v1.4.2
v1.4.0
v1.4.1
v1.3.4
v1.3.3
v1.3.1
v1.2.8
v1.2.6
v1.2.5
v1.2.4
v1.2.1
v1.1.15
v1.1.14
v1.1.13
v1.1.12
v1.1.11
v1.1.10
v1.1.9
v1.1.8
v1.0.0
0.9.61-beta.0
0.9.61-beta
Labels
Clear labels
authentication
backlog
bug
chapter editor
config-issue
ebooks
encoding/embedding
enhancement
help wanted
listening sessions & progress
planned
possible plugin
progress sync
pull-request
sorting/filtering/searching
unable to reproduce
upload
users & permissions
waiting
Mirrored from GitHub Pull Request
No Label
enhancement
Milestone
No items
No Milestone
Projects
Clear projects
No project
Assignees
adam (Adam Melkus)
Clear assignees
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: starred/audiobookshelf#74
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @rubbo898 on GitHub (Oct 25, 2021).
I'm using Calibre to fetch metadata from online datasources (Amazon and Google in the first place).
For it's internal logic it creates .opf files for backup/restore purposes, it would be great having the feature to embed these metadata into audio files (eg mp3tag) from .opf files.
With a wider perspective: embed metadata from an external datasource (online? file?) into the audio files
@advplyr commented on GitHub (Oct 25, 2021):
I think this will be 2 separate things:
The opf file metadata has been requested a few times, this should be fairly straightforward.
Updating audio file metadata has been a long time coming and is a bigger project. I want to be sure that anything done to the users files is explicit and well documented about what is happening. When syncing your audio file meta tags it will need to be clear which book details will be mapped to which ID3 tags and on what audio files.
Just talking it out.
I think you will need to elaborate on your last suggestion about external datasources.
@jarrodCoombes commented on GitHub (Oct 26, 2021):
Personally I'd be happy if the meta data was pulled from the internet and simply stored in a text file with the audio audio files, and just parsed into the database from there, similar to how the covers work. This might be a good place to start.
I get nervous when you start talking about modifying the MP3s directly (that's mostly due to the mess that is the meta data in all my audiobook files). Then again, if I was to have the option of doing it manually by book, author, series or the entire library, then I'd welcome Audiobookshelf in cleaning up the id3 tags on my files, it is a logical step IMO, just not automatically just yet.
The more I think about it, a button that says "Save Metadata to ID3" button would be pretty awesome, especially after all the data has been scraped and verified. Documenting what goes were would be done via a simple wiki page and ? icon in the confirmation dialogue.
@rubbo898 commented on GitHub (Oct 26, 2021):
@advplyr forget my last suggestion, it's more or less what @jarrodCoombes said in the first couple of lines of his comment: data pulled from internet (like Calibre) and stored in an file (text o different format) that can be used by Audiobookshelf for the "embed to ID3" feature. My idea was to interact not only with .opf files for a wider compatibility, but I understand that is a huge work even with a single extension.
@jarrodCoombes totally agree with you. If I did understand well what you described in the first place is the "job" performed by Calibre, Audiobookshelf could get involved for the last piece working with the scraped and verified data of Calibre.
@advplyr commented on GitHub (Oct 27, 2021):
Audiobookshelf will never modify or add files to your filesystem outside of the
/configand/metadatafolders unless manually opted in with sufficient explanation.Side note: The config and metadata directories are poorly named because they have changed purposes since I started the project. Config = database & metadata = streams, backups, metadata, downloads. Unfortunately I also learned that unraid community apps overrides the default mapping I chose for
/config, so most people have their metadata inside their config. It's a proper mess now.Back to the point, I think the 2 items I initially identified are still the way to go. When you update metadata in calibre it is first stored in the .opf file, then you can press some buttons to embed that data into your ebook. I think audiobookshelf should function the same way.
When scanning, if an .opf file is present it will be parsed and mapped to audiobookshelf fields.
There is an order of precedence in audiobookshelf for mapping data. For example, the folder names will take precedence over audio file ID3 tags, ID3 tags will take precedence over an .opf file, etc.
Eventually data will be pulled from the internet, but so far I haven't come across a good reliable source yet.
If audiobookshelf can take advantage of all the information from your current files though, it should be pretty solid for most people.
Hopefully that isn't too much rambling and makes sense.
@rubbo898 commented on GitHub (Oct 27, 2021):
All crystal clear!!
About this I can only suggest to allow the users to explicitly choose their own priority.
For example in my case Calibre mess up with both Author (folder) and Title (audio file) names (replace ":" with "_" and cut too long file names), don't know why maybe I'm doing something wrong...
Also the ID3 tags are not consistent, I should use a tool to erase them all and re-tag accordingly to the library structure (but here would come back the above issue...)
Anyway! If I'd able to use the .opf file with priority over both folder/file name and ID3 tags it resolves all my pains.
@advplyr commented on GitHub (Oct 28, 2021):
Metadata from the internet was discussed here, so I want to announce the new experimental match feature #157
@advplyr commented on GitHub (Nov 9, 2021):
I just pushed
v1.6.13that looks for ametadata.opformetadata.xmlfile and extracts the following:I skipped description for now because calibre stores description as HTML and audiobookshelf uses plain text only. It may make sense for audiobookshelf to support HTML in the future.
The current order of precedence for setting metadata is
This order is not adjustable yet.
@rubbo898 commented on GitHub (Nov 9, 2021):
What a great news! It looks for a metadata.opf file with the same name of the audio file? Or is mandatory that the .opf is named "metadata"?
I've performed some test and it seems that the .opf file isn't recognized:
Here below the .opf file:
Il sangue della lupa.zip
OT: I'm trying to set up Treafik as reverse proxy, it works via web UI but not with the App.
@advplyr commented on GitHub (Nov 10, 2021):
Thanks for sharing your opf file, I was able to extract more information after seeing your example.
I updated the scanner to find any file with the extension
.opf, instead of justmetadata.opf.I noticed that the description in the one you shared was plain text and not html, so I added a check to see if it is plain text and to use it if it is.
I added genres too, so the genres in your example will populate.
The new full list of metadata extracted is:
To test it I removed all the details of a book in my library, put your opf file in the directory, then pressed re-scan.

This is
v1.6.14@jarrodCoombes commented on GitHub (Nov 10, 2021):
Would it be possible to add an option to save the meta data out to a file in the folder with the MP3s, similar to what happens with cover images?
@advplyr commented on GitHub (Nov 10, 2021):
That's what the "Save Metadata" button is supposed to do. Although it is probably not complete since it was before a lot of the details were added.
Is that not working for you?
@jarrodCoombes commented on GitHub (Nov 10, 2021):
Ahh, ok. I honestly had no idea what that button did, and completely missed the tool tip when you hover it. I did test it, and it does work.
@rubbo898 commented on GitHub (Nov 13, 2021):
It's working as described, awsome!
Where can I find the language tag? I didn't spot it in any menu.
Embed metadata in the ID3 is the last piece but I understand is a critical step, thanks a lot for your efforts!
@advplyr commented on GitHub (Nov 13, 2021):
I haven't exposed the language field yet. I added it because I anticipate this will be requested at some point. I try not to clutter up the UI with stuff people won't use.
@jarrodCoombes commented on GitHub (Nov 14, 2021):
This would suggest the need for the option in the "Settings" page where people can turn this on and off.
@rubbo898 commented on GitHub (Nov 16, 2021):
Got the point!
2 secondary question:
@advplyr commented on GitHub (Dec 17, 2021):
There is still no option for batch saving metadata, I think there is another issue open for this. I'm doing some house cleaning now because I lost track of a lot of threads it seems.
I'm not sure about the naming of the metadata file, it seems common practice to use the same name in each folder.
@wtanksleyjr commented on GitHub (Jan 18, 2022):
Can someone who's gotten this working please post an example, ideally using all of the supported fields? There doesn't seem to be any document that defines this format in the terms used in this discussion (the fields of that format don't include an "author", for example, but rather a "contributor" with a subfield something like "aut" IIRC). It's incredibly complicated so far as I can tell.
Is it possible to set a book's series using this OPF file? I can't tell how to do that at all, but some of my books appear in series for reasons I ... can't tell at all. Some of them appear in a series named as the author, I'm guessing because I'm following the wrong naming conventions.
@advplyr commented on GitHub (Jan 18, 2022):
There is no documentation written for the specifics of how OPF files are mapped to abs details. Here is the relevant code for the parsing: https://github.com/advplyr/audiobookshelf/blob/master/server/utils/parseOpfMetadata.js#L73.
I linked to the line that will pull the series from the OPF file, using tag
calibre:seriesThe incorrect series getting filled out for you is most likely due to your folder structure. See https://www.audiobookshelf.org/docs#structure
You can use the folder structures:
@wtanksleyjr commented on GitHub (Jan 18, 2022):
Thank you for both pointers! That doesn't look too hard to figure out. And
of course I see what my directory structure got wrong.
-Wm
On Mon, Jan 17, 2022 at 4:17 PM advplyr @.***> wrote:
@advplyr commented on GitHub (Jun 18, 2022):
This was added a while back and just getting refined now