mikf / gallery-dl

Command-line program to download image galleries and collections from several image hosting sites
GNU General Public License v2.0
11.35k stars 925 forks source link

[Fanbox] Missing metadata #3784

Open Eradicate2968 opened 1 year ago

Eradicate2968 commented 1 year ago
    "fanbox":
    {
        "#": "override global archive path for fanbox",
        "archive": "~/gallery-dl/archives/archive-fanbox.sqlite3",

        "#": "set custom directory and filename format strings for all fanbox downloads",
        "filename": "{title}{num}.{extension}",
        "directory": ["fanbox", "{creatorId}", "{title}"],
        "postprocessors": [{
            "name" : "metadata",
            "mode" : "custom",
            "event": "post",
            "filename": "{title}.txt",
            "extension": "txt",
            "format": "{content}\n{embed[url]:?/\n/}"
        }]
    },

This is my config for Fanbox. There is an imgur link on every fanbox post but the text file will always say "None" whereas it should have the imgur link.

I have tried changing the "postprocessor" section to what I use for Kemono to get the error

fanbox: An unexpected error occurred: NameError - name 'embed' is not defined. Please run gallery-dl again with the --verbose flag, copy its output and report this issue on https://github.com/mikf/gallery-dl/issues

`>` "postprocessors": [
                {
            "name": "metadata",
                    "event": "post",
                    "filename": "{title}.txt",

                "filter": "embed.get('url') or re.search(r'(?i (redgifs|atomicloli|gfycat|google|drive|onedrive|1drv|mega|xgf|k00|koofr|gigafile|mediafire|porn3dx|gofile|dropbox)', content)",
                    "#": "write text content and external URLs",
                    "mode": "custom",
                    "format": "{content}\n{embed[url]:?/\n/}",

                    "#": "onlx write file if there is an external link present",
                    "filter": "embed.get('url') or re.search(r'(?i)(gigafile|xgf|1drv|mediafire|mega|google|drive)', content)"
                }
            ]

I have done "gallery -dl -K fanboxlink" to find that the text i need is in a category called "excerpt" but I do not know how to make my config fetch the "excerpt" as I am new to this.

Any help would be appreciated.

mikf commented 1 year ago

I have done "gallery -dl -K fanboxlink" to find that the text i need is in a category called "excerpt" but I do not know how to make my config fetch the "excerpt" as I am new to this.

Change "format" to include excerpt instead of content.

You can't just copy-paste a post processor specific to kemono and expect it work for fanbox, at least not without changing anything site-specific.

For fanbox, text content can be in several different places, depending on post type and where the author put it. content, html, text, and excerpt (although that's just a short version of the whole thing) can all contain text. Maybe there's even more.

    {
        "name": "metadata",
        "event": "post",
        "filename": "{title}.txt",

        "#": "write text content",
        "format": [
            "{content:?//}",
            "{html:?//}",
            "{text:?//}",
            "{excerpt:?//}"
        ]
    }

(:?// at the end makes it not crash when a field is not defined)

Eradicate2968 commented 1 year ago

Thank you its now grabbing the imgur links.

Is there also a way to grab the images from the imgur link from the fanbox post? Or do I have to input the imgur link into gallery-dl?

mikf commented 1 year ago

You have to (manually) input them into gallery-dl, I'm afraid, or you use r:file//... like in https://github.com/mikf/gallery-dl/issues/3743#issuecomment-1460007721 to have gdl fetch URLs from a text file.