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.
Files changed (59) hide show
  1. noneto/__init__.py +1 -0
  2. noneto/__main__.py +3 -0
  3. noneto/app.py +113 -0
  4. noneto/assets/noneto.ico +0 -0
  5. noneto/audio/__init__.py +1 -0
  6. noneto/audio/controller.py +427 -0
  7. noneto/audio/inspector.py +21 -0
  8. noneto/audio/ipc_unix.py +29 -0
  9. noneto/audio/ipc_windows.py +94 -0
  10. noneto/audio/lifetime.py +68 -0
  11. noneto/audio/media_controls.py +107 -0
  12. noneto/audio/mpv_install.py +71 -0
  13. noneto/audio/player.py +222 -0
  14. noneto/audio/pulse_tap.py +120 -0
  15. noneto/audio/spectrum.py +44 -0
  16. noneto/audio/streams.py +101 -0
  17. noneto/audio/tap.py +208 -0
  18. noneto/audio/windows_identity.py +79 -0
  19. noneto/audio/windows_media.py +157 -0
  20. noneto/auth/__init__.py +1 -0
  21. noneto/auth/dpapi.py +28 -0
  22. noneto/auth/service.py +53 -0
  23. noneto/auth/storage.py +120 -0
  24. noneto/diagnostics.py +115 -0
  25. noneto/errors.py +12 -0
  26. noneto/i18n.py +199 -0
  27. noneto/platform/__init__.py +1 -0
  28. noneto/platform/paths.py +27 -0
  29. noneto/security.py +59 -0
  30. noneto/services/__init__.py +1 -0
  31. noneto/services/covers.py +88 -0
  32. noneto/services/executor.py +83 -0
  33. noneto/services/library.py +110 -0
  34. noneto/services/tidal.py +188 -0
  35. noneto/settings.py +48 -0
  36. noneto/state/__init__.py +1 -0
  37. noneto/state/queue.py +130 -0
  38. noneto/state/writer.py +38 -0
  39. noneto/ui/__init__.py +1 -0
  40. noneto/ui/common.py +36 -0
  41. noneto/ui/cover.py +88 -0
  42. noneto/ui/dialogs.py +107 -0
  43. noneto/ui/linux_login.py +57 -0
  44. noneto/ui/login_window.py +201 -0
  45. noneto/ui/lyrics.py +142 -0
  46. noneto/ui/player.py +172 -0
  47. noneto/ui/quality.py +75 -0
  48. noneto/ui/queue.py +34 -0
  49. noneto/ui/terminal.py +65 -0
  50. noneto/ui/themes.py +352 -0
  51. noneto/ui/top.py +39 -0
  52. noneto/ui/tracks.py +139 -0
  53. noneto/ui/tui.py +601 -0
  54. noneto/ui/visualizer.py +343 -0
  55. noneto_cli-1.1.1.dist-info/METADATA +222 -0
  56. noneto_cli-1.1.1.dist-info/RECORD +59 -0
  57. noneto_cli-1.1.1.dist-info/WHEEL +4 -0
  58. noneto_cli-1.1.1.dist-info/entry_points.txt +2 -0
  59. noneto_cli-1.1.1.dist-info/licenses/LICENSE +21 -0
noneto/ui/player.py ADDED
@@ -0,0 +1,172 @@
1
+ """Player bar: mini cover, current song, transport controls, volume and clickable progress.
2
+
3
+ The bar handles its own buttons and clicks and sends the orders through the app's `control()`.
4
+ """
5
+ from rich.text import Text
6
+ from textual import on
7
+ from textual.containers import Horizontal, Vertical
8
+ from textual.message import Message
9
+ from textual.widgets import Button, ProgressBar, Static
10
+
11
+ from ..i18n import _
12
+ from .common import Changes, album, artist, clean, duration
13
+
14
+ CSS = """
15
+ #player { height: 5; background: $panel; padding: 1 1; }
16
+ #player-body { width: 1fr; }
17
+ #now-row, #now-detail, #seek { height: 1; }
18
+ #now-detail { color: $text-muted; }
19
+ #now-playing { width: 1fr; height: 1; }
20
+ #controls { width: auto; height: 1; }
21
+ #controls Button { min-width: 4; margin: 0 1; background: $panel; }
22
+ #controls Button.-primary { min-width: 6; background: $primary; }
23
+ #shuffle, #repeat { color: $text-muted; }
24
+ #controls Button.active { color: $foreground; text-style: bold; }
25
+ #volume { width: 1fr; height: 1; align-horizontal: right; }
26
+ #volume Button { min-width: 3; margin: 0; background: $panel; color: $text-muted; }
27
+ #volume-bar { width: 10; }
28
+ #volume-label { width: 5; text-align: right; }
29
+ #elapsed, #total { width: 6; color: $text-muted; }
30
+ #total { text-align: right; }
31
+ #progress { width: 1fr; height: 1; }
32
+ #progress > #bar { width: 1fr; }
33
+ #progress:hover { background: $surface-lighten-1; }
34
+ #progress > .bar--bar, #progress > .bar--complete { color: $primary; }
35
+ """
36
+
37
+ VOLUME_CELLS = 10
38
+ REPEAT_LABELS = {"off": _("off"), "all": _("queue"), "one": _("one")}
39
+ CONTROLS = (("shuffle", "⇄", _("Shuffle")), ("previous", "◁◁", _("Previous")),
40
+ ("pause", "▷", _("Play or pause")), ("next", "▷▷", _("Next")),
41
+ ("repeat", "↻", _("Repeat: off / queue / song")))
42
+
43
+
44
+ def level_bar(volume):
45
+ filled = round(max(0, min(100, volume)) / 100 * VOLUME_CELLS)
46
+ output = Text("━" * filled, style="bold")
47
+ output.append("─" * (VOLUME_CELLS - filled), style="dim")
48
+ return output
49
+
50
+
51
+ def playback_mode(state):
52
+ """Status bar text: playback status, repeat mode and shuffle."""
53
+ mode = f"{_(state.status)} · {_("Repeat: {mode}", mode=REPEAT_LABELS[state.repeat])}"
54
+ return mode + (" · " + _("Shuffle") if state.shuffle else "")
55
+
56
+
57
+ class SeekProgress(ProgressBar):
58
+ class SeekRequested(Message):
59
+ def __init__(self, fraction):
60
+ super().__init__()
61
+ self.fraction = fraction
62
+
63
+ def on_click(self, event):
64
+ if event.button != 1:
65
+ return
66
+ bar = self.query_one("#bar")
67
+ region = bar.content_region
68
+ if region.width:
69
+ fraction = (event.screen_x - region.x) / max(1, region.width - 1)
70
+ self.post_message(self.SeekRequested(max(0.0, min(1.0, fraction))))
71
+ event.stop()
72
+
73
+
74
+ class VolumeBar(Static):
75
+ """Click a cell to jump to that volume, in steps of 10%."""
76
+
77
+ class VolumeRequested(Message):
78
+ def __init__(self, volume):
79
+ super().__init__()
80
+ self.volume = volume
81
+
82
+ def on_click(self, event):
83
+ if event.button == 1 and self.content_region.width:
84
+ cell = event.screen_x - self.content_region.x
85
+ self.post_message(self.VolumeRequested(max(0, min(VOLUME_CELLS, cell + 1)) * 100 // VOLUME_CELLS))
86
+ event.stop()
87
+
88
+
89
+ class PlayerBar(Horizontal):
90
+ def __init__(self, cover, **kwargs):
91
+ super().__init__(**kwargs)
92
+ self._cover = cover
93
+ self._changes = Changes()
94
+
95
+ def compose(self):
96
+ yield self._cover
97
+ with Vertical(id="player-body"):
98
+ with Horizontal(id="now-row"):
99
+ yield Static(_("No song"), id="now-playing", markup=False)
100
+ with Horizontal(id="controls"):
101
+ for identifier, label, tooltip in CONTROLS:
102
+ button = Button(label, id=identifier,
103
+ variant="primary" if identifier == "pause" else "default")
104
+ button.tooltip = tooltip
105
+ yield button
106
+ with Horizontal(id="volume"):
107
+ yield Button("−", id="quieter")
108
+ yield VolumeBar(level_bar(60), id="volume-bar")
109
+ yield Button("+", id="louder")
110
+ yield Static("60%", id="volume-label", markup=False)
111
+ yield Static("", id="now-detail", markup=False)
112
+ with Horizontal(id="seek"):
113
+ yield Static("0:00", id="elapsed", markup=False)
114
+ yield SeekProgress(total=1, show_percentage=False, show_eta=False, id="progress")
115
+ yield Static("0:00", id="total", markup=False)
116
+
117
+ def on_mount(self):
118
+ self._now_playing = self.query_one("#now-playing", Static)
119
+ self._now_detail = self.query_one("#now-detail", Static)
120
+ self._elapsed = self.query_one("#elapsed", Static)
121
+ self._total = self.query_one("#total", Static)
122
+ self._progress = self.query_one("#progress", ProgressBar)
123
+ self._volume_bar = self.query_one("#volume-bar", Static)
124
+ self._volume_label = self.query_one("#volume-label", Static)
125
+ self._pause_button = self.query_one("#pause", Button)
126
+ self._shuffle_button = self.query_one("#shuffle", Button)
127
+ self._repeat_button = self.query_one("#repeat", Button)
128
+
129
+ def show(self, state, track, source):
130
+ changes = self._changes
131
+ now = Text()
132
+ detail = ""
133
+ if track:
134
+ now.append(f"{'❚❚' if state.paused else '▷'} {clean(track.name)}", style="bold")
135
+ detail = " · ".join(part for part in (artist(track), album(track), source) if part)
136
+ else:
137
+ now.append(_("No song"), style="dim")
138
+ changes.show(self._now_playing, now)
139
+ changes.show(self._now_detail, detail)
140
+ changes.show(self._elapsed, duration(state.position))
141
+ changes.show(self._total, duration(state.duration or getattr(track, "duration", 0)))
142
+ self._progress.update(total=max(1, state.duration or getattr(track, "duration", 0) or 1),
143
+ progress=max(0, state.position))
144
+ changes.show(self._volume_bar, level_bar(state.volume))
145
+ changes.show(self._volume_label, f"{state.volume}%")
146
+ changes.label(self._pause_button, "▷" if state.paused or state.index < 0 else "❚❚")
147
+ self._shuffle_button.set_class(state.shuffle, "active")
148
+ self._repeat_button.set_class(state.repeat != "off", "active")
149
+ changes.label(self._repeat_button, "↻1" if state.repeat == "one" else "↻")
150
+
151
+ @on(Button.Pressed)
152
+ def pressed(self, event):
153
+ event.stop()
154
+ identifier = event.button.id
155
+ if identifier == "pause":
156
+ self.app.action_pause()
157
+ elif identifier in ("next", "previous", "shuffle", "repeat"):
158
+ self.app.control(identifier)
159
+ elif identifier in ("quieter", "louder"):
160
+ self.app.control("volume", -5 if identifier == "quieter" else 5)
161
+
162
+ @on(SeekProgress.SeekRequested)
163
+ def seek_requested(self, event):
164
+ state = self.app.playback.snapshot()
165
+ if state.status in ("Playing", "Paused") and state.duration > 0:
166
+ self.app.control("seek_absolute", round(state.duration * event.fraction, 2))
167
+
168
+ @on(VolumeBar.VolumeRequested)
169
+ def volume_requested(self, event):
170
+ change = event.volume - self.app.playback.snapshot().volume
171
+ if change:
172
+ self.app.control("volume", change)
noneto/ui/quality.py ADDED
@@ -0,0 +1,75 @@
1
+ """Quality badge in the top bar: what was requested, and what mpv actually decodes."""
2
+ from textual.widgets import Static
3
+
4
+ from ..diagnostics import emit
5
+ from ..i18n import _
6
+ from .common import clean
7
+
8
+ CSS = """
9
+ #quality { width: auto; padding: 0 1; text-style: bold; color: $primary; }
10
+ #quality.degraded { color: $warning; }
11
+ """
12
+
13
+ # Requested tier: a ceiling, not a promise. The badge shows what mpv decodes once a track loads.
14
+ QUALITY_LABELS = {
15
+ "LOW": ("AAC 96k", "AAC 96 kbps"),
16
+ "HIGH": ("AAC 320k", "AAC 320 kbps"),
17
+ "LOSSLESS": ("Lossless", "FLAC 16-bit / 44.1 kHz"),
18
+ "HI_RES_LOSSLESS": ("Hi-Res", _("FLAC up to 24-bit / 192 kHz")),
19
+ }
20
+ TIER_RANK = {"LOW": 0, "HIGH": 1, "LOSSLESS": 2, "HI_RES_LOSSLESS": 3}
21
+ TIER_NAMES = {"HIGH": "AAC", "LOSSLESS": _("Lossless 16-bit / 44.1 kHz"), "HI_RES_LOSSLESS": "Hi-Res"}
22
+
23
+
24
+ def offered_tier(track):
25
+ """Best tier TIDAL lists for a track, or None when it does not say."""
26
+ tags = getattr(track, "media_metadata_tags", None) or ()
27
+ if "HIRES_LOSSLESS" in tags:
28
+ return "HI_RES_LOSSLESS"
29
+ if "LOSSLESS" in tags:
30
+ return "LOSSLESS"
31
+ quality = getattr(track, "audio_quality", None)
32
+ return quality if quality in TIER_NAMES else None
33
+
34
+
35
+ class QualityBadge(Static):
36
+ def __init__(self, quality, **kwargs):
37
+ super().__init__("◆", markup=False, **kwargs)
38
+ self.quality = quality
39
+ self._key = None
40
+
41
+ def on_mount(self):
42
+ self.show((), None)
43
+
44
+ def show(self, audio, track):
45
+ """What mpv decodes now; before that, only what was asked for, never as a promise.
46
+
47
+ Getting less than the track offers (within what was asked) is flagged: that is a real loss,
48
+ unlike a track that only exists in 16-bit / 44.1 kHz.
49
+ """
50
+ key = (audio, getattr(track, "id", None))
51
+ if self._key == key:
52
+ return
53
+ self._key = key
54
+ short, detail = QUALITY_LABELS.get(self.quality, (clean(self.quality), clean(self.quality)))
55
+ asked = _("Requested: {short} ({detail}).", short=short, detail=detail)
56
+ best = offered_tier(track)
57
+ degraded = False
58
+ if track is None:
59
+ text, tip = _("Requested: {short}", short=short), f"{asked} {_("While playing, the quality that arrives is shown.")}"
60
+ elif not audio:
61
+ text, tip = "◆ …", f"{asked} {_("Waiting for audio.")}"
62
+ else:
63
+ label, received, tier = audio
64
+ expected = min(TIER_RANK.get(self.quality, 0), TIER_RANK[best]) if best else None
65
+ degraded = expected is not None and tier is not None and TIER_RANK[tier] < expected
66
+ text = f"◇ {label} ↓" if degraded else f"◆ {label}"
67
+ tip = f"{asked} {_("Received: {received}.", received=received)}"
68
+ if best:
69
+ tip += " " + _("This track is available in: {tier}.", tier=TIER_NAMES[best])
70
+ if degraded:
71
+ tip += " " + _("TIDAL delivered less than this track offers.")
72
+ emit("playback.degraded", track_id=getattr(track, "id", None), quality=received)
73
+ self.update(text, layout=True)
74
+ self.tooltip = tip
75
+ self.set_class(degraded, "degraded")
noneto/ui/queue.py ADDED
@@ -0,0 +1,34 @@
1
+ """Queue tab: the songs after the current one."""
2
+ from rich.text import Text
3
+ from textual.containers import VerticalScroll
4
+ from textual.widgets import Static
5
+
6
+ from ..i18n import _
7
+ from .common import artist, clean
8
+
9
+ CSS = """
10
+ #rail { height: 1fr; padding: 0 1; scrollbar-size: 1 1; }
11
+ #up-next { height: auto; color: $text-muted; }
12
+ """
13
+ SHOWN = 100 # longer queues end with "+ N songs"
14
+
15
+
16
+ class QueueList(VerticalScroll):
17
+ def compose(self):
18
+ yield Static(_("No songs in the queue."), id="up-next", markup=False)
19
+
20
+ def show(self, next_tracks):
21
+ up_next = self.query_one("#up-next", Static)
22
+ if not next_tracks:
23
+ up_next.update(_("No songs in the queue."))
24
+ return
25
+ text = Text()
26
+ for number, queued in enumerate(next_tracks[:SHOWN], 1):
27
+ if number > 1:
28
+ text.append("\n")
29
+ text.append(f"{number:>3} ", style="dim")
30
+ text.append(clean(queued.name), style="bold")
31
+ text.append(f" · {artist(queued)}", style="dim")
32
+ if len(next_tracks) > SHOWN:
33
+ text.append("\n\n" + _("+ {count} songs", count=len(next_tracks) - SHOWN))
34
+ up_next.update(text)
noneto/ui/terminal.py ADDED
@@ -0,0 +1,65 @@
1
+ """Console messages shown before the TUI opens (login, logs) and after it closes."""
2
+ import webbrowser
3
+
4
+ from ..errors import AppError, error_label
5
+ from ..i18n import _
6
+ from .login_window import ClipboardUnavailable, WindowUnavailable, clipboard_login, window_login
7
+
8
+
9
+ class Terminal:
10
+ def notify(self, event, **data):
11
+ if event == "logs-ready":
12
+ print(_("Diagnostics: {path}", path=data["path"]))
13
+ elif event == "logs-unavailable":
14
+ print(_("Could not open the diagnostics file."))
15
+ elif event == "welcome":
16
+ print("NONETO CLI")
17
+ elif event == "logout":
18
+ print(_("Local session deleted."))
19
+ elif event == "mpv-installing":
20
+ print(_("Installing mpv (if missing)..."))
21
+ elif event == "mpv-ready":
22
+ print(_("mpv ready: {path}", path=data["path"]))
23
+ elif event == "bye":
24
+ print("\n" + _("Goodbye."))
25
+ elif event == "error":
26
+ error = data["error"]
27
+ if isinstance(error, AppError):
28
+ print(f"\n{error}")
29
+ else:
30
+ print("\n" + _("The operation could not be completed ({label}).", label=error_label(error)))
31
+ print(_("Check your connection and your account. To sign in again: noneto --logout"))
32
+ elif event == "session-restored":
33
+ print(_("Session restored."))
34
+ elif event == "session-invalid":
35
+ print(_("Could not restore the session. Please sign in again."))
36
+ elif event == "session-upgrade":
37
+ print(_("Your session is an older type without Hi-Res access. Please sign in again (only this once)."))
38
+ elif event == "authorize-window":
39
+ print(_("Sign in in the TIDAL window that just opened. It closes by itself when you are done."))
40
+ elif event == "authorize-browser":
41
+ print("\n" + _("Could not open the window. Sign in to TIDAL in your browser:"))
42
+ print(data["url"])
43
+ print("\n" + _("When you finish, TIDAL shows an error page (\"Oops\"). That is expected."))
44
+ print(_("Copy that page's address (Ctrl+L, Ctrl+C): Noneto picks it up by itself. (Ctrl+C here cancels)"))
45
+ elif event == "session-started":
46
+ print(_("Signed in."))
47
+
48
+ def ask(self, question, **data):
49
+ if question != "redirect":
50
+ raise ValueError(question)
51
+ self.notify("authorize-window")
52
+ try:
53
+ return window_login(data["url"], data["redirect"])
54
+ except WindowUnavailable:
55
+ pass
56
+ self.notify("authorize-browser", url=data["url"])
57
+ try:
58
+ webbrowser.open(data["url"])
59
+ except webbrowser.Error:
60
+ pass
61
+ try:
62
+ return clipboard_login(data["redirect"])
63
+ except ClipboardUnavailable:
64
+ print(_("Could not read the clipboard. Paste the final URL to continue."))
65
+ return input(_("Redirect URL: ")).strip()