mikf / gallery-dl

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

way to rename certain characters #936

Closed hellomynameisleo closed 4 years ago

hellomynameisleo commented 4 years ago

since gallery-dl can't name a file/folder with these characters "?", ":" """, "/", "*" when downloading is there a way I can make gallery-dl automatically replace them with another character I set?

mikf commented 4 years ago

You can set a general replacement character with the path-replace option, or you set path-restrict to a "replacement map" like in this example

hellomynameisleo commented 4 years ago

You can set a general replacement character with the path-replace option, or you set path-restrict to a "replacement map" like in this example

copy and pasted it into the config but doesn't work, says expecting "," delimiter line 181

 {
    "extractor":
    {
        "base-directory": "./gallery-dl/",
        "postprocessors": null,
        "archive": null,
        "cookies": null,
        "cookies-update": false,
        "proxy": null,
        "skip": true,
        "sleep": 0,
        "path-restrict": "auto",
        "path-replace": "_",
        "path-remove": "\\u0000-\\u001f\\u007f",
        "user-agent": "Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0",

        "artstation":
        {
            "external": false
        },
        "blogger":
        {
            "videos": true
        },
        "danbooru":
        {
            "username": null,
            "password": null,
            "ugoira": false
        },
        "deviantart":
        {
            "extra": false,
            "flat": true,
            "folders": false,
            "journals": "html",
            "mature": true,
            "metadata": false,
            "original": true,
            "quality": 100,
            "wait-min": 0
        },
        "exhentai":
        {
            "username": null,
            "password": null,
            "original": true,
            "wait-min": 3.0,
            "wait-max": 6.0
        },
        "flickr":
        {
            "videos": true,
            "size-max": null
        },
        "gelbooru":
        {
            "api": true
        },
        "gfycat":
        {
            "format": "mp4"
        },
        "hitomi":
        {
            "metadata": true
        },
        "idolcomplex":
        {
            "username": null,
            "password": null,
            "wait-min": 3.0,
            "wait-max": 6.0
        },
        "imgur":
        {
            "mp4": true
        },
        "instagram":
        {
            "highlights": false,
            "videos": true
        },
        "kissmanga":
        {
            "captcha": "stop"
        },
        "nijie":
        {
            "username": null,
            "password": null
        },
        "oauth":
        {
            "browser": true,
            "cache": true,
            "port": 6414
        },
        "pixiv":
        {
            "username": "",
            "password": "",
            "avatar": false,
            "ugoira": true
        },
        "reactor":
        {
            "wait-min": 3.0,
            "wait-max": 6.0
        },
        "readcomiconline":
        {
            "captcha": "stop"
        },
        "recursive":
        {
            "blacklist": ["directlink", "oauth", "recursive", "test"]
        },
        "reddit":
        {
            "comments": 0,
            "morecomments": false,
            "date-min": 0,
            "date-max": 253402210800,
            "date-format": "%Y-%m-%dT%H:%M:%S",
            "id-min": "0",
            "id-max": "zik0zj",
            "recursion": 0,
            "videos": true,
            "user-agent": "Python:gallery-dl:0.8.4 (by /u/mikf1)"
        },
        "redgifs":
        {
            "format": "mp4"
        },
        "sankaku":
        {
            "username": null,
            "password": null,
            "wait-min": 3.0,
            "wait-max": 6.0
        },
        "seiga":
        {
            "username": null,
            "password": null
        },
        "tumblr":
        {
            "avatar": false,
            "external": false,
            "inline": true,
            "posts": "all",
            "reblogs": true
        },
        "twitter":
        {
            "quoted": true,
            "replies": true,
            "retweets": true,
            "twitpic": false,
            "videos": true
        },
        "vsco":
        {
            "videos": true
        },
        "wallhaven":
        {
            "api-key": null
        },
        "weibo":
        {
            "retweets": true,
            "videos": true
        },
        "booru":
        {
            "tags": false
        }
        "replace invalid path characters with unicode alternatives": true,
        "path-replace": {
            "\\": "⧹",
            "/" : "⧸",
            "|" : "│",
            ":" : "꞉",
            "*" : "∗",
            "?" : "?",
            "\"": "″",
            "<" : "﹤",
            ">" : "﹥"
        }
    },

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

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

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

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

    "netrc": false
}
mikf commented 4 years ago

There is comma , missing after

        "booru":
        {
            "tags": false
        }

It should end with },

It is also called path-restrict, not path-replace, and you might want to simply replace "path-restrict": "auto", at the top of your config file with the new value (and don't forget to put a comma after it):


...
        "sleep": 0,
        "path-restrict": {
            "\\": "⧹",
            "/" : "⧸",
            "|" : "│",
            ":" : "꞉",
            "*" : "∗",
            "?" : "?",
            "\"": "″",
            "<" : "﹤",
            ">" : "﹥"
        },
        "path-replace": "_",
...
hellomynameisleo commented 4 years ago

There is comma , missing after

        "booru":
        {
            "tags": false
        }

It should end with },

It is also called path-restrict, not path-replace, and you might want to simply replace "path-restrict": "auto", at the top of your config file with the new value (and don't forget to put a comma after it):

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

It works, gallery-dl also renames titles with the character """ to "&quot ;" I've tried adding """ : """, but it doesn't parse. The same goes for "&" it turns into "&amp ;", the "&" : "&", that I put in doesn't work.