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

Kemonoparty: Very long links #2740

Closed
valdearg opened this issue Jul 8, 2022 · 5 comments
Closed

Kemonoparty: Very long links #2740

valdearg opened this issue Jul 8, 2022 · 5 comments

Comments

@valdearg
Copy link

valdearg commented Jul 8, 2022

In some cases, the Kemonoparty links from Patreon end up being extremely long which can cause a couple of issues with the files downloaded.

An example of this would be: https://kemono.party/patreon/user/11975898/post/67500422

The image link in here: https://kemono.party/data/c2/6f/c26f722c64d01abd33529241ad8ee7ba119aad19d7a95b10a4e9f3f10425b5c8.jpg?f=https%3A//www.patreon.com/media-u/Z0FBQUFBQml5RUNfZFFHUXo4RVRvZUFOM3piM25VVzFnQ3FDR1d3Sm9pMEpWVmx3VzQwa0MzcTg5ZTNTWjFQNDE0Ul9xaXUwZTZxUkpSMHVkZndGT2FaYTBEOWFxZFRTbDkxR0htNlFRZEk0MEY3bnVqbUZOamJseUJPakNDWV8zeFlWeVJRc3dLdjVyb1JjWlVnTWxpeXJiaUFLd0c2MGg1ckFpQjZCN1JnazFueDZOMGtnZGZJTFZSV0owbFRJS2RRRURkMVFfdXVIRTQ0dXZpWjlvM0JVZWxPLUI3SUtFUT09

This ends up by default as: 67500422_Set B✧video -小惡魔荷官影片_01_Z0FBQUFBQml5RUNfZFFHUXo4RVRvZUFOM3piM25VVzFnQ3FDR1d3Sm9pMEpWVmx3VzQwa0MzcTg5ZTNTWjFQNDE0Ul9xaXUwZTZxUkpSMHVkZndGT2FaYTBEOWFxZFRTbDkxR0htNlFRZEk0MEY3bnVqbUZOamJseUJPakNDWV8zeFlWeVJR.jpg

Taking the filename variable from the end of the link.

Would there be any way to handle in these cases to use the filename from the first part: c26f722c64d01abd33529241ad8ee7ba119aad19d7a95b10a4e9f3f10425b5c8.jpg

If I run the URL through the -K option it gives:
extension

filename
Z0FBQUFBQml5RUNfZFFHUXo4RVRvZUFOM3piM25VVzFnQ3FDR1d3Sm9pMEpWVmx3VzQwa0MzcTg5ZTNTWjFQNDE0Ul9xaXUwZTZxUkpSMHVkZndGT2FaYTBEOWFxZFRTbDkxR0htNlFRZEk0MEY3bnVqbUZOamJseUJPakNDWV8zeFlWeVJRc3dLdjVyb1JjWlVnTWxpeXJiaUFLd0c2MGg1ckFpQjZCN1JnazFueDZOMGtnZGZJTFZSV0owbFRJS2RRRURkMVFfdXVIRTQ0dXZpWjlvM0JVZWxPLUI3SUtFUT09

Where the extension is empty.

It looks like the URL to the image works without the media link in it, e.g. https://data3.kemono.party/data/c2/6f/c26f722c64d01abd33529241ad8ee7ba119aad19d7a95b10a4e9f3f10425b5c8.jpg

I'm wondering if it might be easiest to split based on ?f=https ? Of course, better thoughts appreciated!

@enduser420
Copy link
Contributor

enduser420 commented Jul 9, 2022

You can add this to your config.json to handle filenames for files from patreon or remove the service == 'patreon' and keep the string empy for using this format for all the services that kemonoparty provides. (configuration.rst)

"extractor": {
    "kemonoparty": {
	"filename": {
	    "service == 'patreon'": "{id}_{title}_{num:>02}_{hash}.{extension}" 
        }
    }
}

Result:

[1/2] https://kemono.party/patreon/user/11975898/post/67500422
# 67500422_Set B✧video -小惡魔荷官影片_01_c26f722c64d01abd33529241ad8ee7ba119aad19d7a95b10a4e9f3f10425b5c8.jpg
[2/2] https://kemono.party/patreon/user/11975898/post/68356106
# 68356106_Set C✧ Rem ♡軟綿綿雷姆_01_9073a6e275868c8e58e0f71e9fc8c0c198ee5317f02eb6308d8fa78d165759cd.jpg
# 68356106_Set C✧ Rem ♡軟綿綿雷姆_02_d4f875b25915872cc6ee85d76068c2b442022d8b0d81c5fc7db0dfe15426c5bc.jpg
# 68356106_Set C✧ Rem ♡軟綿綿雷姆_03_c7aa97fd27d94f1e3f89c1186e2f3c0ef0fae02236e65e419f555bcf1d64044d.jpg

@mikf
Copy link
Owner

mikf commented Jul 10, 2022

You can also use the same "technique" from #2740 (comment) to decide between filename or hash based on filename length:

    "extractor": {
        "kemonoparty": {
            "filename": {
                "len(filename) > 100": "{id}_{title}_{num:>02}_{hash}.{extension}",
                ""                   : "{id}_{title}_{num:>02}_{filename}.{extension}"
            }
        }
    }

(> 100 is just an arbitrary limit)

Where the extension is empty.

Fixed in 7c05058

@valdearg
Copy link
Author

Oh hey, that's pretty damn cool. That'll work for me!

@valdearg
Copy link
Author

Just tested, works perfectly. Thanks for your help and for the fix on the extension!

@afterdelight
Copy link

or you can trim the filename to 25 characters like this
"filename": "{id}_{title}_{num:>02}_{filename[:25]}.{extension}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants