Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 084488a88c | |||
| 270da18543 | |||
| 163532b1ef |
@@ -1 +1 @@
|
|||||||
v1.5.2
|
v1.5.3
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "aniworld-web",
|
"name": "aniworld-web",
|
||||||
"version": "1.5.2",
|
"version": "1.5.3",
|
||||||
"description": "Aniworld Anime Download Manager - Web Frontend",
|
"description": "Aniworld Anime Download Manager - Web Frontend",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
|
import time
|
||||||
import threading
|
import threading
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from urllib.parse import quote
|
from urllib.parse import quote
|
||||||
@@ -383,6 +384,12 @@ class AniworldLoader(Loader):
|
|||||||
"Direct stream download starting (type=%s)",
|
"Direct stream download starting (type=%s)",
|
||||||
content_type
|
content_type
|
||||||
)
|
)
|
||||||
|
total_size = int(response.headers.get(
|
||||||
|
"Content-Length", 0
|
||||||
|
))
|
||||||
|
received = 0
|
||||||
|
last_emit = 0
|
||||||
|
start_time = time.monotonic()
|
||||||
with open(output_path, "wb") as fh:
|
with open(output_path, "wb") as fh:
|
||||||
for chunk in response.iter_content(chunk_size=1024 * 1024):
|
for chunk in response.iter_content(chunk_size=1024 * 1024):
|
||||||
if self._cancel_flag.is_set():
|
if self._cancel_flag.is_set():
|
||||||
@@ -391,7 +398,33 @@ class AniworldLoader(Loader):
|
|||||||
)
|
)
|
||||||
return False
|
return False
|
||||||
if chunk:
|
if chunk:
|
||||||
|
received += len(chunk)
|
||||||
fh.write(chunk)
|
fh.write(chunk)
|
||||||
|
# Emit progress events at ~1% intervals
|
||||||
|
if total_size > 0:
|
||||||
|
pct = (received / total_size) * 100
|
||||||
|
if pct - last_emit >= 1.0 or received == total_size:
|
||||||
|
elapsed = time.monotonic() - start_time
|
||||||
|
speed_bps = (
|
||||||
|
received / elapsed
|
||||||
|
if elapsed > 0 else 0
|
||||||
|
)
|
||||||
|
eta = (
|
||||||
|
int((total_size - received) / speed_bps)
|
||||||
|
if speed_bps > 0 else None
|
||||||
|
)
|
||||||
|
self.events.download_progress({
|
||||||
|
"downloaded_bytes": received,
|
||||||
|
"total_bytes": total_size,
|
||||||
|
"speed": speed_bps,
|
||||||
|
"eta": eta,
|
||||||
|
"status": (
|
||||||
|
"finished"
|
||||||
|
if received >= total_size
|
||||||
|
else "downloading"
|
||||||
|
),
|
||||||
|
})
|
||||||
|
last_emit = pct
|
||||||
return True
|
return True
|
||||||
except requests.RequestException as exc:
|
except requests.RequestException as exc:
|
||||||
logger.warning("Direct stream download failed: %s", exc)
|
logger.warning("Direct stream download failed: %s", exc)
|
||||||
|
|||||||
@@ -136,13 +136,16 @@ AniWorld.IndexSocketHandler = (function() {
|
|||||||
// Series events
|
// Series events
|
||||||
socket.on(WS_EVENTS.SERIES_UPDATED, function(data) {
|
socket.on(WS_EVENTS.SERIES_UPDATED, function(data) {
|
||||||
console.log('Series updated:', data);
|
console.log('Series updated:', data);
|
||||||
|
|
||||||
// Use the data directly to update the series instead of full refresh
|
// NOTE: websocket-client.js strips the outer {type, data, ...} wrapper
|
||||||
if (data && data.data && AniWorld.SeriesManager && AniWorld.SeriesManager.updateSingleSeries) {
|
// before emitting, so `data` here is the inner series data object
|
||||||
AniWorld.SeriesManager.updateSingleSeries(data.data);
|
// (e.g. {key, name, missing_episodes, ...}) — NOT {type, data, ...}.
|
||||||
|
// AniWorld.SeriesManager.updateSingleSeries() expects this flat object.
|
||||||
|
if (data && data.key && AniWorld.SeriesManager && AniWorld.SeriesManager.updateSingleSeries) {
|
||||||
|
AniWorld.SeriesManager.updateSingleSeries(data);
|
||||||
} else {
|
} else {
|
||||||
// Fallback to full reload if data is incomplete
|
// Fallback to full reload if data is incomplete
|
||||||
console.warn('Incomplete series update data, falling back to full reload');
|
console.warn('Incomplete series update data, falling back to full reload', data);
|
||||||
if (AniWorld.SeriesManager && AniWorld.SeriesManager.loadSeries) {
|
if (AniWorld.SeriesManager && AniWorld.SeriesManager.loadSeries) {
|
||||||
AniWorld.SeriesManager.loadSeries();
|
AniWorld.SeriesManager.loadSeries();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user