Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@adiirfan
Copy link
Contributor

@purarue
Copy link
Contributor

purarue commented Nov 13, 2020

Nice, thanks. It does seem like this would fix the issue; Perhaps remote just had this request cached and I didn't notice.

Strange that this just broke, perhaps MAL changed something with how they handle the gx flag.

[ ~ ] $ curl 'localhost:8000/v3/search/anime?q=&page=1&genre=12&genre_exclude=1&order_by=id&sort=desc' > before_one.json
[ ~ ] $ curl 'localhost:8000/v3/search/anime?q=&page=1&genre=12&genre_exclude=0&order_by=id&sort=desc' > before_zero.json
[ ~ ] $ diff -s before_*
Files before_one.json and before_zero.json are identical
# git checkout your branch, restart PHP, flush cache
[ ~ ] $ redis-cli flushall
OK
[ ~ ] $ curl 'localhost:8000/v3/search/anime?q=&page=1&genre=12&genre_exclude=0&order_by=id&sort=desc' > after_zero.json
[ ~ ] $ curl 'localhost:8000/v3/search/anime?q=&page=1&genre=12&genre_exclude=1&order_by=id&sort=desc' > after_one.json
[ ~ ] $ jq '.results | .[0]' <after_zero.json
{
  "mal_id": 43467,
  "url": "https://myanimelist.net/anime/43467/Ajisai_no_Chiru_Koro_ni",
  "image_url": "https://cdn.myanimelist.net/images/anime/1367/109804.jpg?s=f650391a7183bb05b255c6fc38d438eb",
  "title": "Ajisai no Chiru Koro ni",
  "airing": false,
  "synopsis": "",
  "type": "OVA",
  "episodes": 1,
  "score": 0,
  "start_date": "2021-01-29T00:00:00+00:00",
  "end_date": "2021-01-29T00:00:00+00:00",
  "members": 201,
  "rated": "Rx"
}
[ ~ ] $ jq '.results | .[0]' <after_one.json
{
  "mal_id": 43917,
  "url": "https://myanimelist.net/anime/43917/Viola_wa_Utau",
  "image_url": "https://cdn.myanimelist.net/images/anime/1438/110173.jpg?s=983efdbac8060591d035738b95697265",
  "title": "Viola wa Utau",
  "airing": false,
  "synopsis": "Music video for the song Viola wa Utau by Noriyuki Makihara that was featured on NHK's Minna no Uta program. The video was animated by Kouichirou Uchida with assistance from Super Brain.",
  "type": "Music",
  "episodes": 1,
  "score": 0,
  "start_date": "2010-06-01T00:00:00+00:00",
  "end_date": "2010-06-01T00:00:00+00:00",
  "members": 0,
  "rated": "G"
}
[ ~ ] $ diff -s after_*
[ ~ ] $ diff <(jq '.results | .[] | .mal_id' <./after_zero.json) <(jq '.results | .[] | .mal_id' <./after_one.json)
1,50c1,50
< 43467
< 43466
< 43465
< 43426
< 43016
< 43015
< 43013
< 42848
< 42757
< 42756
< 42592
< 42591
< 42383
< 42324
< 42224
< 42223
< 42141
< 42048
< 42031
< 41848
< 41824
< 41795
< 41794
< 41691
< 41512
< 41397
< 41396
< 41375
< 41370
< 41282
< 41261
< 41260
< 41236
< 41235
< 41212
< 41211
< 41207
< 41200
< 40959
< 40941
< 40922
< 40855
< 40819
< 40801
< 40700
< 40658
< 40639
< 40521
< 40520
< 40519
---
> 43917
> 43814
> 43787
> 43779
> 43778
> 43775
> 43774
> 43772
> 43771
> 43768
> 43767
> 43763
> 43762
> 43761
> 43760
> 43756
> 43755
> 43746
> 43741
> 43735
> 43729
> 43727
> 43722
> 43711
> 43704
> 43694
> 43693
> 43692
> 43691
> 43690
> 43689
> 43688
> 43684
> 43683
> 43682
> 43629
> 43628
> 43627
> 43626
> 43609
> 43608
> 43603
> 43602
> 43600
> 43598
> 43591
> 43590
> 43567
> 43566
> 43565

@purarue
Copy link
Contributor

purarue commented Nov 13, 2020

Hmm, works there but not in a couple other requests, trying to look for patterns

Edit: nevermind, I was mistakenly comparing against cached redis requests, this works properly on a the couple tests Ive done:

[ ~ ] $ curl 'localhost:8000/v3/search/anime?q=&page=1&genre=12&genre_exclude=0&order_by=members&sort=desc' | jq '.results | .[0]'
{
  "mal_id": 1639,
  "url": "https://myanimelist.net/anime/1639/Boku_no_Pico",
  "image_url": "https://cdn.myanimelist.net/images/anime/12/39497.jpg?s=cfc87f8db2765beffef4ec72f2b70023",
  "title": "Boku no Pico",
  "airing": false,
  "synopsis": "Upbeat and effeminate Pico is working at his grandfather's coffee shop, Café Bebe, for the summer. Tamotsu is a white-collar worker looking for an escape from the mundanity of his everyday life. When...",
  "type": "OVA",
  "episodes": 1,
  "score": 4.44,
  "start_date": "2006-09-07T00:00:00+00:00",
  "end_date": "2006-09-07T00:00:00+00:00",
  "members": 125193,
  "rated": "Rx"
}
[ ~ ] $ curl 'localhost:8000/v3/search/anime?q=&page=1&genre=1&genre_exclude=1&order_by=members&sort=desc' | jq '.results | .[0]'
{
  "mal_id": 1535,
  "url": "https://myanimelist.net/anime/1535/Death_Note",
  "image_url": "https://cdn.myanimelist.net/images/anime/9/9453.jpg?s=b89e80691ac5cc0610847ccbe0b8424a",
  "title": "Death Note",
  "airing": false,
  "synopsis": "A shinigami, as a god of death, can kill any person—provided they see their victim's face and write their victim's name in a notebook called a Death Note. One day, Ryuk, bored by the shinigami lifesty...",
  "type": "TV",
  "episodes": 37,
  "score": 8.62,
  "start_date": "2006-10-04T00:00:00+00:00",
  "end_date": "2007-06-27T00:00:00+00:00",
  "members": 2327770,
  "rated": "R"
}
# most recent approved non-acton  item (compare to https://myanimelist.net/anime.php?o=9&c%5B0%5D=a&c%5B1%5D=d&cv=2&w=1)
[ ~ ] $ curl 'localhost:8000/v3/search/anime?q=&page=1&genre=1&genre_exclude=1&order_by=id&sort=desc' | jq '.results | .[0]'
{
  "mal_id": 43917,
  "url": "https://myanimelist.net/anime/43917/Viola_wa_Utau",
  "image_url": "https://cdn.myanimelist.net/images/anime/1438/110173.jpg?s=983efdbac8060591d035738b95697265",
  "title": "Viola wa Utau",
  "airing": false,
  "synopsis": "Music video for the song Viola wa Utau by Noriyuki Makihara that was featured on NHK's Minna no Uta program. The video was animated by Kouichirou Uchida with assistance from Super Brain.",
  "type": "Music",
  "episodes": 1,
  "score": 0,
  "start_date": "2010-06-01T00:00:00+00:00",
  "end_date": "2010-06-01T00:00:00+00:00",
  "members": 0,
  "rated": "G"
}
# most recent approved action item
[ ~ ] $ curl 'localhost:8000/v3/search/anime?q=&page=1&genre=1&genre_exclude=0&order_by=id&sort=desc' | jq '.results | .[0]'
{
  "mal_id": 43814,
  "url": "https://myanimelist.net/anime/43814/Deatte_5-byou_de_Battle",
  "image_url": "https://cdn.myanimelist.net/images/anime/1062/110160.jpg?s=a4e64e282a3c4f4eaa64d187d2c625b9",
  "title": "Deatte 5-byou de Battle",
  "airing": false,
  "synopsis": "It was just a usual morning. Akira Shiroyanagi, a high schooler who loves games and Konpeito (Japanese sweets), has suddenly been dragged into a battlefield by a mysterious girl who calls herself Mion...",
  "type": "TV",
  "episodes": 0,
  "score": 0,
  "start_date": null,
  "end_date": null,
  "members": 0,
  "rated": null
}

@purarue
Copy link
Contributor

purarue commented Nov 13, 2020

Ah, but I believe this has flipped the meaning of genre_exclude, technically the 0/1 currently acts as what genre_include might.

Debugging MAL search queries always makes me confused, but I think that has to be fixed.

According to my code/looking back on discussions in the discord, the API currently does -

genre=12&genre_exclude=1 should mean NSFW results are included, genre=12&genre_exclude=0 should mean NSFW results (the genre 12) are not included -- excluded.

Currently it does the opposite (though Im still not totally clear on why flipping the bool worked, not sure if its targeting different integer values for the gx param):

[sean@fish-webserver ~/vps ] $ curl -s 'localhost:8000/v3/search/anime?q=&page=1&genre=12&genre_exclude=1&order_by=id&sort=desc' | jq '.results | .[0]'
{
  "mal_id": 43917,
  "url": "https://myanimelist.net/anime/43917/Viola_wa_Utau",
  "image_url": "https://cdn.myanimelist.net/images/anime/1438/110173.jpg?s=983efdbac8060591d035738b95697265",
  "title": "Viola wa Utau",
  "airing": false,
  "synopsis": "Music video for the song Viola wa Utau by Noriyuki Makihara that was featured on NHK's Minna no Uta program. The video was animated by Kouichirou Uchida with assistance from Super Brain.",
  "type": "Music",
  "episodes": 1,
  "score": 0,
  "start_date": "2010-06-01T00:00:00+00:00",
  "end_date": "2010-06-01T00:00:00+00:00",
  "members": 0,
  "rated": "G"
}
[sean@fish-webserver ~/vps ] $ curl -s 'https://api.jikan.moe/v3/search/anime?q=&page=1&genre=12&genre_exclude=1&order_by=id&sort=desc' | jq '.results | .[0]'
{
  "mal_id": 43467,
  "url": "https://myanimelist.net/anime/43467/Ajisai_no_Chiru_Koro_ni",
  "image_url": "https://cdn.myanimelist.net/images/anime/1367/109804.jpg?s=f650391a7183bb05b255c6fc38d438eb",
  "title": "Ajisai no Chiru Koro ni",
  "airing": false,
  "synopsis": "",
  "type": "OVA",
  "episodes": 1,
  "score": 0,
  "start_date": "2021-01-29T00:00:00+00:00",
  "end_date": "2021-01-29T00:00:00+00:00",
  "members": 193,
  "rated": "Rx"
}

Am still confused as to why flipping the bool worked, and why remote is still working (may be because its using v4, is it?):

This is what I believe it should be, comparing to api.jikan.moe requests:

  • not including any genre_exclude parameter in the request (latest NSFW entry)
  • including genre_exclude=1 (should be NSFW)
  • including genre_exclude=0 (should be SFW)
[sean@fish-webserver ~/vps ] $ curl -s 'https://api.jikan.moe/v3/search/anime?q=&page=1&genre=12&order_by=id&sort=desc' | jq '.results | .[0]'
{
  "mal_id": 43467,
  "url": "https://myanimelist.net/anime/43467/Ajisai_no_Chiru_Koro_ni",
  "image_url": "https://cdn.myanimelist.net/images/anime/1367/109804.jpg?s=f650391a7183bb05b255c6fc38d438eb",
  "title": "Ajisai no Chiru Koro ni",
  "airing": false,
  "synopsis": "",
  "type": "OVA",
  "episodes": 1,
  "score": 0,
  "start_date": "2021-01-29T00:00:00+00:00",
  "end_date": "2021-01-29T00:00:00+00:00",
  "members": 201,
  "rated": "Rx"
[sean@fish-webserver ~/vps ] $ curl -s 'https://api.jikan.moe/v3/search/anime?q=&page=1&genre=12&genre_exclude=1&order_by=id&sort=desc' | jq '.results | .[0]'
{ '.results | .[0]'
  "mal_id": 43467,
  "url": "https://myanimelist.net/anime/43467/Ajisai_no_Chiru_Koro_ni",
  "image_url": "https://cdn.myanimelist.net/images/anime/1367/109804.jpg?s=f650391a7183bb05b255c6fc38d438eb",
  "title": "Ajisai no Chiru Koro ni",
  "airing": false,
  "synopsis": "",
  "type": "OVA",
  "episodes": 1,
  "score": 0,
  "start_date": "2021-01-29T00:00:00+00:00",
  "end_date": "2021-01-29T00:00:00+00:00",
  "members": 193,
  "rated": "Rx"
}
[sean@fish-webserver ~/vps ] $ curl -s 'https://api.jikan.moe/v3/search/anime?q=&page=1&genre=12&genre_exclude=0&order_by=id&sort=desc' | jq '.results | .[0]'
{
  "mal_id": 43814,
  "url": "https://myanimelist.net/anime/43814/Deatte_5-byou_de_Battle",
  "image_url": "https://cdn.myanimelist.net/images/anime/1062/110160.jpg?s=a4e64e282a3c4f4eaa64d187d2c625b9",
  "title": "Deatte 5-byou de Battle",
  "airing": false,
  "synopsis": "It was just a usual morning. Akira Shiroyanagi, a high schooler who loves games and Konpeito (Japanese sweets), has suddenly been dragged into a battlefield by a mysterious girl who calls herself Mion...",
  "type": "TV",
  "episodes": 0,
  "score": 0,
  "start_date": null,
  "end_date": null,
  "members": 0,
  "rated": null
}

@irfan-dahir
Copy link
Contributor

Seems like I seriously messed up the logic there. Thanks for looking into this and the PR!

@purarue
Copy link
Contributor

purarue commented Nov 23, 2020

Very strange bug anyways

This had been working fine for months and all of a sudden stopped.

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

Successfully merging this pull request may close these issues.

genre_exclude parameter on search not applying

3 participants