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

[gallery-dl][error]: error in 'metadata.extension' and 'metadata.extension-format' (KeyError - 'extension') #1285

Closed
rod-giovany opened this issue Jan 31, 2021 · 1 comment
Labels

Comments

@rod-giovany
Copy link

rod-giovany commented Jan 31, 2021

I was editing options when an error appeared and now no files download, this bug jump;
NT: my english is bad.

C:\Users\Jonathan>gallery-dl --verbose https://www.newgrounds.com/portal/view/740431
[gallery-dl][debug] Version 1.16.4
[gallery-dl][debug] Python 3.9.1 - Windows-10-10.0.19041-SP0
[gallery-dl][debug] requests 2.25.1 - urllib3 1.26.3
[gallery-dl][debug] Starting DownloadJob for 'https://www.newgrounds.com/portal/view/740431'
[newgrounds][debug] Using NewgroundsMediaExtractor for 'https://www.newgrounds.com/portal/view/740431'
[urllib3.connectionpool][debug] Starting new HTTPS connection (1): www.newgrounds.com:443
[urllib3.connectionpool][debug] https://www.newgrounds.com:443 "GET /portal/view/740431/format/flash HTTP/1.1" 200 12831
[urllib3.connectionpool][debug] https://www.newgrounds.com:443 "GET /portal/video/740431 HTTP/1.1" 200 246
[newgrounds][debug] Active postprocessor modules: [MetadataPP, ClassifyPP]
[newgrounds][error] An unexpected error occurred: KeyError - 'extension'. Please run gallery-dl again with the --verbose flag, copy its output and report this issue on https://github.com/mikf/gallery-dl/issues .
[newgrounds][debug]
Traceback (most recent call last):
  File "C:\Users\Jonathan\AppData\Local\Programs\Python\Python39\lib\site-packages\gallery_dl\job.py", line 69, in run
    self.dispatch(msg)
  File "C:\Users\Jonathan\AppData\Local\Programs\Python\Python39\lib\site-packages\gallery_dl\job.py", line 107, in dispatch
    self.handle_directory(msg[1])
  File "C:\Users\Jonathan\AppData\Local\Programs\Python\Python39\lib\site-packages\gallery_dl\job.py", line 276, in handle_directory
    self.initialize(kwdict)
  File "C:\Users\Jonathan\AppData\Local\Programs\Python\Python39\lib\site-packages\gallery_dl\job.py", line 452, in initialize
    callback(pathfmt)
  File "C:\Users\Jonathan\AppData\Local\Programs\Python\Python39\lib\site-packages\gallery_dl\postprocessor\metadata.py", line 69, in run
    path = directory + self._filename(pathfmt)
  File "C:\Users\Jonathan\AppData\Local\Programs\Python\Python39\lib\site-packages\gallery_dl\postprocessor\metadata.py", line 94, in _filename_extfmt
    ext = kwdict["extension"]
KeyError: 'extension'

It seems that the cause of the error is the command: metadata.extension-format and metadata.extension, every time I use it.
I know that the error refers to newgrounds and the code to deviantart, but the error is repeated regardless of which page it is used.
My configuration file would be more or less like this:

{
  "extractor": {
    "deviantart": {
      "username": "mich3218",
      "password": "5514602414",
      "journals": "none",
      "filename": "{filename}.{extension}",
      "base-directory": "~\\gallery-dl\\deviantart",
      "include": [
        "gallery",
        "scraps"
      ],
      "folders": true,
      "extra": true,
      "client-id": "<client-id>",
      "client-secret": "<client-secret>",
      "refresh-token": "cache",
      "cookies": "~\\gallery-dl\\deviantart.com_cookies.txt",
      "cookies-update": true,
      "metadata": true,
      "postprocessors": [
        {
          "name": "metadata",
          "mode": "custom",
                  **"extension-format": "{filename}.json",**
          "event": "init",
          "content-format": [
            "usuario: {username}",
            "url: {url}",
            "fecha: {date}\n",
            "descripcion: {description}"
          ]
        }
      ]
    }
  }
}
@rod-giovany rod-giovany changed the title newgrounds error error: " KeyError - 'extension' " Jan 31, 2021
@rod-giovany rod-giovany changed the title error: " KeyError - 'extension' " [gallery-dl][error]: error in metadata.extension and metadata.extension-format (KeyError - 'extension') Feb 1, 2021
@rod-giovany rod-giovany changed the title [gallery-dl][error]: error in metadata.extension and metadata.extension-format (KeyError - 'extension') [gallery-dl][error]: error in 'metadata.extension' and 'metadata.extension-format' (KeyError - 'extension') Feb 1, 2021
@mikf
Copy link
Owner

mikf commented Feb 8, 2021

Sorry for taking this long to respond ... anyway, this error is mainly caused by using "event": "init". There is no filename extension info available when this event triggers.

To not have gallery-dl throw an exception, use "filename": "{filename}.json" instead of "extension-format": "..." or "extension": "...".

I'd also recommend "event": "post". This triggers for every post, instead of just once before the first one.

@mikf mikf closed this as completed in b3cd970 Feb 10, 2021
@mikf mikf added the bug label Feb 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants