gallery-dl icon indicating copy to clipboard operation
gallery-dl copied to clipboard

Gallery dl won't detect my cache file or reddit refresh token

Open vraixen opened this issue 10 months ago • 9 comments

In my python code i specify a config file with the argument --config. it does seems to detect it however when i try to download a reddit album it ignore the refresh token in it. also i tried specifying the cache file and i get the same thing

this is my config file

{
    "extractor": {

    },
    "downloader": {

    },
    "output": {

    },
    "postprocessor": {

    },
    "cache": {
        "file": "../data/gallery-dl_cache.sqlite3"
    }
}

my python code

@classmethod
    def download_album(cls, url):
        config_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "data", "gallery-dl_config.json")
        images = []
        success = True
        try:
            command = f'gallery-dl -g --config "{config_path}" {url}'
            result = subprocess.run(command, shell=True, capture_output=True, text=True)
            print(result.stdout)
            print(result.stderr)
            if "error" not in result.stderr.lower():
                for image_url in result.stdout.splitlines():
                    extension = os.path.splitext(image_url)[1]
                    filename = f"content_{uuid.uuid4().hex}{extension}"
                    final_file_path = os.path.join(cls.TMP_PATH, filename)
                    command = f'gallery-dl --config "{config_path}" -o "{final_file_path}" "{image_url}"'
                    download_result = subprocess.run(command, shell=True, capture_output=True, text=True)
                    print(download_result.stdout)
                    print(download_result.stderr)
                    images.append(final_file_path)
            else:
                cls.logger.error(f"Errore durante il download dell'album: {result.stderr}")
                success = False
        except Exception as e:
            cls.logger.error(f"Errore durante il download dell'album: {e}")
            success = False

        return success, images

My objective is to keep all the configurations in the project data folder so i can move it somewhere else.

vraixen avatar Apr 08 '24 15:04 vraixen

        "file": "../data/gallery-dl_cache.sqlite3"

Relative paths are relative to your working directory, not your script or config file. Maybe that's the problem.

While you are already using a config file, why not put your Reddit refresh token directly in there instead of relying on a cache file?

mikf avatar Apr 09 '24 14:04 mikf

        "file": "../data/gallery-dl_cache.sqlite3"

Relative paths are relative to your working directory, not your script or config file. Maybe that's the problem.

While you are already using a config file, why not put your Reddit refresh token directly in there instead of relying on a cache file?

because i tried but it doesn't seems to detect it. i also tried using it outside python using the powershell and it doesn't detect it.

vraixen avatar Apr 09 '24 17:04 vraixen

        "file": "../data/gallery-dl_cache.sqlite3"

Relative paths are relative to your working directory, not your script or config file. Maybe that's the problem. While you are already using a config file, why not put your Reddit refresh token directly in there instead of relying on a cache file?

because i tried but it doesn't seems to detect it. i also tried using it outside python using the powershell and it doesn't detect it.

What makes you think that?

429 errors are unrelated to a refresh token, by the way. For those you need a custom client ID and user agent.

mikf avatar Apr 09 '24 17:04 mikf

        "file": "../data/gallery-dl_cache.sqlite3"

Relative paths are relative to your working directory, not your script or config file. Maybe that's the problem. While you are already using a config file, why not put your Reddit refresh token directly in there instead of relying on a cache file?

because i tried but it doesn't seems to detect it. i also tried using it outside python using the powershell and it doesn't detect it.

What makes you think that?

429 errors are unrelated to a refresh token, by the way. For those you need a custom client ID and user agent.

because when i try to download an album it gives me this output

[reddit][info] Requesting public access token [reddit][info] Register your own OAuth application and use its credentials to prevent this error: https://github.com/mikf/gallery-dl/blob/master/docs/configuration.rst#extractorredditclient-id--user-agent [reddit][info] Waiting until 10:40:09 for rate limit reset.

vraixen avatar Apr 10 '24 08:04 vraixen

https://github.com/mikf/gallery-dl/assets/58710194/06e5d199-8c21-446e-8707-373064692733

and if you wonder if i tried putting the refresh token in the config yes i already tried. maybe you can show me an example on how it should placed correctly inside the json maybe i did somethings wrong.

vraixen avatar Apr 10 '24 08:04 vraixen

{
    "extractor":
    {
        "base-directory": "./gallery-dl/",

        "reddit":
        {
            "other_options": "here",


            "refresh-token": "<token here>"
        }
    }
}

Hrxn avatar Apr 10 '24 10:04 Hrxn

{
    "extractor":
    {
        "base-directory": "./gallery-dl/",

        "reddit":
        {
            "other_options": "here",


            "refresh-token": "<token here>"
        }
    }
}

is it correct if this appear? [reddit][info] Refreshing private access token

vraixen avatar Apr 10 '24 17:04 vraixen

Yes, that's normal.

Hrxn avatar Apr 11 '24 03:04 Hrxn

@vraixen

I'm having the same problem as you with a nearly exact Python code. Were you able to fix the problem?

Neltherion avatar Apr 28 '24 14:04 Neltherion