Don't curl if no url for image. Allow crawl url directly

This commit is contained in:
poka 2020-09-03 19:33:00 +02:00
parent adc8d8a2ec
commit 1728196f23
2 changed files with 14 additions and 11 deletions

View File

@ -23,6 +23,7 @@ import time
import re
from termcolor import colored
from optparse import OptionParser
from urllib.parse import unquote
# Load options
parser = OptionParser()
@ -40,18 +41,21 @@ scraper = YggTorrentScraper(requests.session())
from yggtorrentscraper import set_yggtorrent_tld
set_yggtorrent_tld("si")
name = ' '.join(sys.argv[1:])
name = re.sub(r'\w*-\w*', '', name)
# Search torrent name
research = os.popen('./lib/scrabash.sh search --best=true ' + name).read()
if ("https://" not in name):
name = re.sub(r'\w*-\w*', '', name)
research = os.popen('./lib/scrabash.sh search --best=true ' + name).read()
try:
research.index("No torrent found")
except ValueError:
True
try:
research.index("No torrent found")
except ValueError:
True
else:
print(colored('No torrent named "' + name + '" on YggTorrent', 'blue'))
sys.exit(1)
else:
print(colored('No torrent named "' + name + '" on YggTorrent', 'blue'))
sys.exit(1)
research = unquote(name, errors='strict')
# Allow only one torrent downling in same time, and remove oldest torrent if disk size is full.
def rollingFiles():

View File

@ -51,8 +51,7 @@ get_details() {
# Get image
[[ ! -d img ]] && mkdir img && cd img
url=$(wget -qO- -np -nd $name | awk -v RS=' ' '/.jpg/' | awk -F '"' '{ print $2 }' | head -n1)
curl -s -O $url
[[ $url ]] && curl -s -O $url
fi
}
@ -65,6 +64,6 @@ vpn() {
nordvpn c $vpn_citie
}
$1
$cmd
[[ $err == 1 ]] && exit 1 || exit 0