From 26053b0e8b5b1ff2efedbb5536d64fefc82f8bda Mon Sep 17 00:00:00 2001 From: Lucien Cartier-Tilet Date: Wed, 6 Jan 2021 16:10:39 +0100 Subject: [PATCH] [Bin] Fix issue downloading videos with ytdl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When downloading a whole channel, ytdl used to download everything including playlists displayed on the user’s main page. Now, a check is performed in order to verify if the URL passed is a channel, and if it is only download the videos listed on their uploads page. --- org/config/bin.org | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/org/config/bin.org b/org/config/bin.org index f724af6..2ea73ad 100644 --- a/org/config/bin.org +++ b/org/config/bin.org @@ -833,7 +833,7 @@ The main aim of this function is to transform the URLs contained in the argument :END: The final function to declare before the main body of the script is ~_ytdl_download_batch~: it will look for each line, ignoring the ones beginning by ~#~, ~;~ and ~]~ (just like ~youtube-dl~) and will download them, assuming these are channel URLs or playlist URLs, however it should also work with direct video URLs. -What this function does is for each line, it will fetch the entierty of the video IDs found in a playlist or channel. Then, it will look each ID up the list of already downloaded videos and will add all new IDs to a queue of videos to be downloaded. It will then pass each new video ID to ~_ytdl_download_video~ directly. +What this function does is for each line, it will fetch the entierty of the video IDs found in a playlist or channel. Then, it will look each ID up the list of already downloaded videos and will add all new IDs to a queue of videos to be downloaded. It will then pass each new video ID to ~_ytdl_download_video~ directly. Beware that if you pass directly the URL of the channel, such as ~https://www.youtube.com/user/enyay~ if you want to download Tom Scott’s videos, it will download everything on the main page of their channel, which means it will even download videos from playlists they decided to put on their channel’s front page, even if it is not theirs. So in that case, we need to append ~/videos~ to any channel URL. #+BEGIN_SRC fish function _ytdl_download_batch set -q $FILE @@ -842,7 +842,11 @@ What this function does is for each line, it will fetch the entierty of the vide set CHANNELS (cat $FILE | grep -vE "#|;|\]") for c in $CHANNELS _ytdl_log "INFO" "Getting IDs for channel $c" - set IDS (youtube-dl --get-id $c) + if test (egrep '\/c\/|user|channel' (echo $c |psub)) + set -g IDS (youtube-dl --get-id "$c/videos") + else + set -g IDS (youtube-dl --get-id $c) + end _ytdl_log "INFO" "Fetching new videos from channel" for i in (seq (count $IDS)) printf "\rsearching (%d/%d)" $IDn (count $IDS)