forked from trav/lintunes
v0.22.1: not a bot
Import from URL now gets past YouTube's "Sign in to confirm you're not a bot": a run that downloads nothing for that reason retries once with yt-dlp's --cookies-from-browser (Firefox first), and a browser that worked is remembered in this machine's config.json so later imports send the cookies from the start.
This commit is contained in:
@@ -16,6 +16,7 @@ from lintunes.andtunes import sync as andtunes_sync
|
||||
from lintunes.art_search import AlbumArtFetcher
|
||||
from lintunes.cast.controller import CastController
|
||||
from lintunes.eventlog import log_control
|
||||
from lintunes.config import load_config, save_config
|
||||
from lintunes.export import exporter
|
||||
from lintunes.fingerprint import TrackIdentifier, fpcalc_available
|
||||
from lintunes.inhibit import INHIBIT_LOGOUT, INHIBIT_SUSPEND, SleepInhibitor
|
||||
@@ -1161,7 +1162,10 @@ class MainWindow(QMainWindow):
|
||||
self._url_note = (f"tags proposed from filenames only ({problem})"
|
||||
if problem else "")
|
||||
|
||||
worker = url_import.UrlImportWorker(dialog.url(), self)
|
||||
worker = url_import.UrlImportWorker(
|
||||
dialog.url(), self,
|
||||
cookies_browser=load_config().get(url_import.COOKIES_KEY))
|
||||
worker.cookies_used.connect(self._remember_cookies_browser)
|
||||
worker.item_started.connect(self._on_url_item_started)
|
||||
worker.progress.connect(self._sync_progress.setValue)
|
||||
worker.downloaded.connect(self._on_url_downloaded)
|
||||
@@ -1176,6 +1180,15 @@ class MainWindow(QMainWindow):
|
||||
self._sync_progress.show()
|
||||
worker.start()
|
||||
|
||||
def _remember_cookies_browser(self, browser: str):
|
||||
"""A bot-checked link got through on this browser's cookies: send
|
||||
them from the start next time. config.json, not preferences — the
|
||||
browser holding a YouTube login is this machine's business."""
|
||||
config = load_config()
|
||||
if config.get(url_import.COOKIES_KEY) != browser:
|
||||
config[url_import.COOKIES_KEY] = browser
|
||||
save_config(config)
|
||||
|
||||
def _on_url_item_started(self, index: int, count: int, title: str):
|
||||
short = title if len(title) <= 40 else title[:39] + "…"
|
||||
where = f"{index} of {count} · " if count > 1 else ""
|
||||
|
||||
Reference in New Issue
Block a user