Re: [CBLX] youtube-dl et question de venv

[ Thread Index | Date Index | More lists.tuxfamily.org/carrefourblinux Archives ]


Hello Didier, Patrick et Pierre,

merci pour vos suggestions.

Ce n'est pas un souci d'avoir - ou pas - la version récente compatible 
avec Python 3.x,
je pense même que le problème vient de là: sous Python2.7 (cf. ancienne
Ubuntu mise à jour) ça fonctionnait nickel!
Ici, sur cet ordi Dell, Ubuntu 20.04 est installé/e "de fabrique" et pas suite 
à une maj (16 vers 18 vers 20.04).
Donc, j'ai l'impression que l'ordi mis à jour avait gardé un reste de
Python2.7/2.8, permettant de maintenir la copatibilité de certaines applis,
dont youtube-dl.

Suivant ma lecture sur pip.pypa.io/warnings/venv je devrais utiliser un
"virtual environment" pour continuer à utiliser "mon appli",
mais ce n'est pas tout à fait exact, car ici je n'ai aucun problème à
utiliser /usr/local/bin/youtube-dl à la main, alors que j'ai le warning +
sortie du script lorsque j'utilise mon youtube_to_mp3 (que je mets ci-après):
le script s'arrête car il cherche un répertoire (/usr/bin/env) 
alors que sous mon système c'est un fichier... ! 

Voici le script de mon pote Luc Berger de Linux Bruxelles, amélioré par bibi: 

 ###

#!/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

 ### 

J'ai déjà installé yt-dlp et vais creuser dès que j'ai + de temps... 

Aldo. 


On Mon, Feb 21, 2022 at 07:23:11PM +0100, Patrick ZAJDA wrote:
> Hello,
> 
> 
> C'est un simple warning qui dit qu'utiliser pip en tant que root est
> déconseillé et qu'à la place ça serait mieux d'utiliser un virtual env.
> 
> Tu aurais le message avec n'importe quoi d'autre que tu installerais avec
> pip en tant que root.
> 
> 
> As-tu essayé de l'utiliser après avoir fait cette commande ? Parce qu'il
> devrait très bien fonctionner malgré ce warning...
> 
> 
> Bonne chance,
> 
> 
> Patrick
> 
> 
> Le 21/02/2022 à 19:13, Aldo a écrit :
> > Bonjour,
> > 
> > sur l'ordi d'où j'envois le présent courriel, je n'arrive pas à utiliser le
> > téléchrgeur youtube-dl, il me reproche à chaque fois qq chose relatif à
> > venv.
> > J'ai fait une maj comme ci-après,
> > mais je n'arrive tj pas à comprendre ce qu'il faut faire:
> > 
> > ###
> > root@aldo-Latitude-E6420:~# pip install --upgrade youtube-dl
> > Requirement already satisfied: youtube-dl in /usr/local/lib/python3.8/dist-packages (2021.12.17)
> > WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead:https://pip.pypa.io/warnings/venv
> > root@aldo-Latitude-E6420:~#
> > ###
> > 
> > Avez-vous une idée ?
> > Merci,
> > A+
> > Aldo.
> > 
> -- 
> Patrick ZAJDA

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

--
   CBLX - CarrefourBLinuX MailingListe
   Pour obtenir de l'aide, envoyez le sujet  help  à:
   carrefourblinux-request@xxxxxxxxxxxxxxxxxxx
   Archives:
   http://listengine.tuxfamily.org/lists.tuxfamily.org/carrefourblinux
   ou
   http://www.mail-archive.com/carrefourblinux@xxxxxxxxxxxxxxxxxxx/


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/