2012-04-15 14:30:53 +00:00
|
|
|
#!/bin/bash
|
2012-02-27 16:59:03 +00:00
|
|
|
|
2013-12-26 11:19:34 +00:00
|
|
|
pwd=$(dirname $0)
|
2012-02-27 16:59:03 +00:00
|
|
|
|
2012-03-05 21:46:25 +00:00
|
|
|
# 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
|
|
|
|
touch /tmp/dlEnCours
|
|
|
|
|
2013-12-26 11:19:34 +00:00
|
|
|
lign=`sed '2,$d' "$f" | tr -d '\n'`
|
2012-03-05 21:46:25 +00:00
|
|
|
|
2013-12-26 11:19:34 +00:00
|
|
|
while [ -n "$lign" ] && [ `cat "$f" | wc -l` -gt 0 ]
|
2012-03-05 21:46:25 +00:00
|
|
|
do
|
|
|
|
if [ -z "$lign" ]; then
|
2013-12-26 11:19:34 +00:00
|
|
|
sed -i '1d' "$f"
|
|
|
|
lign=`sed '2,$d' "$f" | tr -d '\n'`
|
2012-03-05 21:46:25 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Action: $lign"
|
|
|
|
if [ "$lign" = "clear" ]; then
|
2013-12-26 11:19:34 +00:00
|
|
|
echo "-- " >> "$f.done"
|
2012-03-05 21:46:25 +00:00
|
|
|
else
|
2013-12-26 11:19:34 +00:00
|
|
|
"$pwd"/youtube-dl --skip-download "$lign"
|
|
|
|
size=`"$pwd"/youtube-dl --skip-download "$lign" | grep "File size"`
|
2012-10-31 20:09:35 +00:00
|
|
|
if echo $size | grep -E " [1234]?[0-9]{1,2}\.[0-9]+M "
|
2012-05-20 08:22:37 +00:00
|
|
|
then
|
2013-12-26 11:19:34 +00:00
|
|
|
echo "$lign" >> "$pwd"/database
|
2012-05-20 08:22:37 +00:00
|
|
|
|
2013-12-26 11:19:34 +00:00
|
|
|
"$pwd"/youtube-dl --get-title --get-thumbnail --get-filename "$lign" >> "$pwd"/database
|
|
|
|
echo "-- " >> "$pwd"/database
|
2012-05-20 08:22:37 +00:00
|
|
|
|
2013-12-26 11:19:34 +00:00
|
|
|
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"
|
2012-05-20 08:22:37 +00:00
|
|
|
echo "${f:$((${#pwd} + 7)):4}"
|
|
|
|
if [ "${f:$((${#pwd} + 7)):4}" == "nemu" ]; then
|
|
|
|
echo "nemu convertion"
|
2013-12-26 11:19:34 +00:00
|
|
|
"$pwd"/youtube-dl --no-progress -c -k -o "$pwd/content/%(id)s.%(ext)s" --extract-audio --audio-format=vorbis "$lign"
|
2012-05-20 08:22:37 +00:00
|
|
|
else
|
2013-12-26 11:19:34 +00:00
|
|
|
"$pwd"/youtube-dl --no-progress -c -k -o "$pwd/content/%(id)s.%(ext)s" --extract-audio --audio-format=mp3 "$lign"
|
2012-05-20 08:22:37 +00:00
|
|
|
fi
|
2013-12-26 11:19:34 +00:00
|
|
|
echo "" > "$f.ec"
|
2012-05-20 08:22:37 +00:00
|
|
|
|
2013-12-26 11:19:34 +00:00
|
|
|
echo "$lign" >> "$f.done"
|
2012-05-20 08:22:37 +00:00
|
|
|
|
2013-12-26 11:19:34 +00:00
|
|
|
chgrp www-data "$f.done" "$f.ec"
|
|
|
|
chmod g+rw "$f.done" "$f.ec"
|
2012-04-15 14:30:53 +00:00
|
|
|
else
|
2012-05-20 08:22:37 +00:00
|
|
|
echo $size
|
|
|
|
fi
|
|
|
|
fi
|
2012-03-05 21:46:25 +00:00
|
|
|
#Remove the action from the file
|
2013-12-26 11:19:34 +00:00
|
|
|
sed -i '1d' "$f"
|
|
|
|
chgrp www-data "$f"
|
|
|
|
chmod g+rw "$f"
|
2012-03-05 21:46:25 +00:00
|
|
|
|
|
|
|
#What's next?
|
2013-12-26 11:19:34 +00:00
|
|
|
lign=`sed '2,$d' "$f" | tr -d '\n'`
|
2012-03-05 21:46:25 +00:00
|
|
|
done
|
|
|
|
fi
|
2012-02-27 16:59:03 +00:00
|
|
|
done
|
2012-03-05 21:46:25 +00:00
|
|
|
rm /tmp/dlEnCours 2> /dev/null
|
2012-02-27 16:59:03 +00:00
|
|
|
fi
|