README, minor corrections
[BABOOSHKA.TV] / renewplaylist.sh
1 #!/bin/bash
2
3 if [ $# -lt 1 ]; then
4         echo "Usage: $0 <playlist>"
5         exit 0
6 fi 
7
8 PLAYLIST=$1
9
10 VIDEO="VIDEO/"
11 DOWNLOADED_VIDEO="YOUTUBE/"
12
13 if [ ! -d "$VIDEO" ] || [ ! -d "$DOWNLOADED_VIDEO" ]; then 
14         mkdir "$VIDEO"
15         mkdir "$DOWNLOADED_VIDEO"
16         echo "$VIDEO and $DOWNLOADED_VIDEO directories has been created. Use them to upload video files to make playlist updated automatically."
17 fi
18
19 IFS=$'\n';
20
21 while [ 1 ]; do
22
23         VIDEO=$(find "$VIDEO" -type f)
24         YOUTUBE=$(find "$DOWNLOADED_VIDEO" -type f | grep -v ".part")
25
26         for file in $VIDEO; do 
27
28                 if ! grep "$file" "$PLAYLIST" >/dev/null; then 
29                         echo "$file" >> "$PLAYLIST"
30                         echo "VIDEO playlist updated: $file"
31                 fi  
32         done 
33
34         for file in $YOUTUBE; do 
35
36                 if ! grep "$file" "$PLAYLIST" >/dev/null; then 
37                         echo "$file" >> "$PLAYLIST"
38                         echo "YOUTUBE playlist updated: $file"
39                 fi  
40         done 
41
42         sleep 60
43 done 
Contact me: dev (at) shalnoff (dot) com
PGP fingerprint: A6B8 3B23 6013 F18A 0C71 198B 83D8 C64D 917A 5717