Section 13.8 revised

This commit is contained in:
Uwe Schimanski 2024-11-24 19:30:36 +01:00
parent 76888d4c56
commit 124455ed02

View File

@ -1,8 +1,8 @@
\section{Youtube-dl - Video / Musik}
\section{yt-dlp - Video / Musik}
\begin{justify}
Mit dem Programm {\ttfamily youtube-dl} kann man die Videos von Youtube downloaden oder auch aus den Videos die Audio Spur extrahieren.
Mit dem Programm {\ttfamily yt-dlp} kann man die Videos von Youtube downloaden oder auch aus den Videos die Audio Spur extrahieren. Dies ist ein Fork von youtube-dl, das wohl nicht mehr aktiv weiterentwickelt wird.
\subsection{Konfiguration}
Es gibt eine Systemweite Konfigurationsdatei und eine benutzerspezifische. Die Systemweite Datei {\ttfamily youtube-dl.conf} befindet sich im Verzeichnis /etc und die benutzerspezifische unter ~/.config/youtube-dl/config. Man kann auch verschiedene Konfigurationen erstellen und diese dann mit dem Parameter {\ttfamily \verb|--|config-location} verwenden. Mit dem Parameter {\ttfamily \verb|--|ignore-config} werden die Konfigurationsdateien nicht ber"ucksichtigt.
Es gibt eine Systemweite Konfigurationsdatei und eine benutzerspezifische. Die Systemweite Datei {\ttfamily yt-dlp.conf} befindet sich im Verzeichnis /etc und die Benutzerspezifische unter ~/.config/yt-dlp/config. Die Benutzerspezifische Datei wird ohne .conf erstellt. Man kann auch verschiedene Konfigurationen erstellen und diese dann mit dem Parameter {\ttfamily \verb|--|config-location} verwenden. Mit dem Parameter {\ttfamily \verb|--|ignore-config} werden die Konfigurationsdateien nicht ber"ucksichtigt.
\listBash
\begin{lstlisting}[captionpos=b, caption=Beispiel Konfiguration]
uws@tux>cat audio.conf
@ -23,21 +23,76 @@ uws@tux>cat audio.conf
\end{lstlisting}
\listBash
\begin{lstlisting}[captionpos=b, caption=Beispiel alternative Konfiguration]
uws@tux>youtube-dl --config-location ~/.config/youtube-dl/config/video.conf youtube-url
uws@tux>yt-dlp --config-location ~/.config/youtube-dl/config/video.conf youtube-url
\end{lstlisting}
Man kann sich auch verschiedene Aliase anlegen mit den Parametern.
\listBash
\begin{lstlisting}[captionpos=b, caption=Beispiel Alias]
uws@tux>alias yta="youtube-dl -x --audio-format mp3 --audio-quality 320 --add-metadata -o '/daten/music/%(title)s320.%(ext)s'"
uws@tux>alias yta="yt-dlp -x --audio-format mp3 --audio-quality 320 --add-metadata -o '/daten/music/%(title)s320.%(ext)s'"
\end{lstlisting}
\newpage
Anstelle eines Aliases kann man auch eine Funktion schreiben.
\begin{lstlisting}[captionpos=b, caption=Beispiel Funktion]
#=====================================================================
# Function: dyoutube
#=====================================================================
# Download Youtube Video or extract audio
# yt-dlp (Fork von youtube-dl)
# -a => extract audio
# -v => download Video
# yt-dlp -x --audio-format mp3 --audio-quality 320 --add-metadata -o '/home/uws/Musik/%(title)s.%(ext)s' https://www.youtube.com/watch?v=5tXb17dAFB4
dyoutube() {
dsyntax="Syntax:
dyoutube [-a] [-v] [-i] URL
-a Extract Audio from Video
-v Download Video
-i Infomation about Video
"
case $1 in
-a)
if [ -z "$2" ]
then
printf "Missing Youtube URL.\n"
exit 1
else
yt-dlp -x --audio-format mp3 --audio-quality 320 --add-metadata -o "$HOME/Musik/%(title)s.%(ext)s" $2
printf "Die MP3-Datei wurde unter $HOME/Musik abgelegt.\n"
fi
;;
-v)
if [ -z "$2" ]
then
printf "Missing Youtube URL.\n"
exit 1
else
yt-dlp --add-metadata -o "$HOME/Videos/%(title)s.%(ext)s" $2
printf "Das Video wurde unter $HOME/Videos abgelegt.\n"
fi
;;
-i)
if [ -z "$2" ]
then
printf "Missing Youtube URL.\n"
exit 1
else
yt-dlp -F $2
fi
;;
*) printf "$dsyntax\n" ;;
esac
}
\end{lstlisting}
%--------------------------------------------------------------------------------
% Subsction: Video Formate
%--------------------------------------------------------------------------------
\subsection{Video Formate}
Wird youtube-dl mit dem Parameter {\ttfamily -F} aufgerufen, so werden alle verf"ugbaren Formate des Videos ausgegeben und mit der Angabe des Format Codes wird dann das Video heruntergeladen.
Wird yt-dlp mit dem Parameter {\ttfamily -F} aufgerufen, so werden alle verf"ugbaren Formate des Videos ausgegeben und mit der Angabe des Format Codes wird dann das Video heruntergeladen.
\listBash
\begin{lstlisting}[captionpos=b, caption=Anzeige Video Formate]
uws@tux>youtube-dl -F https://www.youtube.com/watch?v=uekZpkYf7-E
uws@tux>yt-dlp -F https://www.youtube.com/watch?v=uekZpkYf7-E
[youtube] uekZpkYf7-E: Downloading webpage
[youtube] uekZpkYf7-E: Downloading video info webpage
[info] Available formats for uekZpkYf7-E:
@ -63,12 +118,13 @@ format code extension resolution note
36 3gp 320x180 small , mp4v.20.3, mp4a.40.2, 8.60MiB
18 mp4 640x360 medium , avc1.42001E, mp4a.40.2@ 96k, 25.05MiB (best)
uws@tux>youtube-dl -f 137 https://www.youtube.com/watch?v=uekZpkYf7-E
uws@tux>yt-dlp -f 137 https://www.youtube.com/watch?v=uekZpkYf7-E
[youtube] uekZpkYf7-E: Downloading webpage
[youtube] uekZpkYf7-E: Downloading video info webpage
[download] Destination: Severija - Zu Asche, Zu Staub (Psycho Nikoros) - (Official Babylon Berlin O.S.T.)-uekZpkYf7-E.mp4
[download] 100% of 69.19MiB in 00:40
\end{lstlisting}
\newpage
%-------------------------------------------------------------------------------
% Subsection: Audio extract
%-------------------------------------------------------------------------------
@ -76,7 +132,7 @@ uws@tux>youtube-dl -f 137 https://www.youtube.com/watch?v=uekZpkYf7-E
In dem n"achsten Beispiel wird die Audio Spur aus einem Video extrahiert und als MP3 Datei gespeichert.
\listBash
\begin{lstlisting}[captionpos=b, caption=Audio extract]
uws@tux>youtube-dl --extract-audio --audio-format mp3 --audio-quality 512k https://www.youtube.com/watch?v=uekZpkYf7-E
uws@tux>yt-dlp --extract-audio --audio-format mp3 --audio-quality 512k https://www.youtube.com/watch?v=uekZpkYf7-E
[youtube] uekZpkYf7-E: Downloading webpage
[youtube] uekZpkYf7-E: Downloading video info webpage
[youtube] uekZpkYf7-E: Downloading js player vfl07ioI6