aktiiviset haut muokkauksen parannus
This commit is contained in:
Binary file not shown.
@@ -101,6 +101,23 @@ def poista_kohde(index):
|
|||||||
torrent_vahti.tallenna_kaikki_data(kaikki_data)
|
torrent_vahti.tallenna_kaikki_data(kaikki_data)
|
||||||
return jsonify({'status': 'ok'})
|
return jsonify({'status': 'ok'})
|
||||||
|
|
||||||
|
@app.route('/paivita_kohde/<int:index>', methods=['POST'])
|
||||||
|
def paivita_kohde(index):
|
||||||
|
data = request.json
|
||||||
|
kaikki_data = torrent_vahti.lataa_kaikki_data()
|
||||||
|
|
||||||
|
if 0 <= index < len(kaikki_data.get("hakukohteet", [])):
|
||||||
|
kaikki_data["hakukohteet"][index] = {
|
||||||
|
"jackett_haku": data['jackett_haku'],
|
||||||
|
"regex_suodatin": data.get('regex_suodatin', '.*'),
|
||||||
|
"kohdekansio": data['kohdekansio'],
|
||||||
|
"paivat": data.get('paivat', [0, 1, 2, 3, 4, 5, 6])
|
||||||
|
}
|
||||||
|
torrent_vahti.tallenna_kaikki_data(kaikki_data)
|
||||||
|
return jsonify({'status': 'ok'})
|
||||||
|
|
||||||
|
return jsonify({'status': 'error', 'message': 'Virheellinen indeksi'}), 400
|
||||||
|
|
||||||
@app.route('/poista_historiarivi', methods=['POST'])
|
@app.route('/poista_historiarivi', methods=['POST'])
|
||||||
def poista_historiarivi():
|
def poista_historiarivi():
|
||||||
data = request.json
|
data = request.json
|
||||||
@@ -128,7 +145,6 @@ def tyhjenna_loki():
|
|||||||
return jsonify({'status': 'ok'})
|
return jsonify({'status': 'ok'})
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# Käytetään dynaamista ajastinta asetuksista
|
|
||||||
def automaattinen_ajastin():
|
def automaattinen_ajastin():
|
||||||
while True:
|
while True:
|
||||||
kaikki_data = torrent_vahti.lataa_kaikki_data()
|
kaikki_data = torrent_vahti.lataa_kaikki_data()
|
||||||
|
|||||||
+8
-1
@@ -4,7 +4,6 @@
|
|||||||
"torrentgalaxyclone",
|
"torrentgalaxyclone",
|
||||||
"therarbg",
|
"therarbg",
|
||||||
"thepiratebay",
|
"thepiratebay",
|
||||||
"torrentdownload",
|
|
||||||
"limetorrents",
|
"limetorrents",
|
||||||
"filemood"
|
"filemood"
|
||||||
],
|
],
|
||||||
@@ -60,6 +59,14 @@
|
|||||||
"paivat": [
|
"paivat": [
|
||||||
6
|
6
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"jackett_haku": "audiobook suomeksi",
|
||||||
|
"regex_suodatin": ".*",
|
||||||
|
"kohdekansio": "All",
|
||||||
|
"paivat": [
|
||||||
|
6
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"asetukset": {
|
"asetukset": {
|
||||||
|
|||||||
+74
-30
@@ -118,6 +118,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
let muokattavaIndex = null;
|
||||||
|
|
||||||
function rullaaLokiAlas() {
|
function rullaaLokiAlas() {
|
||||||
const lokit = ['loki-sisalto', 'skripti-loki'];
|
const lokit = ['loki-sisalto', 'skripti-loki'];
|
||||||
lokit.forEach(id => {
|
lokit.forEach(id => {
|
||||||
@@ -167,7 +169,9 @@
|
|||||||
}).join('');
|
}).join('');
|
||||||
|
|
||||||
const iList = document.getElementById('indexer-lista');
|
const iList = document.getElementById('indexer-lista');
|
||||||
iList.innerHTML = (data.indeksorit || []).map((idx, i) => `<li class="list-group-item d-flex justify-content-between py-1">${idx}<button onclick="poistaIndexer(${i})" class="btn btn-danger btn-sm py-0">Poista</button></li>`).join('');
|
iList.innerHTML = (data.indeksorit || []).map((idx, i) =>
|
||||||
|
`<li class="list-group-item d-flex justify-content-between py-1">${idx}<button onclick="poistaIndexer(${i})" class="btn btn-danger btn-sm py-0">Poista</button></li>`
|
||||||
|
).join('');
|
||||||
|
|
||||||
document.getElementById('skripti-loki').innerText = data.loki_skripti;
|
document.getElementById('skripti-loki').innerText = data.loki_skripti;
|
||||||
document.getElementById('cfg-url').value = data.asetukset.jackett_url || '';
|
document.getElementById('cfg-url').value = data.asetukset.jackett_url || '';
|
||||||
@@ -181,6 +185,32 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function muokkaaKohdetta(i) {
|
||||||
|
fetch('/status')
|
||||||
|
.then(res => res.json())
|
||||||
|
.then(data => {
|
||||||
|
const kohde = data.hakukohteet[i];
|
||||||
|
muokattavaIndex = i;
|
||||||
|
|
||||||
|
document.getElementById('haku-sana').value = kohde.jackett_haku;
|
||||||
|
document.getElementById('haku-kansio').value = kohde.kohdekansio;
|
||||||
|
|
||||||
|
[0, 1, 2, 3, 4, 5, 6].forEach(p => {
|
||||||
|
const cb = document.getElementById('pv-' + p);
|
||||||
|
if (cb) cb.checked = kohde.paivat.includes(p);
|
||||||
|
});
|
||||||
|
|
||||||
|
document.querySelector('#lisaa-form button[type="submit"]').textContent = 'Päivitä haku';
|
||||||
|
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetLomake() {
|
||||||
|
muokattavaIndex = null;
|
||||||
|
document.getElementById('lisaa-form').reset();
|
||||||
|
document.querySelector('#lisaa-form button[type="submit"]').textContent = 'Lisää';
|
||||||
|
}
|
||||||
|
|
||||||
function poistaHist(riviTeksti) {
|
function poistaHist(riviTeksti) {
|
||||||
if(confirm("Poistetaanko tämä rivi historiasta?")) {
|
if(confirm("Poistetaanko tämä rivi historiasta?")) {
|
||||||
fetch('/poista_historiarivi', {
|
fetch('/poista_historiarivi', {
|
||||||
@@ -194,46 +224,60 @@
|
|||||||
function lisaaIndexer() { const val = document.getElementById('uusi-indexer').value; if(!val) return; fetch('/status').then(r => r.json()).then(d => { let l = d.indeksorit || []; l.push(val); fetch('/paivita_indeksorit', {method:'POST', headers:{'Content-Type':'application/json'}, body:JSON.stringify({indeksorit:l})}).then(() => paivitaNakyma()); }); }
|
function lisaaIndexer() { const val = document.getElementById('uusi-indexer').value; if(!val) return; fetch('/status').then(r => r.json()).then(d => { let l = d.indeksorit || []; l.push(val); fetch('/paivita_indeksorit', {method:'POST', headers:{'Content-Type':'application/json'}, body:JSON.stringify({indeksorit:l})}).then(() => paivitaNakyma()); }); }
|
||||||
function poistaIndexer(i) { fetch('/status').then(r => r.json()).then(d => { let l = d.indeksorit; l.splice(i, 1); fetch('/paivita_indeksorit', {method:'POST', headers:{'Content-Type':'application/json'}, body:JSON.stringify({indeksorit:l})}).then(() => paivitaNakyma()); }); }
|
function poistaIndexer(i) { fetch('/status').then(r => r.json()).then(d => { let l = d.indeksorit; l.splice(i, 1); fetch('/paivita_indeksorit', {method:'POST', headers:{'Content-Type':'application/json'}, body:JSON.stringify({indeksorit:l})}).then(() => paivitaNakyma()); }); }
|
||||||
function poistaKohde(i) { fetch(`/poista_kohde/${i}`, {method:'DELETE'}).then(() => paivitaNakyma()); }
|
function poistaKohde(i) { fetch(`/poista_kohde/${i}`, {method:'DELETE'}).then(() => paivitaNakyma()); }
|
||||||
|
|
||||||
document.getElementById('lisaa-form').addEventListener('submit', (e) => {
|
document.getElementById('lisaa-form').addEventListener('submit', (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
const paivat = [0,1,2,3,4,5,6].filter(i => document.getElementById('pv-'+i).checked);
|
const paivat = [0,1,2,3,4,5,6].filter(i => document.getElementById('pv-'+i).checked);
|
||||||
fetch('/lisaa_kohde', {
|
const payload = {
|
||||||
|
jackett_haku: document.getElementById('haku-sana').value,
|
||||||
|
regex_suodatin: document.getElementById('haku-regex').value,
|
||||||
|
kohdekansio: document.getElementById('haku-kansio').value,
|
||||||
|
paivat: paivat
|
||||||
|
};
|
||||||
|
|
||||||
|
if (muokattavaIndex !== null) {
|
||||||
|
fetch(`/paivita_kohde/${muokattavaIndex}`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {'Content-Type': 'application/json'},
|
||||||
|
body: JSON.stringify(payload)
|
||||||
|
}).then(() => {
|
||||||
|
resetLomake();
|
||||||
|
paivitaNakyma();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
fetch('/lisaa_kohde', {
|
||||||
|
method:'POST',
|
||||||
|
headers:{'Content-Type':'application/json'},
|
||||||
|
body:JSON.stringify(payload)
|
||||||
|
}).then(() => {
|
||||||
|
resetLomake();
|
||||||
|
paivitaNakyma();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById('asetukset-form').addEventListener('submit', (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
fetch('/tallenna_asetukset', {
|
||||||
method:'POST',
|
method:'POST',
|
||||||
headers:{'Content-Type':'application/json'},
|
headers:{'Content-Type':'application/json'},
|
||||||
body:JSON.stringify({
|
body:JSON.stringify({
|
||||||
jackett_haku: document.getElementById('haku-sana').value,
|
jackett_url:document.getElementById('cfg-url').value,
|
||||||
regex_suodatin: document.getElementById('haku-regex').value,
|
jackett_api_key:document.getElementById('cfg-apikey').value,
|
||||||
kohdekansio: document.getElementById('haku-kansio').value,
|
qbit_url:document.getElementById('cfg-qbiturl').value,
|
||||||
paivat: paivat
|
qbit_user:document.getElementById('cfg-qbituser').value,
|
||||||
|
qbit_pass:document.getElementById('cfg-qbitpass').value,
|
||||||
|
haku_vali:document.getElementById('cfg-interval').value
|
||||||
})
|
})
|
||||||
}).then(() => { e.target.reset(); paivitaNakyma(); });
|
}).then(() => paivitaNakyma());
|
||||||
});
|
});
|
||||||
document.getElementById('asetukset-form').addEventListener('submit', (e) => { e.preventDefault(); fetch('/tallenna_asetukset', {method:'POST', headers:{'Content-Type':'application/json'}, body:JSON.stringify({jackett_url:document.getElementById('cfg-url').value, jackett_api_key:document.getElementById('cfg-apikey').value, qbit_url:document.getElementById('cfg-qbiturl').value, qbit_user:document.getElementById('cfg-qbituser').value, qbit_pass:document.getElementById('cfg-qbitpass').value, haku_vali:document.getElementById('cfg-interval').value})}).then(() => paivitaNakyma()); });
|
|
||||||
document.getElementById('suorita-haku-btn').addEventListener('click', () => fetch('/suorita_haku', {method:'POST'}));
|
document.getElementById('suorita-haku-btn').addEventListener('click', () => fetch('/suorita_haku', {method:'POST'}));
|
||||||
document.getElementById('tyhjenna-loki-btn').addEventListener('click', () => fetch('/tyhjenna_loki', {method:'POST'}).then(() => paivitaNakyma()));
|
document.getElementById('tyhjenna-loki-btn').addEventListener('click', () => fetch('/tyhjenna_loki', {method:'POST'}).then(() => paivitaNakyma()));
|
||||||
|
|
||||||
paivitaNakyma(); setInterval(paivitaNakyma, 5000);
|
paivitaNakyma();
|
||||||
function muokkaaKohdetta(i) {
|
setInterval(paivitaNakyma, 5000);
|
||||||
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);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+1
-1
@@ -55,7 +55,7 @@ def hae_jackettista(jackett_url, api_key, indeksori, hakusana):
|
|||||||
url = f"{jackett_url}/api/v2.0/indexers/{indeksori}/results/torznab/api"
|
url = f"{jackett_url}/api/v2.0/indexers/{indeksori}/results/torznab/api"
|
||||||
params = {"apikey": api_key, "t": "search", "q": hakusana}
|
params = {"apikey": api_key, "t": "search", "q": hakusana}
|
||||||
try:
|
try:
|
||||||
res = requests.get(url, params=params, timeout=15)
|
res = requests.get(url, params=params, timeout=30)
|
||||||
res.raise_for_status()
|
res.raise_for_status()
|
||||||
soup = BeautifulSoup(res.text, 'xml')
|
soup = BeautifulSoup(res.text, 'xml')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user