2018-10-08 05:43:12 +00:00
|
|
|
# This prunes torrents.csv, removing those with too many columns, and sorts it
|
2018-11-25 23:53:55 +00:00
|
|
|
echo "Pruning torrents.csv ..."
|
2018-10-11 22:27:47 +00:00
|
|
|
cd ..
|
2018-10-08 05:43:12 +00:00
|
|
|
torrents_csv="`pwd`/torrents.csv"
|
|
|
|
|
|
|
|
# Remove lines that don't have exactly 7 ';'
|
|
|
|
rg "^([^;]*;){7}[^;]+$" $torrents_csv > tmp_adds
|
|
|
|
mv tmp_adds $torrents_csv
|
|
|
|
|
|
|
|
# Remove random newlines
|
|
|
|
sed -i '/^$/d' $torrents_csv
|
|
|
|
|
|
|
|
# Extract the header
|
|
|
|
header=$(head -n1 $torrents_csv)
|
|
|
|
sed -i '1d' $torrents_csv
|
|
|
|
|
2018-12-02 18:39:57 +00:00
|
|
|
# Sort by seeders desc (so when we remove dups it removes the lower seeder counts)
|
|
|
|
# TODO this should actually probably do it by scraped date
|
|
|
|
sort --field-separator=';' --key=5 -nr -o $torrents_csv $torrents_csv
|
|
|
|
|
2018-10-08 05:43:12 +00:00
|
|
|
# Remove dups
|
|
|
|
sort -u -t';' -k1,1 -o $torrents_csv $torrents_csv
|
2018-11-16 01:22:14 +00:00
|
|
|
sort -u -t';' -k2,2 -k3,3 -o $torrents_csv $torrents_csv
|
2018-10-08 05:43:12 +00:00
|
|
|
|
2018-12-02 18:39:57 +00:00
|
|
|
# Sort by infohash asc
|
|
|
|
sort --field-separator=';' --key=1 -o $torrents_csv $torrents_csv
|
2018-10-08 05:43:12 +00:00
|
|
|
|
|
|
|
# Add the header back in
|
|
|
|
sed -i "1i $header" $torrents_csv
|
2018-10-15 21:02:47 +00:00
|
|
|
#truncate -s -1 $torrents_csv # Removing last newline
|
2018-10-08 05:43:12 +00:00
|
|
|
|
2018-11-25 23:53:55 +00:00
|
|
|
echo "Pruning done."
|
|
|
|
|
2018-10-08 05:43:12 +00:00
|
|
|
|