diff --git a/README.md b/README.md index a36046f..f7a2808 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,22 @@

NOTFLIX

-

f@#k netflix use notflix a tool which search magnet links and stream it with peerflix

+

f@#k netflix use notflix a tool which search magnet links with dmenu and streams it with webtorrent-cli

##

-Video Preview +Video Preview

-> Watch this video to understand - [bugswriter's notflix](https://youtu.be/FbE19_omaWY) +> Watch this video to understand the script better- [bugswriter's notflix video](https://youtu.be/FbE19_omaWY) ### How does this work? -This is a shell script. It scape 1337x and get the magnet link. -After this it use [peerflix](https://github.com/mafintosh/peerflix) to stream the video from magnet link. -For scraping script use simple gnu utils like sed, awk, paste, cut. +This is a dmenu script. It searches 1337x and gets the magnet link for which media u choose. +After this it uses [webtorrent-cli](https://github.com/webtorrent/webtorrent-cli) to stream the video with mpv from the magnet link. +For scraping script it uses simple gnu utils like sed, awk, paste, grep, cut. -## Requirements +## Requirements / Dependencies -* [peerflix](https://github.com/mafintosh/peerflix) - A tool to stream torrent. `sudo npm install peerflix -g` +* [webtorrent-cli](https://github.com/webtorrent/webtorrent-cli) - A tool to stream torrent. `sudo npm install webtorrent-cli -g` or `paru -S webtorrent-cli` / `yay -S webtorrent-cli` for Arch Linux Users ## Installation @@ -24,12 +24,16 @@ For scraping script use simple gnu utils like sed, awk, paste, cut. cURL **notflix** to your **$PATH** and give execute permissions. ```sh -$ sudo curl -sL "https://raw.githubusercontent.com/Bugswriter/notflix/master/notflix" -o /usr/local/bin/notflix -$ sudo chmod +x /usr/local/bin/notflix +--- If you are using sudo --- +sudo curl -sL "https://raw.githubusercontent.com/zakky20/notflix-dmenu/master/notflix" -o /usr/local/bin/notflix +sudo chmod +x /usr/local/bin/notflix + +--- If you are using doas instead of sudo --- +doas curl -sL "https://raw.githubusercontent.com/zakky20/notflix-dmenu/master/notflix" -o /usr/local/bin/notflix +doas chmod +x /usr/local/bin/notflix ``` - To update, just do `curl` again, no need to `chmod` anymore. - To uninstall, simply remove `notflix` from your **$PATH**, for example `sudo rm -f /usr/local/bin/notflix. ## License This project is licensed under [GPL-3.0](https://raw.githubusercontent.com/Illumina/licenses/master/gpl-3.0.txt). - diff --git a/notflix b/notflix index 2a63050..8ef378b 100755 --- a/notflix +++ b/notflix @@ -1,6 +1,75 @@ -#!/bin/sh +#!/usr/bin/env bash -query=$(printf '%s' "$*" | tr ' ' '+' ) -movie=$(curl -s https://1337x.to/search/$query/1/ | grep -Eo "torrent\/[0-9]{7}\/[a-zA-Z0-9?%-]*/" | head -n 1) -magnet=$(curl -s https://1337x.to/$movie | grep -Po "magnet:\?xt=urn:btih:[a-zA-Z0-9]*" | head -n 1) -peerflix -l -k $magnet +mkdir -p $HOME/.cache/notflix + +menu="dmenu -i -l 20" +baseurl="https://1337x.to" +cachedir="$HOME/.cache/notflix" + +category=$(dmenu -p "Movies? TV? Documentaries? Anime? (1,2,3,4): " <&-) +case $category in +"1") category="Movies" ;; +"2") category="TV" ;; +"3") category="Documentaries" ;; +"4") category="Anime" ;; +*) category="Movies" ;; +esac + +if [ -z $1 ]; then + query=$(dmenu -p "Search Torrent: " <&-) +else + query=$1 +fi +query="$(echo $query | sed 's/ /+/g')" + +curl -s "$baseurl/category-search/$query/$category/1/" >"$cachedir/tmp.html" + +grep -o ']*>//g' >"$cachedir/titles.bw" + +result_count=$(wc -l "$cachedir/titles.bw" | awk '{print $1}') +if [ "$result_count" -lt 1 ]; then + notify-send "No Result found. Try again" -i "NONE" + exit 0 +fi + +grep -o '' "$cachedir/tmp.html" | + sed 's/<[^>]*>//g' | sed 'N;s/\n/ /' >"$cachedir/seedleech.bw" + +grep -o '.*<\/span>//g' | + sed -e 's/<[^>]*>//g' >"$cachedir/size.bw" + +grep -E '/torrent/' "$cachedir/tmp.html" | + sed -E 's#.*(/torrent/.*)/">.*#\1#' >"$cachedir/links.bw" + +sed 's/\./ /g; s/\-/ /g' "$cachedir/titles.bw" | + sed 's/[^A-Za-z0-9 ]//g' | tr -s " " >"$cachedir/tmp" && mv "$cachedir/tmp" "$cachedir/titles.bw" + +awk '{print NR " - ["$0"]"}' "$cachedir/size.bw" >"$cachedir/tmp" && mv "$cachedir/tmp" "$cachedir/size.bw" +awk '{print "[S:"$1 ", L:"$2"]" }' "$cachedir/seedleech.bw" >"$cachedir/tmp" && mv "$cachedir/tmp" "$cachedir/seedleech.bw" + +LINE=$(paste -d\ "$cachedir/size.bw" "$cachedir/seedleech.bw" "$cachedir/titles.bw" | + $menu | + cut -d\- -f1 | + awk '{$1=$1; print}') + +if [ -z "$LINE" ]; then + notify-send "No Result selected. Exiting..." -i "NONE" + exit 0 +fi + +notify-send "Searching Magnet seeds" -i "NONE" + +url=$(head -n $LINE "$cachedir/links.bw" | tail -n +$LINE) +fullURL="${baseurl}${url}/" +curl -s "$fullURL" >"$cachedir/tmp.html" + +magnet=$(grep -Po 'href="magnet:\?xt=urn:btih:[^"]+"' "$cachedir/tmp.html" | head -n 1 | sed 's/href="//;s/"$//') + +if [ -z "$magnet" ]; then + notify-send "Magnet link not found" -i "NONE" + exit 0 +fi +webtorrent "$magnet" --mpv +notify-send "Enjoy!" -i "NONE" diff --git a/notflix.gif b/notflix.gif new file mode 100644 index 0000000..40cbde4 Binary files /dev/null and b/notflix.gif differ diff --git a/preview.gif b/preview.gif deleted file mode 100644 index 05d5b85..0000000 Binary files a/preview.gif and /dev/null differ