From e767fe77fb2f968b0f8861feb2f9b270f562432d Mon Sep 17 00:00:00 2001 From: Dessalines Date: Fri, 5 Oct 2018 23:58:09 -0700 Subject: [PATCH] Adding humanized size output to search. Fixes #1 --- README.md | 21 +++++++++++++++------ scrape_and_clean.sh => prune.sh | 0 search.sh | 7 +++++-- 3 files changed, 20 insertions(+), 8 deletions(-) rename scrape_and_clean.sh => prune.sh (100%) diff --git a/README.md b/README.md index eaf2995..f2cb090 100644 --- a/README.md +++ b/README.md @@ -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 - \ No newline at end of file +`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. \ No newline at end of file diff --git a/scrape_and_clean.sh b/prune.sh similarity index 100% rename from scrape_and_clean.sh rename to prune.sh diff --git a/search.sh b/search.sh index e9eaff1..4db4b85 100755 --- a/search.sh +++ b/search.sh @@ -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