Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
%(artist)s retrieved from --metadata-from-title does not apply to -o option #13047
Comments
|
It's not supposed to replace original metadata. It only overrides original metadata during postprocessing since it's a postprocessing option. |
|
OK. |
|
So 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... |
|
If it's not supposed to replace original metadata, then how we can specify output filename based on original YouTube video parsed title? |
|
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']) |
Please follow the guide below
xinto all the boxes [ ] relevant to your issue (like that [x])Make sure you are using the latest version: run
youtube-dl --versionand ensure your version is 2017.05.09. If it's not read this FAQ entry and update. Issues with outdated version will be rejected.Before submitting an issue make sure you have:
What is the purpose of your issue?
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
-vflag 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 ```):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-metadatafunction works fine. However, as the document says that this--metadata-from-titleshould replace the original and also should be applied to-ofunction 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-titleand causes the problem.