mikf / gallery-dl

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

[Postimg] Parent metadata missing when spawning extractor for a Postimg gallery #5987

Closed taskhawk closed 1 month ago

taskhawk commented 1 month ago

Specifically for Reddit posts linking to Postimg galleries. My latest changes in my config to process Postimg pictures using Reddit metadata is throwing errors as if the parent metadata was dropped along the way.

My full config for this is convoluted but in short I'm using "parent-metadata": "reddit" to make available Reddit's metadata for any extractor spawned from it, while the config for Reddit-spawned Postimg is something along the lines of:

"reddit>postimg": {
    "filename": "{reddit[id]}_postimg_{token} - {reddit[title][:190]}.{extension}"
}

Depending if I enable or not the postprocessors where it further uses Reddit's metadata, I'm getting either:

[postimg][error] An unexpected error occurred: NameError - name 'reddit' is not defined.

or

[postimg][error] FilenameFormatError: Applying filename format string failed (NameError: name 'reddit' is not defined)

More or less I'm using the same config with success for Imgur, ImgChest, Lensdump, and RedGifs for Reddit posts as well.

Does this has something to do with this message when I check -K for the Postimg gallery?

[postimg][info] This extractor only spawns other extractors and does not provide any metadata on its own.
[postimg][info] Showing results for 'https://postimg.cc/YhF7fbf9' instead:

Example of a post that causes this issue (despite saying NSFW, it's actually not NSFW for once): https://new.reddit.com/r/ElsaHoskNSFW/comments/13tjcc5/high_summer/

mikf commented 1 month ago

The issue here is that there is more than 1 level of parent-child inheritance and parent-metadata currently doesn't account for that when set for reddit only.

https://new.reddit.com/r/ElsaHoskNSFW/comments/13tjcc5/high_summer/
->
https://postimg.cc/gallery/RSHHdRd
->
https://postimg.cc/VJsz7mbm
etc

Enabling this option for postimg as well to transfer data from postimg:gallery to postimg:image seems to make it work.

        "reddit": {
            "parent-metadata": "reddit"
        },
        "reddit>postimg": {
            "parent-metadata": true,
            "filename": "{reddit[id]}_postimg_{token} - {reddit[title][:190]}.{extension}"
        }
taskhawk commented 1 month ago

Thanks, working now.