aboutsummaryrefslogtreecommitdiff
path: root/yts
diff options
context:
space:
mode:
authorsinanmohd <sinan@firemail.cc>2023-05-08 11:21:15 +0530
committersinanmohd <sinan@firemail.cc>2023-05-08 12:05:46 +0530
commitd5ef702213ebaf7c08d7a62dbc68625f2a1f2e04 (patch)
tree6840db3ac5b42f7eef9ba3a78a3ab717460e02f7 /yts
parent0e942d035d09b04d88cb018d22b8ce6aa4f4283b (diff)
1337x, yts: exit quietly if query is empty
Diffstat (limited to 'yts')
-rwxr-xr-xyts32
1 files changed, 13 insertions, 19 deletions
diff --git a/yts b/yts
index 36eec01..88377ad 100755
--- a/yts
+++ b/yts
@@ -42,36 +42,31 @@ search_yts()
grep browse-movie-link | sed -e 's/^.*movies\///g' -e 's/".*$//g'
}
-dllink_yts()
+id_yts()
{
: "${1:?}"
fetch=
select=
- id=
fetch="$(get_yts "movies/$1" | grep -Eo "value=\"[A-Z0-9]{40}\">[a-zA-Z0-9 ]*")"
select="$(echo "$fetch" | cut -d'>' -f2 | "$menu" -l 25 -p " ")"
- [ -z "$select" ] &&
- die "please select a quality"
- id="$(echo "$fetch" | grep "$select" | cut -d'"' -f2)"
- printf "${url_yts}/torrent/download/%s\n" "$id"
+ [ -n "$select" ] &&
+ echo "$fetch" | grep "$select" | cut -d'"' -f2
- unset id
unset select
unset fetch
}
main()
{
+ query=
fetch=
- dllink=
+ id=
out=
- query=
[ -z "$WAYLAND_DISPLAY" ] &&
menu="dmenu"
- if [ "$#" -gt 0 ] && [ "$1" = "-o" ]
- then
+ if [ "$#" -gt 0 ] && [ "$1" = "-o" ]; then
out=true
shift
fi
@@ -80,20 +75,19 @@ main()
query="${*:-$(printf "" | "$menu" -p "󱇒 ")}"
[ -z "$query" ] &&
- die "please enter a query"
+ exit 1
fetch="$(search_yts "$query")"
- dllink="$(dllink_yts "$(echo "$fetch" | tr '-' ' ' | "$menu" -l 25 -p "󰎁 " | tr ' ' '-')")"
- [ -z "$dllink" ] &&
- die "empty magnet"
+ id="$(id_yts "$(echo "$fetch" | tr '-' ' ' | "$menu" -l 25 -p "󰎁 " | tr ' ' '-')")"
+ [ -z "$id" ] &&
+ exit 1
- if [ "$out" = true ]
- then
- echo "$dllink"
+ if [ "$out" = true ]; then
+ echo "${url_yts}/torrent/download/${id}"
else
dep_check "pirowatch"
- pirowatch -s "$dllink"
+ pirowatch -s "${url_yts}/torrent/download/${id}"
fi
}