vosmiic / jellyfin-ani-sync

Synchronize anime watch status between Jellyfin and anime tracking sites.
GNU General Public License v3.0
215 stars 15 forks source link

Add NSFW param to MAL API calls #95

Closed PythonCoderAS closed 5 months ago

PythonCoderAS commented 6 months ago

Fix #94

vosmiic commented 6 months ago

Thanks for the PR, but I think it needs some extensions. First we would need to make sure the other providers support operating on NSFW content and I would prefer if there were a switch to allow or disallow updating NSFW content. I'll work on the above changes soon, got quite a lot to catch up on.

PythonCoderAS commented 6 months ago

Thanks for the PR, but I think it needs some extensions. First we would need to make sure the other providers support operating on NSFW content and I would prefer if there were a switch to allow or disallow updating NSFW content. I'll work on the above changes soon, got quite a lot to catch up on.

With regards to NSFW, I know Anilist supports it (with a setting that has to be enabled somewhere in the settings), Kitsu does not, and Simkl supports some level (I see Redo of healer but no H-anime).

vosmiic commented 6 months ago

I think that should be good to go, could you confirm that this is working? I can't test it with my local library

PythonCoderAS commented 6 months ago

I think that should be good to go, could you confirm that this is working? I can't test it with my local library

How do I install this into my Jellyfin?

vosmiic commented 5 months ago

You can build it if you are able to and then follow the manual install instructions (but use the built dll file, not one from releases). If you can't build it I can send you a dll file.

PythonCoderAS commented 5 months ago

All looks good, just waiting for the go-ahead from you after you have tested it (if you are able to)

I tested it but I'm still getting the error:

[2024-01-14 20:36:21.573 +00:00] [WRN] [76] jellyfin_ani_sync.UpdateProviderStatus: Did not get provider IDs, defaulting to episode provided AniList ID
[2024-01-14 20:36:21.577 +00:00] [INF] [76] jellyfin_ani_sync.UpdateProviderStatus: Using provider Mal...
[2024-01-14 20:36:21.626 +00:00] [INF] [76] jellyfin_ani_sync.Api.MalApiCalls: Starting search for anime (GET https://api.myanimelist.net/v2/anime?q=SweetPunishment&nsfw=true&fields=id%2Ctitle%2Calternative_titles%2Cnum_episodes%2Cstatus)...
[2024-01-14 20:36:22.022 +00:00] [INF] [76] jellyfin_ani_sync.Api.MalApiCalls: Search complete
[2024-01-14 20:36:22.027 +00:00] [WRN] [76] jellyfin_ani_sync.UpdateProviderStatus: (Mal) Series not found

The URL is not the problem, however, as this is the JSON I got back:

{
  "data": [
    {
      "node": {
        "id": 37440,
        "title": "Psycho-Pass: Sinners of the System Case.1 - Tsumi to Batsu",
        "main_picture": {
          "medium": "https://cdn.myanimelist.net/images/anime/1623/96878.jpg",
          "large": "https://cdn.myanimelist.net/images/anime/1623/96878l.jpg"
        },
        "alternative_titles": {
          "synonyms": [
            "Psycho-Pass SS Case 1: Tsumi to Batsu"
          ],
          "en": "Psycho-Pass: Sinners of the System Case.1 - Crime and Punishment",
          "ja": "PSYCHO-PASS サイコパス|SS(Sinners of the System) Case.1「罪と罰」"
        },
        "num_episodes": 1,
        "status": "finished_airing"
      }
    },
    {
      "node": {
        "id": 37320,
        "title": "Amai Choubatsu: Watashi wa Kanshu Senyou Pet",
        "main_picture": {
          "medium": "https://cdn.myanimelist.net/images/anime/1464/108630.jpg",
          "large": "https://cdn.myanimelist.net/images/anime/1464/108630l.jpg"
        },
        "alternative_titles": {
          "synonyms": [
            "Amai Choubatsu: Watashi wa Kanshu Sen'you Pet"
          ],
          "en": "Sweet Punishment: I'm the Guard's Personal Pet",
          "ja": "甘い懲罰~私は看守専用ペット"
        },
        "num_episodes": 13,
        "status": "finished_airing"
      }
    },
    {
      "node": {
        "id": 30460,
        "title": "Kanojo ga Nekomimi ni Kigaetara",
        "main_picture": {
          "medium": "https://cdn.myanimelist.net/images/anime/1767/119772.jpg",
          "large": "https://cdn.myanimelist.net/images/anime/1767/119772l.jpg"
        },
        "alternative_titles": {
          "synonyms": [],
          "en": "Cat Play Punishment",
          "ja": "彼女がネコミミに着替えたら"
        },
        "num_episodes": 1,
        "status": "finished_airing"
      }
    },
    {
      "node": {
        "id": 3382,
        "title": "Korashime",
        "main_picture": {
          "medium": "https://cdn.myanimelist.net/images/anime/7/7431.jpg",
          "large": "https://cdn.myanimelist.net/images/anime/7/7431l.jpg"
        },
        "alternative_titles": {
          "synonyms": [],
          "en": "Punishment",
          "ja": "懲らしめ"
        },
        "num_episodes": 2,
        "status": "finished_airing"
      }
    },
    {
      "node": {
        "id": 56009,
        "title": "Yuusha-kei ni Shosu: Choubatsu Yuusha 9004-tai Keimu Kiroku",
        "main_picture": {
          "medium": "https://cdn.myanimelist.net/images/anime/1377/137193.jpg",
          "large": "https://cdn.myanimelist.net/images/anime/1377/137193l.jpg"
        },
        "alternative_titles": {
          "synonyms": [
            "Punishment for Brave Hero: 9004 Corps Prison Record, Sentenced to Hero Punishment: The Service Records of the 9004th Penitent Hero Corps",
            "Hero Punishment"
          ],
          "en": "Sentenced to Brave Punishment",
          "ja": "勇者刑に処す 懲罰勇者9004隊刑務記録"
        },
        "num_episodes": 0,
        "status": "not_yet_aired"
      }
    },
    {
      "node": {
        "id": 25457,
        "title": "Avengers Confidential: Black Widow to Punisher",
        "main_picture": {
          "medium": "https://cdn.myanimelist.net/images/anime/10/66947.jpg",
          "large": "https://cdn.myanimelist.net/images/anime/10/66947l.jpg"
        },
        "alternative_titles": {
          "synonyms": [],
          "en": "Marvel Avengers Confidential: Black Widow & Punisher",
          "ja": "アベンジャーズ コンフィデンシャル: ブラックウィドウとパニッシャー"
        },
        "num_episodes": 1,
        "status": "finished_airing"
      }
    },
    {
      "node": {
        "id": 14175,
        "title": "Hanasaku Iroha Movie: Home Sweet Home",
        "main_picture": {
          "medium": "https://cdn.myanimelist.net/images/anime/9/70701.jpg",
          "large": "https://cdn.myanimelist.net/images/anime/9/70701l.jpg"
        },
        "alternative_titles": {
          "synonyms": [
            "Hanasaku Iroha: Home Sweet Home"
          ],
          "en": "Hanasaku Iroha the Movie: Home Sweet Home",
          "ja": "劇場版 花咲くいろは HOME SWEET HOME"
        },
        "num_episodes": 1,
        "status": "finished_airing"
      }
    },
    {
      "node": {
        "id": 36864,
        "title": "Akkun to Kanojo",
        "main_picture": {
          "medium": "https://cdn.myanimelist.net/images/anime/1404/90601.jpg",
          "large": "https://cdn.myanimelist.net/images/anime/1404/90601l.jpg"
        },
        "alternative_titles": {
          "synonyms": [
            "Akkun and His Girlfriend"
          ],
          "en": "My Sweet Tyrant",
          "ja": "あっくんとカノジョ"
        },
        "num_episodes": 25,
        "status": "finished_airing"
      }
    },
    {
      "node": {
        "id": 2325,
        "title": "Angel Blade Punish!",
        "main_picture": {
          "medium": "https://cdn.myanimelist.net/images/anime/5/3662.jpg",
          "large": "https://cdn.myanimelist.net/images/anime/5/3662l.jpg"
        },
        "alternative_titles": {
          "synonyms": [],
          "en": "",
          "ja": "エンジェルブレイドパニッシュ!"
        },
        "num_episodes": 3,
        "status": "finished_airing"
      }
    },
    {
      "node": {
        "id": 32828,
        "title": "Amaama to Inazuma",
        "main_picture": {
          "medium": "https://cdn.myanimelist.net/images/anime/6/80546.jpg",
          "large": "https://cdn.myanimelist.net/images/anime/6/80546l.jpg"
        },
        "alternative_titles": {
          "synonyms": [],
          "en": "Sweetness & Lightning",
          "ja": "甘々と稲妻"
        },
        "num_episodes": 12,
        "status": "finished_airing"
      }
    }
  ],
  "paging": {
    "next": "https://api.myanimelist.net/v2/anime?offset=10&q=SweetPunishment&nsfw=true&fields=id%2Ctitle%2Calternative_titles%2Cnum_episodes%2Cstatus"
  }
}

The correct entry is the second item in the search, but it didn't find it for some reason. The Anilist ID assigned is 101160 which does have the MAL ID:

{
  "data": {
    "Media": {
      "id": 101160,
      "idMal": 37320
    }
  }
}
vosmiic commented 5 months ago

That is because the plugin is falling back to the traditional method of searching via the API, which does a basic title match to detect the anime instead of using the metadata. Normally this would be fixed by using the TVDB metadata provider, but the anime list XML file seems to not contain the entry so it won't help in this case.

Is the Anilist metadata provider supplying that MAL ID? If so, we could use that to map to the other providers (and of course to MAL).

PythonCoderAS commented 5 months ago

That is because the plugin is falling back to the traditional method of searching via the API, which does a basic title match to detect the anime instead of using the metadata. Normally this would be fixed by using the TVDB metadata provider, but the anime list XML file seems to not contain the entry so it won't help in this case.

Is the Anilist metadata provider supplying that MAL ID? If so, we could use that to map to the other providers (and of course to MAL).

Anilist specifically has a mapping to MyAnimeList only. Kitsu has mappings to at least these ones (not guaranteed to exist but these are possible known values) and more that aren't documented (I saw Trakt and a bunch of others as well): Screenshot 2024-01-14 at 7 26 08 PM

Kitsu in particular will not show mature content without being logged in and the user needs to enable it in their settings.

PythonCoderAS commented 5 months ago

I think for now this does fix the immediate problem but there are still other problems.

vosmiic commented 5 months ago

Anilist specifically has a mapping to MyAnimeList only. Kitsu has mappings to at least these ones (not guaranteed to exist but these are possible known values) and more that aren't documented (I saw Trakt and a bunch of others as well): Screenshot 2024-01-14 at 7 26 08 PM

Kitsu in particular will not show mature content without being logged in and the user needs to enable it in their settings.

Ah I thought it might have added it to the metadata list when using Anilist as the main metadata provider. Yeah I have seen that the MAL ID is returned by the Anilist API, but I don't think using resources from one provider API to feed into another API is a good idea, as a few API's simply disallow this.

PythonCoderAS commented 5 months ago

Anilist specifically has a mapping to MyAnimeList only. Kitsu has mappings to at least these ones (not guaranteed to exist but these are possible known values) and more that aren't documented (I saw Trakt and a bunch of others as well): Screenshot 2024-01-14 at 7 26 08 PM Kitsu in particular will not show mature content without being logged in and the user needs to enable it in their settings.

Ah I thought it might have added it to the metadata list when using Anilist as the main metadata provider. Yeah I have seen that the MAL ID is returned by the Anilist API, but I don't think using resources from one provider API to feed into another API is a good idea, as a few API's simply disallow this.

I'm pretty sure that most providers just disallow wholesale scraping. It should probably be fine to get records for individual anime. Although this would require adding ways for providers to return data on other providers. A problem can easily develop where someone is using the plugin to update Kitsu but the anime item has an Anilist ID. Theoretically, if the Kitsu entry (maybe found by title search) only has a MAL ID, and the Anilist ID has the same MAL ID, you could reasonably determine that the anime is the same, but it would be very complex.