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

[NSFW] Sankaku Complex image booru's new IDs #5073

Open
arisboch opened this issue Jan 18, 2024 · 8 comments
Open

[NSFW] Sankaku Complex image booru's new IDs #5073

arisboch opened this issue Jan 18, 2024 · 8 comments

Comments

@arisboch
Copy link

arisboch commented Jan 18, 2024

Since a few days or weeks or so, the Sankaku image booru changed their IDs from purely numeric to alphanumeric (among others apparent changes to their API). Downloads now sometimes fail with various errors or do succeed, but with nonsensical IDs. Here are a few examples:

[gallery-dl][debug] Version 1.26.7-dev
[gallery-dl][debug] Python 3.11.6 - Linux-6.5.0-14-generic-x86_64-with-glibc2.38
[gallery-dl][debug] requests 2.31.0 - urllib3 2.1.0
[gallery-dl][debug] Configuration Files ['${HOME}/.gallery-dl.conf']
[gallery-dl][debug] Starting DownloadJob for 'https://sankaku.app/posts/vkr3g3gN2rZ'
[gallery-dl][error] Unsupported URL 'https://sankaku.app/posts/vkr3g3gN2rZ'

An attempt to download posts with containing more... extreme content throws the following error message, even though I do have a premium account and could view these kinda posts in the browser without problems:

[gallery-dl][debug] Version 1.26.7-dev
[gallery-dl][debug] Python 3.11.6 - Linux-6.5.0-14-generic-x86_64-with-glibc2.38
[gallery-dl][debug] requests 2.31.0 - urllib3 2.1.0
[gallery-dl][debug] Configuration Files ['${HOME}/.gallery-dl.conf']
[gallery-dl][debug] Starting DownloadJob for 'https://sankaku.app/posts/[reacted]'
[sankaku][debug] Using SankakuPostExtractor for 'https://sankaku.app/posts/[reacted]'
[urllib3.connectionpool][debug] Starting new HTTPS connection (1): capi-v2.sankakucomplex.com:443
[urllib3.connectionpool][debug] https://capi-v2.sankakucomplex.com:443 "GET /posts?lang=en&page=1&limit=1&tags=id_range%3A9 HTTP/1.1" 404 105
[sankaku][error] snackbar__content-belongs-to-premium-client

Another post with extreme content throws the following error:

[gallery-dl][debug] Version 1.26.7-dev
[gallery-dl][debug] Python 3.11.6 - Linux-6.5.0-14-generic-x86_64-with-glibc2.38
[gallery-dl][debug] requests 2.31.0 - urllib3 2.1.0
[gallery-dl][debug] Configuration Files ['${HOME}/.gallery-dl.conf']
[gallery-dl][debug] Starting DownloadJob for 'https://sankaku.app/posts/[redacted]'
[sankaku][debug] Using SankakuPostExtractor for 'https://sankaku.app/posts/[redacted]'
[urllib3.connectionpool][debug] Starting new HTTPS connection (1): capi-v2.sankakucomplex.com:443
[urllib3.connectionpool][debug] https://capi-v2.sankakucomplex.com:443 "GET /posts?lang=en&page=1&limit=1&tags=id_range%3Ae HTTP/1.1" 408 157
[sankaku][error] snackbar__account_search-invalid-structure
@arisboch arisboch changed the title [NSFW] Sankaku Complex image booru changed their IDs (and likely also the API) [NSFW] Sankaku Complex image booru changed the API Jan 18, 2024
@mikf
Copy link
Owner

mikf commented Jan 18, 2024

Posts with alphanumeric IDs are now supported (a416d4c).
This might also fix the other [sankaku][error] snackbar__… errors, not sure though.

@arisboch
Copy link
Author

Thanks a bunch, that did the trick.

@arisboch
Copy link
Author

Could you also please add a directory and file template field for the new post IDs?

@mikf
Copy link
Owner

mikf commented Jan 20, 2024

I can't figure out how to do this in general. I would have thought and hoped that these new IDs can somehow be gotten by converting an existing value (numeric ID, MD5) to another format/base, but that doesn't seem to work.

New IDs are all 11 characters long and in base 62 (ASCII letters and digits) from what I can tell.

We could obviously just take the given ID for post URLs, but it would be missing for everything else like tag searches.

@arisboch arisboch changed the title [NSFW] Sankaku Complex image booru changed the API [NSFW] Sankaku Complex image booru's new IDs Jan 20, 2024
@mikf mikf removed the help wanted label Jan 26, 2024
mikf added a commit that referenced this issue Jan 26, 2024
@mikf
Copy link
Owner

mikf commented Jan 26, 2024

So I figured out how to get alphanumeric IDs (34a4ddc, "id-format": "alnum"), but you can only have either new-style IDs or the old numeric IDs. Both at the same time would theoretically be possible by repeating each API call, once with Api-Version: 2 header and once without.

bradenhilton pushed a commit to bradenhilton/gallery-dl that referenced this issue Feb 5, 2024
bradenhilton pushed a commit to bradenhilton/gallery-dl that referenced this issue Feb 5, 2024
@AlttiRi
Copy link

AlttiRi commented Feb 29, 2024

https://forum.sankakucomplex.com/t/converting-between-legacy-numeric-new-alphanumeric-post-ids/48568

What is the algorithm or formula to convert from the old numeric post ID format to the new alphanumeric ID format?

The admin wrote:

if the algorithm was public, there wouldn’t be much point in the change, no? they use a similar hashing method to a service like youtube. the hash key is just obviously the same between Chan and Idol

@mo-han
Copy link
Contributor

mo-han commented Jun 9, 2024

@mikf
id-format=alnum seem not working for the idol site, maybe it drop legacy id.

since the id is not int now, i suppose we can't use op like > < == with id in filter anymore, right?

@mikf
Copy link
Owner

mikf commented Jun 12, 2024

id-format only works on chan.sankakucomplex / sankaku.app, but it never did on idol.sankakucomplex. The idol site had both id and id_alnum for as long as that was possible, but it removed numeric IDs completely some time ago (32262a0).

It is possible to compare str with > < ==, but this is kind of pointless here since IDs are no longer in any predictable order. Comparing date values might be an alternative.

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

4 participants