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

%(artist)s retrieved from --metadata-from-title does not apply to -o option #13047

Closed
yjs990427 opened this issue May 10, 2017 · 5 comments
Closed
Labels

Comments

@yjs990427
Copy link

@yjs990427 yjs990427 commented May 10, 2017

Please follow the guide below

  • You will be asked some questions and requested to provide some information, please read them carefully and answer honestly
  • Put an x into all the boxes [ ] relevant to your issue (like that [x])
  • Use Preview tab to see how your issue will actually look like

Make sure you are using the latest version: run youtube-dl --version and ensure your version is 2017.05.09. 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.05.09

Before submitting an issue make sure you have:

  • [*] At least skimmed through README and most notably 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

The following sections concretize particular purposed issues, you can erase any section (the contents between triple ---) not applicable to your issue


If the purpose of this issue is a bug report, site support request or you are not completely sure provide the full verbose output as follows:

Add -v flag to your command line you run youtube-dl with, copy the whole output and insert it here. It should look similar to one below (replace it with your log inserted between triple ```):

$ youtube-dl https://www.youtube.com/watch?v=qcijCmUkqrc -x -f bestaudio[ext=mp3]/bestaudio/best --audio-format mp3 0 --metadata-from-title "[MV] %(artist)s - %(title)s" --add-metadata --embed-thumbnail -o "%(artist)s - %(title)s.%(ext)s" --hls-prefer-native -v
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['https://www.youtube.com/watch?v=y2tZJQQnAHQ', '-x', '-f', 'bestaudio[ext=mp3]/bestaudio/bes
t', '--audio-format', 'mp3', '0', '--metadata-from-title', '%(artist)s - %(title)s', '--add-metadata', '--embed-thumbnai
l', '-o', '%(artist)s_%(title)s.%(ext)s', '--hls-prefer-native', '-v']
[debug] Encodings: locale cp949, fs mbcs, out cp949, pref cp949
[debug] youtube-dl version 2017.05.09
[debug] Python version 3.4.4 - Windows-10-10.0.15063
[debug] exe versions: ffmpeg N-85750-ga75ef15, ffprobe N-85750-ga75ef15
[debug] Proxy map: {}
[youtube] y2tZJQQnAHQ: Downloading webpage
[youtube] y2tZJQQnAHQ: Downloading video info webpage
[youtube] y2tZJQQnAHQ: Extracting video information
[youtube] y2tZJQQnAHQ: Downloading MPD manifest
[youtube] y2tZJQQnAHQ: Downloading thumbnail ...
[youtube] y2tZJQQnAHQ: Writing thumbnail to: NA_NieR - Automata OST - Song of the Ancients - Atonement (Instrumental).jp
g
[debug] Invoking downloader on 'https://r1---sn-vgpvoj5-tu1e.googlevideo.com/videoplayback?id=o-AJ4CS_RNYwigf_xBOMSAuQ7_
wBBxmMZP0vddzlSvtvpQ&itag=251&ip=199.212.251.24&key=yt6&dur=133.941&lmt=1488403299539061&ms=au&clen=2228993&mv=m&mt=1494
420863&expire=1494442505&pl=24&requiressl=yes&signature=7D8CC838539EF9C4AAF81D7536D409F43459B408.A064C55E87D6B3817762C82
D7339BEA0BB29EE24&ipbits=0&mn=sn-vgpvoj5-tu1e&mm=31&ei=qQ0TWZbpIcTwugKU74KQDg&gir=yes&initcwndbps=5720000&keepalive=yes&
source=youtube&upn=bhawi_m5tAU&mime=audio%2Fwebm&sparams=clen%2Cdur%2Cei%2Cgir%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2
Ckeepalive%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cpl%2Crequiressl%2Csource%2Cupn%2Cexpire&ratebypass=yes'
[download] Destination: NA_NieR - Automata OST - Song of the Ancients - Atonement (Instrumental).webm
[download] 100% of 2.13MiB in 00:00
[fromtitle] parsed title: Atonement (Instrumental)
[fromtitle] parsed artist: NieR: Automata OST - Song of the Ancients
[debug] ffmpeg command line: ffprobe -show_streams 'file:NA_NieR - Automata OST - Song of the Ancients - Atonement (Inst
rumental).webm'
[ffmpeg] Destination: NA_NieR - Automata OST - Song of the Ancients - Atonement (Instrumental).mp3
[debug] ffmpeg command line: ffmpeg -y -i 'file:NA_NieR - Automata OST - Song of the Ancients - Atonement (Instrumental)
.webm' -vn -acodec libmp3lame -q:a 5 'file:NA_NieR - Automata OST - Song of the Ancients - Atonement (Instrumental).mp3'
Deleting original file NA_NieR - Automata OST - Song of the Ancients - Atonement (Instrumental).webm (pass -k to keep)
[ffmpeg] Adding metadata to 'NA_NieR - Automata OST - Song of the Ancients - Atonement (Instrumental).mp3'
[debug] ffmpeg command line: ffmpeg -y -i 'file:NA_NieR - Automata OST - Song of the Ancients - Atonement (Instrumental)
.mp3' -c copy -metadata 'description=0'
[ffmpeg] Adding thumbnail to "NA_NieR - Automata OST - Song of the Ancients - Atonement (Instrumental).mp3"
[debug] ffmpeg command line: ffmpeg -y -i 'file:NA_NieR - Automata OST - Song of the Ancients - Atonement (Instrumental)
.mp3' -i 'file:NA_NieR - Automata OST - Song of the Ancients - Atonement (Instrumental).jpg' -c copy -map 0 -map 1 -meta
data:s:v 'title="Album cover"' -metadata:s:v 'comment="Cover (Front)"' 'file:NA_NieR - Automata OST - Song of the Ancien
ts - Atonement (Instrumental).temp.mp3'
ERROR: '0' is not a valid URL. Set --default-search "ytsearch" (or run  youtube-dl "ytsearch:0" ) to search YouTube
Traceback (most recent call last):
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmpup5muf90\build\youtube_dl\YoutubeDL.py", line 760,
in extract_info
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmpup5muf90\build\youtube_dl\extractor\common.py", lin
e 433, in extract
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmpup5muf90\build\youtube_dl\extractor\generic.py", li
ne 1845, in _real_extract
youtube_dl.utils.ExtractorError: '0' is not a valid URL. Set --default-search "ytsearch" (or run  youtube-dl "ytsearch:0
" ) to search YouTube
...
<end of log>

If the purpose of this issue is a site support request please provide all kinds of example URLs support for which should be included (replace following example URLs by yours):

Note that youtube-dl does not support sites dedicated to copyright infringement. In order for site support request to be accepted all provided example URLs should not violate any copyrights.


Description of your issue, suggested solution and other information

So the title and the artist is well retrieved from the title and the --add-metadata function works fine. However, as the document says that this --metadata-from-title should replace the original and also should be applied to -o function as well. The title is retrieved as NA and the title is retrieved as the whole title of the video. It seems like that the download of the file and the naming happens before the retrieval of --metadata-from-title and causes the problem.

@dstftw
Copy link
Collaborator

@dstftw dstftw commented May 10, 2017

It's not supposed to replace original metadata. It only overrides original metadata during postprocessing since it's a postprocessing option.

@dstftw dstftw closed this May 10, 2017
@dstftw dstftw added the invalid label May 10, 2017
@yjs990427
Copy link
Author

@yjs990427 yjs990427 commented May 10, 2017

OK.

@JoshuaSCochrane
Copy link

@JoshuaSCochrane JoshuaSCochrane commented Sep 29, 2018

So --metadata-from-title only applies to the metadata added to the file? And doesn't override any existing metadata? From what I can tell, it also doesn't appear in the '.info.json' (with --write-info-json)?

That's not clear from the readme; I'm willing to draft a PR to update, but want to make sure I'm clear on the particulars first...

@morsik
Copy link

@morsik morsik commented Jun 22, 2019

If it's not supposed to replace original metadata, then how we can specify output filename based on original YouTube video parsed title?

@morsik
Copy link

@morsik morsik commented Jun 22, 2019

Ok, did this workaround using Python (which I wanted to use anyway).

I hope it'll be useful for someone!

import youtube_dl
from youtube_dl.postprocessor.metadatafromtitle import MetadataFromTitlePP

class YTDL(youtube_dl.YoutubeDL):
    def prepare_filename(self, info_dict):
        mftpp = MetadataFromTitlePP(self, self.params['_titleformat'])
        _, info = mftpp.run(info_dict)
        return self.params['outtmpl'] % info

def main():
    titleformat = '(?P<artist>.*) - (?P<track>.*) \(Karaoke\)'
    ydl_opts = {
        'recode_format': 'mp4',
        'outtmpl': '%(artist)s - %(track)s',

        # add processors so metadata will be embedded into file, cause "why not?"
        'postprocessors': [
            {
                'key': 'MetadataFromTitle',
                'titleformat': titleformat,
            },
            {
                'key': 'FFmpegMetadata',
            },

        # this will be used by overriden `prepare_filename` method
        '_titleformat': titleformat,
    }
    with YTDL(ydl_opts) as ydl:
        x = ydl.download(['https://www.youtube.com/watch?v=uXibGgDyy_0'])
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
4 participants
You can’t perform that action at this time.