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,
|
||||
|
||||
Reference in New Issue
Block a user