32 lines
708 B
Bash
Executable File
32 lines
708 B
Bash
Executable File
#!/bin/bash
|
|
|
|
echo "Creating temporary torrents.db file..."
|
|
|
|
# Remove double quotes for csv import
|
|
sed 's/\"//g' ../torrents.csv > torrents_removed_quotes.csv
|
|
|
|
# Sort by seeders desc before insert
|
|
sort --field-separator=';' --key=5 -nr -o torrents_removed_quotes.csv torrents_removed_quotes.csv
|
|
|
|
rm ../torrents.db
|
|
|
|
sqlite3 -batch ../torrents.db <<"EOF"
|
|
create table torrents(
|
|
"infohash" TEXT,
|
|
"name" TEXT,
|
|
"size_bytes" INTEGER,
|
|
"created_unix" INTEGER,
|
|
"seeders" INTEGER,
|
|
"leechers" INTEGER,
|
|
"completed" INTEGER,
|
|
"scraped_date" INTEGER
|
|
);
|
|
.separator ";"
|
|
.import torrents_removed_quotes.csv torrents
|
|
UPDATE torrents SET completed=NULL WHERE completed = '';
|
|
|
|
EOF
|
|
rm torrents_removed_quotes.csv
|
|
|
|
|