refactor: ⚡ rework 2hdp keyword
This commit is contained in:
parent
a58e7ba4c1
commit
f4f1a93611
@ -11,7 +11,10 @@ from requests import get
|
||||
|
||||
parser = ArgumentParser()
|
||||
parser.add_argument(
|
||||
"--keyword", action="append", default=["mhdgz"], help="Prefered words to search on names"
|
||||
"--keyword",
|
||||
action="append",
|
||||
default=["mhdgz", "winks", "pophd", "multi"],
|
||||
help="Prefered words to search on names",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--exclude",
|
||||
@ -103,30 +106,14 @@ for feed in args.feed:
|
||||
rows = soup.select("table.table tr")
|
||||
column = None
|
||||
|
||||
for row in rows:
|
||||
columns = row.find_all("td")
|
||||
|
||||
if len(columns) == 0:
|
||||
continue
|
||||
|
||||
if any(keyword.lower() in columns[1].text.strip().lower() for keyword in args.keyword):
|
||||
if is_valid(
|
||||
int(columns[2].a["target"]),
|
||||
columns[1].text.strip(),
|
||||
parse_size(columns[5].text.strip()),
|
||||
int(columns[6].text.strip()),
|
||||
):
|
||||
column = columns
|
||||
break
|
||||
|
||||
if not column:
|
||||
for keyword in args.keyword:
|
||||
for row in rows:
|
||||
columns = row.find_all("td")
|
||||
|
||||
if len(columns) == 0:
|
||||
continue
|
||||
|
||||
if "multi" in columns[1].text.strip().lower():
|
||||
if keyword.lower() in columns[1].text.strip().lower():
|
||||
if is_valid(
|
||||
int(columns[2].a["target"]),
|
||||
columns[1].text.strip(),
|
||||
@ -135,6 +122,9 @@ for feed in args.feed:
|
||||
):
|
||||
column = columns
|
||||
break
|
||||
|
||||
if column:
|
||||
break
|
||||
|
||||
writer.writerow(
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user