ShokoAnime / Shokofin

Repository for Shokofin, a plugin that brings Shoko to Jellyfin.
https://shokoanime.com
MIT License
140 stars 17 forks source link

Bug: Image fetching is broken and possibly more? #17

Closed xNinjaKittyx closed 3 years ago

xNinjaKittyx commented 3 years ago

Had a discussion on #shokofin on discord a while back. I didn't file a bug, but since this has recently been updated, I figured I'd leave this here.

I initially started looking into this when my thumbnails would never show up for new anime... so I started looking into it more.

I'm pretty sure everything is broken out of the box (at least for people who don't use the "auto group" in shoko. Not sure if this applies to people who have the library structured differently).

I did a patch on my own build back in february (disclaimer, I don't know .NET, but I just did some quick googling to figure it out)

diff --git a/Shokofin/Providers/SeriesProvider.cs b/Shokofin/Providers/SeriesProvider.cs
index e18a62d..1de4146 100644
--- a/Shokofin/Providers/SeriesProvider.cs
+++ b/Shokofin/Providers/SeriesProvider.cs
@@ -34,12 +34,17 @@ namespace Shokofin.Providers
             {
                 var result = new MetadataResult<Series>();

-                var dirname = Path.DirectorySeparatorChar + info.Path.Split(Path.DirectorySeparatorChar).Last();
+                var dirname = info.Path.Split(Path.DirectorySeparatorChar).Last();

                 _logger.LogInformation($"Shoko Scanner... Getting series ID ({dirname})");

                 var apiResponse = await ShokoAPI.GetSeriesPathEndsWith(dirname);
-                var seriesIDs = apiResponse.FirstOrDefault()?.IDs;
+                // if an exact match shows up, use that one.
+                var seriesIDs = apiResponse?.FirstOrDefault(series => series.Name == dirname)?.IDs;
+                if (seriesIDs is null)
+                {
+                    seriesIDs = apiResponse.FirstOrDefault()?.IDs;
+                }
                 var seriesId = seriesIDs?.ID.ToString();

                 if (string.IsNullOrEmpty(seriesId))

The main problem here is the var apiResponse = await ShokoAPI.GetSeriesPathEndsWith(dirname); which the URL currently ends with /, so you end up searching for /api/v3/Series/PathEndsWith//Senryuu Shoujo (double slash is intentional) for example, and this returns empty because there's no show that ends with /Senryuu Shoujo in my shoko instance.

At least for my case, this patch works perfectly. It simply checks to make sure the name is exactly the same as Shoko (since shoko is also managing the library anyways).

Without the Exact check (but with the / fix), you run into some scenarios that are unfixable even with the "Identify" feature

Eiga K-On! vs K-On! - When you Identify as K-On!, the problem is both of these shows show up in the shoko api. Since Eiga K-On! comes first, K-On! is now impossible to label as K-On!

I didn't want to think I was crazy, So i spun up 2 more jellyfin instances fresh, but using my existing library, 1 using 1.4.0 and 1 using my patched "1.3.1-dev"

No shows appeared on 1.4.0 at all - but 1.3.1-patched showed my shows with the metadata.

I don't think my patch is perfect, but this problem is there and should probably be fixed?

Shoko: 4.1.0.0 - daily build Shokofin: 1.4.0 Jellyfin - 10.7.0

Shoko Settings: Autogroup Series - Off Determine Main Series... - Off

On Shokofin: All default settings.

Jellyfin Library settings: All Default except changing all fetchers to use Shoko only.

harshithmohan commented 3 years ago

Fixed in release 1.4.5.1