Don't curl if no url for image. Allow crawl url directly
This commit is contained in:
parent
adc8d8a2ec
commit
1728196f23
20
crawl.py
20
crawl.py
|
@ -23,6 +23,7 @@ import time
|
||||||
import re
|
import re
|
||||||
from termcolor import colored
|
from termcolor import colored
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
from urllib.parse import unquote
|
||||||
|
|
||||||
# Load options
|
# Load options
|
||||||
parser = OptionParser()
|
parser = OptionParser()
|
||||||
|
@ -40,18 +41,21 @@ scraper = YggTorrentScraper(requests.session())
|
||||||
from yggtorrentscraper import set_yggtorrent_tld
|
from yggtorrentscraper import set_yggtorrent_tld
|
||||||
set_yggtorrent_tld("si")
|
set_yggtorrent_tld("si")
|
||||||
name = ' '.join(sys.argv[1:])
|
name = ' '.join(sys.argv[1:])
|
||||||
name = re.sub(r'\w*-\w*', '', name)
|
|
||||||
|
|
||||||
# Search torrent 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:
|
try:
|
||||||
research.index("No torrent found")
|
research.index("No torrent found")
|
||||||
except ValueError:
|
except ValueError:
|
||||||
True
|
True
|
||||||
|
else:
|
||||||
|
print(colored('No torrent named "' + name + '" on YggTorrent', 'blue'))
|
||||||
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
print(colored('No torrent named "' + name + '" on YggTorrent', 'blue'))
|
research = unquote(name, errors='strict')
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
# Allow only one torrent downling in same time, and remove oldest torrent if disk size is full.
|
# Allow only one torrent downling in same time, and remove oldest torrent if disk size is full.
|
||||||
def rollingFiles():
|
def rollingFiles():
|
||||||
|
|
|
@ -51,8 +51,7 @@ get_details() {
|
||||||
# Get image
|
# Get image
|
||||||
[[ ! -d img ]] && mkdir img && cd img
|
[[ ! -d img ]] && mkdir img && cd img
|
||||||
url=$(wget -qO- -np -nd $name | awk -v RS=' ' '/.jpg/' | awk -F '"' '{ print $2 }' | head -n1)
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,6 +64,6 @@ vpn() {
|
||||||
nordvpn c $vpn_citie
|
nordvpn c $vpn_citie
|
||||||
}
|
}
|
||||||
|
|
||||||
$1
|
$cmd
|
||||||
|
|
||||||
[[ $err == 1 ]] && exit 1 || exit 0
|
[[ $err == 1 ]] && exit 1 || exit 0
|
||||||
|
|
Loading…
Reference in New Issue