code cleanup

This commit is contained in:
CoolnsX
2022-03-02 19:45:36 +05:30
parent 31dd83a47f
commit 11729968e7
8 changed files with 20 additions and 55 deletions

View File

@@ -4,7 +4,7 @@
static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
/* -fn option overrides fonts[0]; default X11 font or font set */
static const char *fonts[] = {
"Comic Sans MS:size=15"
"Roboto:size=13"
};
static const char *prompt = NULL; /* -p option; prompt to the left of input field */
static const char *colors[SchemeLast][2] = {

View File

@@ -4,7 +4,7 @@
static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
/* -fn option overrides fonts[0]; default X11 font or font set */
static const char *fonts[] = {
"Comic Sans MS:size=15"
"Roboto:size=13"
};
static const char *prompt = NULL; /* -p option; prompt to the left of input field */
static const char *colors[SchemeLast][2] = {

Binary file not shown.

Binary file not shown.

9
rss
View File

@@ -1,18 +1,13 @@
#!/bin/sh
#script for downloading latest anime episode via torrent using rss provided by website named "subsplease.org"
#parsing rss file
notify-send "Parsing SubsPlease RSS... Please Wait..."
curl -s https://subsplease.org/rss/?r=1080 | tr "<" "\n" > $HOME/.cache/rss
#extracting names and providing the menu for selecting particular title
name=$(sed -n -e 's/title>\[.*Please\] \(.*\)/\1/p' .cache/rss | dmenu -l 25 -p "Search anime:")
if [ -z "$name" ]; then
notify-send -u critical "Err.. Query empty"
exit 0
fi
[ -z "$name" ] && notify-send -u critical "Err.. Query empty" && exit 0
#extracting id from anime_name_[id].mkv
id=$(printf "$name" | sed -n -e 's/.*\[\(.*\)\].*/\1/p')
@@ -21,4 +16,4 @@ id=$(printf "$name" | sed -n -e 's/.*\[\(.*\)\].*/\1/p')
magnet=$(sed -n -e "s/link>\(.*$id.*\).*/\1/p" .cache/rss | sed 's/amp;//g')
#custom script for downloading torrent using aria2c.. you can use your own bittorrent client here
st -e $HOME/repos_scripts/torrent "$magnet" &
setsid -f st -e $HOME/repo_scripts/torrent "$magnet"

47
tor-cli
View File

@@ -1,62 +1,37 @@
#!/usr/bin/bash
mkdir -p $HOME/.cache/pirokit
query=$(printf "" | dmenu -p "Search Torrent: ")
baseurl="https://www.1337xx.to"
cachedir="$HOME/.cache/pirokit"
query="$(sed 's/ /+/g' <<<$query)"
curl -s -G $baseurl/search/$query/1/ > $cachedir/tmp.html
curl -s "$baseurl/search/$query/1/" > $cachedir/tmp.html
# Get Titles
grep -o '<a href="/torrent/.*</a>' $cachedir/tmp.html |
sed 's/<[^>]*>//g' > $cachedir/titles.bw
grep -o '<a href="/torrent/.*</a>' $cachedir/tmp.html | sed 's/<[^>]*>//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 🔴"
exit
fi
[ "$result_count" -lt 1 ] && notify-send "😔 No Result found. Try again 🔴" && exit 0
# Seeders and Leechers
grep -o '<td class="coll-2 seeds.*</td>\|<td class="coll-3 leeches.*</td>' $cachedir/tmp.html |
sed 's/<[^>]*>//g' | sed 'N;s/\n/ /' > $cachedir/seedleech.bw
grep -o '<td class="coll-2 seeds.*</td>\|<td class="coll-3 leeches.*</td>' $cachedir/tmp.html | sed 's/<[^>]*>//g' | sed 'N;s/\n/ /' > $cachedir/seedleech.bw
# Size
grep -o '<td class="coll-4 size.*</td>' $cachedir/tmp.html |
sed 's/<span class="seeds">.*<\/span>//g' |
sed -e 's/<[^>]*>//g' > $cachedir/size.bw
grep -o '<td class="coll-4 size.*</td>' $cachedir/tmp.html | sed 's/<span class="seeds">.*<\/span>//g' | sed -e 's/<[^>]*>//g' > $cachedir/size.bw
# Links
grep -E '/torrent/' $cachedir/tmp.html |
sed -E 's#.*(/torrent/.*)/">.*/#\1#' |
sed 's/td>//g' > $cachedir/links.bw
grep -E '/torrent/' $cachedir/tmp.html | sed -E 's#.*(/torrent/.*)/">.*/#\1#' | sed 's/td>//g' > $cachedir/links.bw
# Clearning up some data to display
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
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
# Getting the line number
LINE=$(paste -d\ $cachedir/size.bw $cachedir/seedleech.bw $cachedir/titles.bw |
dmenu -l 25 |
cut -d\- -f1 |
awk '{$1=$1; print}')
if [ -z "$LINE" ]; then
notify-send -u critical "Err.. No torrent selected!!"
exit
fi
LINE=$(paste -d\ $cachedir/size.bw $cachedir/seedleech.bw $cachedir/titles.bw | dmenu -l 25 | cut -d\- -f1 | awk '{$1=$1; print}')
[ -z "$LINE" ] && notify-send -u critical "Err.. No torrent selected!!" && exit 0
url=$(head -n $LINE $cachedir/links.bw | tail -n +$LINE)
fullURL="${baseurl}${url}/"
# Requesting page for magnet link
curl -s $fullURL -o $cachedir/tmp.html
magnet=$(grep -Po "magnet.*\" " $cachedir/tmp.html | tr -d \")
st -e $HOME/repos_scripts/torrent "$magnet" &
magnet=$(curl -s "${baseurl}${url}" | sed -nE 's/.*class="(.*)" href="([^"]*)" .*/\2/p')
setsid -f st -e $HOME/repos_scripts/torrent "$magnet"

View File

@@ -9,13 +9,10 @@ c_reset="\033[0m"
down(){
tput reset
notify-send "Torrent: Downloading"
aria2c -d movies --select-file=$2 --seed-time=0 $1 && notify-send "Torrent: Download complete" && rm -f $file || notify-send -u critical "Torrent: Error!!"
}
aria2c -d movies --select-file=$2 --seed-time=0 $1 && notify-send "Torrent: Download complete" && rm -f $file || notify-send -u critical "Torrent: Error!!" }
trap "rm -f $HOME/.cache/*.torrent;exit 0" INT HUP
[ -z "$*" ] && magnet=$(xclip -out clipboard) || magnet=$*
echo "$magnet"
printf "${c_yellow}Download>>\n${c_green}[f]ull torrent\n${c_cyan}[p]artial torrent \n${c_red}[q]uit"
printf "${c_reset}\n\tenter choice:"

10
youtube
View File

@@ -1,6 +1,6 @@
#!/bin/sh
# script for downloading youtube videos and split it into pieces..
# script for downloading videos/audios and/or extract part from it..
# defining shell colors for distinction
c_red="\033[1;31m"
@@ -12,16 +12,14 @@ c_cyan="\033[1;36m"
c_reset="\033[0m"
#function to download full video/audio
full()
{
full(){
[ -z "$2" ] &&
yt-dlp -o "$HOME/Videos/%(title)s.%(ext)s" "$1" ||
yt-dlp -f 'ba' -x --audio-format mp3 "$1" -o "$HOME/Music/%(title)s.%(ext)s"
}
# function to download part of a video/audio..
part()
{
part(){
video=$1
printf "${c_magenta}Enter Start Point(hh:mm:ss)or(mm:ss)${c_reset}:"
read start
@@ -35,7 +33,7 @@ part()
#program starts from here..
x=$(xclip -out clipboard)
printf "${c_blue}Youtube link :${c_magenta}$x\n"
printf "${c_yellow}Download>>\n${c_blue}[a]Audio only\n${c_magenta}[f]part of Audio only\n${c_green}[v]Full video\n${c_cyan}[p]Part of video\n${c_red}[q]Quit"
printf "${c_yellow}Download>>\n${c_blue}[a]udio only\n${c_magenta}[f]part of Audio only\n${c_green}[v]ideo\n${c_cyan}[p]art of video\n${c_red}[q]uit"
printf "\n${c_reset}Enter choice:${c_green}"
read choice
case $choice in