Skip to content

Instantly share code, notes, and snippets.

@antiops
Created July 30, 2022 08:19
Show Gist options
  • Select an option

  • Save antiops/42ba58019b6a73056d78d16552c776c2 to your computer and use it in GitHub Desktop.

Select an option

Save antiops/42ba58019b6a73056d78d16552c776c2 to your computer and use it in GitHub Desktop.
Tubi Movie Downloader
#!/bin/bash
#####
# Requires: yt-dlp, xidel, ffmpeg, aria2c
#
# ./tubi-dl.sh LINK
#
## Output Examples:
#
# Film.Name.2022.1080p.TUBI.WEB-DL.AAC2.0.x264.mkv
# Le.Foreign.Filme.2022.FRENCH.1080p.TUBI.WEB-DL.AAC2.0.x264.mkv
#
#####
## Extract language from webpage
# yt-dlp doesnt report language
LANG=$(xidel "$1" -e "css('.MrIY6')/inner-html()" -s)
## Language Check
# The default language on Tubi is English, they only display the language if it isn't English
if [ -z "$LANG" ]
then
echo "[+] English Film Detected"
LANG_FILENAME=""
else
echo "[+] Foreign Film Detected: $LANG"
LANG_FILENAME=$(echo "$LANG" | sed 's/$/./')
fi
#LANG_FILENAME=$(echo "$LANG" | sed 's/$/./')
#echo "[Custom Language] ${LANG:=English}"
## Download The Movie
# Filename: Replace spaces with periods, include resolution & release year (whatever Tubi labeled it as)
# Embeds any available metadata and extras like subtitles, chapters, and thumbnails
# If the film is not in English it will add the language to the filename and change the audio channel metadata to the language
#
LC_ALL=en_US.UTF-8 yt-dlp -ciw --remux-video mkv \
--all-subs --embed-subs --embed-metadata --convert-subs ass --embed-chapters --embed-thumbnail \
--download-archive ~/.config/tubi.hist \
--replace-in-metadata "title" "[ ]" "." \
--output "/$HOME/Tubi/%(title)s.%(release_year)s.${LANG_FILENAME^^}%(height)sp.TUBI.WEB-DL.AAC2.0.x264.%(ext)s" \
--ppa "Metadata+ffmpeg:-metadata:s:a:0 language=${LANG:=English}" \
--external-downloader aria2c --external-downloader-args "-j 10 -x 10 -s 10" \
$1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment