Merge branch 'master' of ssh://patema.crystalyx.net:2222/Xefir/dl
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Michel Roux 2022-12-01 14:03:59 +01:00
commit 395f1e0d90
2 changed files with 28 additions and 12 deletions

View File

@ -1,4 +1,4 @@
FROM linuxserver/ffmpeg:4.4-cli-ls65
FROM linuxserver/ffmpeg:4.4-cli-ls68
RUN apt-get update && \
apt-get install -y \

View File

@ -16,6 +16,7 @@ parser = argparse.ArgumentParser()
parser.add_argument("-u", "--uploader", action="append")
parser.add_argument("-y", "--year", type=int)
parser.add_argument("-s", "--size", type=int, default=10)
parser.add_argument("-d", "--downloads", type=int, default=20)
parser.add_argument("query")
args = parser.parse_args()
@ -74,15 +75,15 @@ session.mount("http://", DNSAdapter(["1.1.1.1"]))
session.mount("https://", DNSAdapter(["1.1.1.1"]))
def get_files(id):
def check_files(id):
req = session.get(f"{YGGTORRENT_BASE_URL}/engine/get_files", params={"torrent": id})
files = req.json()
html = BeautifulSoup(files["html"], "html.parser")
trs = html.select("tr")
return len(trs)
return len(trs) == 1 and "mkv" in trs[0].get_text().lower()
def search_ygg(query, multi):
def search_ygg(query, multi, full):
ygg_params = {
"name": query,
"description": "",
@ -95,6 +96,9 @@ def search_ygg(query, multi):
"sort": "publish_date",
}
if full and args.year:
ygg_params["name"] += f" {args.year}"
if multi:
ygg_params["option_langue:multiple[]"] = "4"
@ -109,15 +113,19 @@ def search_ygg(query, multi):
tds = tr.find_all("td")
size = tds[5].get_text()
downloads = tds[6].get_text()
name = tds[1].get_text().lower().strip()
if parse_size(size) > parse_size(f"{args.size}Go"):
continue
if int(downloads) < args.downloads:
continue
if any(word.lower() in name for word in BLACKLIST_WORDS):
continue
if args.year and args.year not in name:
if args.year and str(args.year) not in name:
continue
if args.uploader and not any(
@ -128,7 +136,7 @@ def search_ygg(query, multi):
link = tds[1].a["href"]
id = link.split("/")[-1].split("-")[0]
if get_files(id) > 1:
if not check_files(id):
continue
print(f"{name} {link}")
@ -164,11 +172,19 @@ fra = (
)
search_ygg(args.query, True)
search_ygg(fra, True)
search_ygg(eng, True)
search_ygg(args.query, False)
search_ygg(fra, False)
search_ygg(eng, False)
search_ygg(args.query, True, True)
search_ygg(fra, True, True)
search_ygg(eng, True, True)
search_ygg(args.query, False, True)
search_ygg(fra, False, True)
search_ygg(eng, False, True)
if args.year:
search_ygg(args.query, True, False)
search_ygg(fra, True, False)
search_ygg(eng, True, False)
search_ygg(args.query, False, False)
search_ygg(fra, False, False)
search_ygg(eng, False, False)
print("No results :(")