Skip to content

Commit d17aa6c

Browse files
authored
Merge pull request #553 from arabcoders/dev
Fix: sidecar loading for history items
2 parents 8659f74 + 651aa14 commit d17aa6c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+2439
-2595
lines changed

API.md

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ This document describes the available endpoints and their usage. All endpoints r
117117
- [Connection Events](#connection-events)
118118
- [`config_update`](#config_update)
119119
- [`connected`](#connected)
120-
- [`active_queue`](#active_queue)
121120
- [Logging Events](#logging-events)
122121
- [`log_info`](#log_info)
123122
- [`log_success`](#log_success)
@@ -2742,29 +2741,6 @@ Emitted when a client successfully connects to the WebSocket.
27422741

27432742
---
27442743

2745-
##### `active_queue`
2746-
2747-
Emitted periodically with the current active queue status.
2748-
2749-
**Event**:
2750-
```json
2751-
{
2752-
"event": "active_queue",
2753-
"data": {
2754-
"queue": [
2755-
{
2756-
"id": "abc123",
2757-
"status": "downloading",
2758-
"progress": 45.6,
2759-
...
2760-
}
2761-
]
2762-
}
2763-
}
2764-
```
2765-
2766-
---
2767-
27682744
#### Logging Events
27692745

27702746
##### `log_info`

app/features/conditions/router.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ async def conditions_test(request: Request, encoder: Encoder, cache: Cache, conf
8787
preset: str = params.get("preset", config.default_preset)
8888
key: str = cache.hash(url + str(preset))
8989
if not cache.has(key):
90-
from app.library.downloads.extractor import fetch_info
91-
from app.library.YTDLPOpts import YTDLPOpts
90+
from app.features.ytdlp.extractor import fetch_info
91+
from app.features.ytdlp.ytdlp_opts import YTDLPOpts
9292

9393
(data, _) = await fetch_info(
9494
config=YTDLPOpts.get_instance().preset(name=preset).get_all(),
@@ -115,7 +115,7 @@ async def conditions_test(request: Request, encoder: Encoder, cache: Cache, conf
115115
)
116116

117117
try:
118-
from app.library.mini_filter import match_str
118+
from app.features.ytdlp.mini_filter import match_str
119119

120120
status: bool = match_str(cond, data)
121121
except Exception as e:

app/features/conditions/schemas.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66

77
from app.features.core.schemas import Pagination
88
from app.features.core.utils import parse_int
9-
from app.library.mini_filter import match_str
10-
from app.library.Utils import arg_converter
9+
from app.features.ytdlp.mini_filter import match_str
1110

1211

1312
class Condition(BaseModel):
@@ -38,6 +37,8 @@ def _validate_cli(cls, value: str) -> str:
3837
if not value:
3938
return ""
4039
try:
40+
from app.features.ytdlp.utils import arg_converter
41+
4142
arg_converter(args=value)
4243
except ModuleNotFoundError:
4344
return value

app/features/conditions/service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
from app.features.conditions.models import ConditionModel
66
from app.features.conditions.repository import ConditionsRepository
7+
from app.features.ytdlp.mini_filter import match_str
78
from app.library.Events import EventBus, Events
8-
from app.library.mini_filter import match_str
99
from app.library.Singleton import Singleton
1010

1111
LOG: logging.Logger = logging.getLogger("feature.conditions")

app/features/core/utils.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,20 @@ def format_validation_errors(exc: ValidationError) -> list[dict[str, Any]]:
7979

8080
def gen_random(length: int = 16) -> str:
8181
import secrets
82+
import string
8283

83-
return "".join(secrets.token_urlsafe(length)[:length])
84+
if length < 1:
85+
msg = "length must be >= 1"
86+
raise ValueError(msg)
87+
88+
middle_alphabet = string.ascii_letters + string.digits + "-_"
89+
edge_alphabet = string.ascii_letters + string.digits
90+
91+
if 1 == length:
92+
return secrets.choice(edge_alphabet)
93+
94+
return (
95+
secrets.choice(edge_alphabet)
96+
+ "".join(secrets.choice(middle_alphabet) for _ in range(length - 2))
97+
+ secrets.choice(edge_alphabet)
98+
)

app/features/presets/migration.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from app.features.presets.schemas import Preset
1010
from app.features.presets.utils import preset_name
1111
from app.library.config import Config
12-
from app.library.Utils import arg_converter
1312

1413
if TYPE_CHECKING:
1514
from app.features.presets.repository import PresetsRepository
@@ -87,6 +86,8 @@ def _normalize(self, item: Any, index: int, seen_names: dict[str, int]) -> dict[
8786

8887
if cli:
8988
try:
89+
from app.features.ytdlp.utils import arg_converter
90+
9091
arg_converter(args=cli, level=True)
9192
except Exception as exc:
9293
LOG.warning("Skipping preset '%s' due to invalid CLI: %s", name, exc)

app/features/presets/schemas.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from app.features.core.utils import parse_int
1010
from app.features.presets.utils import preset_name
1111
from app.library.config import Config
12-
from app.library.Utils import arg_converter, create_cookies_file
12+
from app.library.Utils import create_cookies_file
1313

1414

1515
class Preset(BaseModel):
@@ -58,6 +58,8 @@ def _validate_cli(cls, value: Any) -> str:
5858
return ""
5959

6060
try:
61+
from app.features.ytdlp.utils import arg_converter
62+
6163
arg_converter(args=value, level=True)
6264
except Exception as e:
6365
msg = f"Invalid command options for yt-dlp: {e!s}"

app/features/streaming/__init__.py

Whitespace-only changes.
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,10 @@
1313

1414
import anyio
1515

16+
from app.features.streaming.types import FFProbeError
1617
from app.library.Utils import timed_lru_cache
1718

18-
LOG: logging.Logger = logging.getLogger(__name__)
19-
20-
21-
class FFProbeError(Exception):
22-
pass
19+
LOG: logging.Logger = logging.getLogger("streaming.ffprobe")
2320

2421

2522
class FFStream:
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
from pathlib import Path
33
from urllib.parse import quote
44

5-
from .ffprobe import ffprobe
6-
from .Utils import StreamingError
5+
from app.features.streaming.library.ffprobe import ffprobe
6+
from app.features.streaming.types import StreamingError
77

88

99
class M3u8:

0 commit comments

Comments
 (0)