56 lines
1.9 KiB
Bash
Executable File
56 lines
1.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
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 -c -o "$pwd/content/%(id)s.%(ext)s" "$lign"
|
|
# $pwd/youtube-dl --no-progress -c -o "$pwd/content/%(id)s.%(ext)s" "$lign"
|
|
echo "$lign" >> $f.ec
|
|
echo "${f:$((${#pwd} + 7)):4}"
|
|
if [ "${f:$((${#pwd} + 7)):4}" == "nemu" ]; then
|
|
echo "nemu convertion"
|
|
$pwd/youtube-dl --no-progress -c -k -o "$pwd/content/%(id)s.%(ext)s" --extract-audio --audio-format=vorbis "$lign"
|
|
else
|
|
$pwd/youtube-dl --no-progress -c -k -o "$pwd/content/%(id)s.%(ext)s" --extract-audio --audio-format=mp3 "$lign"
|
|
fi
|
|
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
|