Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #*********************
- #
- # Variables
- #
- #*********************
- artista="artista"
- cancion="cancion"
- archivo="archivo"
- #*********************
- #
- # Searching Downloading and converting
- #
- #*********************
- #artista + cancion + archivo = archivo.l
- function getList() {
- lynx -dump -listonly http://www.youtube.com/results?search_query="${1}"+"${2}">>${3}.rl
- grep http://www.youtube.com/watch?v= ${3}.rl >> ${3}.rl1
- rm ${3}.rl
- cut -b 1-6 --complement ${3}.rl1 >> ${3}.rl2
- rm ${3}.rl1
- uniq ${3}.rl2 >> ${3}.rl3
- rm ${3}.rl2
- grep -v \& ${3}.rl3 >> ${3}.l
- rm ${3}.rl3
- }
- #link + archivo = archivo.ytb
- function download() {
- youtube-dl ${1} -o ${2}.ytb
- }
- #archivo = archivo.wav
- function extractAudio() {
- ffmpeg -i ${1}.ytb -ac 2 ${1}.wav
- }
- #archivo = archivo.mp3
- function toMp3() {
- lame -b 320 ${1}.wav ${1}.mp3
- }
- #*********************
- #
- # MAIN
- #
- #*********************
- index=`expr index "${lista}" \|`
- read -p "Banda: " artista
- read -p "Tema: " cancion
- archivo=$(echo "${artista} ${cancion}" | sed -e 's/ /_/g')
- if [ -f "${archivo}".mp3 ]
- then
- echo "Ya existe!"
- break
- fi
- getList "$artista" "$cancion" "$archivo"
- for link in $(cat ${archivo}.l)
- do
- download $link $archivo
- if [ -f "${archivo}.ytb" ]
- then
- extractAudio $archivo
- if [ -f "${archivo}.wav" ]
- then
- toMp3 $archivo
- if [ -f "${archivo}.mp3" ]
- then
- rm ${archivo}.l
- rm ${archivo}.ytb
- rm ${archivo}.wav
- break
- else
- rm ${archivo}.ytb
- rm ${archivo}.wav
- fi
- else
- rm ${archivo}.ytb
- fi
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement