2018-12-02 18:39:57 +00:00
|
|
|
echo "Creating temporary torrents.db file..."
|
|
|
|
|
|
|
|
# Remove double quotes for csv import
|
2018-12-02 09:16:31 +00:00
|
|
|
sed 's/\"//g' ../torrents.csv > torrents_removed_quotes.csv
|
|
|
|
|
2018-12-02 18:39:57 +00:00
|
|
|
# Sort by seeders desc before insert
|
|
|
|
sort --field-separator=';' --key=5 -nr -o torrents_removed_quotes.csv torrents_removed_quotes.csv
|
|
|
|
|
2018-12-02 09:16:31 +00:00
|
|
|
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 = '';
|
2018-12-02 18:39:57 +00:00
|
|
|
# create index idx_name_seeders on torrents (name, seeders desc);
|
|
|
|
# create index idx_name on torrents (name);
|
|
|
|
# create index idx_seeders on torrents (seeders desc);
|
|
|
|
# create index idx_name on torrents (name collate nocase);
|
|
|
|
|
2018-12-02 09:16:31 +00:00
|
|
|
EOF
|
|
|
|
rm torrents_removed_quotes.csv
|
|
|
|
|
|
|
|
|