Last version before Gearman
This commit is contained in:
parent
da8345eca6
commit
b3464284c7
49
dl.sh
49
dl.sh
@ -1,62 +1,63 @@
|
||||
#!/bin/bash
|
||||
|
||||
pwd=`echo "$0" | sed -e "s/[^\/]*$//"`
|
||||
pwd=$(dirname $0)
|
||||
|
||||
# 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'`
|
||||
lign=`sed '2,$d' "$f" | tr -d '\n'`
|
||||
|
||||
while [ -n "$lign" ] && [ `cat $f | wc -l` -gt 0 ]
|
||||
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'`
|
||||
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
|
||||
echo "-- " >> "$f.done"
|
||||
else
|
||||
$pwd/youtube-dl --skip-download "$lign"
|
||||
size=`$pwd/youtube-dl --skip-download "$lign" | grep "File size"`
|
||||
"$pwd"/youtube-dl --skip-download "$lign"
|
||||
size=`"$pwd"/youtube-dl --skip-download "$lign" | grep "File size"`
|
||||
if echo $size | grep -E " [1234]?[0-9]{1,2}\.[0-9]+M "
|
||||
then
|
||||
echo "$lign" >> $pwd/database
|
||||
echo "$lign" >> "$pwd"/database
|
||||
|
||||
$pwd/youtube-dl --get-title --get-thumbnail --get-filename "$lign" >> $pwd/database
|
||||
echo "-- " >> $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 "$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"
|
||||
"$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"
|
||||
"$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 "" > "$f.ec"
|
||||
|
||||
echo "$lign" >> $f.done
|
||||
echo "$lign" >> "$f.done"
|
||||
|
||||
chown www-data:www-data $f.done $f.ec
|
||||
chgrp www-data "$f.done" "$f.ec"
|
||||
chmod g+rw "$f.done" "$f.ec"
|
||||
else
|
||||
echo $size
|
||||
fi
|
||||
fi
|
||||
#Remove the action from the file
|
||||
sed -i '1d' $f
|
||||
sed -i '1d' "$f"
|
||||
chgrp www-data "$f"
|
||||
chmod g+rw "$f"
|
||||
|
||||
#What's next?
|
||||
lign=`sed '2,$d' $f | tr -d '\n'`
|
||||
lign=`sed '2,$d' "$f" | tr -d '\n'`
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
Reference in New Issue
Block a user