renew script
This commit is contained in:
parent
3e06ca7217
commit
e20e489488
1 changed files with 71 additions and 54 deletions
125
youtube.sh
125
youtube.sh
|
@ -2,11 +2,10 @@
|
|||
|
||||
set -ex
|
||||
|
||||
if [ "$1" == "--help" ]
|
||||
then
|
||||
echo "bash ./youtube-dl.sh URL FORMAT"
|
||||
echo "Formate: [opus/m4a/video/hd/fullhd/4k/bestaudio]"
|
||||
echo "Extra: (Zusätzliche Parameter)"
|
||||
if [ "$1" == "--help" ]; then
|
||||
echo "Usage: $0 [URL] [FORMAT] [EXTRA]"
|
||||
echo "Formate: opus/flac/m4a/mp4/video/hd/fullhd/4k/bestaudio"
|
||||
echo "Beispiel für Unterordner: -o '%(channel)s/%(playlist_title)s/%(title)s.%(ext)s'"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
@ -14,55 +13,71 @@ url="$1"
|
|||
format="$2"
|
||||
extra="$3"
|
||||
|
||||
# Abfragen für interaktive Eingaben
|
||||
[[ -z "${url}" ]] && read -p "URL: " url
|
||||
[[ -z "${format}" ]] && read -p "Format [opus/flac/m4a/mp4/video/hd/fullhd/4k/bestaudio]: " format
|
||||
echo "Wenn man für alle Playlisten Unterordner anlegen will: [-o %(channel)s/%(playlist_title)s/%(title)s.%(ext)s/--cookies cookies.txt/--cookies-from-browser firefox] (Praktisch für Downloads ganzer Kanäle"
|
||||
[[ -z "${extra}" ]] && read -p "Sind noch zusätzliche Parameter gewünscht?: " extra
|
||||
|
||||
if [ "$format" == "opus" ]
|
||||
then
|
||||
# https://github.com/yt-dlp/yt-dlp/issues/979
|
||||
format="--audio-format opus -f "ba" --format-sort "abr,codec""
|
||||
audio="-x"
|
||||
quality="--audio-quality 0"
|
||||
elif [ "$format" == "flac" ]
|
||||
then
|
||||
format="--audio-format flac -f "ba" --format-sort "abr,codec""
|
||||
audio="-x"
|
||||
quality="--audio-quality 0"
|
||||
elif [ "$format" == "m4a" ]
|
||||
then
|
||||
format="--audio-format m4a"
|
||||
audio="-x"
|
||||
elif [ "$format" == "mp4" ]
|
||||
then
|
||||
format="--audio-format mp4"
|
||||
audio="-x"
|
||||
elif [ "$format" == "video" ]
|
||||
then
|
||||
# Download and merge the best video-only format and the best audio-only format,
|
||||
# or download the best combined format if video-only format is not available
|
||||
|
||||
# Download the best video available with the largest resolution but no better than 480p,
|
||||
# or the best video with the smallest resolution if there is no video under 480p
|
||||
# Resolution is determined by using the smallest dimension.
|
||||
# So this works correctly for vertical videos as well
|
||||
format="-S "res:480" -f "bv+ba/b""
|
||||
elif [ "$format" == "hd" ]
|
||||
then
|
||||
format="-S "res:720" -f "bv+ba/b""
|
||||
elif [ "$format" == "fullhd" ]
|
||||
then
|
||||
format="-S "res:1080" -f "bv+ba/b""
|
||||
elif [ "$format" == "4k" ]
|
||||
then
|
||||
format="-S "res:2160" -f "bv+ba/b""
|
||||
elif [ "$format" == "bestaudio" ]
|
||||
then
|
||||
# Lädt das beste Audioformat OHNE Umwandlung (z.B. Opus/WebM oder AAC/M4A)
|
||||
format="-f bestaudio"
|
||||
# Abfrage für Various Artists
|
||||
read -p "Album als Playlist Title setzen? [Y/n] " title
|
||||
if [[ "$title" != "n" ]]; then
|
||||
album_metadata="--parse-metadata playlist_title:%(album)s"
|
||||
fi
|
||||
|
||||
# Abfrage für Cookies
|
||||
read -p "Cookies aus cookies.txt verwenden? [Y/n] " cookies
|
||||
if [[ "$cookies" != "n" ]]; then
|
||||
cookies_cmd="--cookies cookies.txt"
|
||||
fi
|
||||
|
||||
# Abfrage für Unterordner-Struktur
|
||||
read -p "Unterordner nach Kanal erstellen? [Y/n] " folders
|
||||
if [[ "$folders" != "n" ]]; then
|
||||
output_template="-o %(channel)s/%(title)s.%(ext)s"
|
||||
fi
|
||||
|
||||
# Format-Spezifikationen
|
||||
case "$format" in
|
||||
opus)
|
||||
format_cmd="-f ba --audio-format opus --format-sort abr,codec"
|
||||
audio="-x"
|
||||
quality="--audio-quality 0"
|
||||
;;
|
||||
flac)
|
||||
format_cmd="-f ba --audio-format flac --format-sort abr,codec"
|
||||
audio="-x"
|
||||
quality="--audio-quality 0"
|
||||
;;
|
||||
m4a)
|
||||
format_cmd="--audio-format m4a"
|
||||
audio="-x"
|
||||
;;
|
||||
mp4)
|
||||
format_cmd="--audio-format mp4"
|
||||
audio="-x"
|
||||
;;
|
||||
video)
|
||||
format_cmd="-S res:480 -f bv+ba/b"
|
||||
;;
|
||||
hd)
|
||||
format_cmd="-S res:720 -f bv+ba/b"
|
||||
;;
|
||||
fullhd)
|
||||
format_cmd="-S res:1080 -f bv+ba/b"
|
||||
;;
|
||||
4k)
|
||||
format_cmd="-S res:2160 -f bv+ba/b"
|
||||
;;
|
||||
bestaudio)
|
||||
format_cmd="-f bestaudio"
|
||||
;;
|
||||
*)
|
||||
format_cmd=""
|
||||
audio=""
|
||||
quality=""
|
||||
;;
|
||||
esac
|
||||
|
||||
# Hauptbefehl mit allen Optionen
|
||||
yt-dlp \
|
||||
-i \
|
||||
-c \
|
||||
|
@ -71,11 +86,13 @@ yt-dlp \
|
|||
--restrict-filenames \
|
||||
--embed-thumbnail \
|
||||
--embed-metadata \
|
||||
--parse-metadata "playlist_title:%(album)s" \
|
||||
$album_metadata \
|
||||
$cookies_cmd \
|
||||
${output_template} \
|
||||
--match-filter "!was_live" \
|
||||
${format} \
|
||||
${audio} \
|
||||
${quality} \
|
||||
$format_cmd \
|
||||
$audio \
|
||||
$quality \
|
||||
-v \
|
||||
${url} \
|
||||
"$url" \
|
||||
${extra}
|
||||
|
|
Loading…
Add table
Reference in a new issue