New version

This commit is contained in:
Némunaire 2012-03-05 22:46:25 +01:00
commit cf8262d3cb
8 changed files with 5058 additions and 133 deletions

61
dl.sh
View file

@ -2,38 +2,47 @@
pwd=`echo "$0" | sed -e "s/[^\/]*$//"`
if [ `cat $pwd/urls | wc -l` -gt 0 ] && [ ! -e /tmp/dlEnCours ]; then
transmission-remote -asu 10 -as
# Don't do anything if this script is already launched
if [ ! -e /tmp/dlEnCours ]; then
for f in "$pwd"/users/*.dlist; do
if [ `cat $f | wc -l` -gt 0 ]; then
transmission-remote -asu 10 -as
touch /tmp/dlEnCours
touch /tmp/dlEnCours
lign=`sed '2,$d' $f | tr -d '\n'`
lign=`sed '2,$d' $pwd/urls | tr -d '\n'`
while [ -n "$lign" ] && [ `cat $f | wc -l` -gt 0 ]
do
if [ -z "$lign" ]; then
sed -i '1d' $f
lign=`sed '2,$d' $f | tr -d '\n'`
fi
if [ -z "$lign" ]; then
sed -i '1d' $pwd/urls
lign=`sed '2,$d' $pwd/urls | tr -d '\n'`
fi
echo "Action: $lign"
if [ "$lign" = "clear" ]; then
echo "-- " >> $f.done
transmission-remote -AS
else
echo "$lign" >> $pwd/database
$pwd/youtube-dl --get-title --get-thumbnail --get-filename "$lign" >> $pwd/database
echo "-- " >> $pwd/database
while [ -n "$lign" ] && [ `cat $pwd/urls | wc -l` -gt 0 ]
do
echo "Action: $lign"
if [ "$lign" = "clear" ]; then
sed -i '1d' $pwd/urls
mkdir $pwd/content/`date +%Y%m%d%H%M%S`
mv $pwd/content/*.mp3 $pwd/content/`date +%Y%m%d%H%M%S`
transmission-remote -AS
else
$pwd/youtube-dl -e $lign > $pwd/dlEc
echo "$lign" > $f.ec
$pwd/youtube-dl --no-progress -c -o "$pwd/content/%(id)s.%(ext)s" "$lign"
echo "$lign" >> $f.ec
$pwd/youtube-dl --no-progress -c -k -o "$pwd/content/%(id)s.%(ext)s" --extract-audio --audio-format=mp3 "$lign"
echo "" > $f.ec
sed -i '1d' $pwd/urls
echo "$lign" >> $f.done
fi
$pwd/youtube-dl --no-progress -c -k -o "$pwd/content/%(title)s.%(ext)s" --extract-audio --audio-format=mp3 "$lign"
#Remove the action from the file
sed -i '1d' $f
echo "" > $pwd/dlEc
fi
lign=`sed '2,$d' $pwd/urls | tr -d '\n'`
#What's next?
lign=`sed '2,$d' $f | tr -d '\n'`
done
fi
done
rm /tmp/dlEnCours
rm /tmp/dlEnCours 2> /dev/null
fi