Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(revisited) Civitai How-to implement?? 'save text prompt' 6693ae1 / #6383 #6867

Open
earthyrock opened this issue Jan 22, 2025 · 0 comments
Open

Comments

@earthyrock
Copy link

The below is generally to anyone that can help. Thanks to Mikf for your previous work.

My apologies. after Mikf responded, I fell sick and didn't have the energy to follow-up on the previous posted question and his reply. Better now. Not a high priority, but when/if anyone familiar w/ how-to, might have time... Humbly, any advice is appreciated from anyone.

Copied from original query:

PROBLEM:
Sorry to bother, but am confused over how to properly implement 6693ae1 stemming from #6383.
I attempted to enter into my .bat & .conf some semblance of what I gleaned from the above (a very incomplete job), and "think it should(?)" result in some type of .txt file as an output - alongside the .jpg/.png/.mp4(??). Currently I get no .txt file. I understand I'm missing something (sad face). If you could point out what/where my .bat / .conf are lacking, I'd appreciate it.

Mikf had responded w/ the following:

You need a metadata post processor to write metadata to disk. The simplest way would be to use --write-metadata or "postprocessors": "metadata", but that writes all metadata to a .json file.
To be a bit more specific with what data to write, use something like

{
    "metadata": true,
    "postprocessors": {
        "name": "metadata",
        "extension": "txt",
        "format": [
            "prompt: {generation[meta][prompt]}",
            "negativePrompt: {generation[meta][negativePrompt]}"
        ]
    }
}

VERY unsure of my use of --o metadata=1 in the .bat, below.

--o metadata=1 "works" at the moment as long as gallery-dl does not have another command-line option starting with o, but it really should be either -o metadata=1 (one -) or --option metadata=1

Thanks for the above Mikf. I tried to figure out the how/where of the postprocessors but just a bunch of fails on my end. Trying the simplest integration, "at best" I was generating empty json files., "At worst," trying something else was getting no txt files whatsoever. Of the latter options, I preferred --option metadata=1 in my bat, so my conf is really lacking. I copy/pasted the original conf rather than the broken copy, something I know doesn't work.
If not asking too much, I don't suppose someone could "plug-and'play" w/ my below conf and the above postprocessors? I obviously have no idea where it properly goes.

bat

"c:\Users\AdminS6\gallery-dl\gallery-dl.exe" --dest "..\..\..\Civitai" --option metadata=1 --download-archive "%~dp0GDB.sqlite3" "https://civitai.com/user/kimpureh/images"
"c:\Users\AdminS6\gallery-dl\gallery-dl.exe" --dest "..\..\..\Civitai" --option metadata=1 --download-archive "%~dp0GDB.sqlite3" "https://civitai.com/user/kimpureh/videos"

conf

{
    "extractor":
    {
        "base-directory": "",
        "archive": null,
        "cookies": null,
        "cookies-update": false,
        "proxy": null,
        "skip": true,
        "sleep": 0,
        "path-replace": "_",
        "path-remove": "\\u0000-\\u001f\\u007f",
        "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36",

        "postprocessors": [
            {
                "name": "ugoira",
                "whitelist": ["pixiv", "danbooru"],
                "extension": "mp4",
                "keep-files": false,
                "ffmpeg-twopass": false,
                "ffmpeg-args": ["-hide_banner", "-loglevel", "quiet", "-c:v", "libx264", "-b:v", "2M", "-preset", "veryfast", "-pix_fmt", "yuv420p"],
                "ffmpeg-location": "G:\\00OSz\\12win10b zEnt-LTSC 1809 x64\\05Apps\\Multimedia\\Video\\Installed\\ffmpeg\\bin\\ffmpeg.exe"
            },
            {
                "name": "metadata",
                "whitelist": ["danbooru", "yandere", "sankaku"],
                "mode": "tags"
            }
        ],

        "path-restrict": {
            "\\": "⧹",
            "/" : "⧸",
            "|" : "│",
            ":" : "꞉",
            "*" : "∗",
            "?" : "?",
            "\"": "″",
            "<" : "﹤",
            ">" : "﹥"
        },

        "civitai":
        {
            "directory": ["{user['username']}"],
            "filename": "{filename[:50]} - {uuid}.{extension}",
            "api"     : "trpc",
            "files"   : ["image"],
            "include" : ["user-models", "user-posts"],
            "metadata": ["generation"],
            "nsfw"    : true,
            "quality" : "original=true",
            "sleep-request": "0.5-1.5"
        },

        "deviantart":
        {
            "directory": [],
            "filename": "{index} - {title[:50]}.{extension}",
            "auto-watch": true,
            "auto-unwatch": true,
            "client-id": "removed",
            "client-secret": "removed",
            "cookies": "G:\\00OSz\\12win10b zEnt-LTSC 1809 x64\\05Apps\\Multimedia\\Pictures\\Installed\\gallery-dl\\Support\\aUseful .bat's\\Cookies\\www.deviantart.com_cookies.txt",
            "cookies-update": true,
            "extra": false,
            "flat": true,
            "folders": false,
            "journals": "html",
            "mature": true,
            "metadata": false,
            "original": true,
            "quality": 100,
            "refresh-token": "cache",
            "wait-min": "0.5-1.5"
        },

        "exhentai":
        {
            "directory": ["{title[:100]}"],
            "filename": "{num:>04}_{name[:50]}.{extension}",
            "username": "removed",
            "password": "removed"
        },

        "imgur":
        {
            "image": {
                "directory": ["Imgur", "{album['account']['username']}"],
                "filename": "{album['title'][:50]}.{extension}"
            },
            "album": {
                "directory": ["Imgur", "{album['account']['username']}", "{album['title']}"],
                "filename": "{album['title'][:50]}.{extension}"
            },
            "mp4": true,
            "postprocessors": [
                {
                    "name": "metadata",
                    "filter": "description",
                    "format": "{description}"
                }
            ]
        },

        "instagram":
        {
            "directory": [],
            "cookies": "G:\\00OSz\\12win10b zEnt-LTSC 1809 x64\\05Apps\\Multimedia\\Pictures\\Installed\\gallery-dl\\Support\\aUseful .bat's\\Cookies\\www.instagram.com_cookies.txt",
            "cookies-update": true,
            "sleep-request" : "6.0-12.0",
            "sleep": "2-10",
            "wait-min": 0,
            "wait-max": 8,
            "videos": true
        },

        "kemonoparty":
        {
            "directory": ["{username} - {service} - {user}"],
            "filename": "{filename[:50]} - {title[:50]} - {tags[:75]}.{extension}",
            "metadata": true
        },

        "oauth":
        {
            "browser": true,
            "cache": true,
            "port": 6414
        },

        "pinterest":
        {
            "directory": ["{board['owner']['username']} - {board['name']}"],
            "filename": "{board['owner']['username']} - {title[:50]}.{extension}"
        },

        "pixiv":
        {
            "directory": [],
            "filename": "{filename} - {title} - {tags[:150]}.{extension}",
            "refresh-token": "cache",
            "avatar": false,
            "wait-min": 0,
            "wait-max": 0.2,
            "ugoira": true
        },

        "reddit":
        {
            "subreddit":
            {
            },
            "submission":
            {
            },
            "image":
            {
            },
            "user":
            {
            },

            "parent-directory": true,
            "parent-metadata": "_reddit_",

            "comments": 0,
            "morecomments": false,
            "previews": true,
            "recursion": 1,
            "videos": "ytdl",
            "fallback": true,
            "sleep-request": [0.2, 2.4],
            "date-format": "%Y-%m-%dT%H:%M:%S",
            "blacklist": ["twitter", "instagram", "tumblr", "flickr", "behance", "artstation"]
         },

        "reddit>imgur":
        {
            "directory": ["Imgur", "{_reddit_[author]}"],
            "filename": "{_reddit_[author]} - {_reddit_[title][:50]}.{extension}",
            "client-id": "removed",
            "user-agent": "Python:gallery-dl-20241122:v1.0 (by /u/earthyrock)"
        },

        "reddit>redgifs":
        {
            "directory": ["RedGIFs", "{_reddit_[author]}"],
            "filename": "{_reddit_[author]} - {_reddit_[title][:50]}.{extension}",
            "client-id": "removed",
            "user-agent": "Python:gallery-dl-20241122:v1.0 (by /u/earthyrock)"
        },

        "redgifs":
        {
            "directory": ["RedGIFs", "{userName}"],
            "filename": "{userName} - {filename[:50]}.{extension}"
        },

        "twitter":
        {
            "directory": ["{user['name']}"],
            "filename": "{content[:175]} - {conversation_id} - {num}.{extension}",
            "username": "removed",
            "password": "removed",
            "cards": false,
            "conversations": false,
            "pinned": false,
            "quoted": false,
            "replies": true,
            "retweets": false,
            "text-tweets": false,
            "twitpic": false,
            "users": "timeline",
            "videos": true
        }
    },

    "downloader":
    {
        "part": true,
        "part-directory": null,

        "http":
        {
            "adjust-extensions": true,
            "mtime": true,
            "rate": null,
            "retries": 4,
            "timeout": 30.0,
            "verify": true
        },

        "ytdl":
        {
            "format": null,
            "forward-cookies": false,
            "mtime": true,
            "outtmpl": null,
            "rate": null,
            "retries": 4,
            "timeout": 30.0,
            "verify": true
        }
    },

    "output":
    {
        "mode": "auto",
        "progress": true,
        "shorten": true,
        "log": "[{name}][{levelname}] {message}",
        "logfile": null,
        "unsupportedfile": null
    },

    "postprocessor":
    {
        "gif to mp4":
        {
            "name": "exec",
            "async"  : false,
            "command": "\"G:\\00OSz\\12win10b zEnt-LTSC 1809 x64\\05Apps\\Multimedia\\Video\\Installed\\ffmpeg\\bin\\ffmpeg.exe\" -i {} {}.mp4 && del {}",
            "event"  : "after",
            "filter": "extension == 'gif'"
        }
    },

    "netrc": false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant