ytdl-org / youtube-dl

Command-line program to download videos from YouTube.com and other video sites
http://ytdl-org.github.io/youtube-dl/
The Unlicense
131.39k stars 9.96k forks source link

Adding thumbnail to video with special characters in title causes error due to incorrectly escaped thumbnail filename #9090

Closed pkirkovsky closed 8 years ago

pkirkovsky commented 8 years ago
$ youtube-dl --version
2016.04.05
$ echo $BASH_VERSION
4.3.42(1)-release

Downloading a single video works fine:

$ youtube-dl --merge-output-format "mkv" --add-metadata "https://www.youtube.com/watch?v=u4I6qunvdT0" -v
[debug] System config: []
[debug] User config: []
[debug] Command-line args: [u'--merge-output-format', u'mkv', u'--add-metadata', u'https://www.youtube.com/watch?v=u4I6qunvdT0', u'-v']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2016.04.05
[debug] Python version 2.7.11 - Darwin-14.5.0-x86_64-i386-64bit
[debug] exe versions: avconv 11.4, avprobe 11.4, ffmpeg 3.0.1, ffprobe 3.0.1
[debug] Proxy map: {}
[youtube] u4I6qunvdT0: Downloading webpage
[youtube] u4I6qunvdT0: Downloading video info webpage
[youtube] u4I6qunvdT0: Extracting video information
[youtube] u4I6qunvdT0: Downloading MPD manifest
[debug] Invoking downloader on u'https://r14---sn-nx57ynez.googlevideo.com/videoplayback?id=bb823aaae9ef753d&itag=137&source=youtube&requiressl=yes&mv=m&mm=31&mn=sn-nx57ynez&pl=26&ms=au&nh=IgpwcjAxLnNlYTAzKgkxMjcuMC4wLjE&ratebypass=yes&mime=video/mp4&gir=yes&clen=351762472&lmt=1459862457178129&dur=790.182&fexp=9408503,9413142,9416126,9416891,9417157,9420452,9422596,9423662,9426927,9427413,9427902,9428092,9428246,9428398,9429504,9429544,9432134,9432224,9432564,9432683,9433068,9433596,9433630&mt=1459923304&sver=3&key=dg_yt0&signature=43F1C38690E110628FCA6ABE8FB355D02ADED749.6B272F8517909D9BC690DEB1D0F620E4B7D1CF58&upn=wN__RX3oZNA&ip=2601:1c1:c000:e45c:aca1:3abc:e022:5c3e&ipbits=0&expire=1459945088&sparams=ip,ipbits,expire,id,itag,source,requiressl,mv,mm,mn,pl,ms,nh,ratebypass,mime,gir,clen,lmt,dur'
[download] Destination: 'What you growing through Winter Rob' & a look at a Scaly Visitor-u4I6qunvdT0.f137.mp4
[download] 100% of 335.47MiB in 00:50
[debug] Invoking downloader on u'https://r14---sn-nx57ynez.googlevideo.com/videoplayback?dur=790.701&clen=12944435&source=youtube&initcwndbps=2122500&fexp=9408503%2C9413142%2C9416126%2C9416891%2C9417157%2C9420452%2C9422596%2C9423662%2C9426927%2C9427413%2C9427902%2C9428092%2C9428246%2C9428398%2C9429504%2C9429544%2C9432134%2C9432224%2C9432564%2C9432683%2C9433068%2C9433596%2C9433630&nh=IgpwcjAxLnNlYTAzKgkxMjcuMC4wLjE&ipbits=0&upn=sekMTVOZmMI&mime=audio%2Fwebm&id=o-APp3ZLM4r9NEY-5Xp5kRkr5f5zvf85UvRgH4YqqyuXZX&pl=26&lmt=1459901021561137&sver=3&ms=au&sparams=clen%2Cdur%2Cgir%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Ckeepalive%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cnh%2Cpl%2Crequiressl%2Csource%2Cupn%2Cexpire&mt=1459923304&mv=m&mm=31&ip=2601%3A1c1%3Ac000%3Ae45c%3Aaca1%3A3abc%3Ae022%3A5c3e&mn=sn-nx57ynez&gir=yes&expire=1459945087&keepalive=yes&itag=251&signature=DF087B88734A1C1DC7E912E8C7FBFF691DEDB384.B6F63B65E7F5F302F7C4EC988D6E1DF71D7C9935&requiressl=yes&key=yt6&ratebypass=yes'
[download] Destination: 'What you growing through Winter Rob' & a look at a Scaly Visitor-u4I6qunvdT0.f251.webm
[download] 100% of 12.34MiB in 00:01
[ffmpeg] Merging formats into "'What you growing through Winter Rob' & a look at a Scaly Visitor-u4I6qunvdT0.mkv"
[debug] ffmpeg command line: avconv -y -i 'file:'"'"'What you growing through Winter Rob'"'"' & a look at a Scaly Visitor-u4I6qunvdT0.f137.mp4' -i 'file:'"'"'What you growing through Winter Rob'"'"' & a look at a Scaly Visitor-u4I6qunvdT0.f251.webm' -c copy -map 0:v:0 -map 1:a:0 'file:'"'"'What you growing through Winter Rob'"'"' & a look at a Scaly Visitor-u4I6qunvdT0.temp.mkv'
Deleting original file 'What you growing through Winter Rob' & a look at a Scaly Visitor-u4I6qunvdT0.f137.mp4 (pass -k to keep)
Deleting original file 'What you growing through Winter Rob' & a look at a Scaly Visitor-u4I6qunvdT0.f251.webm (pass -k to keep)
[ffmpeg] Adding metadata to ''What you growing through Winter Rob' & a look at a Scaly Visitor-u4I6qunvdT0.mkv'
[debug] ffmpeg command line: avconv -y -i 'file:'"'"'What you growing through Winter Rob'"'"' & a look at a Scaly Visitor-u4I6qunvdT0.mkv' -c copy -metadata 'comment=Hi Folks. Had a few people curious as to what I'"'"'m planting/sowing out for our winter crops in the patch so here'"'"'s a bit of a sneak peek. 😉
This is only round one & hope to get a few lots of brassicas over the cooler months. Also added a look at a common green tree snake I found slithering through the aquaponics last week.

Subscribing to us here at Bits Out the Back is as easy as clicking below,
http://www.youtube.com/subscription_center?add_user=bnbob01

You can also find Bits Out the Back various social media where we post mini updates on the aquaponics, chooks, worms, wicking bed gardens & other small tidbits daily.

www.facebook.com/Bitsouttheback
http://bitsouttheback.tumblr.com/
http://instagram.com/bits_out_the_back    @bits_out_the_back
https://www.pinterest.com/bitsouttheback/
https://twitter.com/RobsUrbanFarm     @RobsUrbanFarm

Happy growing all & have a great one,
Rob.' -metadata 'description=Hi Folks. Had a few people curious as to what I'"'"'m planting/sowing out for our winter crops in the patch so here'"'"'s a bit of a sneak peek. 😉
This is only round one & hope to get a few lots of brassicas over the cooler months. Also added a look at a common green tree snake I found slithering through the aquaponics last week.

Subscribing to us here at Bits Out the Back is as easy as clicking below,
http://www.youtube.com/subscription_center?add_user=bnbob01

You can also find Bits Out the Back various social media where we post mini updates on the aquaponics, chooks, worms, wicking bed gardens & other small tidbits daily.

www.facebook.com/Bitsouttheback
http://bitsouttheback.tumblr.com/
http://instagram.com/bits_out_the_back    @bits_out_the_back
https://www.pinterest.com/bitsouttheback/
https://twitter.com/RobsUrbanFarm     @RobsUrbanFarm

Happy growing all & have a great one,
Rob.' -metadata 'artist=Rob Bob'"'"'s Backyard Farming' -metadata 'title="What you growing through Winter Rob?" & a look at a Scaly Visitor' -metadata date=20160403 -metadata 'purl=https://www.youtube.com/watch?v=u4I6qunvdT0' 'file:'"'"'What you growing through Winter Rob'"'"' & a look at a Scaly Visitor-u4I6qunvdT0.temp.mkv'

Downloading the same video with an embedded thumbnail causes an error:

$ youtube-dl --merge-output-format "mkv" --embed-thumbnail --add-metadata "https://www.youtube.com/watch?v=u4I6qunvdT0" -v
[debug] System config: []
[debug] User config: []
[debug] Command-line args: [u'--merge-output-format', u'mkv', u'--embed-thumbnail', u'--add-metadata', u'https://www.youtube.com/watch?v=u4I6qunvdT0', u'-v']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2016.04.05
[debug] Python version 2.7.11 - Darwin-14.5.0-x86_64-i386-64bit
[debug] exe versions: avconv 11.4, avprobe 11.4, ffmpeg 3.0.1, ffprobe 3.0.1
[debug] Proxy map: {}
[youtube] u4I6qunvdT0: Downloading webpage
[youtube] u4I6qunvdT0: Downloading video info webpage
[youtube] u4I6qunvdT0: Extracting video information
[youtube] u4I6qunvdT0: Downloading MPD manifest
[youtube] u4I6qunvdT0: Downloading thumbnail ...
[youtube] u4I6qunvdT0: Writing thumbnail to: 'What you growing through Winter Rob' & a look at a Scaly Visitor-u4I6qunvdT0.jpg
[download] 'What you growing through Winter Rob' & a look at a Scaly Visitor-u4I6qunvdT0.mkv has already been downloaded and merged
[ffmpeg] Adding metadata to ''What you growing through Winter Rob' & a look at a Scaly Visitor-u4I6qunvdT0.mkv'
[debug] ffmpeg command line: avconv -y -i 'file:'"'"'What you growing through Winter Rob'"'"' & a look at a Scaly Visitor-u4I6qunvdT0.mkv' -c copy -metadata 'comment=Hi Folks. Had a few people curious as to what I'"'"'m planting/sowing out for our winter crops in the patch so here'"'"'s a bit of a sneak peek. 😉
This is only round one & hope to get a few lots of brassicas over the cooler months. Also added a look at a common green tree snake I found slithering through the aquaponics last week.

Subscribing to us here at Bits Out the Back is as easy as clicking below,
http://www.youtube.com/subscription_center?add_user=bnbob01

You can also find Bits Out the Back various social media where we post mini updates on the aquaponics, chooks, worms, wicking bed gardens & other small tidbits daily.

www.facebook.com/Bitsouttheback
http://bitsouttheback.tumblr.com/
http://instagram.com/bits_out_the_back    @bits_out_the_back
https://www.pinterest.com/bitsouttheback/
https://twitter.com/RobsUrbanFarm     @RobsUrbanFarm

Happy growing all & have a great one,
Rob.' -metadata 'description=Hi Folks. Had a few people curious as to what I'"'"'m planting/sowing out for our winter crops in the patch so here'"'"'s a bit of a sneak peek. 😉
This is only round one & hope to get a few lots of brassicas over the cooler months. Also added a look at a common green tree snake I found slithering through the aquaponics last week.

Subscribing to us here at Bits Out the Back is as easy as clicking below,
http://www.youtube.com/subscription_center?add_user=bnbob01

You can also find Bits Out the Back various social media where we post mini updates on the aquaponics, chooks, worms, wicking bed gardens & other small tidbits daily.

www.facebook.com/Bitsouttheback
http://bitsouttheback.tumblr.com/
http://instagram.com/bits_out_the_back    @bits_out_the_back
https://www.pinterest.com/bitsouttheback/
https://twitter.com/RobsUrbanFarm     @RobsUrbanFarm

Happy growing all & have a great one,
Rob.' -metadata 'artist=Rob Bob'"'"'s Backyard Farming' -metadata 'title="What you growing through Winter Rob?" & a look at a Scaly Visitor' -metadata date=20160403 -metadata 'purl=https://www.youtube.com/watch?v=u4I6qunvdT0' 'file:'"'"'What you growing through Winter Rob'"'"' & a look at a Scaly Visitor-u4I6qunvdT0.temp.mkv'
[ffmpeg] Adding thumbnail to "'What you growing through Winter Rob' & a look at a Scaly Visitor-u4I6qunvdT0.mkv"
[debug] ffmpeg command line: avconv -y -i 'file:'"'"'What you growing through Winter Rob'"'"' & a look at a Scaly Visitor-u4I6qunvdT0.mkv' -i 'file:'"'"'What you growing through Winter Rob'"'"' & a look at a Scaly Visitor-u4I6qunvdT0.jpg' -c copy -map 0 -map 1 -metadata:s:v 'title="Album cover"' -metadata:s:v 'comment="Cover (Front)"' 'file:'"'"'What you growing through Winter Rob'"'"' & a look at a Scaly Visitor-u4I6qunvdT0.temp.mkv'
ERROR: file:'What you growing through Winter Rob' & a look at a Scaly Visitor-u4I6qunvdT0.jpg: No such file or directory
Traceback (most recent call last):
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1771, in post_process
    files_to_delete, info = pp.run(info)
  File "/usr/local/bin/youtube-dl/youtube_dl/postprocessor/embedthumbnail.py", line 50, in run
    self.run_ffmpeg_multiple_files([filename, thumbnail_filename], temp_filename, options)
  File "/usr/local/bin/youtube-dl/youtube_dl/postprocessor/ffmpeg.py", line 168, in run_ffmpeg_multiple_files
    raise FFmpegPostProcessorError(msg)
FFmpegPostProcessorError

The thumbnail file does get downloaded correctly, but its filename gets mangled in the avconv call:

$ ll
total 714032
-rw-r--r--   1 user  staff   319K Apr  5 23:19 'What you growing through Winter Rob' & a look at a Scaly Visitor-u4I6qunvdT0.jpg
-rw-r--r--   1 user  staff   348M Apr  5 06:20 'What you growing through Winter Rob' & a look at a Scaly Visitor-u4I6qunvdT0.mkv

Manually escaping the file names works:

$ avconv -y -i "'What you growing through Winter Rob' & a look at a Scaly Visitor-u4I6qunvdT0.mkv" -i "'What you growing through Winter Rob' & a look at a Scaly Visitor-u4I6qunvdT0.jpg" -c copy -map 0 -map 1 -metadata:s:v 'title="Album cover"' -metadata:s:v 'comment="Cover (Front)"' "What you growing through Winter Rob' & a look at a Scaly Visitor-u4I6qunvdT0.temp.mkv"
avconv version 11.4, Copyright (c) 2000-2014 the Libav developers
  built on Oct 16 2015 08:29:13 with Apple LLVM version 7.0.0 (clang-700.0.72)
Input #0, matroska,webm, from ''What you growing through Winter Rob' & a look at a Scaly Visitor-u4I6qunvdT0.mkv':
  Metadata:
    title           : "What you growing through Winter Rob?" & a look at a Scaly Visitor
[...]
Press ctrl-c to stop encoding
frame=23293 fps=2429 q=-1.0 Lq=-1.0 size=  356272kB time=790.22 bitrate=3693.4kbits/s
video:343457kB audio:12368kB other streams:0kB global headers:0kB muxing overhead: 0.125847%
jaimeMF commented 8 years ago

This is an issue in avconv (and the quotes is not the problem, using -o foo.'%(ext)s' works), ffmpeg works fine. See https://github.com/rg3/youtube-dl/issues/7238#issuecomment-149328864.