Don't curl if no url for image. Allow crawl url directly
This commit is contained in:
parent
adc8d8a2ec
commit
1728196f23
6
crawl.py
6
crawl.py
|
@ -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,9 +41,10 @@ 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
|
||||
if ("https://" not in name):
|
||||
name = re.sub(r'\w*-\w*', '', name)
|
||||
research = os.popen('./lib/scrabash.sh search --best=true ' + name).read()
|
||||
|
||||
try:
|
||||
|
@ -52,6 +54,8 @@ except ValueError:
|
|||
else:
|
||||
print(colored('No torrent named "' + name + '" on YggTorrent', 'blue'))
|
||||
sys.exit(1)
|
||||
else:
|
||||
research = unquote(name, errors='strict')
|
||||
|
||||
# Allow only one torrent downling in same time, and remove oldest torrent if disk size is full.
|
||||
def rollingFiles():
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue