Re: Help with YT-DLP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Rob, 

another solution could be this youtube_to_mp3 script. 
It uses the latest ytdl bin from yt-dl.org : 
- just have to put it in /usr/local/bin or in ~/bin and make it executable 
- then enter the 11 chars part of a YT url like this: 
  youtube_to_mp3 ANd_yT-C0de  ENTER 
- the clip is downloaded and converted to mp3 (you can choose to keep or not
  the mp4 file) 
- the name is automatically something like 
  Artist_or_File - Name - ANd_yT-C0de.mp3
- files are saved in ~/yt-dl/20220205/ (today) 
- and you can uncomment lines in the script to check and get the latest ytdl
  bin automatically (if available) 

Feel free to personalize it. HEre it is:

### <script> ### 

#!/bin/bash 
# 
# YouTube_to_MP3-script  -  orig. by L. Berger  -  modified ver. by O. La Rosa  
# 2020.04.17 

clear

## Inst. dir + YT base-URL + YT-DL binary name var 
#InstRepo="/usr/local/bin/"
InstRepo="$HOME/bin/"
#YTDLName="youtube-dl"
YTDLName="yt-dl"
#YTBURL="http://youtu.be/";
YTBURL="http://www.youtube.com/watch?v=";
#YTBURL="https://www.youtube.com/watch?v=";
 
## Go ! 
echo "YouTube_to_MP3-script ! "

#echo "Positional parameters"
#echo '$0 = ' $0
#echo '$1 = ' $1

## Output 
#OUTPUT="/home/${USER}/Music"
#OUTPUT="/home/${USER}/Musique"
#OUTPUT="/home/${USER}/Muziek"
#OUTPUT="/home/${USER}/Downloads"
OUTPUT="/home/${USER}/yt-dl"
mkdir -p $OUTPUT
echo "   
   Binary name  &  destination is :    $InstRepo$YTDLName 
   YouTube download repository is :    $OUTPUT " 
echo "   YT base URL (to download from) is : $YTBURL" 

## Date  
NOWSHORT=`date +%Y%m%d`
#http://man7.org/linux/man-pages/man1/date.1.html
#NOWSHORT=`date '+%Y%m%d%H%M%S'`
#NOWSHORT=`date '+%Y%m%d-%H%M%S'`
#NOWSHORT=`date '+%Y%m%d.%H%M%S'`
echo "   Today : $NOWSHORT " 
echo " " 

## Download a full mix play list  
## How to download YouTube playlist in Linux   
## http://xmodulo.com/how-to-download-youtube-playlist-in-linux.html

## YT-DL(.org) bin installation 
#sudo curl -L https://yt-dl.org/latest/youtube-dl -o $InstRepo$YTDLName
#curl -L https://yt-dl.org/latest/youtube-dl -o $InstRepo$YTDLName
#sudo chmod a+rx $InstRepo$YTDLName 
#chmod a+rx $InstRepo$YTDLName 
ls -l $InstRepo$YTDLName

echo " " 
#read -p "Press a key to continue  ... " 
#clear 

## Updating ... 
#$InstRepo$YTDLName -U 

echo " " 
#read -p "Press a key to continue  ... " 
#clear 

## Added --exec touch in place !!
## https://superuser.com/questions/731227/how-to-extract-the-filename-without-the-extension-from-a-full-path
#FILENAME=${1%.*}

# help ==================
if [ -z $1 ]; then
   echo "Version `$YTDLName --version`"
#	echo "Usage : $(basename $0) youtube_full_address (keep)"
	echo "Usage : $(basename $0) youtube ID (11 chars) (keep)"
	echo "   If 'keep' is specified, it will keep a copy of the orig. files"
#	echo "Example:  youtube_to_mp3  https://www.youtube.com/watch?v=cFMnG4cSVJM";
#	echo "Example:  youtube_to_mp3  https://www.youtube.com/watch?v=cFMnG4cSVJM  keep"
	echo "Example:  youtube_to_mp3  cFMnG4cSVJM"
	echo "Example:  youtube_to_mp3  cFMnG4cSVJM  keep"
   echo " " 
	exit 1
fi
# help ==================

echo "
---------------------------------------------------------------------------"
echo "Date is : $NOWSHORT" 
echo "Making dir $NOWSHORT (if not exist) to store new files ..." 
mkdir -p $OUTPUT/$NOWSHORT
#echo "--- $OUTPUT/$NOWSHORT ---"
echo "--- URL $YTBURL$1 @ $OUTPUT/$NOWSHORT ---"

echo " " 
#read -p "Press a key to continue  ... " 
clear 

echo "YouTube_to_MP3-script !
 "

echo Downloading
echo and converting to 
echo "   $OUTPUT/$NOWSHORT"
echo "(Please note, file's date is NOT today : Search by file name.) "
echo ....... Busy ....... 
echo    $FILENAME
cd $OUTPUT/$NOWSHORT

echo " "
#read -p "Press a key to continue  ... " 
#clear 

## --audio-quality QUALITY          Specify ffmpeg/avconv audio quality, 
## Insert a value between 0 (better) and 9

if [ "$2" == "keep" ]; then
	echo "Will keep source video ´$1´"
#    	$InstRepo$YTDLName --exec touch {} -i -x -k --audio-quality 0 --audio-format mp3 $1
#    	$InstRepo$YTDLName --exec touch {} -i -x -k --audio-quality 0 --audio-format mp3 $YTBURL$1
    	$InstRepo$YTDLName --exec touch {} -i -x -k --no-check-certificate --audio-quality 0 --audio-format mp3 $YTBURL$1
else
#	$YTDLName --exec touch {} -i -x --audio-quality 0 --audio-format mp3 $1
#	$YTDLName --exec touch {} -i -x --audio-quality 0 --audio-format mp3 $YTBURL$1
	$YTDLName --exec touch {} -i -x --no-check-certificate --audio-quality 0 --audio-format mp3 $YTBURL$1
fi

echo "
---------------------------------------------------------------------------"
#touch $FILENAME".mp3"
cd $OUTPUT/$NOWSHORT
ls -lrt

echo " " 
read -p "Press a key to continue / CTRL+C to quit now without reupdating youtube-dl ... " 
#clear 

echo "--- Updating youtube-dl (yt-dl) : Please type root / sudo pwd (if required) ---"
#sudo YTDLName --update
$InstRepo$YTDLName --update
echo "--- End updating youtube-dl ($InstRepo$YTDLName) ---"

echo "------  Done youtube_to_mp3  -----------------------------------------"
echo " "

## End of script !  
exit

### </script> ### 

Osvaldo La Rosa  aka  Aldo. 


--- Your session --- 
On Fri, Feb 04, 2022 at 07:02:58PM -0500, Linux for blind general discussion wrote:
> OK thanks,
> 
> I like this, having the link at the end is easier.
> 
> Thanks,
> 
> Rob
> 
> 
> On 2/4/22 17:46, Linux for blind general discussion wrote:
> > My usual youtube-dl line is as follows
> > yt-dlp -ciw -x --audio-format mp3 -o "%(title)s.%(ext)s" <video-link>
> > This names the file as title.mp3
> > ----- Original Message -----
> > From: Linux for blind general discussion <blinux-list@xxxxxxxxxx>
> > To: Linux for blind general discussion <blinux-list@xxxxxxxxxx>
> > Date: Fri, 4 Feb 2022 17:19:23 -0500
> > Subject: Re: Help with YT-DLP
> > 
> > > Thank you Chrys,
> > That fixed it.
> > 
> > Now I need to find out how to have the video named, instead of just
> > letters and numbers.
> > 
> > Thanks,
> > 
> > Rob
> > 
> > 
> > On 2/4/22 16:57, Linux for blind general discussion wrote:
> > > Howdy Rob,
> > > 
> > > Well there is an open single tick but missing the closing one in -o parameter. So the string is not terminated.
> > > 
> > > Cheers chrys
> > > 
> > > > Am 04.02.2022 um 22:40 schrieb Linux for blind general discussion <blinux-list@xxxxxxxxxx>:
> > > > 
> > > > ?Hi,
> > > > 
> > > > I am trying to use yt-dlp to convert YouTube video to mp3.
> > > > 
> > > > I installed the latest version of yt-dlp using the info below.
> > > > 
> > > > sudo wget https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -O /usr/local/bin/yt-dlp
> > > > 
> > > > sudo chmod a+rx /usr/local/bin/yt-dlp
> > > > 
> > > > update command
> > > > yt-dlp -U
> > > > 
> > > > When I use the below command, I get nothing but a greater than sign.
> > > > 
> > > > yt-dlp -f 'ba' -x --audio-format mp3 https://www.youtube.com/watch?v=dQw4w9WgXcQ -o '%(id)s.mp3
> > > > 
> > > > 
> > > > Thanks,
> > > > 
> > > > Rob
> > > > 
> > > > 
> > > > _______________________________________________
> > > > Blinux-list mailing list
> > > > Blinux-list@xxxxxxxxxx
> > > > https://listman.redhat.com/mailman/listinfo/blinux-list
> > > > 
> > > _______________________________________________
> > > Blinux-list mailing list
> > > Blinux-list@xxxxxxxxxx
> > > https://listman.redhat.com/mailman/listinfo/blinux-list
> > 
> > _______________________________________________
> > Blinux-list mailing list
> > Blinux-list@xxxxxxxxxx
> > https://listman.redhat.com/mailman/listinfo/blinux-list
> > 
> > 
> > _______________________________________________
> > Blinux-list mailing list
> > Blinux-list@xxxxxxxxxx
> > https://listman.redhat.com/mailman/listinfo/blinux-list
> > 
> 
> _______________________________________________
> Blinux-list mailing list
> Blinux-list@xxxxxxxxxx
> https://listman.redhat.com/mailman/listinfo/blinux-list
> 

-- 
  |  Verstuurd vanaf mijn GNU/Linux  |  Envoyé de mon GNU/Linux  | 
  |  -----------------  Sent from GNU/Linux  ------------------  | 


_______________________________________________
Blinux-list mailing list
Blinux-list@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/blinux-list





[Index of Archives]     [Linux Speakup]     [Fedora]     [Linux Kernel]     [Yosemite News]     [Big List of Linux Books]