v0.18.0: paste a link, get the song

File > Import from URL... runs trav's `song` helper (yt-dlp --extract-audio
--audio-format mp3) from inside the app. Everything at the link downloads to
a private temp dir and is imported as each song lands. "and add to current
playlist?" puts the batch above the selected song, else at the end of the
playing playlist, else at the end of the shown one, in the link's order.
Each song goes straight into Identify Track. With no AcoustID key, the
proposal comes from the filename alone.

Album art now opens on a single click, in a window shaped like the cover
and as big as the screen allows.

Also fixed the dev fixture's play journal, which crashed startup (wrong
shape) and would have been ignored anyway (wrong keys). The loader now
skips a journal it can't read instead of aborting.

Claude-Session: https://claude.ai/code/session_01R5m9mXFPHNro78BdD69mG2
This commit is contained in:
2026-09-10 23:44:45 -05:00
parent 3d19b0de0a
commit d335e9144b
13 changed files with 1179 additions and 33 deletions
+63
View File
@@ -0,0 +1,63 @@
"""File ▸ Import from URL…: paste a link, optionally add to the current playlist.
Passive, like IdentifyDialog: the caller works out where the songs would go
(``url_import.resolve_target``) and passes its description in. The dialog only
reports the link and whether the box was ticked.
"""
from PyQt6.QtWidgets import (
QApplication, QCheckBox, QDialog, QDialogButtonBox, QLabel, QLineEdit,
QVBoxLayout,
)
from lintunes.url_import import looks_like_url
class UrlImportDialog(QDialog):
def __init__(self, target_description: str | None, parent=None):
super().__init__(parent)
self.setWindowTitle("Import from URL")
self.setMinimumWidth(460)
layout = QVBoxLayout(self)
layout.addWidget(QLabel("Paste a link to a song, or to a playlist of "
"songs:"))
self._url = QLineEdit()
self._url.setPlaceholderText("https://…")
clipboard = QApplication.clipboard().text().strip()
if looks_like_url(clipboard):
self._url.setText(clipboard)
self._url.selectAll()
layout.addWidget(self._url)
self._add = QCheckBox("and add to current playlist?")
layout.addWidget(self._add)
self._hint = QLabel(target_description
or "Select or play a playlist to add songs to it.")
self._hint.setEnabled(False) # the greyed-hint idiom
self._hint.setWordWrap(True)
self._hint.setContentsMargins(22, 0, 0, 0)
layout.addWidget(self._hint)
if target_description is None:
self._add.setEnabled(False)
else:
self._add.setChecked(True)
buttons = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok
| QDialogButtonBox.StandardButton.Cancel)
self._ok = buttons.button(QDialogButtonBox.StandardButton.Ok)
self._ok.setText("Import")
buttons.accepted.connect(self.accept)
buttons.rejected.connect(self.reject)
layout.addWidget(buttons)
self._url.textChanged.connect(self._update_ok)
self._update_ok()
def _update_ok(self):
self._ok.setEnabled(looks_like_url(self._url.text()))
def url(self) -> str:
return self._url.text().strip()
def add_to_playlist(self) -> bool:
return self._add.isEnabled() and self._add.isChecked()