Changing delimiter to ;

Adding a find.sh script
This commit is contained in:
Dessalines 2018-10-04 16:24:56 -07:00
parent 0af1db917d
commit 01c3d23b42
4 changed files with 44 additions and 29 deletions

View File

@ -1,33 +1,28 @@
# Torrent.csv
Torrent.csv is a vetted database of torrents, consisting of a
single, searchable `torrent.csv` file.
`Torrent.csv` is a vetted database of torrents, consisting of a single, searchable `torrent.csv` file.
An "upload", consists of making a pull request adding your torrents
to the last line of the file.
An *upload*, consists of making a pull request after running the `add_torrents.sh` script that adds your new unique torrents to the file, after checking that they aren't already there, and that they have seeders.
To find torrents run `./find.sh "SEARCH"`
Run `./torrents_to_csv.sh ~/TORRENTS_DIR` to generate your add lines.
To contribute:
- [Click here](https://gitlab.com/dessalines/torrent.csv/forks/new) to fork this repo.
```sh
git clone https://gitlab.com/[MY_USER]/torrent.csv
cd torrent.csv
./add_torrents.sh MY_TORRENTS_DIR # `MY_TORRENTS_DIR` is `~/.local/share/data/qBittorrent/BT_backup/` for qBittorrent on linux, but you can search for where your torrents are stored for your client.
git commit -am "Adding my torrents"
git push
```
Then [click here](https://gitlab.com/dessalines/torrent.csv/merge_requests/new) to do a pull/merge request to my branch.
The file will periodically be sorted
by `name`, and `seeders` descending.
## How the file looks
```sh
infohash;name;size_bytes;created_unix;seeders;leechers;completed;scraped_date
# torrents here...
```
## Columns
name,size_bytes,infohash,created_unix,seeders,leechers,completed,scraped_date
To get the correct format run this script: `todo.txt`
Seeder and leecher counts are necessary, I suggest using the [
torrent-tracker-scraper](https://github.com/ZigmundVonZaun/torrent-tracker-scraper)
to get seeders, leechers, and completed.
The columns are...
Start with that one huge backup.
TODO
- Create add line script. Inputs a torrent or a torrent directory, and spits out the add lines.
- Add a Dup checker
`Torrent.csv` will be periodically purged of non-seeded torrents, and potentially sorted.

View File

@ -1,5 +1,3 @@
export LC_ALL=C
# Checking arguments
# Help line
torrent_csv_file="`pwd`/torrent.csv"
@ -46,7 +44,7 @@ for torrent_file in *.torrent; do
# echo "show text = $show_text"
name=$(grep -Po -m 1 'Name: \K.*' <<< $show_text)
name=$(sed 's/,/\\,/g' <<< $name) # Escape the commas for .csv
name=$(sed 's/;/\\;/g' <<< $name) # Escape the commas for .csv
# Size: Unfortunately this will chop off some sigfigs
size=$(grep -Po 'Total Size: \K.*' <<< $show_text)
@ -70,7 +68,7 @@ for torrent_file in *.torrent; do
scraped_date=$(date +%s)
# Construct add line
add_line="$infohash,$name,$size_bytes,$created_date,$seeders,$leechers,$completed,$scraped_date"
add_line="$infohash;$name;$size_bytes;$created_date;$seeders;$leechers;$completed;$scraped_date"
# Only add the line if there are seeds, and the infohash doesn't already exist
if (( $seeders > 0 )) && ! grep -q $infohash $torrent_csv_file; then

22
find.sh Executable file
View File

@ -0,0 +1,22 @@
torrent_csv_file="`pwd`/torrent.csv"
search=$(grep -i "$1" $torrent_csv_file)
# Sort results by seeders
search=$(echo -e "$search" | sort --field-separator=';' --key=5 -g)
if [ -z "$search" ]; then
echo "No results found"
else
# Read the lines of the results
while read -r line; do
infohash=$(echo -e "$line" | cut -d ';' -f1)
magnet_link="magnet:?xt=urn:btih:$infohash"
name=$(echo -e "$line" | cut -d ';' -f2)
# Construct the search result
result="$name\n\t$magnet_link"
echo -e "$result"
done <<< "$search"
fi

View File

@ -1 +1 @@
infohash,name,size_bytes,created_unix,seeders,leechers,completed,scraped_date
infohash;name;size_bytes;created_unix;seeders;leechers;completed;scraped_date
1 infohash name size_bytes created_unix seeders leechers completed scraped_date