Adding some logging to prune, fixing scan torrents.

This commit is contained in:
Dessalines 2018-11-25 16:53:55 -07:00
parent 7bb576805c
commit ad17496f28
2 changed files with 25 additions and 10 deletions

View File

@ -1,4 +1,5 @@
# This prunes torrents.csv, removing those with too many columns, and sorts it
echo "Pruning torrents.csv ..."
cd ..
torrents_csv="`pwd`/torrents.csv"
@ -24,4 +25,6 @@ sort --field-separator=';' --key=5 -nr -o $torrents_csv $torrents_csv
sed -i "1i $header" $torrents_csv
#truncate -s -1 $torrents_csv # Removing last newline
echo "Pruning done."

View File

@ -51,24 +51,36 @@ for torrent_file in *.torrent; do
found_line=$(rg -n $infohash $torrents_csv)
found_seeders=$(echo -e $found_line | cut -d';' -f 5)
# Only re-add if the infohash doesn't exist, and the seeder counts are different
if [ ! -z "$found_line" ] && [ "$found_seeders" != "$seeders" ]; then
# Only re-add if the infohash doesn't exist, or
if [ ! -z "$found_line" ]; then
# Delete the original infohash line
grep -v "$infohash" $torrents_csv > torfile.tmp.2; mv torfile.tmp.2 $torrents_csv
# Seeder counts are different
if [ "$found_seeders" != "$seeders" ]; then
# Delete the original infohash line
grep -v "$infohash" $torrents_csv > torfile.tmp.2; mv torfile.tmp.2 $torrents_csv
# Append the add lines to the torrents.csv file
echo -e "\n$add_line" >> $torrents_csv
# truncate -s -1 $torrents_csv # Removing last newline
echo -e "Updating Seeders: $torrent_file | $name | $infohash | $seeders"
else
echo -e "Not adding $name, had identical seeders"
fi
else
# Append the add lines to the torrents.csv file
echo -e "\n$add_line" >> $torrents_csv
# truncate -s -1 $torrents_csv # Removing last newline
echo -e "Added $torrent_file | $name | $infohash | $seeders"
else
echo -e "Not adding $name, had identical seeders"
echo -e "New Torrent: $torrent_file | $name | $infohash | $seeders"
fi
else
echo -e "$name has no seeders, removing if existed."
# Deleting the line if it existed
grep -v "$infohash" $torrents_csv > torfile.tmp.2; mv torfile.tmp.2 $torrents_csv
if [ ! -z "$infohash" ]; then
echo -e "$name has no seeders, removing if existed."
grep -v "$infohash" $torrents_csv > torfile.tmp.2; mv torfile.tmp.2 $torrents_csv
fi
fi
done