updated bandcamp and list parsing

This commit is contained in:
2026-04-13 14:28:38 -07:00
parent 01f5e35b61
commit 97e310be70
5 changed files with 182 additions and 14 deletions
+20 -2
View File
@@ -16,6 +16,15 @@ class Bandcamp(Provider):
TABLE_AUTO_STAGES = {
"bandcamp": ["download-file"],
}
AUTO_STAGE_USE_SELECTION_ARGS = True
@staticmethod
def _download_selection_args(target_url: str, media_type: str) -> Optional[List[str]]:
target = str(target_url or "").strip()
kind = str(media_type or "").strip().lower()
if not target or kind == "artist":
return None
return ["-url", target]
@staticmethod
def _base_url(raw_url: str) -> str:
@@ -89,6 +98,8 @@ class Bandcamp(Provider):
"album" if "/album/" in target else
("track" if "/track/" in target else "item")
)
selection_args = self._download_selection_args(target, kind)
selection_action = (["download-file"] + selection_args) if selection_args else None
results.append(
SearchResult(
@@ -111,6 +122,8 @@ class Bandcamp(Provider):
"url": target,
"artist_url": base,
},
selection_args=selection_args,
selection_action=selection_action,
)
)
except Exception as exc:
@@ -318,6 +331,8 @@ class Bandcamp(Provider):
itemtype = item.query_selector(".itemtype")
media_type = itemtype.inner_text().strip() if itemtype else "album"
selection_args = self._download_selection_args(str(target_url or ""), media_type)
selection_action = (["download-file"] + selection_args) if selection_args else None
results.append(
SearchResult(
@@ -335,13 +350,16 @@ class Bandcamp(Provider):
("Type",
media_type),
("Url",
base_url or str(target_url or "")),
str(target_url or "")),
],
full_metadata={
"artist": artist,
"type": media_type,
"url": base_url or str(target_url or ""),
"url": str(target_url or ""),
"artist_url": base_url,
},
selection_args=selection_args,
selection_action=selection_action,
)
)