Ubuntu – Download videos from youtube playlist or user based on date

downloadsyoutubeyoutube-dl

Can I do a date-wise download of youtube videos of particular user or playlist using youtube-dl ?

For example – download all videos uploaded by User X in this week.

Looking for provision of downloading youtube videos from a channel/user/playlist with start-date and end-date.

Best Answer

Yes. From the youtube-dl man page:

--date DATE
          Download only videos uploaded in this date

--datebefore DATE
          Download only videos uploaded on or before this date (i.e.  inclusive)

--dateafter DATE
          Download only videos uploaded on or after this date (i.e.  inclusive)

Not stated there, but only hidden in the code, is that DATE is in the format YYYYMMDD or (now|today)[+-][0-9](day|week|month|year)(s)?, so for example the 17th August 2016 would be 20160817, and seven days ago would be now-7days or now-1week.

You can specify a range by using --datebefore and --dateafter together, so:

youtube-dl -i --dateafter 20160808 --datebefore 20160810 https://www.youtube.com/channel/CHANNEL

will download all videos from a channel uploaded between and including August 8th and August 10th 2016, and:

youtube-dl -i --dateafter now-1week https://www.youtube.com/playlist?list=PLAYLIST

will download all videos from a playlist uploaded in the past week.

The -i option prevents youtube-dl from exiting prematurely if some videos are unavailable.

Note youtube-dl will still say it is downloading each video even when it doesn't. For example:

[download] Downloading video 1 of 123
[youtube] xxxxxxxxxxx: Downloading webpage
[youtube] xxxxxxxxxxx: Downloading video info webpage
[youtube] xxxxxxxxxxx: Extracting video information
[youtube] xxxxxxxxxxx: Downloading MPD manifest
[download] 2016-08-07 upload date is not in range 2016-08-08 - 2016-08-10
[download] Downloading video 2 of 123
...