This repository has been archived on 2020-08-21. You can view files and clone it, but cannot push or open issues or pull requests.
musik/dl.sh
2012-03-05 22:46:25 +01:00

49 lines
1.5 KiB
Bash
Executable File

#!/bin/sh
pwd=`echo "$0" | sed -e "s/[^\/]*$//"`
# 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
lign=`sed '2,$d' $f | 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
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
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
echo "$lign" >> $f.done
fi
#Remove the action from the file
sed -i '1d' $f
#What's next?
lign=`sed '2,$d' $f | tr -d '\n'`
done
fi
done
rm /tmp/dlEnCours 2> /dev/null
fi