-
-
Save uNouss/66bf56fd0cce133378b99974e44e663a to your computer and use it in GitHub Desktop.
youtube url extractor in pouet radio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pouetradio(){ | |
PLAYLIST=/tmp/pouet.txt; | |
LINK_BASE="https://framapiaf.org/tags/pouetradio"; | |
#Si c'est pas la premire fois que le script est lancé on récupere juste la page courante qu'on n'ajoute en début de $PLAYLIST | |
if [ -f "$PLAYLIST" ] ; then | |
PREMIEREPAGE=/tmp/temp.txt; | |
lynx -dump $LINK_BASE | awk 'match($0,/((\/|&|\?)v=)([^&]*)/,x){print x[3]}' | cut -d" " -f1 > $PREMIEREPAGE; | |
sed -i "1i\\$PREMIEREPAGE" $PLAYLIST | |
#Sinon, on parse l'ensemble des tags et on les mets dans $PLAYLIST | |
else | |
lynx -dump $LINK_BASE | awk 'match($0,/((\/|&|\?)v=)([^&]*)/,x){print x[3]}' | cut -d" " -f1 > $PLAYLIST; | |
#echo -e "hors boucle:_$LINK_BASE\n" | |
MAX_ID=$(lynx -dump "$LINK_BASE" | awk '/max_id/' | cut -d"=" -f2); | |
ITER=1; | |
MAX_ITER=250 | |
while [[ ( "$MAX_ID" != "" ) && ( $ITER -lt $MAX_ITER ) ]] | |
do | |
LINK="$LINK_BASE?max_id=$MAX_ID" | |
#echo -e "$ITER:_$LINK" | |
lynx -dump "$LINK" | awk 'match($0,/((\/|&|\?)v=)([^&]*)/,x){print x[3]}' | cut -d" " -f1 >> $PLAYLIST; | |
MAX_ID=$(lynx -dump "$LINK" | awk '/max_id/' | cut -d"=" -f2 | tail -1); | |
ITER=$(expr $ITER + 1); | |
done | |
sed -i '$!N; /^\(.*\)\n\1$/!P; D' $PLAYLIST; | |
sed -i 's#^#https://youtu.be/#g' $PLAYLIST; | |
fi | |
if [ -f "$PLAYLIST" ] ; then | |
mpv --no-video --ytdl-format=bestaudio --playlist=$PLAYLIST; | |
else | |
echo "'$PLAYLIST' is not a valid file or not exist !" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment