Adding humanized size output to search. Fixes #1

This commit is contained in:
Dessalines 2018-10-05 23:58:09 -07:00
parent ad8bd076e9
commit e767fe77fb
3 changed files with 20 additions and 8 deletions

View File

@ -2,13 +2,20 @@
`Torrents.csv` is a vetted database of torrents, consisting of a single, searchable `torrents.csv` file.
An *upload*, consists of making a pull request after running the `add_torrents.sh` script, which adds torrents from a directory to the `.csv` file, after checking that they aren't already there, and that they have seeders.
To find torrents run `./search.sh "SEARCH"`
## Searching
To find torrents run `./search.sh "frasier s01"`
```
Frasier S01-S11 (1993-)
seeders: 33
size: 13.43 GB
link: magnet:?xt=urn:btih:3cc5142d0d139bcc9ea9925239a142770b98cf74
```
To add your own torrents, run `./add_torrents.sh MY_TORRENTS_DIR`
## Instructions
## Uploading
An *upload*, consists of making a pull request after running the `add_torrents.sh` script, which adds torrents from a directory to the `.csv` file, after checking that they aren't already there, and that they have seeders.
[Click here](https://gitlab.com/dessalines/torrents.csv/forks/new) to fork this repo.
```sh
@ -27,6 +34,8 @@ infohash;name;size_bytes;created_unix;seeders;leechers;completed;scraped_date
# torrents here...
```
`Torrents.csv` will be periodically purged of non-seeded torrents, and sorted by seeders descending.
## Other info
<!-- https://github.com/danfolkes/Magnet2Torrent -->
`Torrents.csv` will only store torrents with at least one seeder to keep the file small, and will be periodically purged of non-seeded torrents, and sorted by seeders descending.
Its initially populated with a January 2017 backup of the pirate bay, but eventually scripts will be written that pull in new torrents daily.

View File

@ -1,3 +1,4 @@
#!/bin/bash
torrent_csv_file="`pwd`/torrents.csv"
search_string=${1// /.*} # turn multiple string regexes into i.*am.*spartacus
@ -16,9 +17,11 @@ else
magnet_link="magnet:?xt=urn:btih:$infohash"
name=$(echo -e "$line" | cut -d ';' -f2)
seeders=$(echo -e "$line" | cut -d ';' -f5)
size_bytes=$(echo -e "$line" | cut -d ';' -f3)
size=$(~/.local/bin/humanfriendly -s $size_bytes) # This slows down the results a bit
# Construct the search result
result="$name\n\tseeders: $seeders\n\tlink: $magnet_link"
result="$name\n\tseeders: $seeders\n\tsize: $size\n\tlink: $magnet_link"
echo -e "$result"
done <<< "$search"
fi