Created
May 11, 2021 00:29
-
-
Save EmperorPenguin18/f5b126158e97d4bd5827c07aa7cb8743 to your computer and use it in GitHub Desktop.
Download the most recent 15 videos from a YouTube channel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
USER=$(ls /home) | |
mkdir -p /home/$USER/YouTube | |
for I in $(curl -s "https://www.youtube.com/feeds/videos.xml?channel_id=$1" | awk -F '"' '/watch/ {print $4}') | |
do | |
FORMATS=$(youtube-dl -F $I) | |
TITLE="$(youtube-dl --get-title $I)" | |
AUDIO=$(echo "$FORMATS" | awk '/audio/ {print $NF}' | sort -h | tail -1) | |
AUDIO=$(echo "$FORMATS" | awk "/$AUDIO/ {print \$1}") | |
VIDEO=$(echo "$FORMATS" | awk '/video/ {print $NF}' | sort -h | tail -1) | |
VIDEO=$(echo "$FORMATS" | awk "/$VIDEO/ {print \$1}") | |
youtube-dl --download-archive /home/$USER/.config/archive.txt -f $AUDIO -o "/home/$USER/YouTube/%(title)s.audio.%(ext)s" $I && \ | |
youtube-dl -f $VIDEO -o "/home/$USER/YouTube/%(title)s.video.%(ext)s" $I && \ | |
AUDIO="$(find /home/$USER/YouTube -name "$TITLE.*audio*")" && \ | |
VIDEO="$(find /home/$USER/YouTube -name "$TITLE.*video*")" && \ | |
ffmpeg -loglevel warning -i "$AUDIO" -i "$VIDEO" -c copy "/home/$USER/YouTube/$TITLE.mkv" | |
rm "$AUDIO" "$VIDEO" | |
done | |
#https://wiki.archlinux.org/index.php/Youtube-dl | |
#Fix redownloading (possible fix with man page line 668?) | |
#Fix single quote in title | |
#Audio not working | |
#Max resolution |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment