Phase 2: PS1 library scan, settings, conversion queue, and PS1 tab
This commit is contained in:
@@ -6,6 +6,7 @@ archives, a remote HTTPS store server, etc.
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import tempfile
|
||||
import urllib.parse
|
||||
@@ -200,6 +201,53 @@ class FileCopySource(Source):
|
||||
return dest
|
||||
|
||||
|
||||
class Ps1ConvertSource(Source):
|
||||
"""Convert a PS1 disc image (.cue/.iso) into an EBOOT.PBP.
|
||||
|
||||
``item`` must carry ``source`` (path to the .cue or single image),
|
||||
``title`` and ``game_id``. ``base_pbp`` is a PSN PS1 classic EBOOT used to
|
||||
supply the encrypted DATA.PSP loader and STARTDAT block.
|
||||
"""
|
||||
|
||||
label = "PS1 convert"
|
||||
|
||||
def __init__(self, base_pbp):
|
||||
self.base_pbp = Path(base_pbp)
|
||||
|
||||
def scan(self, root=None):
|
||||
return []
|
||||
|
||||
def download(self, item, dest_dir, progress_cb=None, cancel_event=None):
|
||||
dest_dir = Path(dest_dir)
|
||||
dest_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
source = Path(item["source"])
|
||||
title = str(item.get("title") or source.stem)
|
||||
game_id = item.get("game_id")
|
||||
if not game_id:
|
||||
raise RuntimeError("missing game_id for PS1 conversion")
|
||||
|
||||
safe = re.sub(r'[<>:"/\\|?*]', " ", title).strip() or "PS1 game"
|
||||
out_path = dest_dir / f"{safe} ({game_id}).pbp"
|
||||
if out_path.exists():
|
||||
raise FileExistsError(str(out_path))
|
||||
|
||||
def cb(done, total):
|
||||
if progress_cb is not None and total:
|
||||
progress_cb("Converting", min(done / total, 1.0), "")
|
||||
|
||||
from . import ps1_convert
|
||||
|
||||
try:
|
||||
ps1_convert.convert(
|
||||
source, title, game_id, self.base_pbp, out_path,
|
||||
progress_cb=cb, cancel_event=cancel_event,
|
||||
)
|
||||
except ps1_convert.Cancelled:
|
||||
raise TransferCancelled() from None
|
||||
return out_path
|
||||
|
||||
|
||||
class TreeCopySource(Source):
|
||||
"""Copy a whole directory (save-data folder) into a destination directory."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user