diff options
-rwxr-xr-x | 1337x | 88 | ||||
-rw-r--r-- | README.md | 5 |
2 files changed, 92 insertions, 1 deletions
@@ -0,0 +1,88 @@ +#!/bin/sh + +url_1337x="https://1337x.to" + +die() +{ + : "${1:?}" + + command -v notify-send > /dev/null && + notify-send " 1337x" "$1" + + printf "\033[31;1merr: %b\033[0m\n" "$1" + exit "${2:-1}" +} + +dep_check() +{ + : "${1:?}" + + for dep; do + command -v "$dep" 1>/dev/null || + die "$dep not found, please install it" 127 + done + + unset dep +} + +get_1337x() +{ + : "${1:?}" + dep_check curl + + curl --silent "${url_1337x}/$1" +} + +search_1337x() +{ + : "${1:?}" + + get_1337x "search/$(echo "$1" | tr ' ' '+')/1/" | + grep -o "[0-9][0-9][0-9][0-9][0-9][0-9][0-9]/[^/]*" +} + +magnet_1337x() +{ + : "${1:?}" + + get_1337x "torrent/$1/" | + grep -om1 "magnet:?xt=urn:btih:.*announce" +} + +main() +{ + fetch= + select= + magnet= + out= + query= + + dep_check "dmenu" "pirowatch" + + if [ "$#" -gt 0 ] && [ "$1" = "-o" ] + then + out=true + shift + fi + + query="$*" + : "${query:=$(printf "" | dmenu -p " ")}" + [ -z "$query" ] && + die "please enter a query" + + fetch="$(search_1337x "$query")" + select="$(echo "$fetch" | sed 's/^.*\///g' | dmenu -l 25 -p " ")" + magnet="$(magnet_1337x "$(echo "$fetch" | grep "$select")")" + + [ -z "$magnet" ] && + die "empty magnet" + + if [ "$out" = true ] + then + echo "$magnet" + else + pirowatch "$magnet" + fi +} + +main "$@" @@ -2,11 +2,14 @@ [dmenu](https://tools.suckless.org/dmenu/) is a fast and lightweight dynamic menu for X written by the [suckless](https://suckless.org/) community. this is my collection of posix scripts for dmenu. these scripts might use [nerd fonts](https://www.nerdfonts.com/), make sure you've installed them for the best experience. you can find more info about them below ## damb - dmenu ambience -listen to ambient music while working on somthing fun. audio files should be stored at ~/.local/share/damb/. damb also has a config file located at ~/.conf/damb/links, where you can provide direct links to media sources or links to youtube-dl supported sites, it should be in the format \<name> = \<link>, you can also play links from your clipboard using the stream option. mix together varous ambient sounds and stream with damb +listen to ambient music while working on somthing fun. audio files should be stored at ~/.local/share/damb/. damb also has a config file located at ~/.conf/damb/links, where you can provide direct links to media sources or links to youtube-dl supported sites, it should be in the format \<name> = \<link>, you can also play links from your clipboard using the stream option. mix together varous ambient sounds and stream with damb ## pirowatch pirowatch is a dmenu wrapper for [web torrent](https://webtorrent.io/), provide magnet or torrent files as command line argument or input from dmenu and consoom the media using [mpv](https://mpv.io/) +## 1337x +scraper for 1337x.to, has an optional dependency on pirowatch. if you pass "-o" as the first argument it'll print the scraped magnet link to stdin otherwise it will pass the magnet link to pirowatch + ## vpn dmenu wrapper for wireguard, depends on wip |