GingerSnap96 / Radarr-To-Plex-Collections

C# console application that creates movie collections in Plex based on collections in Radarr.
GNU General Public License v3.0
4 stars 0 forks source link

Attempted to divide by zero. #3

Closed ghost closed 4 months ago

ghost commented 4 months ago

First of all, thank you for creating this program!

However when I try to use it I get the following error: 2024-06-14 01:40:11.529 +02:00 [INF] Processing collections to Plex 2024-06-14 01:40:11.532 +02:00 [INF] Processing plex collection (1/11): The Lord of the Rings Collection 2024-06-14 01:40:11.532 +02:00 [ERR] Error processing Radarr movies in collection: The Lord of the Rings Collection. Details: Attempted to divide by zero.

I've attached the full log as well. log-2024-06-14_01-40-07.txt

I've tried on both Windows 11 64bit and Linux 64bit but get the same error on both.

Radarr version: 5.6.0.8846 Plex version: 1.40.3.8555

GingerSnap96 commented 4 months ago

Sorry to hear you're having issues! What is your value in the config.json for "MinForCollection"?

ghost commented 4 months ago

I've set the "MinForCollection" to 2. When changing it to 1 I get a bad request error.

2024-06-14 12:28:52.417 +02:00 [ERR] Failed to create collection. Status code: BadRequest

GingerSnap96 commented 4 months ago

Could you please upload your config.json for me to review? Ensure you remove the API keys.

ghost commented 4 months ago

As requested.

config.json

GingerSnap96 commented 4 months ago

Try as I might, I am unable to replicate this issue. I suspect there's something specific to your installation / configuration that is preventing the application from working as intended. I recommend checking out https://kometa.wiki/en/latest/ to see if it can assist you instead.

ghost commented 4 months ago

Thanks for looking in to it at least, I was hoping to skip plex meta manager/kometa because of the pretty daunting setup process, guess I'll have to make some time to set it up. 😔

ghost commented 4 months ago

I got around the Attempted to divide by zero. error by changing some code but now just stuck on BadRequest.

In the CreateCollection method, the collectionURL seems to just give me 400 Bad Request's.

If I create the Collection manually, the movies seem to get added fine.

GingerSnap96 commented 4 months ago

You can try to send the request and see if you're able to create a collection by replicating the request in postman or another http client. This is the actual http request that the app is trying to send that is giving you a bad request error.

  1. Get your server id by going to {yourIP}:32400/identity and copy the value for machineIdentifier
  2. Go into your plex library and select get info on any movie > view xml
  3. copy the value for ratingKey
  4. enter the values into the following url, replace any value including square brackets (including the brackets) and send the request as a post request.
GingerSnap96 commented 4 months ago

Disregard, i think i have the solution! Please replace the collectionURL in the program.cs with the following and see if this resolves your issue

string collectionURL = $"{plexURL}/library/collections?type=1&title={title}&smart=0&uri=server%3A%2F%2F{serverId}%2Fcom.plexapp.plugins.library%2Flibrary%2Fmetadata%2F{ratingKey}&sectionId={libraryId}&X-Plex-Product=Plex%20Web&X-Plex-Version=4.123.2&X-Plex-Client-Identifier=1mjve8qjaa7j8aodxmk18eo5&X-Plex-Platform=Microsoft%20Edge&X-Plex-Platform-Version=121.0&X-Plex-Features=external-media%2Cindirect-media%2Chub-style-list&X-Plex-Model=hosted&X-Plex-Device=Windows&X-Plex-Device-Name=Microsoft%20Edge&X-Plex-Device-Screen-Resolution=2505x1289%2C2561x1440&X-Plex-Token={plexToken}&X-Plex-Provider-Version=6.5&X-Plex-Text-Format=plain&X-Plex-Drm=playready&X-Plex-Language=en";

ghost commented 4 months ago

It works!!! Thank you so much!

GingerSnap96 commented 4 months ago

Awesome!! I will get this patched and a new version released. Thanks for sticking with it and helping me get this corrected to prevent issues for others!

ghost commented 4 months ago

And as for the original issue, I fixed it by doing the following: https://github.com/paatchii/Radarr-To-Plex-Collections/commit/8acf9a455bb12476faffd18e4b27e2a7e3bded24 , probably not the best way to solve the issue but the percentIncrement seems to be 0 with certain amounts of movies in the library.