updated bandcamp and list parsing
This commit is contained in:
+20
-2
@@ -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,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user