torrents.csv/find.sh

24 lines
630 B
Bash
Raw Normal View History

2018-10-04 23:33:33 +00:00
torrent_csv_file="`pwd`/torrents.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)
2018-10-05 05:25:52 +00:00
seeders=$(echo -e "$line" | cut -d ';' -f5)
# Construct the search result
2018-10-05 05:25:52 +00:00
result="$name\n\tseeders: $seeders\n\tlink: $magnet_link"
echo -e "$result"
done <<< "$search"
fi