Adding some logging to prune, fixing scan torrents.
This commit is contained in:
parent
7bb576805c
commit
ad17496f28
|
@ -1,4 +1,5 @@
|
||||||
# This prunes torrents.csv, removing those with too many columns, and sorts it
|
# This prunes torrents.csv, removing those with too many columns, and sorts it
|
||||||
|
echo "Pruning torrents.csv ..."
|
||||||
cd ..
|
cd ..
|
||||||
torrents_csv="`pwd`/torrents.csv"
|
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
|
sed -i "1i $header" $torrents_csv
|
||||||
#truncate -s -1 $torrents_csv # Removing last newline
|
#truncate -s -1 $torrents_csv # Removing last newline
|
||||||
|
|
||||||
|
echo "Pruning done."
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -51,8 +51,11 @@ for torrent_file in *.torrent; do
|
||||||
found_line=$(rg -n $infohash $torrents_csv)
|
found_line=$(rg -n $infohash $torrents_csv)
|
||||||
found_seeders=$(echo -e $found_line | cut -d';' -f 5)
|
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
|
# Only re-add if the infohash doesn't exist, or
|
||||||
if [ ! -z "$found_line" ] && [ "$found_seeders" != "$seeders" ]; then
|
if [ ! -z "$found_line" ]; then
|
||||||
|
|
||||||
|
# Seeder counts are different
|
||||||
|
if [ "$found_seeders" != "$seeders" ]; then
|
||||||
|
|
||||||
# Delete the original infohash line
|
# Delete the original infohash line
|
||||||
grep -v "$infohash" $torrents_csv > torfile.tmp.2; mv torfile.tmp.2 $torrents_csv
|
grep -v "$infohash" $torrents_csv > torfile.tmp.2; mv torfile.tmp.2 $torrents_csv
|
||||||
|
@ -60,16 +63,25 @@ for torrent_file in *.torrent; do
|
||||||
# Append the add lines to the torrents.csv file
|
# Append the add lines to the torrents.csv file
|
||||||
echo -e "\n$add_line" >> $torrents_csv
|
echo -e "\n$add_line" >> $torrents_csv
|
||||||
# truncate -s -1 $torrents_csv # Removing last newline
|
# truncate -s -1 $torrents_csv # Removing last newline
|
||||||
echo -e "Added $torrent_file | $name | $infohash | $seeders"
|
echo -e "Updating Seeders: $torrent_file | $name | $infohash | $seeders"
|
||||||
else
|
else
|
||||||
echo -e "Not adding $name, had identical seeders"
|
echo -e "Not adding $name, had identical seeders"
|
||||||
fi
|
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 "New Torrent: $torrent_file | $name | $infohash | $seeders"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
else
|
else
|
||||||
echo -e "$name has no seeders, removing if existed."
|
|
||||||
# Deleting the line if it existed
|
# Deleting the line if it existed
|
||||||
|
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
|
grep -v "$infohash" $torrents_csv > torfile.tmp.2; mv torfile.tmp.2 $torrents_csv
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue