Add All filter to NoPayStation store source
This commit is contained in:
+12
-3
@@ -506,11 +506,19 @@ class NoPayStationSource(Source):
|
||||
def __init__(self, content_type, tsv_url="", force=False):
|
||||
from . import nopaystation
|
||||
self.content_type = content_type
|
||||
self.tsv_url = tsv_url or nopaystation.tsv_url(content_type)
|
||||
self.tsv_url = tsv_url or ("" if content_type == "all" else nopaystation.tsv_url(content_type))
|
||||
self.force = force
|
||||
|
||||
def scan(self, root=None):
|
||||
from . import nopaystation
|
||||
if self.content_type == "all":
|
||||
items = []
|
||||
for ct in ("psp", "psx", "theme", "dlc"):
|
||||
try:
|
||||
items.extend(nopaystation.fetch_items(ct, force=self.force))
|
||||
except Exception: # noqa: BLE001 - skip a source that fails
|
||||
log.warning("could not fetch NoPayStation %s list", ct)
|
||||
return items
|
||||
return nopaystation.fetch_items(self.content_type, self.tsv_url, force=self.force)
|
||||
|
||||
def download(self, item, dest_dir, progress_cb=None, cancel_event=None):
|
||||
@@ -520,6 +528,7 @@ class NoPayStationSource(Source):
|
||||
|
||||
# The bundled Python decryptor handles PSP/PSX/themes/DLC directly.
|
||||
title_id = item.get("title_id") or item.get("content_id") or ""
|
||||
item_ct = item.get("content_type") or self.content_type
|
||||
pkg_name = re.sub(r"[^A-Za-z0-9_-]", "", title_id) or "pkg"
|
||||
tmp = Path(tempfile.mkdtemp(prefix="nps-download-"))
|
||||
pkg = tmp / f"{pkg_name}.pkg"
|
||||
@@ -527,10 +536,10 @@ class NoPayStationSource(Source):
|
||||
if progress_cb is not None:
|
||||
progress_cb("Downloading", 0.0, "")
|
||||
download_url(item["pkg_url"], pkg, None, progress_cb, cancel_event)
|
||||
kind_hint = self.content_type if self.content_type in ("theme", "dlc") else None
|
||||
kind_hint = item_ct if item_ct in ("theme", "dlc") else None
|
||||
folder = nopaystation.extract_pkg(pkg, title_id, dest_dir,
|
||||
kind_hint, progress_cb, cancel_event)
|
||||
if self.content_type in ("theme", "dlc"):
|
||||
if item_ct in ("theme", "dlc"):
|
||||
_write_sidecar(folder, item)
|
||||
return folder
|
||||
finally:
|
||||
|
||||
Reference in New Issue
Block a user