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

This user's avatar is too old to generate a proper date for, so you get a special null object instead. It didn't support a date - datetime(...) operation, but it does now (https://github.com/mikf/gallery-dl/commit/ad73789256502426c6d39931cf9196f67e008751). #6009

Closed
maplestory03 opened this issue Aug 13, 2024 · 6 comments

Comments

@maplestory03
Copy link

This user's avatar is too old to generate a proper date for, so you get a special null object instead. It didn't support a date - datetime(...) operation, but it does now (ad73789).

You could also use conditional format strings to test if date has an actual value.

Originally posted by @mikf in #6007 (comment)

If I want to customize it , how to fix it?

      "avatar":{
        "filename": { 
        
        "locals().get('date') == None"        :"[avatar] {tweet_id} .{extension}",
        ""                                    :"[avatar] {tweet_id} {date:Olocal/%Y-%m-%d}.{extension}"          
                    }
               }
@maplestory03
Copy link
Author

I tried it out.

          "avatar":{
            "filename": { 
            "locals().get('date') is None"         :"[avatar] {tweet_id} {date:Olocal/%Y-%m-%d}.{extension}" ,
            ""                                                  :"[avatar] {tweet_id} .{extension}"   
                        }
                   }

this can work

@mikf
Copy link
Owner

mikf commented Aug 13, 2024

"locals().get('date') is None"
  1. This doesn't work and
  2. It should be the condition for "there is a valid date available", not the reverse

Just "date" is enough here.

Also, you can still post in closed issues.

@maplestory03
Copy link
Author

"locals().get('date') is None"
  1. This doesn't work and
  2. It should be the condition for "there is a valid date available", not the reverse

Just "date" is enough here.

Also, you can still post in closed issues.

@mikf
I run it under Windows and can download it normally with the correct name.
If we follow the correct rules, how do we need to modify it here?
The judgment condition when the date is None
when date is None, filename don't use date

@maplestory03 maplestory03 reopened this Aug 13, 2024
@mikf
Copy link
Owner

mikf commented Aug 13, 2024

not date

@maplestory03
Copy link
Author

not date

          "avatar":{
            "filename": { 
            ""                                    :"[avatar] {tweet_id}.{extension}" ,
            "not date"        :"[avatar] {tweet_id} {date:Olocal/%Y-%m-%d}.{extension}" 
               
                        }
                   }

@mikf
[twitter][error] FilenameFormatError: Applying filename format string failed (TypeError: 'CustomNone' object cannot be interpreted as an integer)
If use this, there will be an error and there will be no download

@mikf
Copy link
Owner

mikf commented Aug 13, 2024

    "avatar": {
        "filename": { 
            "date": "[avatar] {tweet_id} {date:Olocal/%Y-%m-%d}.{extension}",
            ""    : "[avatar] {tweet_id}.{extension}"
        }
    }

All you had to do was to replace "locals().get('date') is None" with "date"

@mikf mikf closed this as completed Aug 13, 2024
mikf added a commit that referenced this issue Aug 14, 2024
- Make it compatible with functions expecting integer arguments
- Simplify and reuse some method definitions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants