diff --git a/__pycache__/torrent_vahti.cpython-311.pyc b/__pycache__/torrent_vahti.cpython-311.pyc index d6a9893..91f690b 100644 Binary files a/__pycache__/torrent_vahti.cpython-311.pyc and b/__pycache__/torrent_vahti.cpython-311.pyc differ diff --git a/hakulista.json b/hakulista.json index 3955505..c29cbb4 100644 --- a/hakulista.json +++ b/hakulista.json @@ -9,25 +9,49 @@ "filemood" ], "hakukohteet": [ - { - "jackett_haku": "motogp 2026 720p jff", - "regex_suodatin": "motogp.*?2026.*?720p.*?jff.*?", - "kohdekansio": "MotoGP" - }, { "jackett_haku": "motogp 2026 tntsportshd 1080p", - "regex_suodatin": "motogp.*?2026.*?tntsportshd.*?1080p.*?", - "kohdekansio": "MotoGP" + "regex_suodatin": ".*", + "kohdekansio": "MotoGP", + "paivat": [ + 3, + 4, + 5, + 6 + ] }, { "jackett_haku": "Formula 1 2026 1080p SS", - "regex_suodatin": "\tFormula.*?1.*?2026.*?1080p.*?SS.*?", - "kohdekansio": "Formula1" + "regex_suodatin": ".*", + "kohdekansio": "Formula1", + "paivat": [ + 3, + 4, + 5, + 6 + ] }, { "jackett_haku": "Formula 1 2026 SkyF1HD 1080p", - "regex_suodatin": "(?i)Formula.?1.*2026.*SkyF1HD.*1080p", - "kohdekansio": "Formula1" + "regex_suodatin": ".*", + "kohdekansio": "Formula1", + "paivat": [ + 3, + 4, + 5, + 6 + ] + }, + { + "jackett_haku": "motogp 2026 720p jff", + "regex_suodatin": ".*", + "kohdekansio": "MotoGP", + "paivat": [ + 3, + 4, + 5, + 6 + ] } ], "asetukset": { @@ -36,6 +60,6 @@ "qbit_url": "http://192.168.1.40:8080/", "qbit_user": "admin", "qbit_pass": "qbt_uFxc7gqD7sJsBk9FJdH38bLIyapr", - "haku_vali": 10 + "haku_vali": 900 } } \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index c38e733..0957c6e 100644 --- a/templates/index.html +++ b/templates/index.html @@ -132,7 +132,22 @@ document.getElementById('tila-badge').className = "badge bg-success"; const lista = document.getElementById('hakukohteet-lista'); - lista.innerHTML = data.hakukohteet.map((k, i) => `${k.jackett_haku}${k.kohdekansio}`).join(''); + lista.innerHTML = data.hakukohteet.map((k, i) => { + const paivaNimet = ['Ma', 'Ti', 'Ke', 'To', 'Pe', 'La', 'Su']; + const paivatTeksti = [0, 1, 2, 3, 4, 5, 6].map(p => + k.paivat.includes(p) ? `${paivaNimet[p]}` : `${paivaNimet[p]}` + ).join(' '); + + return ` + ${k.jackett_haku} + ${k.kohdekansio} + ${paivatTeksti} + + + + + `; + }).join(''); const hakuTermi = document.getElementById('historia-haku').value.toLowerCase(); const lokiDiv = document.getElementById('loki-sisalto'); @@ -199,6 +214,26 @@ document.getElementById('tyhjenna-loki-btn').addEventListener('click', () => fetch('/tyhjenna_loki', {method:'POST'}).then(() => paivitaNakyma())); paivitaNakyma(); setInterval(paivitaNakyma, 5000); + function muokkaaKohdetta(i) { + fetch('/status') + .then(res => res.json()) + .then(data => { + const kohde = data.hakukohteet[i]; + // Täytetään lomake hakukohteen tiedoilla + document.getElementById('haku-sana').value = kohde.jackett_haku; + document.getElementById('haku-kansio').value = kohde.kohdekansio; + + // Päivitetään checkboxit + [0, 1, 2, 3, 4, 5, 6].forEach(p => { + const cb = document.getElementById('pv-' + p); + if (cb) cb.checked = kohde.paivat.includes(p); + }); + + // Vieritetään sivu takaisin ylös lomakkeeseen + window.scrollTo(0, 0); + }); +} + diff --git a/torrent_vahti.py b/torrent_vahti.py index c94855e..787dea2 100644 --- a/torrent_vahti.py +++ b/torrent_vahti.py @@ -139,15 +139,18 @@ def tarkista_ja_lataa(): if linkki in ladatut: continue nimi_lower = nimi.lower() - viimeisin_indeksi = -1 loytyy_kaikki = True + viimeisin_indeksi = 0 for sana in hakusanat: - indeksi = nimi_lower.find(sana, viimeisin_indeksi + 1) - if indeksi == -1: + 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 = indeksi + + viimeisin_indeksi += match.end() if loytyy_kaikki: uudet_kohteet.append((nimi, linkki))