Site Map - skip to main content

Hacker Public Radio

Your ideas, projects, opinions - podcasted.

New episodes Monday through Friday.

hpr2710 :: Youtube downloader for channels

A followup to hpr2675 how you can download an entire youtube channel for local playout

<< First, < Previous, Latest >>

Host Image
Hosted by Ken Fallon on 2018-12-21 is flagged as Explicit and is released under a CC-BY-SA license.
Tags: youtube, youtube-dl.
Listen in ogg, spx, or mp3 format. | Comments (1)

I had a very similar problem to Ahuka aka Kevin, in hpr2675 :: YouTube Playlists. I wanted to be able to download an entire youtube channel and store them so that I could play them in the order that they were posted.

Add the url's to a file called subscriptions.txt.

#LASTRUN: 20181030
# /home/ken/sourcecode/personal/bestofyoutube/youtube-channel-watcher.bash
# Big Clive	20181030
# Essential Craftsman

Then run the script

# Downloads videos from youtube based on selection from
# (c) Ken Fallon
# Released under the CC-0

RUNDATE=$(date +%Y%m%d)
#DRYRUN="echo DEBUG: "

if [ ! -e "${subscriptions}" ]
	echo "Cannot find subscription file "${subscriptions}""
	exit 1

if [ "$(grep "#LASTRUN: " "${subscriptions}" | wc -l )" -eq 0 ]
	sed --follow-symlinks '1s/^/#LASTRUN: n/' -i "${subscriptions}"

# Read the subscriptions
cat "${subscriptions}" | grep -v '#' | while read channel_info
	if [ "$(echo "${channel_info}" | grep -P 't' | wc -l )" -eq 0 ]
		DATEAFTER="--dateafter ${YOUNGERTHAN}"
		DATEAFTER="--dateafter $(echo "${channel_info}" | awk '{print $NF}' )"
	channel="$(echo "${channel_info}" | awk '{print $1}' )"
	echo "Processing Channel "${channel}" since ${DATEAFTER}"
	${DRYRUN} ${youtubedl} ${DATEAFTER} --ignore-errors --no-mtime --restrict-filenames --format mp4 -o ${savepath}'/%(uploader)s/%(upload_date)s-%(title)s⋄%(id)s.%(ext)s' ${channel}
	${DRYRUN} sed --follow-symlinks "s,${channel}.*$,${channel}t${RUNDATE},g" -i "${subscriptions}"

${DRYRUN} sed --follow-symlinks "s/#LASTRUN: .*$/#LASTRUN: ${RUNDATE}/" -i "${subscriptions}"


Subscribe to the comments RSS feed.

Comment #1 posted on 2018-12-21T08:07:55Z by Gustaf

Thank you

Nice one, this will come in handy. Thank you for posting

<< First, < Previous, Latest >>

Leave Comment

Note to Verbose Commenters
If you can't fit everything you want to say in the comment below then you really should record a response show instead.

Note to Spammers
All comments are moderated. All links are checked by humans. We strip out all html. Feel free to record a show about yourself, or your industry, or any other topic we may find interesting. We also check shows for spam :).

Provide feedback
Your Name/Handle:
Anti Spam Question: What does the P in HPR stand for ?
Are you a spammer →
Who hosted this show →
What does HPR mean to you ?