Skip to content

Instantly share code, notes, and snippets.

@al3xtjames
Created February 14, 2024 03:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save al3xtjames/944b6e8463f9fa511aa03f9c512bf285 to your computer and use it in GitHub Desktop.
Save al3xtjames/944b6e8463f9fa511aa03f9c512bf285 to your computer and use it in GitHub Desktop.
gallery-dl wrapper
#!/usr/bin/env python3
import os
import subprocess
import tempfile
try:
editor = os.environ.get("EDITOR")
except KeyError:
print("EDITOR unset", file=sys.stderr)
os.exit(1)
def run(args):
try:
subprocess.run(args, check=True)
except:
exit(1)
with tempfile.NamedTemporaryFile() as fp:
fp.write(b"\n# Enter links (one per line)")
fp.flush()
run([editor, fp.name])
fp.seek(0)
lines = [line.decode().strip() for line in fp.readlines()]
links = [link for link in lines if len(link) > 0 and link[0] != '#']
run(["gallery-dl", "--write-metadata"] + links)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment