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

How to embed downloading date in filename #10558

Closed
urza opened this issue Sep 5, 2016 · 10 comments
Closed

How to embed downloading date in filename #10558

urza opened this issue Sep 5, 2016 · 10 comments

Comments

@urza
Copy link

@urza urza commented Sep 5, 2016

Hi,
I know there is unix timestamp, but I would like to have just YYYYMMDD date of when the video was downloaded as part of the output filename. Is this possible?

@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Sep 5, 2016

%(upload_date)s should work.

@yan12125 yan12125 closed this Sep 5, 2016
@urza
Copy link
Author

@urza urza commented Sep 5, 2016

I am not interested in "upload date" but "download date".

@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Sep 5, 2016

Sorry I misunderstood you. It's not possible with youtube-dl only. An approach can be using --exec with some script to rename the downloaded file.

@urza
Copy link
Author

@urza urza commented Sep 5, 2016

Can I suggest this as feature somewhere?

@phihag
Copy link
Contributor

@phihag phihag commented Sep 5, 2016

What's wrong with

youtube-dl -o "$(date +%Y%m%d)-%(title)s-%(id)s.%(ext)s" your_url_here

or an equivalent if your shell does not conform to POSIX? I don't think we need to add any features to youtube-dl for that. Or are you really running youtube-dl jobs that span days?

@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Sep 5, 2016

Thanks @phihag. I wasn't aware of such a simple solution.

@urza
Copy link
Author

@urza urza commented Sep 5, 2016

Excellent, I didn't know I could do this. I am not as experienced with command line.
Maybe it would be worth noting in the documentation?

@phihag
Copy link
Contributor

@phihag phihag commented Sep 5, 2016

Not really, composability is a primary feature of any decent shell. There are thousands of simple and useful compositions, and billions in general. We can't list them all, and that's out of scope of youtube-dl.

@urza
Copy link
Author

@urza urza commented Mar 14, 2017

Hi, could you help me please?
I tried to put the date in the filename as suggested by adding the $(date +%Y%m%d) into the output filename but youtube-dl is returning and error when I try to download the videos:
"ERROR: Error in output template: unsupported format character 'Y' (0x59) at index 54 (encoding: 'UTF-8')"

My download command is in file dowload_yt.sh and looks like this:

#!/bin/bash
/usr/local/bin/youtube-dl -o '/path/$(date +%Y%m%d)-%(uploader)s-%(title)s-%(id)s.%(ext)s' -w --restrict-filenames 'https://www.youtube.com/playlist?list=PLq4GeMnWONsS8bLDYF8zvpfz1fEyk22T9' -i

Thanks for any help.

@urza
Copy link
Author

@urza urza commented Mar 14, 2017

Nevermind, I have it working:

#!/bin/bash
-o '/path/'$(date +"%Y%m%d")'-%(uploader)s-%(title)s-%(id)s.%(ext)s' -w --restrict-filenames ...

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.