diff --git a/tools/db/import-md5-list b/tools/db/import-md5-list index 5abf887..0875792 100755 --- a/tools/db/import-md5-list +++ b/tools/db/import-md5-list @@ -73,11 +73,11 @@ moviedir=""$(echo $moviedir | sed 's|/$||g')"" ## functions function md5_in_add() { cat $md5 | while read line; do #for each line in md5 - md5=$(echo $line | cut -c -32) - path=$(echo $line | cut -c 33- | sed 's/^\ //g') - relrevpath=$(echo $path | sed "s|^$moviedir||g" | sed 's|^/||g' | sed 's|/$||g' | rev) - name=$(echo $relrevpath | cut -d '/' -f 1 | rev) - folder=$(echo $relrevpath | cut -d '/' -f 2- | rev) + local md5=$(echo $line | cut -c -32) + local path=$(echo $line | cut -c 33- | sed 's/^\ //g') + local relrevpath=$(echo $path | sed "s|^$moviedir||g" | sed 's|^/||g' | sed 's|/$||g' | rev) + local name=$(echo $relrevpath | cut -d '/' -f 1 | rev) + local folder=$(echo $relrevpath | cut -d '/' -f 2- | rev) db_query "INSERT INTO File (MD5, Folder, Name, TTSync) VALUES ('$md5', '$folder', '$name', $TTSYNC_EXIST );" #-> handle in future: ";'()" done @@ -85,10 +85,28 @@ function md5_in_add() { } function md5_rm() { + cat $md5 | while read line; do #for each line in md5 + local md5=$(echo $line | cut -c -32) + local path=$(echo $line | cut -c 33- | sed 's/^\ //g') + local relrevpath=$(echo $path | sed "s|^$moviedir||g" | sed 's|^/||g' | sed 's|/$||g' | rev) + local name=$(echo $relrevpath | cut -d '/' -f 1 | rev) + local folder=$(echo $relrevpath | cut -d '/' -f 2- | rev) + db_query "DELETE FROM File WHERE MD5='$md5' AND Folder='$folder' AND Name='$name';" #-> handle in future: ";'()" + done + exit 0 } function md5_in_del() { + cat $md5 | while read line; do #for each line in md5 + local md5=$(echo $line | cut -c -32) + local path=$(echo $line | cut -c 33- | sed 's/^\ //g') + local relrevpath=$(echo $path | sed "s|^$moviedir||g" | sed 's|^/||g' | sed 's|/$||g' | rev) + local name=$(echo $relrevpath | cut -d '/' -f 1 | rev) + local folder=$(echo $relrevpath | cut -d '/' -f 2- | rev) + db_query "UPDATE File SET TTSync=$TTSYNC_DEL WHERE MD5='$md5' AND Folder='$folder' AND Name='$name';" #-> handle in future: ";'()" + done + exit 0 }