fix: 🐛 fix bad nb_files
This commit is contained in:
parent
94109da87d
commit
f05fd79dd9
@ -7,7 +7,7 @@ from time import sleep
|
||||
from xml.etree import ElementTree
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
from requests import get
|
||||
from requests import JSONDecodeError, get
|
||||
|
||||
parser = ArgumentParser()
|
||||
parser.add_argument(
|
||||
@ -31,25 +31,28 @@ args = parser.parse_args()
|
||||
|
||||
|
||||
def nb_files(id: int):
|
||||
response = get(
|
||||
f"https://www.ygg.re/engine/get_files?torrent={id}",
|
||||
headers={"Cookie": args.cookie, "User-Agent": args.user_agent},
|
||||
)
|
||||
sleep(1)
|
||||
try:
|
||||
response = get(
|
||||
f"https://www.ygg.re/engine/get_files?torrent={id}",
|
||||
headers={"Cookie": args.cookie, "User-Agent": args.user_agent},
|
||||
)
|
||||
sleep(1)
|
||||
|
||||
json = response.json()
|
||||
soup = BeautifulSoup(json["html"], "html.parser")
|
||||
rows = soup.find_all("tr")
|
||||
is_mkv = False
|
||||
json = response.json()
|
||||
soup = BeautifulSoup(json["html"], "html.parser")
|
||||
rows = soup.find_all("tr")
|
||||
is_mkv = False
|
||||
|
||||
for row in rows:
|
||||
columns = row.find_all("td")
|
||||
for row in rows:
|
||||
columns = row.find_all("td")
|
||||
|
||||
if columns[1].text.strip()[-3:] == "mkv":
|
||||
is_mkv = True
|
||||
break
|
||||
if columns[1].text.strip()[-3:] == "mkv":
|
||||
is_mkv = True
|
||||
break
|
||||
|
||||
return is_mkv and len(rows) == 1
|
||||
return is_mkv and len(rows) == 1
|
||||
except JSONDecodeError:
|
||||
return False
|
||||
|
||||
|
||||
def parse_size(size):
|
||||
@ -122,7 +125,7 @@ for feed in args.feed:
|
||||
):
|
||||
column = columns
|
||||
break
|
||||
|
||||
|
||||
if column:
|
||||
break
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user