Created
February 14, 2024 03:04
-
-
Save al3xtjames/944b6e8463f9fa511aa03f9c512bf285 to your computer and use it in GitHub Desktop.
gallery-dl wrapper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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