aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-x1337x10
-rwxr-xr-xyts32
2 files changed, 17 insertions, 25 deletions
diff --git a/1337x b/1337x
index 2005440..aeacf3c 100755
--- a/1337x
+++ b/1337x
@@ -60,8 +60,7 @@ main()
[ -z "$WAYLAND_DISPLAY" ] &&
menu="dmenu"
- if [ "$#" -gt 0 ] && [ "$1" = "-o" ]
- then
+ if [ "$#" -gt 0 ] && [ "$1" = "-o" ]; then
out=true
shift
fi
@@ -70,17 +69,16 @@ main()
query="${*:-$(printf "" | "$menu" -p "󱇒 ")}"
[ -z "$query" ] &&
- die "please enter a query"
+ exit 1
fetch="$(search_1337x "$query")"
select="$(echo "$fetch" | sed -e's/^.*\///g' | tr '-' ' ' | "$menu" -l 25 -p "󰎁 " | tr ' ' '-')"
magnet="$(magnet_1337x "$(echo "$fetch" | grep "$select")")"
[ -z "$magnet" ] &&
- die "empty magnet"
+ die "empty torrent magnet"
- if [ "$out" = true ]
- then
+ if [ "$out" = true ]; then
echo "$magnet"
else
dep_check "pirowatch"
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
}