Forgot to remove old files
This commit is contained in:
142
zymp3
142
zymp3
@@ -1,142 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
##############################################
|
|
||||||
# Title: Zymp3 v0.1
|
|
||||||
# Description: Convert youtube video to mp3
|
|
||||||
# Author: Justin Moore
|
|
||||||
# Contact: silvernode@gmail.com
|
|
||||||
# github: https://github.com/silvernode/zymp3
|
|
||||||
##############################################
|
|
||||||
|
|
||||||
|
|
||||||
#I wrote this in 2011 and realize now I could have done this alot better
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#inport config
|
|
||||||
#source config.sh
|
|
||||||
MUSICDIR=/home/$USER/Music/
|
|
||||||
|
|
||||||
#convert youtube videos to mp3 with zenity progess bar
|
|
||||||
backend()
|
|
||||||
{
|
|
||||||
t=~/.youtube-dl-$RANDOM-$RANDOM.flv
|
|
||||||
youtube-dl --output=$t --format=18 "$1" | zenity --progress --pulsate --title="Downloading..." --text="Downloading video, please wait.." --auto-close
|
|
||||||
|
|
||||||
if [ ! -f $t ];then
|
|
||||||
zenity --error --text "The mp3 file was does not exist. Either the download failed or the video was not converted to mp3 properly"
|
|
||||||
exit 0;
|
|
||||||
|
|
||||||
elif [ -f $t ];then
|
|
||||||
ffmpeg -i $t -acodec libmp3lame -ac 2 -ab 128k -vn -y "$2" | zenity --progress --pulsate --title="Converting..." --text="Converting video to mp3.." --auto-close
|
|
||||||
rm $t
|
|
||||||
|
|
||||||
echo $y
|
|
||||||
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#first zenity gui window (paste youtube link)
|
|
||||||
gui()
|
|
||||||
{
|
|
||||||
x=$(zenity --title="Zymp3 0.1-1" --height="64" --width="512" --entry --text "Paste youtube link here: ")
|
|
||||||
|
|
||||||
|
|
||||||
if [[ $? == 0 ]] ; then
|
|
||||||
|
|
||||||
|
|
||||||
gui2
|
|
||||||
else
|
|
||||||
exit 0;
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#second gui window to name your mp3 file
|
|
||||||
|
|
||||||
gui2()
|
|
||||||
{
|
|
||||||
y=$(zenity --title="Filename" --height="64" --width="326" --entry --text "Name your file: ")
|
|
||||||
|
|
||||||
if [[ $? == 0 ]] ; then
|
|
||||||
dconvert
|
|
||||||
else
|
|
||||||
exit 0;
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#notify the user that the mp3 file has been moved to their music folder
|
|
||||||
open()
|
|
||||||
{
|
|
||||||
|
|
||||||
zenity --question --title="Hey!" --text="I moved $y.mp3 to $MUSICDIR, do you want to play it now?"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if [[ $? == 0 ]] ; then
|
|
||||||
xdg-open "${MUSICDIR}${y}.mp3"
|
|
||||||
else
|
|
||||||
exit 0;
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#move the mp3 file to the users music directory
|
|
||||||
move()
|
|
||||||
{
|
|
||||||
if [ -d ${MUSICDIR} ];then
|
|
||||||
echo $y
|
|
||||||
mv -v "$y.mp3" ${MUSICDIR}
|
|
||||||
elif [ ! -d ${MUSICDIR} ];then
|
|
||||||
mkdir ${MUSICDIR}
|
|
||||||
mv -v "$y.mp3" ${MUSICDIR}
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
checkFile()
|
|
||||||
{
|
|
||||||
|
|
||||||
if [ -f "${MUSICDIR}$y.mp3" ];then
|
|
||||||
notify-send "$y.mp3 was saved in ${MUSICDIR}"
|
|
||||||
elif [ ! -f "${MUSICDIR}$y.mp3" ];then
|
|
||||||
zenity --error --text "The mp3 file was does not exist. Either the download failed or the video was not converted to mp3 properly"
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#call the backend function so we can use it
|
|
||||||
dconvert()
|
|
||||||
{
|
|
||||||
backend "$x" "$y.mp3"
|
|
||||||
|
|
||||||
move
|
|
||||||
|
|
||||||
checkFile
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
open
|
|
||||||
}
|
|
||||||
|
|
||||||
#call the main gui
|
|
||||||
|
|
||||||
while true;do
|
|
||||||
gui
|
|
||||||
done
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@@ -1,9 +0,0 @@
|
|||||||
[Desktop Entry]
|
|
||||||
Name=Zymp3
|
|
||||||
Comment=Convert youtube videos to mp3
|
|
||||||
Exec=zymp3
|
|
||||||
Icon=zymp3.png
|
|
||||||
Terminal=0
|
|
||||||
Type=Application
|
|
||||||
Encoding=UTF-8
|
|
||||||
Categories=AudioVideo;Application;
|
|
Reference in New Issue
Block a user