34 lines
919 B
Bash
Executable File
34 lines
919 B
Bash
Executable File
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 = '';
|
|
# 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);
|
|
|
|
EOF
|
|
rm torrents_removed_quotes.csv
|
|
|
|
|