'%(uri)s' as part of --output TEMPLATE options ... #320

Closed
opened 2026-02-20 21:09:14 -05:00 by deekerman · 9 comments
Owner

Originally created by @Albretch on GitHub (Sep 6, 2012).

Originally assigned to: @FiloSottile on GitHub.

I keep an updated local cache of some videos on youtube (to use them in classes)
~
I have noticed that youtube users are able to edit their video titles (as the free text entry it is) so sometimes I have mistakenly dowloaded what is exactly the same video
~
The only way I see around that problem is to use the URI (the 11 Base64(?) characters) and download the description as well via "--write-description", but as part of the --output TEMPLATE options I don't see something like '%(uri)s'
~
Of course, you could use a script and parse that piece of text, but restarting a youtube process for each uri is a waste
~
How do you work around this problem? Or could you include such an option?
~
thanks
lbrtchx
github.com/rg3/youtube-dl/:
~
// __ exact command line:

export _ODIR="/media/sda1/yt"
export _IFL="/media/sda1/yturls.txt"

export _DT=date +%Y%m%d%H%M%S

date
youtube-dl --verbose --no-overwrites --continue --no-progress --console-title --prefer-free-formats --audio-format best --max-quality mp4 --write-description -o --cookies cookies_jar.txt "${_ODIR}/"'%(uploader)s'"/"'%(stitle)s'.'%(ext)s' --batch-file "${_IFL}" >> "${_ODIR}/"${_DT}_yt.log.txt 2>&1
date
~
$ youtube-dl --version
2012.02.27
~
$ python --version
Python 2.7.3rc2
~
// __ Operating System

$ uname -a
Linux Microknoppix 3.3.7 #38 SMP PREEMPT Tue May 22 06:21:01 CEST 2012 i686 GNU/Linux

Originally created by @Albretch on GitHub (Sep 6, 2012). Originally assigned to: @FiloSottile on GitHub. I keep an updated local cache of some videos on youtube (to use them in classes) ~ I have noticed that youtube users are able to edit their video titles (as the free text entry it is) so sometimes I have mistakenly dowloaded what is exactly the same video ~ The only way I see around that problem is to use the URI (the 11 Base64(?) characters) and download the description as well via "--write-description", but as part of the --output TEMPLATE options I don't see something like '%(uri)s' ~ Of course, you could use a script and parse that piece of text, but restarting a youtube process for each uri is a waste ~ How do you work around this problem? Or could you include such an option? ~ thanks lbrtchx github.com/rg3/youtube-dl/: ~ // __ exact command line: export _ODIR="/media/sda1/yt" export _IFL="/media/sda1/yturls.txt" export _DT=`date +%Y%m%d%H%M%S` date youtube-dl --verbose --no-overwrites --continue --no-progress --console-title --prefer-free-formats --audio-format best --max-quality mp4 --write-description -o --cookies cookies_jar.txt "${_ODIR}/"'%(uploader)s'"/"'%(stitle)s'.'%(ext)s' --batch-file "${_IFL}" >> "${_ODIR}/"${_DT}_yt.log.txt 2>&1 date ~ $ youtube-dl --version 2012.02.27 ~ $ python --version Python 2.7.3rc2 ~ // __ Operating System $ uname -a Linux Microknoppix 3.3.7 #38 SMP PREEMPT Tue May 22 06:21:01 CEST 2012 i686 GNU/Linux
Author
Owner

@Albretch commented on GitHub (Sep 8, 2012):

for example, both lessons are (exactly) called "Cognitive Science C103 - Lecture 15" ...
~
youtube.com/watch?v=VM-8A5Jmo7c
~
youtube.com/watch?v=sA9fazTAOyE
~
lbrtchx

@Albretch commented on GitHub (Sep 8, 2012): for example, both lessons are (exactly) called "Cognitive Science C103 - Lecture 15" ... ~ youtube.com/watch?v=VM-8A5Jmo7c ~ youtube.com/watch?v=sA9fazTAOyE ~ lbrtchx
Author
Owner

@Albretch commented on GitHub (Sep 8, 2012):

I didn't mean to "close" the issue, but the window ;-)
~
lbrtchx

@Albretch commented on GitHub (Sep 8, 2012): I didn't mean to "close" the issue, but the window ;-) ~ lbrtchx
Author
Owner

@Albretch commented on GitHub (Sep 8, 2012):

I know if you go

$ youtube-dl --verbose http://www.youtube.com/watch?v=sA9fazTAOyE

you will get (as I want) the file name as the youtube URI (the "sA9fazTAOyE" part) and the extension of the downloaded file, but given a list of youtube URLs (which "user(s)" I have no way of knowing before hand), I am trying to download each othe files to a folder named after the youtube uploader/user as named in:

youtube.com/user/...
~
$ _ODIR="/media/sdc1/yt"
$ _DT=date +%Y%m%d%H%M%S
$ _OFL=${ODIR}"/yt-dl"${_DT}".log.txt"
$ echo "// __ logging to "${_OFL}
// __ logging to /media/sdc1/yt/yt-dl_20120908132045.log.txt

$ date
Sat Sep 8 13:20:45 UTC 2012
$ youtube-dl --no-overwrites --continue --no-progress --console-title --verbose --audio-format best --max-quality mp4 -o "${_ODIR}/"'%(uploader)s' "http://www.youtube.com/watch?v=sA9fazTAOyE&hd=1" > ${_OFL} 2>&1
$ date
Sat Sep 8 13:20:46 UTC 2012

$ cat ${_OFL}
[debug] Proxy map: {}
[youtube] Setting language
[youtube] sA9fazTAOyE: Downloading video webpage
[youtube] sA9fazTAOyE: Downloading video info webpage
[youtube] sA9fazTAOyE: Extracting video information
~
and nothing happens. I can't even find any error log
lbrtchx

@Albretch commented on GitHub (Sep 8, 2012): I know if you go $ youtube-dl --verbose http://www.youtube.com/watch?v=sA9fazTAOyE you will get (as I want) the file name as the youtube URI (the "sA9fazTAOyE" part) and the extension of the downloaded file, but given a list of youtube URLs (which "user(s)" I have no way of knowing before hand), I am trying to download each othe files to a folder named after the youtube uploader/user as named in: youtube.com/user/... ~ $ _ODIR="/media/sdc1/yt" $ _DT=`date +%Y%m%d%H%M%S` $ _OFL=${_ODIR}"/yt-dl_"${_DT}".log.txt" $ echo "// __ logging to "${_OFL} // __ logging to /media/sdc1/yt/yt-dl_20120908132045.log.txt $ date Sat Sep 8 13:20:45 UTC 2012 $ youtube-dl --no-overwrites --continue --no-progress --console-title --verbose --audio-format best --max-quality mp4 -o "${_ODIR}/"'%(uploader)s' "http://www.youtube.com/watch?v=sA9fazTAOyE&hd=1" > ${_OFL} 2>&1 $ date Sat Sep 8 13:20:46 UTC 2012 $ cat ${_OFL} [debug] Proxy map: {} [youtube] Setting language [youtube] sA9fazTAOyE: Downloading video webpage [youtube] sA9fazTAOyE: Downloading video info webpage [youtube] sA9fazTAOyE: Extracting video information ~ and nothing happens. I can't even find any error log lbrtchx
Author
Owner

@Chronial commented on GitHub (Nov 27, 2012):

why don’t you just use %(id)s?

@Chronial commented on GitHub (Nov 27, 2012): why don’t you just use `%(id)s`?
Author
Owner

@Albretch commented on GitHub (Nov 28, 2012):

On 11/27/12, Chronial notifications@github.com wrote:

why don’t you just use %(id)s?
~
'%(id)s' worked exactly as I needed. Thank you
~
$ youtube-dl --no-overwrites --continue --no-progress --console-title
--audio-format best --max-quality mp4 -o
'%(uploader)s'"/"'%(id)s'.'%(ext)s'
"http://www.youtube.com/watch?v=d020hcWA_Wg&hd=1"
[youtube] Setting language
[youtube] d020hcWA_Wg: Downloading video webpage
[youtube] d020hcWA_Wg: Downloading video info webpage
[youtube] d020hcWA_Wg: Extracting video information
[download] Destination: ColdplayVEVO/d020hcWA_Wg.mp4
[download] Download completed
knoppix@Microknoppix:~$ cd ColdplayVEVO/

$ ls -l d020hcWA_Wg.mp4
-rw-r--r-- 1 knoppix knoppix 55857786 May 27 2011 d020hcWA_Wg.mp4

$ ffprobe d020hcWA_Wg.mp4
avprobe version 0.8.2-6:0.8.2-2, Copyright (c) 2007-2011 the Libav developers
built on May 16 2012 19:58:09 with gcc 4.7.0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'd020hcWA_Wg.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2011-05-26 15:44:38
Duration: 00:04:17.48, start: 0.000000, bitrate: 1735 kb/s
Stream #0.0(und): Video: h264 (High), yuv420p, 1280x720, 1579
kb/s, 25 fps, 25 tbr, 1k tbn, 50 tbc
Metadata:
creation_time : 1970-01-01 00:00:00
Stream #0.1(und): Audio: aac, 44100 Hz, stereo, s16, 151 kb/s
Metadata:
creation_time : 2011-05-26 15:44:38
~
Now, was it included, after my post?
~
lbrtchx

@Albretch commented on GitHub (Nov 28, 2012): On 11/27/12, Chronial notifications@github.com wrote: > why don’t you just use `%(id)s`? > ~ > '%(id)s' worked exactly as I needed. Thank you > ~ > $ youtube-dl --no-overwrites --continue --no-progress --console-title > --audio-format best --max-quality mp4 -o > '%(uploader)s'"/"'%(id)s'.'%(ext)s' > "http://www.youtube.com/watch?v=d020hcWA_Wg&hd=1" > [youtube] Setting language > [youtube] d020hcWA_Wg: Downloading video webpage > [youtube] d020hcWA_Wg: Downloading video info webpage > [youtube] d020hcWA_Wg: Extracting video information > [download] Destination: ColdplayVEVO/d020hcWA_Wg.mp4 > [download] Download completed > knoppix@Microknoppix:~$ cd ColdplayVEVO/ $ ls -l d020hcWA_Wg.mp4 -rw-r--r-- 1 knoppix knoppix 55857786 May 27 2011 d020hcWA_Wg.mp4 $ ffprobe d020hcWA_Wg.mp4 avprobe version 0.8.2-6:0.8.2-2, Copyright (c) 2007-2011 the Libav developers built on May 16 2012 19:58:09 with gcc 4.7.0 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'd020hcWA_Wg.mp4': Metadata: major_brand : mp42 minor_version : 0 compatible_brands: isommp42 creation_time : 2011-05-26 15:44:38 Duration: 00:04:17.48, start: 0.000000, bitrate: 1735 kb/s Stream #0.0(und): Video: h264 (High), yuv420p, 1280x720, 1579 kb/s, 25 fps, 25 tbr, 1k tbn, 50 tbc Metadata: creation_time : 1970-01-01 00:00:00 Stream #0.1(und): Audio: aac, 44100 Hz, stereo, s16, 151 kb/s Metadata: creation_time : 2011-05-26 15:44:38 ~ Now, was it included, after my post? ~ lbrtchx
Author
Owner

@Chronial commented on GitHub (Nov 28, 2012):

nope, always been there

@Chronial commented on GitHub (Nov 28, 2012): nope, always been there
Author
Owner

@Albretch commented on GitHub (Nov 29, 2012):

nope, always been there
~
Then, thanks. It may be I wasn't getting something right. My original
post was about '%(id)s' not working with the --batch-file option. It
does now:
~
$ date; youtube-dl --no-overwrites --continue --no-progress
--console-title --audio-format best --max-quality mp4 -o
'%(uploader)s'"/"'%(id)s'.'%(ext)s' --batch-file yt_urls.txt; date
Thu Nov 29 11:03:33 UTC 2012
[youtube] Setting language
[youtube] d020hcWA_Wg: Downloading video webpage
[youtube] d020hcWA_Wg: Downloading video info webpage
[youtube] d020hcWA_Wg: Extracting video information
[download] Destination: ColdplayVEVO/d020hcWA_Wg.mp4
[download] Download completed
[youtube] 8hI_rBJ72qg: Downloading video webpage
[youtube] 8hI_rBJ72qg: Downloading video info webpage
[youtube] 8hI_rBJ72qg: Extracting video information
[download] Destination: TransmissionRec/8hI_rBJ72qg.flv
[download] Download completed
Thu Nov 29 11:07:54 UTC 2012

$ cat yt_urls.txt
http://www.youtube.com/watch?v=d020hcWA_Wg&hd=1
http://www.youtube.com/watch?v=8hI_rBJ72qg&hd=1

$ find . -type f -printf "%p %s %As\n"
/media/sdb5/tmp/knoppix/test/ColdplayVEVO/d020hcWA_Wg.mp4 55857786 1354187109
/media/sdb5/tmp/knoppix/test/TransmissionRec/8hI_rBJ72qg.flv 18937643 1354187274
~
lbrtchx

@Albretch commented on GitHub (Nov 29, 2012): > nope, always been there > ~ > Then, thanks. It may be I wasn't getting something right. My original > post was about '%(id)s' not working with the --batch-file option. It > does now: > ~ > $ date; youtube-dl --no-overwrites --continue --no-progress > --console-title --audio-format best --max-quality mp4 -o > '%(uploader)s'"/"'%(id)s'.'%(ext)s' --batch-file yt_urls.txt; date > Thu Nov 29 11:03:33 UTC 2012 > [youtube] Setting language > [youtube] d020hcWA_Wg: Downloading video webpage > [youtube] d020hcWA_Wg: Downloading video info webpage > [youtube] d020hcWA_Wg: Extracting video information > [download] Destination: ColdplayVEVO/d020hcWA_Wg.mp4 > [download] Download completed > [youtube] 8hI_rBJ72qg: Downloading video webpage > [youtube] 8hI_rBJ72qg: Downloading video info webpage > [youtube] 8hI_rBJ72qg: Extracting video information > [download] Destination: TransmissionRec/8hI_rBJ72qg.flv > [download] Download completed > Thu Nov 29 11:07:54 UTC 2012 $ cat yt_urls.txt http://www.youtube.com/watch?v=d020hcWA_Wg&hd=1 http://www.youtube.com/watch?v=8hI_rBJ72qg&hd=1 $ find . -type f -printf "%p %s %As\n" /media/sdb5/tmp/knoppix/test/ColdplayVEVO/d020hcWA_Wg.mp4 55857786 1354187109 /media/sdb5/tmp/knoppix/test/TransmissionRec/8hI_rBJ72qg.flv 18937643 1354187274 ~ lbrtchx
Author
Owner

@archaeologistdev commented on GitHub (May 23, 2014):

@phihag according to the OP, this has been resolved. close?

@archaeologistdev commented on GitHub (May 23, 2014): @phihag according to the OP, this has been resolved. close?
Author
Owner

@phihag commented on GitHub (May 23, 2014):

@codesparkle Thank you very much for your diligent work!

Yes, this has been solved. Either use %(id)s or %(webpage_url)s in the filename template.

@phihag commented on GitHub (May 23, 2014): @codesparkle Thank you very much for your diligent work! Yes, this has been solved. Either use `%(id)s` or `%(webpage_url)s` in the filename template.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/youtube-dl#320
No description provided.