summaryrefslogtreecommitdiff
path: root/bin/extra/1xsearch
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2023-04-16 21:54:54 +0200
committerRaymaekers Luca <raymaekers.luca@gmail.com>2023-04-16 21:54:54 +0200
commit102e7d997a40a7215b10686ce2b0d006d5a97c2e (patch)
tree86449e1b494d7c209563f6870a5c7493528434aa /bin/extra/1xsearch
parenta58ae56e98a8d9fcbe7fc7beaa976a4d164ee99a (diff)
parent0403da37e183e41d3b949b473038806059130815 (diff)
Merge branch 'main' of db:dotfiles
Diffstat (limited to 'bin/extra/1xsearch')
-rwxr-xr-xbin/extra/1xsearch20
1 files changed, 20 insertions, 0 deletions
diff --git a/bin/extra/1xsearch b/bin/extra/1xsearch
new file mode 100755
index 0000000..a248d38
--- /dev/null
+++ b/bin/extra/1xsearch
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# dependencies
+which pup > /dev/null ||
+ exit 1
+
+test -z "${query:=$1}" &&
+ query="$(cat /dev/stdin)"
+
+url="https://1337x.to"
+query="$(echo "$query" | tr ' ' '+' )"
+result="$(curl -s "$url/search/$query/1/" |
+ pup -p 'a attr{href}' |
+ grep "^/torrent" |
+ head -n 1)"
+# result contains / as first char
+curl -s "$url$result" |
+ pup -p 'a attr{href}' |
+ grep "^magnet:" |
+ head -n 1