From bc999359f55e3d41b1f7f58ee92d22e23b26219f Mon Sep 17 00:00:00 2001 From: RandomNinjaAtk Date: Sun, 5 Feb 2023 10:22:11 -0500 Subject: [PATCH] 1.0.2 - Only try production codes for YouTube network videos Also only scrape the page one time, reduce load on servers and increase speed for multiple operations.. #21 --- root/scripts/Youtube-Series-Downloader.bash | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/root/scripts/Youtube-Series-Downloader.bash b/root/scripts/Youtube-Series-Downloader.bash index efb59b2..794df51 100644 --- a/root/scripts/Youtube-Series-Downloader.bash +++ b/root/scripts/Youtube-Series-Downloader.bash @@ -1,5 +1,5 @@ #!/usr/bin/env bash -scriptVersion="1.0.1" +scriptVersion="1.0.2" if [ -z "$arrUrl" ] || [ -z "$arrApiKey" ]; then arrUrlBase="$(cat /config/config.xml | xq | jq -r .Config.UrlBase)" @@ -90,12 +90,16 @@ for id in $(echo $sonarrSeriesIds); do seriesEpisdodeData=$(echo $seriesEpisodeData | jq -r ".[] | select(.tvdbId==$episodeId)") episodeSeasonNumber=$(echo $seriesEpisdodeData | jq -r .seasonNumber) episodeNumber=$(echo $seriesEpisdodeData | jq -r .episodeNumber) - downloadUrl=$(curl -s "https://thetvdb.com/series/$seriesTvdbTitleSlug/episodes/$episodeId" | grep -i youtube.com | grep -i watch | grep -Eo "(http|https)://[a-zA-Z0-9./?=_%:-]*") + tvdbPageData=$(curl -s "https://thetvdb.com/series/$seriesTvdbTitleSlug/episodes/$episodeId") + downloadUrl=$(echo "$tvdbPageData" | grep -i youtube.com | grep -i watch | grep -Eo "(http|https)://[a-zA-Z0-9./?=_%:-]*") if [ -z $downloadUrl ]; then - downloadUrl=$(curl -s "https://thetvdb.com/series/$seriesTvdbTitleSlug/episodes/$episodeId" | grep -iwns "production code" -A 2 | sed 's/\ //g' | cut -d "-" -f2 | tail -n1) - if [ ! -z $downloadUrl ]; then - downloadUrl="https://www.youtube.com/watch?v=$downloadUrl" + network="$(echo "$tvdbPageData" | grep -i "/companies/youtube")" + if [ ! -z "$network" ]; then + downloadUrl=$(echo "$tvdbPageData" | grep -iwns "production code" -A 2 | sed 's/\ //g' | cut -d "-" -f2 | tail -n1) + if [ ! -z $downloadUrl ]; then + downloadUrl="https://www.youtube.com/watch?v=$downloadUrl" + fi fi fi