noneto-cli 1.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- noneto/__init__.py +1 -0
- noneto/__main__.py +3 -0
- noneto/app.py +113 -0
- noneto/assets/noneto.ico +0 -0
- noneto/audio/__init__.py +1 -0
- noneto/audio/controller.py +427 -0
- noneto/audio/inspector.py +21 -0
- noneto/audio/ipc_unix.py +29 -0
- noneto/audio/ipc_windows.py +94 -0
- noneto/audio/lifetime.py +68 -0
- noneto/audio/media_controls.py +107 -0
- noneto/audio/mpv_install.py +71 -0
- noneto/audio/player.py +222 -0
- noneto/audio/pulse_tap.py +120 -0
- noneto/audio/spectrum.py +44 -0
- noneto/audio/streams.py +101 -0
- noneto/audio/tap.py +208 -0
- noneto/audio/windows_identity.py +79 -0
- noneto/audio/windows_media.py +157 -0
- noneto/auth/__init__.py +1 -0
- noneto/auth/dpapi.py +28 -0
- noneto/auth/service.py +53 -0
- noneto/auth/storage.py +120 -0
- noneto/diagnostics.py +115 -0
- noneto/errors.py +12 -0
- noneto/i18n.py +199 -0
- noneto/platform/__init__.py +1 -0
- noneto/platform/paths.py +27 -0
- noneto/security.py +59 -0
- noneto/services/__init__.py +1 -0
- noneto/services/covers.py +88 -0
- noneto/services/executor.py +83 -0
- noneto/services/library.py +110 -0
- noneto/services/tidal.py +188 -0
- noneto/settings.py +48 -0
- noneto/state/__init__.py +1 -0
- noneto/state/queue.py +130 -0
- noneto/state/writer.py +38 -0
- noneto/ui/__init__.py +1 -0
- noneto/ui/common.py +36 -0
- noneto/ui/cover.py +88 -0
- noneto/ui/dialogs.py +107 -0
- noneto/ui/linux_login.py +57 -0
- noneto/ui/login_window.py +201 -0
- noneto/ui/lyrics.py +142 -0
- noneto/ui/player.py +172 -0
- noneto/ui/quality.py +75 -0
- noneto/ui/queue.py +34 -0
- noneto/ui/terminal.py +65 -0
- noneto/ui/themes.py +352 -0
- noneto/ui/top.py +39 -0
- noneto/ui/tracks.py +139 -0
- noneto/ui/tui.py +601 -0
- noneto/ui/visualizer.py +343 -0
- noneto_cli-1.1.1.dist-info/METADATA +222 -0
- noneto_cli-1.1.1.dist-info/RECORD +59 -0
- noneto_cli-1.1.1.dist-info/WHEEL +4 -0
- noneto_cli-1.1.1.dist-info/entry_points.txt +2 -0
- noneto_cli-1.1.1.dist-info/licenses/LICENSE +21 -0
noneto/auth/storage.py
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"""Native secure session storage: Windows DPAPI, Linux Secret Service."""
|
|
2
|
+
import json
|
|
3
|
+
import os
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
import tempfile
|
|
6
|
+
from ..errors import AppError
|
|
7
|
+
from ..i18n import _
|
|
8
|
+
from ..platform.paths import data_dir
|
|
9
|
+
|
|
10
|
+
MAX_SESSION_BYTES = 64 * 1024
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class SessionPersistence:
|
|
14
|
+
"""Called only by the SDK owner, after login has persisted the initial state."""
|
|
15
|
+
def __init__(self, session):
|
|
16
|
+
self.session = session
|
|
17
|
+
self._saved = self._snapshot()
|
|
18
|
+
|
|
19
|
+
def _snapshot(self):
|
|
20
|
+
session = self.session
|
|
21
|
+
return (session.token_type, session.access_token, session.refresh_token,
|
|
22
|
+
session.is_pkce, session.expiry_time)
|
|
23
|
+
|
|
24
|
+
def __call__(self):
|
|
25
|
+
current = self._snapshot()
|
|
26
|
+
if current != self._saved:
|
|
27
|
+
save_session(self.session)
|
|
28
|
+
self._saved = current # Failed writes must be retried, never remembered.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def protect(data: bytes, decrypt: bool = False) -> bytes:
|
|
32
|
+
from .dpapi import protect as windows_protect
|
|
33
|
+
return windows_protect(data, decrypt)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _keyring():
|
|
37
|
+
# Select only the native secure backend: never honor plaintext third-party fallbacks.
|
|
38
|
+
try:
|
|
39
|
+
from keyring.backends.SecretService import Keyring
|
|
40
|
+
backend = Keyring()
|
|
41
|
+
if backend.priority <= 0:
|
|
42
|
+
raise RuntimeError("Unavailable keyring")
|
|
43
|
+
return backend
|
|
44
|
+
except Exception:
|
|
45
|
+
raise AppError(_("No secure credential store is available. Unlock your system keyring.")) from None
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def has_session():
|
|
49
|
+
if os.name == "nt":
|
|
50
|
+
return session_path().exists()
|
|
51
|
+
return _keyring().get_password("Noneto CLI", "session") is not None
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def delete_session():
|
|
55
|
+
if os.name == "nt":
|
|
56
|
+
session_path().unlink(missing_ok=True)
|
|
57
|
+
else:
|
|
58
|
+
backend = _keyring()
|
|
59
|
+
if backend.get_password("Noneto CLI", "session") is not None:
|
|
60
|
+
backend.delete_password("Noneto CLI", "session")
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def session_path() -> Path:
|
|
64
|
+
return data_dir() / "session.bin"
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def save_session(session, path=None):
|
|
68
|
+
path = Path(path) if path is not None else session_path()
|
|
69
|
+
data = dict(token_type=session.token_type, access_token=session.access_token,
|
|
70
|
+
refresh_token=session.refresh_token, is_pkce=session.is_pkce,
|
|
71
|
+
expiry_time=session.expiry_time.isoformat() if session.expiry_time else None)
|
|
72
|
+
serialized = json.dumps(data)
|
|
73
|
+
if len(serialized.encode("utf-8")) > MAX_SESSION_BYTES:
|
|
74
|
+
raise ValueError("Invalid stored session size")
|
|
75
|
+
if os.name != "nt":
|
|
76
|
+
_keyring().set_password("Noneto CLI", "session", serialized)
|
|
77
|
+
return
|
|
78
|
+
encrypted = protect(serialized.encode("utf-8"))
|
|
79
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
80
|
+
temp = None
|
|
81
|
+
try:
|
|
82
|
+
with tempfile.NamedTemporaryFile(dir=path.parent, prefix=".session-", suffix=".tmp",
|
|
83
|
+
delete=False) as output:
|
|
84
|
+
temp = Path(output.name)
|
|
85
|
+
output.write(encrypted)
|
|
86
|
+
output.flush()
|
|
87
|
+
os.fsync(output.fileno())
|
|
88
|
+
temp.replace(path)
|
|
89
|
+
finally:
|
|
90
|
+
if temp is not None:
|
|
91
|
+
temp.unlink(missing_ok=True)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def read_session(path=None):
|
|
95
|
+
from datetime import datetime
|
|
96
|
+
path = Path(path) if path is not None else session_path()
|
|
97
|
+
if os.name == "nt":
|
|
98
|
+
with path.open("rb") as source:
|
|
99
|
+
encrypted = source.read(MAX_SESSION_BYTES + 1)
|
|
100
|
+
if len(encrypted) > MAX_SESSION_BYTES:
|
|
101
|
+
raise ValueError("Invalid stored session size")
|
|
102
|
+
serialized = protect(encrypted, decrypt=True)
|
|
103
|
+
else:
|
|
104
|
+
serialized = _keyring().get_password("Noneto CLI", "session")
|
|
105
|
+
if serialized is None:
|
|
106
|
+
raise FileNotFoundError("No stored session")
|
|
107
|
+
if len(serialized.encode("utf-8")) > MAX_SESSION_BYTES:
|
|
108
|
+
raise ValueError("Invalid stored session size")
|
|
109
|
+
data = json.loads(serialized)
|
|
110
|
+
expected = {"token_type", "access_token", "refresh_token", "is_pkce", "expiry_time"}
|
|
111
|
+
if not isinstance(data, dict) or set(data) != expected:
|
|
112
|
+
raise ValueError("Invalid stored session fields")
|
|
113
|
+
for key in ("token_type", "access_token", "refresh_token"):
|
|
114
|
+
if not isinstance(data[key], str) or not data[key] or len(data[key]) > 16384:
|
|
115
|
+
raise ValueError("Invalid stored token")
|
|
116
|
+
if type(data["is_pkce"]) is not bool:
|
|
117
|
+
raise ValueError("Invalid stored session type")
|
|
118
|
+
if data.get("expiry_time"):
|
|
119
|
+
data["expiry_time"] = datetime.fromisoformat(data["expiry_time"])
|
|
120
|
+
return data
|
noneto/diagnostics.py
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"""Allowlisted JSON diagnostics. Never persist exception text, bodies or media URLs."""
|
|
2
|
+
from datetime import datetime, timezone
|
|
3
|
+
import json
|
|
4
|
+
import logging
|
|
5
|
+
from logging.handlers import RotatingFileHandler
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from .platform.paths import state_dir
|
|
8
|
+
import re
|
|
9
|
+
import traceback
|
|
10
|
+
from urllib.parse import urlsplit
|
|
11
|
+
import uuid
|
|
12
|
+
|
|
13
|
+
LOGGER = logging.getLogger("noneto.diagnostics")
|
|
14
|
+
LOGGER.addHandler(logging.NullHandler())
|
|
15
|
+
LOGGER.propagate = False
|
|
16
|
+
_run = None
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def configure(directory=None):
|
|
20
|
+
global _run
|
|
21
|
+
directory = Path(directory) if directory is not None else state_dir() / "logs"
|
|
22
|
+
directory.mkdir(parents=True, exist_ok=True)
|
|
23
|
+
path = directory / "noneto.log"
|
|
24
|
+
handler = RotatingFileHandler(path, maxBytes=1024 * 1024, backupCount=2, encoding="utf-8")
|
|
25
|
+
handler.setFormatter(logging.Formatter("%(message)s"))
|
|
26
|
+
for previous in LOGGER.handlers[:]:
|
|
27
|
+
LOGGER.removeHandler(previous)
|
|
28
|
+
previous.close()
|
|
29
|
+
LOGGER.addHandler(handler)
|
|
30
|
+
LOGGER.setLevel(logging.INFO)
|
|
31
|
+
_run = uuid.uuid4().hex[:12]
|
|
32
|
+
emit("diagnostics.started")
|
|
33
|
+
return path
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def emit(event, **fields):
|
|
37
|
+
# Call sites supply structured facts, never exception text or arbitrary dictionaries.
|
|
38
|
+
allowed = {"stage", "track_id", "index", "count", "quality", "method", "host", "route",
|
|
39
|
+
"status", "elapsed_ms", "manifest_type", "target_kind", "category",
|
|
40
|
+
"error_types", "codes", "frames", "reason", "component", "command", "request_id"}
|
|
41
|
+
record = {"time": datetime.now(timezone.utc).isoformat(), "run": _run,
|
|
42
|
+
"event": event, **{k: v for k, v in fields.items() if k in allowed}}
|
|
43
|
+
LOGGER.info(json.dumps(record, ensure_ascii=True))
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def classify(text):
|
|
47
|
+
lower = text.lower()
|
|
48
|
+
for category, patterns in (
|
|
49
|
+
("tls_certificate", ("certificate verify failed", "certificate verification failed", "unable to get local issuer")),
|
|
50
|
+
("dns", ("getaddrinfo failed", "name resolution", "name or service not known", "failed to resolve")),
|
|
51
|
+
("connection_reset", ("connection reset", "forcibly closed", "10054", "remote end closed")),
|
|
52
|
+
("connection_refused", ("connection refused", "10061")),
|
|
53
|
+
("timeout", ("timed out", "timeout")),
|
|
54
|
+
("protocol_blocked", ("not on whitelist", "protocol not found")),
|
|
55
|
+
("tls", ("ssl", "tls")),
|
|
56
|
+
("http", ("http error", "server returned", "status code")),
|
|
57
|
+
("media_decode", ("invalid data", "failed to recognize file format", "decoder")),
|
|
58
|
+
):
|
|
59
|
+
if any(pattern in lower for pattern in patterns):
|
|
60
|
+
return category
|
|
61
|
+
return "unknown"
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def failure(event, error, **fields):
|
|
65
|
+
# Inspect causes in memory; only fixed categories, class names, integer codes and
|
|
66
|
+
# source locations leave this function. No traceback source lines or local values.
|
|
67
|
+
pending, seen, errors = [error], set(), []
|
|
68
|
+
while pending and len(errors) < 8:
|
|
69
|
+
current = pending.pop(0)
|
|
70
|
+
if id(current) in seen:
|
|
71
|
+
continue
|
|
72
|
+
seen.add(id(current))
|
|
73
|
+
errors.append(current)
|
|
74
|
+
pending.extend(item for item in (current.__cause__, current.__context__,
|
|
75
|
+
getattr(current, "reason", None), *current.args) if isinstance(item, BaseException))
|
|
76
|
+
category = "unknown"
|
|
77
|
+
for current in errors:
|
|
78
|
+
candidate = classify(str(current))
|
|
79
|
+
if candidate != "unknown":
|
|
80
|
+
category = candidate
|
|
81
|
+
break
|
|
82
|
+
codes = [value for current in errors for key in ("errno", "winerror")
|
|
83
|
+
if isinstance(value := getattr(current, key, None), int)]
|
|
84
|
+
frames = [f"{Path(frame.filename).name}:{frame.lineno}:{frame.name}"
|
|
85
|
+
for frame in traceback.extract_tb(error.__traceback__)[-8:]]
|
|
86
|
+
emit(event, **fields, category=category, error_types=[type(e).__name__ for e in errors],
|
|
87
|
+
codes=codes, frames=frames)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def request_target(url):
|
|
91
|
+
parsed = urlsplit(url)
|
|
92
|
+
# Keep a small route vocabulary; exclude user IDs, searches and all query strings.
|
|
93
|
+
path = parsed.path
|
|
94
|
+
if re.fullmatch(r"/v1/tracks/\d+/playbackinfopostpaywall", path):
|
|
95
|
+
route = "/v1/tracks/:id/playbackinfopostpaywall"
|
|
96
|
+
elif path in {"/v1/oauth2/token", "/v1/oauth2/device_authorization", "/v1/sessions"}:
|
|
97
|
+
route = path
|
|
98
|
+
else:
|
|
99
|
+
route = "catalog"
|
|
100
|
+
return {"host": parsed.hostname, "route": route}
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def track_id(track):
|
|
104
|
+
value = getattr(track, "id", None)
|
|
105
|
+
return value if isinstance(value, int) else None
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def mpv_message(message):
|
|
109
|
+
# Native mpv logs often contain signed URLs. Classify and discard raw text.
|
|
110
|
+
text = str(message.get("text", ""))
|
|
111
|
+
prefix = message.get("prefix")
|
|
112
|
+
component = prefix if prefix in {"ffmpeg", "lavf", "cplayer", "demux", "ao", "ad"} else "mpv"
|
|
113
|
+
status = re.search(r"(?:HTTP (?:error )?|Server returned )(\d{3})\b", text, re.I)
|
|
114
|
+
emit("mpv.warning", component=component, category=classify(text),
|
|
115
|
+
status=int(status.group(1)) if status else None)
|
noneto/errors.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""Only explicit application errors may be displayed verbatim."""
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class AppError(RuntimeError):
|
|
5
|
+
"""A fixed, application-owned message safe for display."""
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def error_label(error):
|
|
9
|
+
response = getattr(error, "response", None)
|
|
10
|
+
if response is not None:
|
|
11
|
+
return f"HTTP {response.status_code}"
|
|
12
|
+
return type(error).__name__
|
noneto/i18n.py
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"""English source messages and optional Spanish translations.
|
|
2
|
+
|
|
3
|
+
English is the default, independent of the operating system language. Set the language before
|
|
4
|
+
importing the TUI: some labels and bindings are built at import time. Logs stay untranslated.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
LANGUAGES = ("en", "es")
|
|
8
|
+
DEFAULT_LANGUAGE = "en"
|
|
9
|
+
_language = DEFAULT_LANGUAGE
|
|
10
|
+
|
|
11
|
+
ES = {
|
|
12
|
+
"This release supports Windows only. Linux support is still in development.": "Esta versión solo admite Windows. El soporte para Linux sigue en desarrollo.",
|
|
13
|
+
"Could not read the clipboard. Paste the final URL to continue.": "No se pudo leer el portapapeles. Pega la direccion final para continuar.",
|
|
14
|
+
"Diagnostics: {path}": "Diagnostico: {path}",
|
|
15
|
+
"Could not open the diagnostics file.": "No se pudo abrir el archivo de diagnostico.",
|
|
16
|
+
"Local session deleted.": "Sesion local eliminada.",
|
|
17
|
+
"Installing mpv (if missing)...": "Instalando mpv (si falta)...",
|
|
18
|
+
"mpv ready: {path}": "mpv listo: {path}",
|
|
19
|
+
"Goodbye.": "Hasta luego.",
|
|
20
|
+
"The operation could not be completed ({label}).": "No se pudo completar la operacion ({label}).",
|
|
21
|
+
"Check your connection and your account. To sign in again: noneto --logout": "Comprueba tu conexion y tu cuenta. Para iniciar sesion otra vez: noneto --logout",
|
|
22
|
+
"Session restored.": "Sesion recuperada.",
|
|
23
|
+
"Could not restore the session. Please sign in again.": "No se pudo recuperar la sesion. Inicia sesion nuevamente.",
|
|
24
|
+
"Your session is an older type without Hi-Res access. Please sign in again (only this once).": "Tu sesion es de un tipo antiguo sin acceso a Hi-Res. Inicia sesion otra vez (solo esta vez).",
|
|
25
|
+
"Sign in in the TIDAL window that just opened. It closes by itself when you are done.": "Inicia sesion en la ventana de TIDAL que se abrio. Se cierra sola al terminar.",
|
|
26
|
+
"Could not open the window. Sign in to TIDAL in your browser:": "No se pudo abrir la ventana. Inicia sesion en TIDAL desde tu navegador:",
|
|
27
|
+
"When you finish, TIDAL shows an error page (\"Oops\"). That is expected.": "Al terminar, TIDAL muestra una pagina de error (\"Oops\"). Es normal.",
|
|
28
|
+
"Copy that page's address (Ctrl+L, Ctrl+C): Noneto picks it up by itself. (Ctrl+C here cancels)": "Copia la direccion de esa pagina (Ctrl+L, Ctrl+C): Noneto la detecta sola. (Ctrl+C aqui cancela)",
|
|
29
|
+
"Signed in.": "Sesion iniciada.",
|
|
30
|
+
"Sign in to TIDAL - Noneto CLI": "Iniciar sesion en TIDAL - Noneto CLI",
|
|
31
|
+
"Noneto CLI: unofficial TIDAL client for the terminal.": "Noneto CLI: cliente no oficial de TIDAL para la terminal.",
|
|
32
|
+
"Link or UUID of the playlist to open at startup": "Enlace o UUID de la playlist que se abre al iniciar",
|
|
33
|
+
"Highest quality requested from TIDAL; by default, the best available": "Calidad maxima pedida a TIDAL; por defecto, la mejor disponible",
|
|
34
|
+
"Delete the local session and exit": "Elimina la sesion local y termina",
|
|
35
|
+
"Download mpv (pinned version, SHA-256 verified) and exit": "Descarga mpv (version fijada, SHA-256 verificado) y termina",
|
|
36
|
+
"Interface language (default: English)": "Idioma de la interfaz (por defecto, inglés)",
|
|
37
|
+
"For now Noneto CLI only runs on Windows.": "Por ahora Noneto CLI funciona solo en Windows.",
|
|
38
|
+
"Sign-in cancelled.": "Inicio de sesion cancelado.",
|
|
39
|
+
"TIDAL rejected the code; it may have expired. Run noneto again.": "TIDAL rechazo el codigo; puede haber caducado. Ejecuta noneto otra vez.",
|
|
40
|
+
"The sign-in address did not arrive in time. Run noneto again.": "No se recibio la direccion de inicio de sesion a tiempo. Ejecuta noneto otra vez.",
|
|
41
|
+
"Invalid network destination.": "Destino de red no valido.",
|
|
42
|
+
"Only valid HTTPS destinations are allowed.": "Solo se permiten destinos HTTPS validos.",
|
|
43
|
+
"The destination does not belong to the authorized service.": "El destino no pertenece al servicio autorizado.",
|
|
44
|
+
"Private network addresses are not allowed.": "No se permiten direcciones de red privadas.",
|
|
45
|
+
"That is not the page TIDAL redirects to after signing in.": "Esa no es la pagina a la que TIDAL redirige al iniciar sesion.",
|
|
46
|
+
"TIDAL did not authorize the sign-in.": "TIDAL no autorizo el inicio de sesion.",
|
|
47
|
+
"The address does not contain an authorization code.": "La direccion pegada no contiene un codigo de autorizacion.",
|
|
48
|
+
"Invalid DASH manifest.": "Manifiesto DASH no valido.",
|
|
49
|
+
"DASH manifest is nested too deeply.": "Manifiesto DASH demasiado profundo.",
|
|
50
|
+
"Unsupported DASH namespace.": "Espacio de nombres DASH no soportado.",
|
|
51
|
+
"The manifest uses an unsupported DASH feature.": "El manifiesto usa una funcion DASH no soportada.",
|
|
52
|
+
"External XML references are not allowed.": "No se permiten referencias XML externas.",
|
|
53
|
+
"Multiple BaseURL elements are not supported.": "Multiples BaseURL no soportadas.",
|
|
54
|
+
"Invalid DASH reference.": "Referencia DASH no valida.",
|
|
55
|
+
"The manifest has no audio destinations.": "El manifiesto no contiene destinos de audio.",
|
|
56
|
+
"Audio manifest too large.": "Manifiesto de audio demasiado grande.",
|
|
57
|
+
"Unsupported manifest format.": "Formato de manifiesto no soportado.",
|
|
58
|
+
"This stream needs an unsupported playback method.": "Este stream requiere un metodo de reproduccion no soportado.",
|
|
59
|
+
"TIDAL did not return a valid audio manifest.": "Tidal no devolvio un manifiesto de audio valido.",
|
|
60
|
+
"Too many pending actions. Wait a moment.": "Demasiadas acciones pendientes. Espera un momento.",
|
|
61
|
+
"Lost communication with mpv. Try playing again.": "Se perdio la comunicacion con mpv. Reintenta reproducir.",
|
|
62
|
+
"Could not load the audio. Try again or pick another song.": "No se pudo cargar el audio. Reintenta o elige otra cancion.",
|
|
63
|
+
"The audio did not load within 45 seconds. Try again.": "El audio no cargo en 45 segundos. Reintenta.",
|
|
64
|
+
"mpv is missing. Install it with: noneto --install-mpv": "Falta mpv. Instalalo con: noneto --install-mpv",
|
|
65
|
+
"mpv could not start.": "mpv no pudo iniciarse.",
|
|
66
|
+
"mpv did not respond within 10 seconds.": "mpv no respondio en 10 segundos.",
|
|
67
|
+
"Could not verify the player channel.": "No se pudo verificar el canal del reproductor.",
|
|
68
|
+
"Could not configure the player channel.": "No se pudo configurar el canal del reproductor.",
|
|
69
|
+
"Windows tar.exe is missing; it is needed to extract mpv.": "Falta tar.exe de Windows para extraer mpv.",
|
|
70
|
+
"Could not download mpv (HTTP {status}).": "No se pudo descargar mpv (HTTP {status}).",
|
|
71
|
+
"The mpv download is too large.": "La descarga de mpv es demasiado grande.",
|
|
72
|
+
"The mpv SHA-256 hash does not match; it was not installed.": "El hash SHA-256 de mpv no coincide; no se instalo.",
|
|
73
|
+
"The downloaded file does not contain mpv.exe.": "El archivo descargado no contiene mpv.exe.",
|
|
74
|
+
"TIDAL returned a disallowed redirect.": "Tidal devolvio una redireccion no permitida.",
|
|
75
|
+
"Playback command too large.": "Comando de reproduccion demasiado grande.",
|
|
76
|
+
"Lost communication with the player.": "Se perdio la comunicacion con el reproductor.",
|
|
77
|
+
"mpv did not answer the command in time.": "mpv no respondio al comando a tiempo.",
|
|
78
|
+
"mpv rejected a command or disconnected.": "mpv rechazo un comando o se desconecto.",
|
|
79
|
+
"Could not prepare the player's automatic shutdown.": "No se pudo preparar el cierre automatico del reproductor.",
|
|
80
|
+
"Could not configure the player's automatic shutdown.": "No se pudo configurar el cierre automatico del reproductor.",
|
|
81
|
+
"Could not tie the player to Noneto CLI's shutdown.": "No se pudo vincular el reproductor al cierre de Noneto CLI.",
|
|
82
|
+
"Cover art too large.": "Caratula demasiado grande.",
|
|
83
|
+
"Cover art not available.": "Caratula no disponible.",
|
|
84
|
+
"Invalid cover art.": "Caratula no valida.",
|
|
85
|
+
"The name must be between 1 and 100 characters.": "El nombre debe tener entre 1 y 100 caracteres.",
|
|
86
|
+
"Type a search between 1 and 200 characters.": "Escribe una busqueda de entre 1 y 200 caracteres.",
|
|
87
|
+
"Pagination exceeded the safety limit.": "La paginacion excedio el limite de seguridad.",
|
|
88
|
+
"You can only add songs to your own playlists.": "Solo puedes agregar canciones a tus propias playlists.",
|
|
89
|
+
"TIDAL returned a larger page than requested.": "Tidal devolvio una pagina mayor de lo solicitado.",
|
|
90
|
+
"Cancel": "Cancelar",
|
|
91
|
+
"Your library": "Tu biblioteca",
|
|
92
|
+
"No playlists. Create one or refresh.": "Sin playlists. Crea una o actualiza.",
|
|
93
|
+
"+ New playlist": "+ Nueva playlist",
|
|
94
|
+
"Refresh": "Actualizar",
|
|
95
|
+
"Close": "Cerrar",
|
|
96
|
+
"New playlist": "Nueva playlist",
|
|
97
|
+
"Your playlist's name": "Nombre de tu playlist",
|
|
98
|
+
"Create": "Crear",
|
|
99
|
+
"Add to one of your playlists": "Agregar a una playlist propia",
|
|
100
|
+
"Quit": "Salir",
|
|
101
|
+
"Search": "Buscar",
|
|
102
|
+
"Library": "Biblioteca",
|
|
103
|
+
"Pause": "Pausa",
|
|
104
|
+
"Next": "Siguiente",
|
|
105
|
+
"Theme": "Tema",
|
|
106
|
+
"Theme: {name} · Ctrl+T to change": "Tema: {name} · Ctrl+T para cambiar",
|
|
107
|
+
"Aura": "Aura",
|
|
108
|
+
"Track aura: {name} · Ctrl+G to change": "Aura de pista: {name} · Ctrl+G para cambiar",
|
|
109
|
+
"Classic": "Clásica",
|
|
110
|
+
"Braille": "Braille",
|
|
111
|
+
"Mirror": "Espejo",
|
|
112
|
+
"Flame": "Llama",
|
|
113
|
+
"User": "Usuario",
|
|
114
|
+
"Library ▾": "Biblioteca ▾",
|
|
115
|
+
"{name}'s playlists · Ctrl+L": "Playlists de {name} · Ctrl+L",
|
|
116
|
+
"Search songs or artists…": "Buscar canciones o artistas…",
|
|
117
|
+
"Search songs or playlists…": "Buscar canciones o playlists…",
|
|
118
|
+
"No playlists in this search.": "Sin playlists en esta búsqueda.",
|
|
119
|
+
"Songs": "Canciones",
|
|
120
|
+
"More results": "Más resultados",
|
|
121
|
+
"Queue": "Cola",
|
|
122
|
+
"Queue · {count}": "Cola · {count}",
|
|
123
|
+
"No songs in the queue.": "Sin canciones en cola.",
|
|
124
|
+
"Lyrics": "Letras",
|
|
125
|
+
"Play a song to see its lyrics.": "Reproduce una canción para ver sus letras.",
|
|
126
|
+
"Loading lyrics…": "Cargando letras…",
|
|
127
|
+
"No lyrics available for this song.": "No hay letras disponibles para esta canción.",
|
|
128
|
+
"Select a song": "Selecciona una canción",
|
|
129
|
+
"Selected ": "Seleccionada ",
|
|
130
|
+
"+ Queue": "+ Cola",
|
|
131
|
+
"No song": "Sin canción",
|
|
132
|
+
"Shuffle": "Aleatorio",
|
|
133
|
+
"Previous": "Anterior",
|
|
134
|
+
"Play or pause": "Reproducir o pausar",
|
|
135
|
+
"Repeat: off / queue / song": "Repetir: apagado / cola / canción",
|
|
136
|
+
"Loading library…": "Cargando biblioteca…",
|
|
137
|
+
"The interface closed because of an error. See the Noneto CLI logs.": "La interfaz se cerro por un error. Consulta los logs de Noneto CLI.",
|
|
138
|
+
"Title": "Título",
|
|
139
|
+
"Duration": "Duración",
|
|
140
|
+
"Could not complete: {label}. You can try again.": "No se pudo completar: {label}. Puedes reintentar.",
|
|
141
|
+
"{count} playlists · Click Library to open another": "{count} playlists · Clic en Biblioteca para abrir otra",
|
|
142
|
+
"Loading…": "Cargando…",
|
|
143
|
+
"Could not load. Open it again to retry.": "No se pudo cargar. Ábrela otra vez para reintentar.",
|
|
144
|
+
"Search results": "Búsqueda",
|
|
145
|
+
"{source} · {count} songs": "{source} · {count} canciones",
|
|
146
|
+
"No songs. Search for music and add it to a playlist.": "Sin canciones. Busca música y agrégala a una playlist.",
|
|
147
|
+
"Results: {query}": "Resultados: {query}",
|
|
148
|
+
"Search failed. Press Search to retry.": "Búsqueda fallida. Pulsa Buscar para reintentar.",
|
|
149
|
+
"Playlist created in your TIDAL account.": "Playlist creada en tu cuenta de Tidal.",
|
|
150
|
+
"The creation was not confirmed. Refresh the library before retrying.": "No se confirmó la creación. Actualiza la biblioteca antes de reintentar.",
|
|
151
|
+
"First create a playlist of your own from Library.": "Primero crea una playlist propia desde Biblioteca.",
|
|
152
|
+
"Song added.": "Canción agregada.",
|
|
153
|
+
"No changes: the song is already there or unavailable.": "Sin cambios: la canción ya existe o no está disponible.",
|
|
154
|
+
"Song added to the end of the queue.": "Canción agregada al final de la cola.",
|
|
155
|
+
"+ {count} songs": "+ {count} canciones",
|
|
156
|
+
"Repeat: {mode}": "Rep: {mode}",
|
|
157
|
+
"off": "no",
|
|
158
|
+
"queue": "cola",
|
|
159
|
+
"one": "una",
|
|
160
|
+
"Not playing": "Sin reproduccion",
|
|
161
|
+
"Loading": "Cargando",
|
|
162
|
+
"Playing": "Reproduciendo",
|
|
163
|
+
"Paused": "Pausado",
|
|
164
|
+
"Stopped": "Detenido",
|
|
165
|
+
"Error": "Error",
|
|
166
|
+
"FLAC up to 24-bit / 192 kHz": "FLAC hasta 24-bit / 192 kHz",
|
|
167
|
+
"Lossless 16-bit / 44.1 kHz": "Lossless 16-bit / 44.1 kHz",
|
|
168
|
+
"Requested: {short}": "Pedido: {short}",
|
|
169
|
+
"Requested: {short} ({detail}).": "Pedido: {short} ({detail}).",
|
|
170
|
+
"While playing, the quality that arrives is shown.": "Al reproducir se muestra la calidad que llega.",
|
|
171
|
+
"Waiting for audio.": "Esperando el audio.",
|
|
172
|
+
"Received: {received}.": "Recibido: {received}.",
|
|
173
|
+
"This track is available in: {tier}.": "Esta pista existe en: {tier}.",
|
|
174
|
+
"TIDAL delivered less than this track offers.": "TIDAL entregó menos de lo que ofrece esta pista.",
|
|
175
|
+
"mpv is missing. Install it with your system package manager.": "Falta mpv. Instalalo con el gestor de paquetes de tu sistema.",
|
|
176
|
+
"No secure credential store is available. Unlock your system keyring.": "No hay un almacen seguro de credenciales disponible. Desbloquea el llavero del sistema.",
|
|
177
|
+
"Sign in to TIDAL in your browser and paste the final URL here:": "Inicia sesion en TIDAL desde tu navegador y pega la URL final aqui:",
|
|
178
|
+
"Redirect URL: ": "URL de redireccion: ",
|
|
179
|
+
"Cover": "Carátula",
|
|
180
|
+
"Lyrics tab: cover only · Ctrl+O to change": "Letras: solo carátula · Ctrl+O para cambiar",
|
|
181
|
+
"Lyrics tab: cover and lyrics · Ctrl+O to change": "Letras: carátula y letras · Ctrl+O para cambiar"
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def set_language(language):
|
|
186
|
+
global _language
|
|
187
|
+
if language not in LANGUAGES:
|
|
188
|
+
raise ValueError(language)
|
|
189
|
+
_language = language
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
def language():
|
|
193
|
+
return _language
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
def _(text, **values):
|
|
197
|
+
if _language == "es":
|
|
198
|
+
text = ES.get(text, text)
|
|
199
|
+
return text.format(**values) if values else text
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Operating system integration boundaries."""
|
noneto/platform/paths.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""User directories, preserving existing Windows data locations."""
|
|
2
|
+
import os
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def _xdg(variable, fallback):
|
|
8
|
+
value = os.environ.get(variable)
|
|
9
|
+
return Path(value) if value and Path(value).is_absolute() else Path.home() / fallback
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def data_dir():
|
|
13
|
+
if sys.platform == "win32":
|
|
14
|
+
return Path(os.environ["LOCALAPPDATA"]) / "Noneto"
|
|
15
|
+
return _xdg("XDG_DATA_HOME", ".local/share") / "noneto"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def config_dir():
|
|
19
|
+
if sys.platform == "win32":
|
|
20
|
+
return data_dir()
|
|
21
|
+
return _xdg("XDG_CONFIG_HOME", ".config") / "noneto"
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def state_dir():
|
|
25
|
+
if sys.platform == "win32":
|
|
26
|
+
return data_dir()
|
|
27
|
+
return _xdg("XDG_STATE_HOME", ".local/state") / "noneto"
|
noneto/security.py
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"""Validation at external input boundaries; never include rejected values in errors."""
|
|
2
|
+
import ipaddress
|
|
3
|
+
import re
|
|
4
|
+
import unicodedata
|
|
5
|
+
from urllib.parse import parse_qs, urlsplit
|
|
6
|
+
|
|
7
|
+
from .errors import AppError
|
|
8
|
+
from .i18n import _
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def https_url(value, *, hosts=None):
|
|
12
|
+
if not isinstance(value, str) or not value or len(value) > 16384:
|
|
13
|
+
raise AppError(_("Invalid network destination."))
|
|
14
|
+
if any(ord(c) < 33 or ord(c) == 127 for c in value) or "\\" in value:
|
|
15
|
+
raise AppError(_("Invalid network destination."))
|
|
16
|
+
try:
|
|
17
|
+
url = urlsplit(value)
|
|
18
|
+
host = (url.hostname or "").lower()
|
|
19
|
+
port = url.port
|
|
20
|
+
except ValueError:
|
|
21
|
+
raise AppError(_("Invalid network destination.")) from None
|
|
22
|
+
if (url.scheme != "https" or not host or url.username is not None
|
|
23
|
+
or url.password is not None or port not in (None, 443) or url.fragment):
|
|
24
|
+
raise AppError(_("Only valid HTTPS destinations are allowed."))
|
|
25
|
+
if hosts is not None and host not in hosts:
|
|
26
|
+
raise AppError(_("The destination does not belong to the authorized service."))
|
|
27
|
+
try:
|
|
28
|
+
address = ipaddress.ip_address(host)
|
|
29
|
+
except ValueError:
|
|
30
|
+
if (not re.fullmatch(r"[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?", host)
|
|
31
|
+
or "." not in host or ".." in host
|
|
32
|
+
or host.endswith((".localhost", ".local", ".internal"))
|
|
33
|
+
or host.rsplit(".", 1)[-1].isdigit()):
|
|
34
|
+
raise AppError(_("Invalid network destination.")) from None
|
|
35
|
+
else:
|
|
36
|
+
if not address.is_global:
|
|
37
|
+
raise AppError(_("Private network addresses are not allowed."))
|
|
38
|
+
return value
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def pkce_code(value, redirect_uri):
|
|
42
|
+
"""Authorization code from the pasted login redirect; only TIDAL's redirect page is accepted."""
|
|
43
|
+
value = value.strip() if isinstance(value, str) else value
|
|
44
|
+
https_url(value, hosts={urlsplit(redirect_uri).hostname})
|
|
45
|
+
url = urlsplit(value)
|
|
46
|
+
if url.path.rstrip("/") != urlsplit(redirect_uri).path.rstrip("/"):
|
|
47
|
+
raise AppError(_("That is not the page TIDAL redirects to after signing in."))
|
|
48
|
+
query = parse_qs(url.query, keep_blank_values=True)
|
|
49
|
+
if "error" in query:
|
|
50
|
+
raise AppError(_("TIDAL did not authorize the sign-in."))
|
|
51
|
+
codes = query.get("code", [])
|
|
52
|
+
if len(codes) != 1 or not re.fullmatch(r"[A-Za-z0-9._~-]{1,4096}", codes[0]):
|
|
53
|
+
raise AppError(_("The address does not contain an authorization code."))
|
|
54
|
+
return codes[0]
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def terminal_text(value):
|
|
58
|
+
# Remote metadata must not emit ESC/OSC, C1 controls or bidi format controls.
|
|
59
|
+
return "".join(c for c in str(value) if not unicodedata.category(c).startswith("C"))[:2000]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""External service adapters."""
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"""Validated JPEG transfers, reusable connection and bounded in-memory LRU."""
|
|
2
|
+
from collections import OrderedDict
|
|
3
|
+
import io
|
|
4
|
+
import time
|
|
5
|
+
import warnings
|
|
6
|
+
|
|
7
|
+
from PIL import Image
|
|
8
|
+
import requests
|
|
9
|
+
|
|
10
|
+
from ..errors import AppError
|
|
11
|
+
from ..i18n import _
|
|
12
|
+
from ..security import https_url
|
|
13
|
+
|
|
14
|
+
# Same rule as the API session (services/tidal.py): TIDAL drops idle connections after a few
|
|
15
|
+
# minutes, and a request on one that is closing fails, so start fresh after a pause.
|
|
16
|
+
IDLE_RESET_SECONDS = 60
|
|
17
|
+
# 640 px keeps the cover sharp when the Lyrics tab shows it large; 320 is TIDAL's next size down.
|
|
18
|
+
COVER_SIZES = (320, 640)
|
|
19
|
+
COVER_SIZE = 640
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def cover_image(data):
|
|
23
|
+
"""Decoded off the UI thread; the TUI scales it to each cover's size."""
|
|
24
|
+
if data is None:
|
|
25
|
+
return None
|
|
26
|
+
with Image.open(io.BytesIO(data)) as picture:
|
|
27
|
+
return picture.convert("RGB")
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class CoverDownloader:
|
|
31
|
+
"""Confined to one media worker. Cache holds only validated JPEG bytes."""
|
|
32
|
+
def __init__(self, max_bytes=8 * 1024 * 1024, max_entries=64):
|
|
33
|
+
self._connection = None
|
|
34
|
+
self._last_used = 0.0
|
|
35
|
+
self._cache = OrderedDict()
|
|
36
|
+
self._bytes = 0
|
|
37
|
+
self._max_bytes, self._max_entries = max_bytes, max_entries
|
|
38
|
+
|
|
39
|
+
def fetch(self, request):
|
|
40
|
+
if request is None:
|
|
41
|
+
return None
|
|
42
|
+
url, resolution = request
|
|
43
|
+
https_url(url, hosts={"resources.tidal.com"})
|
|
44
|
+
if type(resolution) is not int or resolution not in COVER_SIZES:
|
|
45
|
+
raise ValueError("Invalid cover resolution")
|
|
46
|
+
key = (url, resolution)
|
|
47
|
+
if key in self._cache:
|
|
48
|
+
self._cache.move_to_end(key)
|
|
49
|
+
return self._cache[key]
|
|
50
|
+
if self._connection is not None and time.monotonic() - self._last_used > IDLE_RESET_SECONDS:
|
|
51
|
+
self._connection.close()
|
|
52
|
+
self._connection = None
|
|
53
|
+
if self._connection is None:
|
|
54
|
+
self._connection = requests.Session()
|
|
55
|
+
self._connection.trust_env = False
|
|
56
|
+
chunks, size = [], 0
|
|
57
|
+
try:
|
|
58
|
+
with self._connection.get(url, stream=True, timeout=(5, 15), allow_redirects=False,
|
|
59
|
+
verify=True) as response:
|
|
60
|
+
if response.status_code != 200 or not response.headers.get("Content-Type", "").lower().startswith("image/jpeg"):
|
|
61
|
+
raise AppError(_("Cover art not available."))
|
|
62
|
+
for chunk in response.iter_content(16384):
|
|
63
|
+
size += len(chunk)
|
|
64
|
+
if size > 1024 * 1024:
|
|
65
|
+
raise AppError(_("Cover art too large."))
|
|
66
|
+
chunks.append(chunk)
|
|
67
|
+
finally:
|
|
68
|
+
self._last_used = time.monotonic()
|
|
69
|
+
data = b"".join(chunks)
|
|
70
|
+
with warnings.catch_warnings():
|
|
71
|
+
warnings.simplefilter("error", Image.DecompressionBombWarning)
|
|
72
|
+
with Image.open(io.BytesIO(data)) as picture:
|
|
73
|
+
if picture.format != "JPEG" or max(picture.size) > resolution * 2:
|
|
74
|
+
raise AppError(_("Invalid cover art."))
|
|
75
|
+
picture.load()
|
|
76
|
+
if len(data) <= self._max_bytes and self._max_entries > 0:
|
|
77
|
+
self._cache[key] = data
|
|
78
|
+
self._bytes += len(data)
|
|
79
|
+
while self._bytes > self._max_bytes or len(self._cache) > self._max_entries:
|
|
80
|
+
_key, evicted = self._cache.popitem(last=False)
|
|
81
|
+
self._bytes -= len(evicted)
|
|
82
|
+
return data
|
|
83
|
+
|
|
84
|
+
def close(self):
|
|
85
|
+
if self._connection is not None:
|
|
86
|
+
self._connection.close()
|
|
87
|
+
self._cache.clear()
|
|
88
|
+
self._bytes = 0
|