Fix search fuction for javdb source

This commit is contained in:
yoshiko2
2021-05-28 03:16:21 +08:00
parent c533a78357
commit 047da6baa8

View File

@@ -221,6 +221,7 @@ def main(number):
elif cdays != 9999: elif cdays != 9999:
print('[!]Cookies file ' + cookie_json + ' was updated ' + str(cdays) + print('[!]Cookies file ' + cookie_json + ' was updated ' + str(cdays) +
' days ago, it will not be used for HTTP requests.') ' days ago, it will not be used for HTTP requests.')
try: try:
javdb_url = 'https://' + javdb_site + '.com/search?q=' + number + '&f=all' javdb_url = 'https://' + javdb_site + '.com/search?q=' + number + '&f=all'
query_result = get_html(javdb_url, cookies=javdb_cookies) query_result = get_html(javdb_url, cookies=javdb_cookies)
@@ -236,7 +237,11 @@ def main(number):
correct_url = urls[0] correct_url = urls[0]
else: else:
ids =html.xpath('//*[@id="videos"]/div/div/a/div[contains(@class, "uid")]/text()') ids =html.xpath('//*[@id="videos"]/div/div/a/div[contains(@class, "uid")]/text()')
try:
correct_url = urls[ids.index(number)] correct_url = urls[ids.index(number)]
except:
# if input number is "STAR438" not "STAR-438", use first search result.
correct_url = urls[0]
try: try:
javdb_detail_url = 'https://' + javdb_site + '.com' + correct_url javdb_detail_url = 'https://' + javdb_site + '.com' + correct_url
detail_page = get_html(javdb_detail_url, cookies=javdb_cookies) detail_page = get_html(javdb_detail_url, cookies=javdb_cookies)
@@ -249,7 +254,11 @@ def main(number):
if re.search(r'[a-zA-Z]+\.\d{2}\.\d{2}\.\d{2}', number): if re.search(r'[a-zA-Z]+\.\d{2}\.\d{2}\.\d{2}', number):
cover_small = getCover_small(query_result) cover_small = getCover_small(query_result)
else: else:
try:
cover_small = getCover_small(query_result, index=ids.index(number)) cover_small = getCover_small(query_result, index=ids.index(number))
except:
# if input number is "STAR438" not "STAR-438", use first search result.
cover_small = getCover_small(query_result)
if 'placeholder' in cover_small: if 'placeholder' in cover_small:
# replace wit normal cover and cut it # replace wit normal cover and cut it
imagecut = 1 imagecut = 1