gif
This commit is contained in:
@@ -83,11 +83,13 @@ def _detect_kind(ext: str) -> str:
|
||||
return "unknown"
|
||||
|
||||
|
||||
def _allowed(source_kind: str, target_kind: str) -> bool:
|
||||
def _allowed(source_kind: str, target_kind: str, target_ext: str = "") -> bool:
|
||||
if source_kind == target_kind:
|
||||
return True
|
||||
if source_kind == "video" and target_kind == "audio":
|
||||
return True
|
||||
if source_kind == "video" and target_kind == "image" and target_ext.lower().lstrip(".") == "gif":
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
@@ -173,7 +175,7 @@ CMDLET = Cmdlet(
|
||||
SharedArgs.DELETE,
|
||||
],
|
||||
detail=[
|
||||
"Allows video↔video, audio↔audio, image↔image, doc↔doc, and video→audio conversions.",
|
||||
"Allows video↔video, audio↔audio, image↔image, doc↔doc, video→audio, and video→gif conversions.",
|
||||
"Disallows incompatible conversions (e.g., video→pdf).",
|
||||
"Uses ffmpeg for media and pypandoc-binary (bundled pandoc) for document formats (mobi/epub→pdf/txt/etc); PDF output uses the tectonic LaTeX engine when available.",
|
||||
],
|
||||
@@ -250,7 +252,7 @@ def _run(result: Any, args: Sequence[str], config: Dict[str, Any]) -> int:
|
||||
source_ext = input_path.suffix.lower().lstrip(".")
|
||||
source_kind = _detect_kind(source_ext)
|
||||
|
||||
if not _allowed(source_kind, target_kind):
|
||||
if not _allowed(source_kind, target_kind, target_fmt):
|
||||
log(
|
||||
f"Conversion from {source_kind or 'unknown'} to {target_kind} is not allowed",
|
||||
file=sys.stderr,
|
||||
|
||||
@@ -109,6 +109,14 @@ class Download_File(Cmdlet):
|
||||
debug(f"[download-file] run invoked with args: {list(args)}")
|
||||
return self._run_impl(result, args, config)
|
||||
|
||||
@staticmethod
|
||||
def _path_from_download_result(result_obj: Any) -> Path:
|
||||
"""Normalize downloader return values to a concrete filesystem path."""
|
||||
resolved = coerce_to_path(result_obj)
|
||||
if resolved is None:
|
||||
raise DownloadError("Could not determine downloaded file path")
|
||||
return resolved
|
||||
|
||||
def _process_explicit_urls(
|
||||
self,
|
||||
*,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user