advplyr / audiobookshelf

Self-hosted audiobook and podcast server
https://audiobookshelf.org
GNU General Public License v3.0
5.52k stars 380 forks source link

[Enhancement]: Embed Metadata - Update chapters only #2971

Open SenorSmartyPants opened 2 weeks ago

SenorSmartyPants commented 2 weeks ago

Type of Enhancement

Server Backend

Describe the Feature/Enhancement

Please add an option to update only chapter metadata.

I use beets-audible to tag my M4Bs. But I've got a couple that don't have good chapter names, so I've used ABS to pull updated names and then embedded metadata. But I noticed that it wipes out some fields that beets-audible generated. I looked at Tone briefly and to my understanding it has a way to just update the chapters and not everything already. I think if you ran tone with ChptFmtNative as the only tagger it shouldn't touch the rest of the tags?

Here is the ffprobe metadata before Tone updated. I did a tone dump first, but noticed it didn't display some of the fields.

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'pre.m4b':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    title           : Project Hail Mary
    artist          : Andy Weir
    composer        : Ray Porter
    album           : Project Hail Mary
    genre           : Science Fiction & Fantasy
    track           : 1/1
    disc            : 1/1
    date            : 2021-05-04
    compilation     : 0
    encoder         : inAudible 1.97
    LANGUAGE        : English
    ORIGINAL YEAR   : 2021-05-04
    ASIN            : B08G9PRS1K
    CATALOGNUMBER   : B08G9PRS1K
    LABEL           : Audible Studios
    publisher       : Audible Studios
    media_type      : 2
    sort_album_artist:
    sort_artist     :
    sort_composer   :
    grouping        :
    album_artist    : Andy Weir
    sort_album      : Project Hail Mary
    comment         : **Winner of the 2022 Audie Awards Audiobook of the Year.**
                    :
                    : **Number-One Audible and** ***New York Times*** **Audio Best Seller**
                    :
                    : **A lone astronaut must save the earth from disaster in this incredible new science-based thriller from the number-one** ***New York Times*** **best-selling author of** ***The Martian*****.**
                    :
                    : Ryland Grace is the sole survivor on a desperate, last-chance mission - and if he fails, humanity and the Earth itself will perish.
                    :
                    : Except that right now, he doesn't know that. He can't even remember his own name, let alone the nature of his assignment or how to complete it.
                    :
                    : All he knows is that he's been asleep for a very, very long time. And he's just been awakened to find himself millions of miles from home, with nothing but two corpses for company.
                    :
                    : His crewmates dead, his memories fuzzily returning, he realizes that an impossible task now confronts him. Alone on this tiny ship that's been cobbled together by every government and space agency on the planet and hurled into the depths of space, it's up
                    :
                    : And thanks to an unexpected ally, he just might have a chance.
                    :
                    : Part scientific mystery, part dazzling interstellar journey, *Project Hail Mary* is a tale of discovery, speculation, and survival to rival *The Martian* - while taking us to places it never dreamed of going.
                    :
                    : PLEASE NOTE: To accommodate this audio edition, some changes to the original text have been made with the approval of author Andy Weir.
    description     : **Winner of the 2022 Audie Awards Audiobook of the Year.**
                    :
                    : **Number-One Audible and** ***New York Times*** **Audio Best Seller**
                    :
                    : **A lone astronaut must save the earth from disaster in this incredible new science-based thriller from the number-one** ***New York Times*** **best-selling author of** ***The Martian*****.**
                    :
                    : Ryland Grace is the sole survivor on a desperate, last-chance mission - and if he fails, humanity and the Earth itself will perish.
                    :
                    : Except that right now, he doesn't know that. He can't even remember his own name, let alone the nature of his assignment or how to complete it.
                    :
                    : All he knows is that he's been asleep for a very, very long time. And he's just been awakened to find himself millions of miles from home, with nothing but two corpses for company.
                    :
                    : His crewmates dead, his memories fuzzily returning, he realizes that an impossible task now confronts him. Alone on this tiny ship that's been cobbled together by every government and space agency on the planet and hurled into the depths of space, it's up
                    :
                    : And thanks to an unexpected ally, he just might have a chance.
                    :
                    : Part scientific mystery, part dazzling interstellar journey, *Project Hail Mary* is a tale of discovery, speculation, and survival to rival *The Martian* - while taking us to places it never dreamed of going.
                    :
                    : PLEASE NOTE: To accommodate this audio edition, some changes to the original text have been made with the approval of author Andy Weir.
  Duration: 16:10:53.08, start: 0.000000, bitrate: 127 kb/s
  Chapters:
    Chapter #0:0: start 0.000000, end 2224.936000
      Metadata:
        title           : 001
    Chapter #0:1: start 2224.936000, end 3946.417000
      Metadata:
        title           : 002
    Chapter #0:2: start 3946.417000, end 6187.630000
      Metadata:
        title           : 003
    Chapter #0:3: start 6187.630000, end 8648.411000
      Metadata:
        title           : 004
    Chapter #0:4: start 8648.411000, end 11837.765000
      Metadata:
        title           : 005
    Chapter #0:5: start 11837.765000, end 14488.369000
      Metadata:
        title           : 006
    Chapter #0:6: start 14488.369000, end 16295.067000
      Metadata:
        title           : 007
    Chapter #0:7: start 16295.067000, end 18484.755000
      Metadata:
        title           : 008
    Chapter #0:8: start 18484.755000, end 20244.294000
      Metadata:
        title           : 009
    Chapter #0:9: start 20244.294000, end 22365.065000
      Metadata:
        title           : 010
    Chapter #0:10: start 22365.065000, end 23931.924000
      Metadata:
        title           : 011
    Chapter #0:11: start 23931.924000, end 25676.115000
      Metadata:
        title           : 012
    Chapter #0:12: start 25676.115000, end 27630.724000
      Metadata:
        title           : 013
    Chapter #0:13: start 27630.724000, end 30035.940000
      Metadata:
        title           : 014
    Chapter #0:14: start 30035.940000, end 31465.708000
      Metadata:
        title           : 015
    Chapter #0:15: start 31465.708000, end 33415.976000
      Metadata:
        title           : 016
    Chapter #0:16: start 33415.976000, end 35344.509000
      Metadata:
        title           : 017
    Chapter #0:17: start 35344.509000, end 37208.212000
      Metadata:
        title           : 018
    Chapter #0:18: start 37208.212000, end 39384.526000
      Metadata:
        title           : 019
    Chapter #0:19: start 39384.526000, end 41369.321000
      Metadata:
        title           : 020
    Chapter #0:20: start 41369.321000, end 43906.194000
      Metadata:
        title           : 021
    Chapter #0:21: start 43906.194000, end 46302.679000
      Metadata:
        title           : 022
    Chapter #0:22: start 46302.679000, end 48028.850000
      Metadata:
        title           : 023
    Chapter #0:23: start 48028.850000, end 49701.453000
      Metadata:
        title           : 024
    Chapter #0:24: start 49701.453000, end 52078.016000
      Metadata:
        title           : 025
    Chapter #0:25: start 52078.016000, end 53368.047000
      Metadata:
        title           : 026
    Chapter #0:26: start 53368.047000, end 53981.309000
      Metadata:
        title           : 027
    Chapter #0:27: start 53981.309000, end 55172.609000
      Metadata:
        title           : 028
    Chapter #0:28: start 55172.609000, end 57371.538000
      Metadata:
        title           : 029
    Chapter #0:29: start 57371.538000, end 58253.084444
      Metadata:
        title           : 030
  Stream #0:0[0x1](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]
  Stream #0:1[0x2](eng): Data: bin_data (text / 0x74786574)
    Metadata:
      handler_name    : SubtitleHandler
  Stream #0:2[0x0]: Video: mjpeg (Baseline), yuvj420p(pc, bt470bg/unknown/unknown), 2322x2322 [SAR 1:1 DAR 1:1], 90k tbr, 90k tbn (attached pic)

Here is the tone dump metadata after Tone updated

;FFMETADATA
title=Project Hail Mary
artist=Andy Weir
album=Project Hail Mary
composer=Ray Porter
genre=Science Fiction & Fantasy
date=2021-05-04
media_type=2
encoder=inAudible 1.97
album_artist=Andy Weir
comment=**Winner of the 2022 Audie Awards Audiobook of the Year.**\
\
**Number-One Audible and** ***New York Times*** **Audio Best Seller**\
\
**A lone astronaut must save the earth from disaster in this incredible new science-based thriller from the number-one** ***New York Times*** **best-selling author of** ***The
Martian*****.**\
\
Ryland Grace is the sole survivor on a desperate, last-chance mission - and if he fails, humanity and the Earth itself will perish.\
\
Except that right now, he doesn't know that. He can't even remember his own name, let alone the nature of his assignment or how to complete it.\
\
All he knows is that he's been asleep for a very, very long time. And he's just been awakened to find himself millions of miles from home, with nothing but two corpses for
company.\
\
His crewmates dead, his memories fuzzily returning, he realizes that an impossible task now confronts him. Alone on this tiny ship that's been cobbled together by every government
and space agency on the planet and hurled into the depths of space, it's up to him to conquer an extinction-level threat to our species.\
\
And thanks to an unexpected ally, he just might have a chance.\
\
Part scientific mystery, part dazzling interstellar journey, *Project Hail Mary* is a tale of discovery, speculation, and survival to rival *The Martian* - while taking us to
places it never dreamed of going.\
\
PLEASE NOTE: To accommodate this audio edition, some changes to the original text have been made with the approval of author Andy Weir.
compilation=0
publisher=Audible Studios
track=1
disc=1
[CHAPTER]
TIMEBASE=1/1000
START=0
END=15000
title=Opening Credits
[CHAPTER]
TIMEBASE=1/1000
START=15000
END=21000
title=Dedication
[CHAPTER]
TIMEBASE=1/1000
START=21000
END=2224936
title=Chapter 1
[CHAPTER]
TIMEBASE=1/1000
START=2224936
END=3946417
title=Chapter 2
[CHAPTER]
TIMEBASE=1/1000
START=3946417
END=6187630
title=Chapter 3
[CHAPTER]
TIMEBASE=1/1000
START=6187630
END=8648411
title=Chapter 4
[CHAPTER]
TIMEBASE=1/1000
START=8648411
END=11837765
title=Chapter 5
[CHAPTER]
TIMEBASE=1/1000
START=11837765
END=14488369
title=Chapter 6
[CHAPTER]
TIMEBASE=1/1000
START=14488369
END=16295067
title=Chapter 7
[CHAPTER]
TIMEBASE=1/1000
START=16295067
END=18484755
title=Chapter 8
[CHAPTER]
TIMEBASE=1/1000
START=18484755
END=20244294
title=Chapter 9
[CHAPTER]
TIMEBASE=1/1000
START=20244294
END=22365065
title=Chapter 10
[CHAPTER]
TIMEBASE=1/1000
START=22365065
END=23931924
title=Chapter 11
[CHAPTER]
TIMEBASE=1/1000
START=23931924
END=25676115
title=Chapter 12
[CHAPTER]
TIMEBASE=1/1000
START=25676115
END=27630724
title=Chapter 13
[CHAPTER]
TIMEBASE=1/1000
START=27630724
END=30035940
title=Chapter 14
[CHAPTER]
TIMEBASE=1/1000
START=30035940
END=31465708
title=Chapter 15
[CHAPTER]
TIMEBASE=1/1000
START=31465708
END=33415976
title=Chapter 16
[CHAPTER]
TIMEBASE=1/1000
START=33415976
END=35344509
title=Chapter 17
[CHAPTER]
TIMEBASE=1/1000
START=35344509
END=37208212
title=Chapter 18
[CHAPTER]
TIMEBASE=1/1000
START=37208212
END=39384526
title=Chapter 19
[CHAPTER]
TIMEBASE=1/1000
START=39384526
END=41369321
title=Chapter 20
[CHAPTER]
TIMEBASE=1/1000
START=41369321
END=43906194
title=Chapter 21
[CHAPTER]
TIMEBASE=1/1000
START=43906194
END=46302679
title=Chapter 22
[CHAPTER]
TIMEBASE=1/1000
START=46302679
END=48028850
title=Chapter 23
[CHAPTER]
TIMEBASE=1/1000
START=48028850
END=49701453
title=Chapter 24
[CHAPTER]
TIMEBASE=1/1000
START=49701453
END=52078016
title=Chapter 25
[CHAPTER]
TIMEBASE=1/1000
START=52078016
END=53368047
title=Chapter 26
[CHAPTER]
TIMEBASE=1/1000
START=53368047
END=53981309
title=Chapter 27
[CHAPTER]
TIMEBASE=1/1000
START=53981309
END=55172609
title=Chapter 28
[CHAPTER]
TIMEBASE=1/1000
START=55172609
END=57371538
title=Chapter 29
[CHAPTER]
TIMEBASE=1/1000
START=57371538
END=58210000
title=Chapter 30
[CHAPTER]
TIMEBASE=1/1000
START=58210000
END=58253084
title=End Credits

Why would this be helpful?

This will preserve the tags that have been established outside of ABS.

Not explicitly related to this issue. It took tone about 5 minutes to update the metadata on this file. When I'm using beets it is much faster. I'm guessing ABS is making a temp file somewhere when updating the file. Some of my system lives on a not super fast SD card and my guess is that the temporary directory might be on there. I'm using a docker install and could map the temporary directory to somewhere fast if that is possible. Which directory should I check into?

Future Implementation (Screenshot)

image

Audiobookshelf Server Version

v2.9.0

Current Implementation (Screenshot)

No response

SenorSmartyPants commented 2 weeks ago

I embedded metadata in another book file and it went much faster.