Add YAPF style + ignore, and format tracked Python files
This commit is contained in:
@@ -38,9 +38,10 @@ class Bandcamp(Provider):
|
||||
# Bandcamp discography lives under /music.
|
||||
return base.rstrip("/") + "/music"
|
||||
|
||||
def _scrape_artist_page(
|
||||
self, page: Any, artist_url: str, limit: int = 50
|
||||
) -> List[SearchResult]:
|
||||
def _scrape_artist_page(self,
|
||||
page: Any,
|
||||
artist_url: str,
|
||||
limit: int = 50) -> List[SearchResult]:
|
||||
"""Scrape an artist page for albums/tracks (discography)."""
|
||||
base = self._base_url(artist_url)
|
||||
discography_url = self._discography_url(artist_url)
|
||||
@@ -75,7 +76,8 @@ class Bandcamp(Provider):
|
||||
else:
|
||||
target = base.rstrip("/") + "/" + href
|
||||
|
||||
title_node = item.query_selector("p.title") or item.query_selector(".title")
|
||||
title_node = item.query_selector("p.title"
|
||||
) or item.query_selector(".title")
|
||||
title = title_node.inner_text().strip() if title_node else ""
|
||||
if title:
|
||||
title = " ".join(title.split())
|
||||
@@ -83,7 +85,8 @@ class Bandcamp(Provider):
|
||||
title = target.rsplit("/", 1)[-1]
|
||||
|
||||
kind = (
|
||||
"album" if "/album/" in target else ("track" if "/track/" in target else "item")
|
||||
"album" if "/album/" in target else
|
||||
("track" if "/track/" in target else "item")
|
||||
)
|
||||
|
||||
results.append(
|
||||
@@ -95,9 +98,12 @@ class Bandcamp(Provider):
|
||||
annotations=[kind],
|
||||
media_kind="audio",
|
||||
columns=[
|
||||
("Title", title),
|
||||
("Type", kind),
|
||||
("Url", target),
|
||||
("Title",
|
||||
title),
|
||||
("Type",
|
||||
kind),
|
||||
("Url",
|
||||
target),
|
||||
],
|
||||
full_metadata={
|
||||
"type": kind,
|
||||
@@ -112,7 +118,12 @@ class Bandcamp(Provider):
|
||||
return results
|
||||
|
||||
def selector(
|
||||
self, selected_items: List[Any], *, ctx: Any, stage_is_last: bool = True, **_kwargs: Any
|
||||
self,
|
||||
selected_items: List[Any],
|
||||
*,
|
||||
ctx: Any,
|
||||
stage_is_last: bool = True,
|
||||
**_kwargs: Any
|
||||
) -> bool:
|
||||
"""Handle Bandcamp `@N` selection.
|
||||
|
||||
@@ -128,7 +139,8 @@ class Bandcamp(Provider):
|
||||
# Only handle artist selections.
|
||||
chosen: List[Dict[str, Any]] = []
|
||||
for item in selected_items or []:
|
||||
payload: Dict[str, Any] = {}
|
||||
payload: Dict[str,
|
||||
Any] = {}
|
||||
if isinstance(item, dict):
|
||||
payload = item
|
||||
else:
|
||||
@@ -140,11 +152,21 @@ class Bandcamp(Provider):
|
||||
if not payload:
|
||||
try:
|
||||
payload = {
|
||||
"title": getattr(item, "title", None),
|
||||
"url": getattr(item, "url", None),
|
||||
"path": getattr(item, "path", None),
|
||||
"metadata": getattr(item, "metadata", None),
|
||||
"extra": getattr(item, "extra", None),
|
||||
"title": getattr(item,
|
||||
"title",
|
||||
None),
|
||||
"url": getattr(item,
|
||||
"url",
|
||||
None),
|
||||
"path": getattr(item,
|
||||
"path",
|
||||
None),
|
||||
"metadata": getattr(item,
|
||||
"metadata",
|
||||
None),
|
||||
"extra": getattr(item,
|
||||
"extra",
|
||||
None),
|
||||
}
|
||||
except Exception:
|
||||
payload = {}
|
||||
@@ -154,7 +176,10 @@ class Bandcamp(Provider):
|
||||
meta = {}
|
||||
extra = payload.get("extra")
|
||||
if isinstance(extra, dict):
|
||||
meta = {**meta, **extra}
|
||||
meta = {
|
||||
**meta,
|
||||
**extra
|
||||
}
|
||||
|
||||
type_val = str(meta.get("type") or "").strip().lower()
|
||||
if type_val != "artist":
|
||||
@@ -169,7 +194,11 @@ class Bandcamp(Provider):
|
||||
continue
|
||||
|
||||
chosen.append(
|
||||
{"title": title, "url": base, "location": str(meta.get("artist") or "").strip()}
|
||||
{
|
||||
"title": title,
|
||||
"url": base,
|
||||
"location": str(meta.get("artist") or "").strip()
|
||||
}
|
||||
)
|
||||
|
||||
if not chosen:
|
||||
@@ -211,8 +240,12 @@ class Bandcamp(Provider):
|
||||
results_payload.append(
|
||||
{
|
||||
"table": "bandcamp",
|
||||
"title": getattr(r, "title", ""),
|
||||
"path": getattr(r, "path", ""),
|
||||
"title": getattr(r,
|
||||
"title",
|
||||
""),
|
||||
"path": getattr(r,
|
||||
"path",
|
||||
""),
|
||||
}
|
||||
)
|
||||
|
||||
@@ -234,7 +267,8 @@ class Bandcamp(Provider):
|
||||
self,
|
||||
query: str,
|
||||
limit: int = 50,
|
||||
filters: Optional[Dict[str, Any]] = None,
|
||||
filters: Optional[Dict[str,
|
||||
Any]] = None,
|
||||
**kwargs: Any,
|
||||
) -> List[SearchResult]:
|
||||
if sync_playwright is None:
|
||||
@@ -305,10 +339,14 @@ class Bandcamp(Provider):
|
||||
annotations=[media_type],
|
||||
media_kind="audio",
|
||||
columns=[
|
||||
("Title", title),
|
||||
("Location", artist),
|
||||
("Type", media_type),
|
||||
("Url", base_url or str(target_url or "")),
|
||||
("Title",
|
||||
title),
|
||||
("Location",
|
||||
artist),
|
||||
("Type",
|
||||
media_type),
|
||||
("Url",
|
||||
base_url or str(target_url or "")),
|
||||
],
|
||||
full_metadata={
|
||||
"artist": artist,
|
||||
|
||||
Reference in New Issue
Block a user