diff --git a/README.md b/README.md index d527b50..b8a1b3c 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,17 @@ -

NOTFLIX

-

f@#k netf!ix use notflix

-

Watch almost any content available on internet for free

+

NOTFLIX for noobs

+

A fork of notflix by quickcodes (https://github.com/quickcodes/)

+

Watch almost any content available on internet for free as the original but with some quality of life improvements such as automatic dependency installation.

## Requirements -* [webtorrent](https://webtorrent.io/) - A tool to stream torrent. `npm install webtorrent-cli -g` +* [npm](https://www.npmjs.com/) - The tool needed to install webtorrent. +`sudo apt install npm` or `sudo pacman -S npm` if you are using an Arch based distro to install. +* [webtorrent](https://webtorrent.io/) - A tool to stream torrent. The tool that makes this possible. +`sudo npm install webtorrent-cli -g` to install. +* [mpv](https://mpv.io/) - If you don't know about mpv, you are probably new to linux. A very powerful video player. +`sudo apt install mpv` or `sudo pacman -S mpv` if you are using an Arch based distro to install. ## Installation @@ -14,7 +19,7 @@ cURL **notflix** to your **$PATH** and give execute permissions. ```sh -$ sudo curl -sL "https://raw.githubusercontent.com/quickcodes/notflix/main/notflix" -o /usr/local/bin/notflix +$ sudo curl -sL "https://raw.githubusercontent.com/wallmenis/notflix/main/notflix" -o /usr/local/bin/notflix $ sudo chmod 777 /usr/local/bin/notflix ``` - To update, just do `curl` again, no need to `chmod` anymore. diff --git a/notflix b/notflix index c837e33..ec54cff 100644 --- a/notflix +++ b/notflix @@ -1,16 +1,84 @@ -name=$(echo "" | dmenu -p "ENTER NAMEA: ") +pkgmanagersearch=" " #just in case +pkgmanagerinstall=" " +if [ "$(ls /usr/bin | egrep '(^| )apt( |$)' | wc -l)" != "0" ]; +then + pkgmanagersearch="apt list --installed" + pkgmanagerinstall="sudo apt install" +elif [ "$(ls /usr/bin | egrep '(^| )pacman( |$)' | wc -l)" != "0" ]; +then + pkgmanagersearch="pacman -Q" + pkgmanagerinstall="sudo pacman -S" +fi +if [[ "$pkgmanagersearch" == " " ]]; +then + echo "Sorry. We do not support your package manager. So we can't install dependencies automatically. You will have to install them yourself. Continue anyways? [y/n]" + read inp + if [[ "$inp" != "y" ]]; + then + exit + fi +fi +is_webtorrent_installed=$(npm ls -g | grep webtorrent | wc -l) +is_mpv_installed=$($pkgmanagersearch | grep mpv | wc -l) +is_npm_installed=$($pkgmanagersearch | grep npm | wc -l) +if (( $is_npm_installed == 0 )) +then + echo "Found unmet dependency \"npm\". You may be asked to give a password for administrator privelages for your package manager to install npm. Press \"y\" when prompted to install the dependency." + exec $pkgmanagerinstall npm +fi +if (( $is_webtorrent_installed == 0 )) +then + echo "Found unmet dependency \"webtorrent\". You may be asked to give a password for administrator privelages for your package manager to install npm. Press \"y\" when prompted to install the dependency." + sudo npm install -g webtorrent-cli +fi +if (( $is_mpv_installed == 0 )) +then + echo "Found unmet dependency \"mpv\". You may be asked to give a password for administrator privelages for your package manager to install npm. Press \"y\" when prompted to install the dependency." + exec $pkgmanagerinstall mpv +fi + +#-------------------------finding and sellecting movie------------------------- + +#name=$(echo "" | dmenu -p "ENTER NAMEA: ") +echo "ENTER NAME:" +read name name=(${name// /%20}) -movie=$(echo "" | curl -s "https://thepiratebay.party/search/$name/1/99/0" | grep -Eo "(http|https)://thepiratebay.party/torrent/[a-zA-Z0-9./?=_%:-]*" | dmenu -l 15) -echo "$movie" +#movie=$(echo "" | curl -s "https://thepiratebay.party/search/$name/1/99/0" | grep -Eo "(http|https)://thepiratebay.party/torrent/[a-zA-Z0-9./?=_%:-]*") +moviearrayraw=$(curl -s "https://thepiratebay.party/search/$name/1/99/0" | grep -Eo "(http|https)://thepiratebay.party/torrent/[a-zA-Z0-9./?=_%:-]*") + +#breaking the raw string to the array +moviearray=($(echo $moviearrayraw )) +until [ $inp -le ${#moviearray[@]} ] && [ $inp -gt 0 ]; do + echo "Please sellect from the following ${#moviearray[@]} movies:" + for ((i=0; i<${#moviearray[@]}; i++)) + do + let num=$i+1 + echo "$num.${moviearray[$i]}" + done + read inp + if [ $inp -gt ${#moviearray[@]} ] && [ $inp -le 0 ]; + then + echo "Invalid input $inp. Please use something in range of 1 to ${#moviearray[@]}" + fi +done + +let inp=$inp-1 +movie="${moviearray[$inp]}" + +echo "Sellected $movie" magnet=$(curl -s "$movie" | grep -Po "magnet:\?xt=urn:btih:[a-zA-Z0-9]*" | head -1) + +#-------------------------playing the sellected movie------------------------- + echo "PRESS 1 to download only or press any key" read num if (($num == 1)) then - notify-send "🎥 Downloading... ☺️ " - webtorrent download "$magnet" + #notify-send "🎥 Downloading... ☺️ " + echo "🎥 Downloading... ☺️ " + webtorrent download "$magnet" else - notify-send "🎥 Enjoy Watching ☺️ " - webtorrent "$magnet" --mpv + #notify-send "🎥 Enjoy Watching ☺️ " + echo "🎥 Enjoy Watching ☺️ " + webtorrent "$magnet" --mpv fi -