fix: 🐛 fix bad nb_files
All checks were successful
dl / lint (push) Successful in 1m34s
dl / docker (push) Successful in 4m20s

This commit is contained in:
Michel Roux 2024-12-27 21:34:22 +01:00
parent 94109da87d
commit f05fd79dd9

View File

@ -7,7 +7,7 @@ from time import sleep
from xml.etree import ElementTree from xml.etree import ElementTree
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
from requests import get from requests import JSONDecodeError, get
parser = ArgumentParser() parser = ArgumentParser()
parser.add_argument( parser.add_argument(
@ -31,6 +31,7 @@ args = parser.parse_args()
def nb_files(id: int): def nb_files(id: int):
try:
response = get( response = get(
f"https://www.ygg.re/engine/get_files?torrent={id}", f"https://www.ygg.re/engine/get_files?torrent={id}",
headers={"Cookie": args.cookie, "User-Agent": args.user_agent}, headers={"Cookie": args.cookie, "User-Agent": args.user_agent},
@ -50,6 +51,8 @@ def nb_files(id: int):
break break
return is_mkv and len(rows) == 1 return is_mkv and len(rows) == 1
except JSONDecodeError:
return False
def parse_size(size): def parse_size(size):