Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Best way to add metadata (ID3 tags) to m4a files in automated code??? #14271

Closed
maurus56 opened this issue Sep 19, 2017 · 3 comments
Closed

Best way to add metadata (ID3 tags) to m4a files in automated code??? #14271

maurus56 opened this issue Sep 19, 2017 · 3 comments
Labels

Comments

@maurus56
Copy link

@maurus56 maurus56 commented Sep 19, 2017

Make sure you are using the latest version: run youtube-dl --version and ensure your version is 2017.09.15. If it's not, read this FAQ entry and update. Issues with outdated version will be rejected.

  • I've verified and I assure that I'm running youtube-dl 2017.09.15

Before submitting an issue make sure you have:

  • At least skimmed through the README, most notably the FAQ and BUGS sections
  • Searched the bugtracker for similar issues including closed ones

What is the purpose of your issue?

  • Bug report (encountered problems with youtube-dl)
  • Site support request (request for adding support for a new site)
  • Feature request (request for a new functionality)
  • Question
  • Other

After a lot of trouble with online sites I made a code for personal use, to download the way I like it but this time when trying to upgrade the functionalities I had some trouble trying to implement it.
The main issue is that I wasn't able to even get the metadata functioning in any way. So I'm writing to ask if anyone has been able to implement it into actual code, not just use it in the terminal.

For now, I'm just using these options for the download:

MUSIC_OPTIONS_ = {
    'writethumbnail': True,
    'format': 'bestaudio/best',
    'extractaudio': True,
    'audioformat': 'best',
    'outtmpl': '~/Music/Youtube_dl/%(uploader)s/%(title)s.%(ext)s',
    'noplaylist': True,
    'youtubeskipdashmanifest': True,
    'nocheckcertificate': True,
    'externaldownloader': 'aria2c',
    'externaldownloaderargs': '-x 4 -k 2M',
    'postprocessors': [{'key': 'FFmpegExtractAudio',
                        'preferredcodec': 'm4a',
                        'preferredquality': '0', },
                       {'key': 'EmbedThumbnail'}]}

I'm shure there must be an implementation of the --add-metadata and --metadata-from-title, but I couldn't find out how.

Full Code here for anyone interested in reviewing further and helping in any way.

Any commentary is welcomed.

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Sep 19, 2017

Add FFmpegMetadataPP postprocessor.

@dstftw dstftw closed this Sep 19, 2017
@dstftw dstftw added the question label Sep 19, 2017
@maurus56
Copy link
Author

@maurus56 maurus56 commented Sep 20, 2017

ok, I have added the PP and tried a run, it fetches the title and artist but at the end, it isn't added.

in which part of the code should I put the 'addmetadata': True ?

'postprocessors': [{'key': 'FFmpegExtractAudio',
                        'preferredcodec': 'm4a',
                        'preferredquality': '0'},
                       {'key': 'EmbedThumbnail'},
                       {'key': 'MetadataFromTitle',
                        'titleformat': '(?P<title>.+)\ \-\ (?P<artist>.+)'}]}

edit:

Made it work after checking out the code for how the PP is called. Seems that MetadataFromTitle just fetches the metadata and changes the 'info' list where the title is modified to just the name of the song and author changes from uploader to the author fetched from the title. Finally you need to call FFmpegMetadata that gets the 'info' list and writes it as metadata. here is the code:

MUSIC_OPTIONS_ = {
    'writethumbnail': True,
    'format': 'bestaudio/best',
    'extractaudio': True,
    'audioformat': 'best',
    'outtmpl': '~/Music/Youtube_dl/%(uploader)s/%(title)s.%(ext)s',
    'noplaylist': True,
    'youtubeskipdashmanifest': True,
    'nocheckcertificate': True,
    'externaldownloader': 'aria2c',
    'externaldownloaderargs': '-x 4 -k 2M',
    'postprocessors': [{'key': 'FFmpegExtractAudio',
                        'preferredcodec': 'm4a',
                        'preferredquality': '0'},
                       {'key': 'MetadataFromTitle',
                        'titleformat': '(?P<title>.+)\ \-\ (?P<artist>.+)'},
                       {'key': 'FFmpegMetadata'},
                       {'key': 'EmbedThumbnail'}]}

Now I just need to find a way to stop it from writing the comments and date released.

@cafca
Copy link

@cafca cafca commented Nov 8, 2017

MUSIC_OPTIONS_ = {
    'writethumbnail': True,
    'format': 'bestaudio/best',
    'extractaudio': True,
    'audioformat': 'best',
    'outtmpl': '~/Music/Youtube_dl/%(uploader)s/%(title)s.%(ext)s',
    'noplaylist': True,
    'youtubeskipdashmanifest': True,
    'nocheckcertificate': True,
    'externaldownloader': 'aria2c',
    'externaldownloaderargs': '-x 4 -k 2M',
    'postprocessors': [{'key': 'FFmpegExtractAudio',
                        'preferredcodec': 'm4a',
                        'preferredquality': '0'},
                       {'key': 'MetadataFromTitle',
                        'titleformat': '(?P<title>.+)\ \-\ (?P<artist>.+)'},
                       {'key': 'FFmpegMetadata'},
                       {'key': 'EmbedThumbnail'}]}

This should be an example in the youtube-dl README within the section about embedding youtube-dl. Right now it's not possible to figure out how to setup the postprocessors dict without reading the actual postprocessor module code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.