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
pull/24/head
RandomNinjaAtk 2 years ago committed by GitHub
parent 0239e74b44
commit bc999359f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
scriptVersion="1.0.1" scriptVersion="1.0.2"
if [ -z "$arrUrl" ] || [ -z "$arrApiKey" ]; then if [ -z "$arrUrl" ] || [ -z "$arrApiKey" ]; then
arrUrlBase="$(cat /config/config.xml | xq | jq -r .Config.UrlBase)" 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)") seriesEpisdodeData=$(echo $seriesEpisodeData | jq -r ".[] | select(.tvdbId==$episodeId)")
episodeSeasonNumber=$(echo $seriesEpisdodeData | jq -r .seasonNumber) episodeSeasonNumber=$(echo $seriesEpisdodeData | jq -r .seasonNumber)
episodeNumber=$(echo $seriesEpisdodeData | jq -r .episodeNumber) 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 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) network="$(echo "$tvdbPageData" | grep -i "/companies/youtube")"
if [ ! -z $downloadUrl ]; then if [ ! -z "$network" ]; then
downloadUrl="https://www.youtube.com/watch?v=$downloadUrl" 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
fi fi

Loading…
Cancel
Save