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

Intermittent Jellyfin API error #47

Open
vortex91 opened this issue Jun 24, 2024 · 5 comments
Open

Intermittent Jellyfin API error #47

vortex91 opened this issue Jun 24, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@vortex91
Copy link

vortex91 commented Jun 24, 2024

I added

imdb_id_filter:  true
year_filter:  true

but I keep getting wrong movie added to collection for box office for "IF" movie 2024 instead I keep getting "IF ONLY" 2004 picked up.

It also has same issue wityh mdblist plugin

@vortex91 vortex91 changed the title I seem to be having issues with wrong movie being picked up by imdb_list I seem to be having issues with wrong movie being picked up by imdb_chart Jun 24, 2024
@ghomasHudson ghomasHudson added the bug Something isn't working label Jun 25, 2024
@ghomasHudson
Copy link
Owner

Hmmm if you're comfortable with python, try printing item at line 111 of utils/jellyfin.py. Hopefully imdb_id should be there

@vortex91
Copy link
Author

vortex91 commented Jun 25, 2024

Nevermind it seems like its adding correct one now. WHen I was having issues it was 10.9.6 now im on 10.9.7 and its adding correct movie even though its giving the error below.,

Checking for exact IMDb ID match...
Result IMDb ID: tt0332136, Item IMDb ID: tt11152168
Result IMDb ID: tt11152168, Item IMDb ID: tt11152168
Exact IMDb ID match found.
Item ID to add to collection: 74b10010ea45ed62ce9b5d48d45fbbe7
2024-06-25 12:36:49.822 | ERROR | utils.jellyfin:add_item_to_collection:149 - Error adding IF to collection - Status Code: 204
Error adding IF to collection - Status Code: 204
Final match: {'Name': 'IF', 'ServerId': '95e70d793a464bb6addaf24ff336e99c', 'Id': '74b10010ea45ed62ce9b5d48d45fbbe7', 'HasSubtitles': True, 'Container': 'mkv', 'PremiereDate': '2024-05-08T00:00:00.0000000Z', 'CriticRating': 49, 'OfficialRating': 'PG', 'ChannelId': None, 'CommunityRating': 7.06, 'RunTimeTicks': 64454510000, 'ProductionYear': 2024, 'ProviderIds': {'Tmdb': '639720', 'Imdb': 'tt11152168'}, 'IsFolder': False, 'Type': 'Movie', 'UserData': {'PlaybackPositionTicks': 0, 'PlayCount': 1, 'IsFavorite': False, 'LastPlayedDate': '2024-06-21T20:27:50.5315968Z', 'Played': False, 'Key': '639720'}, 'VideoType': 'VideoFile', 'ImageBlurHashes': {}, 'LocationType': 'FileSystem', 'MediaType': 'Video'}

@vortex91
Copy link
Author

I have no idea what i did. But using original codd on 10.9.7 the movie IF now does not get added but If only also does not get added. However editing the code to print debug info somehow makes it add the correct movies even though it prints the error in above comment. Here is my udpated code to print debug info which somehow fixed adding the correct movies.

    # Check if there's an exact imdb_id match first
    match = None
    if "imdb_id" in item:
        print("Checking for exact IMDb ID match...")
        for result in res.json()["Items"]:
            imdb_id = result["ProviderIds"].get("Imdb", None)
            print(f"Result IMDb ID: {imdb_id}, Item IMDb ID: {item['imdb_id']}")
            if imdb_id == item["imdb_id"]:
                match = result
                print("Exact IMDb ID match found.")
                break
    else:
        # Check if there's a year match
        if match is None and year_filter:
            print("Checking for production year match...")
            for result in res.json()["Items"]:
                production_year = result.get("ProductionYear", None)
                print(f"Result Production Year: {production_year}, Item Release Year: {item['release_year']}")
                if production_year == item["release_year"]:
                    match = result
                    print("Production year match found.")
                    break

        # Otherwise, just take the first result
        if match is None and len(res.json()["Items"]) == 1:
            print("No exact IMDb ID or production year match found. Taking the first result.")
            match = res.json()["Items"][0]

    if match is None:
        logger.warning(f"Item {item['title']} not found in jellyfin")
        print(f"Item {item['title']} not found in jellyfin")
    else:
        try:
            item_id = match["Id"]
            print(f"Item ID to add to collection: {item_id}")
            response = requests.post(f'{self.server_url}/Collections/{collection_id}/Items?ids={item_id}', headers={"X-Emby-Token": self.api_key})
            if response.status_code == 200:
                logger.info(f"Added {item['title']} to collection")
                print(f"Added {item['title']} to collection")
            else:
                logger.error(f"Error adding {item['title']} to collection - Status Code: {response.status_code}")
                print(f"Error adding {item['title']} to collection - Status Code: {response.status_code}")
        except json.decoder.JSONDecodeError:
            logger.error(f"Error adding {item['title']} to collection - JSONDecodeError")
            print(f"Error adding {item['title']} to collection - JSONDecodeError")
            return

    # Final match debugging
    print("Final match:", match)

@ghomasHudson
Copy link
Owner

This sounds like the jellyfin api being flakey. I can add back some old code which repeatedly calls the jellyfin api when it breaks like this.

@ghomasHudson ghomasHudson changed the title I seem to be having issues with wrong movie being picked up by imdb_chart Intermittent Jellyfin API error Aug 21, 2024
@ghomasHudson
Copy link
Owner

@vortex91 is this error still happening?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants