paranneltu hakusanojen osuvuutta

This commit is contained in:
Tontze
2026-06-25 17:47:11 +03:00
parent 7356dffe6b
commit a3939a173f
3 changed files with 13 additions and 14 deletions
Binary file not shown.
+8
View File
@@ -52,6 +52,14 @@
5, 5,
6 6
] ]
},
{
"jackett_haku": "äänikirja",
"regex_suodatin": ".*",
"kohdekansio": "All",
"paivat": [
6
]
} }
], ],
"asetukset": { "asetukset": {
+5 -14
View File
@@ -138,23 +138,14 @@ def tarkista_ja_lataa():
for nimi, linkki in list(set(kaikki_tulokset)): for nimi, linkki in list(set(kaikki_tulokset)):
if linkki in ladatut: continue if linkki in ladatut: continue
nimi_lower = nimi.lower() # Luodaan regex: sana1.*?sana2.*?sana3
loytyy_kaikki = True pattern_str = ".*?".join([re.escape(sana) for sana in hakusanat])
viimeisin_indeksi = 0 # Etsitään regexillä osumaa (re.IGNORECASE huomioi kirjainkoon)
for sana in hakusanat: if re.search(pattern_str, nimi, re.IGNORECASE):
pattern = r'\b' + re.escape(sana) + r'\b'
match = re.search(pattern, nimi_lower[viimeisin_indeksi:])
if not match:
loytyy_kaikki = False
break
viimeisin_indeksi += match.end()
if loytyy_kaikki:
uudet_kohteet.append((nimi, linkki)) uudet_kohteet.append((nimi, linkki))
for nimi, linkki in uudet_kohteet: for nimi, linkki in uudet_kohteet:
status = qbit_lisaa_torrent_api_keylla(qbit_url, qbit_api_key, linkki, kategoria) status = qbit_lisaa_torrent_api_keylla(qbit_url, qbit_api_key, linkki, kategoria)
if status == 200 or status == 409: if status == 200 or status == 409: