Jump to content

Python script: Emby MDBList Collection Creator


Recommended Posts

Posted (edited)

Edit: There is a plugin version available now, please see ACdb thread. 

Emby MDBList Collection Creator

URL: https://github.com/jonjonsson/Emby-MDBList-Collection-Creator

This tool allows you to convert lists from MDBList.com into collections within your Emby media server. MDBList aggregates content lists from various platforms including Trakt and IMDB.

Features

  • List Conversion: Transform MDBList lists into Emby collections
  • Metadata Refresh: Keep ratings up-to-date for newly released content
  • Collection Images: Upload local or remote images for collections posters
  • Seasonal Collections: Specify when a collections should be visible
  • Collection Ordering: Show your collections in order of which one was update
  • Backup & Restore: Additional utilities to backup and restore watch history and favorites

Prerequisites:

To use this script, you need:

  • Python installed on your system
  • "Requests" Python package (install with `pip install requests`)
  • Admin privileges on your Emby server
  • A user account on [MDBList](https://mdblist.com/)
  • The script has been tested with Emby Version 4.8.8.0 and later, but other recent versions should also be compatible

Please check out the GitHub Link for more detailed information

image.thumb.png.ce3ed3d626f394527016316306741697.png

Edited by Amything
  • Like 5
  • Thanks 8
Posted

Hi, thanks for sharing.

  • Like 1
Killface69
Posted
On 1/24/2024 at 2:19 PM, Amything said:

This Python script allows you to take lists from MDBList.com and transform them into collections in Emby. If you are not familiar with MDBList is a platform that stores lists from Trakt, IMDB, and more, which can be accessed through an API. Checkout the Readme for more info.

https://github.com/jonjonsson/Emby-MDBList-Collection-Creator

 

You just ruined my evening 😉

  • Haha 1
  • 5 months later...
Posted

Amazing It's exactly what I was looking for. Thank you  !

  • 1 month later...
rbjtech
Posted
On 17/08/2024 at 08:24, shorty1483 said:

Thanks so much @Amything. Works flawlessly.

I take it you have used this to replace the recent test plugin that did the same ?  

Posted (edited)
On 8/22/2024 at 1:05 PM, rbjtech said:

I take it you have used this to replace the recent test plugin that did the same ?  

Yes. Run it as a scheduled task on my Windows machine once a day. Used to have 2 or 3 trakt lists that aren't available at mdblist but that doesn't bother me since mdblist has a bazillion other nice lists. Currently the list section looks like this:

[- IMDB: Top 250 Movies -]
Source = https://mdblist.com/lists/darksidelsd/imdb-top-250
Frequency = 100
update_items_sort_names = False

[- IMDB: Top 250 TV Shows -]
Source = https://mdblist.com/lists/swordfishtrumpet/imdb-top-250-tv-shows
Frequency = 100
update_items_sort_names = False

[- Rotten Tomatoes: Fresh TV Shows -]
Source = https://mdblist.com/lists/mgauci1000/metacritic-2022
Frequency = 100
update_items_sort_names = False

[- Rotten Tomatoes: Fresh Movies -]
Source = https://mdblist.com/lists/wierdaaron/rotten-tomatoes-fresh
Frequency = 100
update_items_sort_names = False

[- Academy Awards: Best Picture -]
Source = https://mdblist.com/lists/telecino/academy-awards-best-picture-winners
Frequency = 100
update_items_sort_names = False

[- Academy Awards: Best Actress -]
Source = https://mdblist.com/lists/qjao/academy-award-for-best-actress
Frequency = 100
update_items_sort_names = False

[- Academy Awards: Best Actor -]
Source = https://mdblist.com/lists/qjao/academy-award-for-best-actor
Frequency = 100
update_items_sort_names = False

[- Academy Awards: Best Music -]
Source = https://mdblist.com/lists/qjao/academy-award-for-best-sound
Frequency = 100
update_items_sort_names = False

[- Rotten Tomatoes: Best Movies 2024 -]
Source = https://mdblist.com/lists/siskourso/rotten-tomatoes-best-of-2024-ed84tni24k
Frequency = 100
update_items_sort_names = False

[- Rotten Tomatoes: Best TV Shows 2024 -]
Source = https://mdblist.com/lists/bustert/rotten-tomato-and-tmdb-best-tv-shows
Frequency = 100
update_items_sort_names = False

[- Metacritic: 90plus -]
Source = https://mdblist.com/lists/robflate/metacritic-all-time-90
Frequency = 100
update_items_sort_names = False

[- Golden Globe: Best Drama -]
Source = https://mdblist.com/lists/qjao/golden-globe-award-best-motion-picture-drama
Frequency = 100
update_items_sort_names = False

[- Golden Globe: Best Musical or Comedy -]
Source = https://mdblist.com/lists/qjao/golden-globe-award-best-motion-picture-musical-or-comedy
Frequency = 100
update_items_sort_names = False

[- Golden Globe: Best Music -]
Source = https://mdblist.com/lists/qjao/golden-globe-award-best-original-score-in-a-motion-picture
Frequency = 100
update_items_sort_names = False

[- Golden Globe: Best Actor Musical or Comedy -]
Source = https://mdblist.com/lists/qjao/golden-globe-award-best-actor-in-a-motion-picture-musical-or-comedy
Frequency = 100
update_items_sort_names = False

[- Golden Globe: Best Actress Musical or Comedy -]
Source = https://mdblist.com/lists/qjao/golden-globe-award-best-actress-in-a-motion-picture-musical-or-comedy
Frequency = 100
update_items_sort_names = False

[- Golden Globe: Best Actor Drama -]
Source = https://mdblist.com/lists/qjao/golden-globe-award-best-actor-in-a-motion-picture-drama
Frequency = 100
update_items_sort_names = False

[- Golden Globe: Best Actress Drama -]
Source = https://mdblist.com/lists/qjao/golden-globe-award-best-actress-in-a-motion-picture-drama
Frequency = 100
update_items_sort_names = False

[- Goldene Palme: Best Movie -]
Source = https://mdblist.com/lists/qjao/cannes-film-festival-palme-dor
Frequency = 100
update_items_sort_names = False

[- Critics Choice Award: Best Picture -]
Source = https://mdblist.com/lists/k0meta/critics-choice
Frequency = 100
update_items_sort_names = False

 

Edited by shorty1483
  • Like 3
  • Thanks 1
rbjtech
Posted (edited)

Excellent thanks for the config file .. saved me a bunch of work.

Not promising, but I may make this or something like it into an emby plugin as mdblist is getting popular now.. 😃

Giving props to @Amything of course !

Edited by rbjtech
  • Like 3
  • Thanks 1
CarneAsada
Posted

This is an amazing add-on function to the EMS experience. Thank you for creating this. I thought my EMS dashboard was complete and now we've added just a touch more. Very nice.

  • Like 1
Amything
Posted

Glad you guys are finding this useful!

I just updated so you can have multiple MDBList URLs in a single collection. I wanted to have fewer collections so, for example, combining Trending TV Shows and Trending Movies to a single collection is pretty useful. 

Example:

[Kids Trending]
Source = https://mdblist.com/lists/tvgeniekodi/trending-kids-movies, https://mdblist.com/lists/japante/trending-kids-shows
Frequency = 100
update_items_sort_names = True

I have not been keeping the thread up to date, but my other favourite updates are:

  • I was really annoyed that I could not easily glance at a collection and see what was newly added.  Now you can update the sort names of all items within a collection so that the newly added items appear first. This comes with the caveat that the sorting of the items within that collection are also affected outside it. Personally it doesn't affect me as I never go into Movies or TV Shows and sort by name. You can always turn it off to reset the sort names.
  • I was also annoyed that the ratings of brand new newly releases was often incorrect or missing at the time of adding them. Then they would stay missing or incorrect as the metadata was not refreshing. Now you can check for newly added items and refresh the metadata for a period of time until the rating has settled. Only works for items within collections.
  • Like 2
CarneAsada
Posted (edited)
On 8/25/2024 at 2:22 PM, Amything said:

Glad you guys are finding this useful!

I just updated so you can have multiple MDBList URLs in a single collection. I wanted to have fewer collections so, for example, combining Trending TV Shows and Trending Movies to a single collection is pretty useful. 

 

This makes it much easier, I also don't search for movies in any special order. I prefer new updates to rank at the top. I prefer community driven activity over any sorting order. I've updated the config file with this list now that I spent some actual time personalizing my Collections.

@AmythingIt would be great to update the Python script to fetch special movie posters from ChatGPT and upload them to the Collections. For the moment, I'm having to generate them manually. Here is a neat example: 

image.thumb.png.cecea9044f4ff7e0ae4edef00fc2cec6.png

 

 

 


[Top Scariest]
Source = https://mdblist.com/lists/chazlarson/esquire-60-scariest-movies-of-all-time
Frequency = 100
update_items_sort_names = True

[Top Funny]
Source = https://mdblist.com/lists/rizreflects/funny
Frequency = 100
update_items_sort_names = True

[Top Stand-Up]
Source = https://mdblist.com/lists/turtlespam/top-stand-up
Frequency = 100
update_items_sort_names = True

[Top Horror]
Source = https://mdblist.com/lists/praveenplex/rotten-tomatoes-2001-to-2021-above-70-horror
Frequency = 100
update_items_sort_names = True

[Top Romance]
Source = https://mdblist.com/lists/parmaster/top-romance-movies
Frequency = 100
update_items_sort_names = True

[Top Gangster]
Source = https://mdblist.com/lists/rizreflects/gangster-films, https://mdblist.com/lists/chazlarson/looper-31-best-gangster-movies-of-all-time
Frequency = 100
update_items_sort_names = True

[Top Hood]
Source = https://mdblist.com/lists/booted2765/hood-gang-related-gangster-crime-and-bitches
Frequency = 100
update_items_sort_names = True

[Weird]
Source = https://mdblist.com/lists/jarvis-12602219/weirdo-watchlist, https://mdblist.com/lists/jarvis-12602219/films-to-watch-at-2-3am-in-case-youre-drunk-andor-on-drugs-psychedelic-stoner
Frequency = 100
update_items_sort_names = True

[New Line Cinema]
Source = https://mdblist.com/lists/booted2765/new-line-production-total-list
Frequency = 100
update_items_sort_names = True

[Top Paranormal]
Source = https://mdblist.com/lists/j22kodi/paranormal
Frequency = 100
update_items_sort_names = True

[Top Conspiracy]
Source = https://mdblist.com/lists/showtime416/conspiracy-docs
Frequency = 100
update_items_sort_names = True

[Weekly Top 10]
Source = https://mdblist.com/lists/garycrawfordgc/top-movies-of-the-week
Frequency = 100
update_items_sort_names = True

[Trending Top 250]
Source = https://mdblist.com/lists/wombatfromheck/mdblist-trending-top-250
Frequency = 100
update_items_sort_names = True

[2000's Best]
Source = https://mdblist.com/lists/pilgrimhk/movies-00s-top-rated-rt-77-imdb-77-and-votes-15k
Frequency = 100
update_items_sort_names = True

[90s Best]
Source = https://mdblist.com/lists/hdlists/rottentomatoes-com-s-best-of-the-90s
Frequency = 100
update_items_sort_names = True

[80s Best]
Source = https://mdblist.com/lists/hdlists/rottentomatoes-com-s-best-of-the-80s
Frequency = 100
update_items_sort_names = True

[Kids Trending]
Source = https://mdblist.com/lists/tvgeniekodi/trending-kids-movies, https://mdblist.com/lists/japante/trending-kids-shows
Frequency = 100
update_items_sort_names = True

[Kids Top Halloween]
Source = https://mdblist.com/lists/hdlists/halloween-movies-for-kids
Frequency = 100
update_items_sort_names = True

[Christmas Movies]
Source = https://mdblist.com/lists/hdlists/christmas-movies
Frequency = 100
update_items_sort_names = True

[Top 100 Holiday]
Source = https://mdblist.com/lists/bbrodka1963/top-100-holiday-movies-english
Frequency = 100
update_items_sort_names = True

[Disney+]
Source = https://mdblist.com/lists/garycrawfordgc/disney-movies
Frequency = 100
update_items_sort_names = True

[HBO MAX]
Source = https://mdblist.com/lists/shaunatkins11/hbo-movies
Frequency = 100
update_items_sort_names = True

[Weekly Best]
Source = https://mdblist.com/lists/linaspurinis/top-watched-movies-of-the-week, https://mdblist.com/lists/jjjonesjr33/trakt-top-weekly
Frequency = 100
update_items_sort_names = True

[New Netflix Movies]
Source = https://mdblist.com/lists/bufoy/new-netflix, https://mdblist.com/lists/barfam/new-netflix-movies
Frequency = 100
update_items_sort_names = True

[Top TV Series]
Source = https://mdblist.com/lists/eplusg/top-tv-series
Frequency = 100
update_items_sort_names = True

# Example using list Mdblist ID
# To find the ID of an MDBList, search for "?list=" in the HTML source. 
[Trending Movies]
Id = 4887
# Source will be ignored if Id is used
Source = https://mdblist.com/lists/xinefq/trending-movie
Frequency = 100
update_items_sort_names = True

[Top 250 Movies]
Source = https://mdblist.com/lists/darksidelsd/imdb-top-250
Frequency = 100
update_items_sort_names = True

[Top 250 Shows]
Source = https://mdblist.com/lists/swordfishtrumpet/imdb-top-250-tv-shows
Frequency = 100
update_items_sort_names = True

[Fresh Movies]
Source = https://mdblist.com/lists/wierdaaron/rotten-tomatoes-fresh
Frequency = 100
update_items_sort_names = True

[Best Picture]
Source = https://mdblist.com/lists/telecino/academy-awards-best-picture-winners
Frequency = 100
update_items_sort_names = True

[Best Actress]
Source = https://mdblist.com/lists/qjao/academy-award-for-best-actress
Frequency = 100
update_items_sort_names = True

[Best Actor]
Source = https://mdblist.com/lists/qjao/academy-award-for-best-actor
Frequency = 100
update_items_sort_names = True

[Best Movies 2024]
Source = https://mdblist.com/lists/siskourso/rotten-tomatoes-best-of-2024-ed84tni24k
Frequency = 100
update_items_sort_names = True

 

Edited by CarneAsada
  • Like 1
Amything
Posted
22 hours ago, CarneAsada said:

@AmythingIt would be great to update the Python script to fetch special movie posters from ChatGPT and upload them to the Collections.

Sorry, I don't think I'll be adding that, mainly because it's a one time thing for each collection. A lot of work for that. 

I actually like the default thumbnail though. It updates whenever the collection updates so you don't even need to click the collection to see the latest 4 items.

image.png.657415612b36774e5a7549c33bc327b8.png

  • Like 1
Posted

As small amount of collection covers (currently RT, Oscars, Globes, Metacritic, Palme D'Or, CC) plus a GIMP template to do more by yourself can be found here.

 

  • Like 1
  • Thanks 1
CarneAsada
Posted
On 9/1/2024 at 10:03 AM, shorty1483 said:

As small amount of collection covers (currently RT, Oscars, Globes, Metacritic, Palme D'Or, CC) plus a GIMP template to do more by yourself can be found here.

 

Thank you! This is very useful. 

Posted

I can't get it to run unfortunately :(
Note, I am using Unraid , installed Python version is 3.12.5 , but not sure if that has anything to do with it

 

Traceback (most recent call last):
  File "/mnt/user/appdata/MDBList-Collection-Creator/venv/lib64/python3.12/site-packages/requests/models.py", line 974, in json
    return complexjson.loads(self.text, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/mnt/user/appdata/MDBList-Collection-Creator/app.py", line 330, in <module>
    main()
  File "/mnt/user/appdata/MDBList-Collection-Creator/app.py", line 289, in main
    process_my_lists_on_mdblist()
  File "/mnt/user/appdata/MDBList-Collection-Creator/app.py", line 233, in process_my_lists_on_mdblist
    process_list(mdblist_list)
  File "/mnt/user/appdata/MDBList-Collection-Creator/app.py", line 103, in process_list
    collection_id = emby.get_collection_id(collection_name)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/user/appdata/MDBList-Collection-Creator/emby.py", line 268, in get_collection_id
    all_collections = self.get_all_collections(False)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/user/appdata/MDBList-Collection-Creator/emby.py", line 167, in get_all_collections
    items = response.json()
            ^^^^^^^^^^^^^^^
  File "/mnt/user/appdata/MDBList-Collection-Creator/venv/lib64/python3.12/site-packages/requests/models.py", line 978, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

 

Posted
18 minutes ago, Deniax said:

I can't get it to run unfortunately :(

In app.py, inside the main() function. There is this line:

# print(f"Emby System Info: {emby.get_system_info()}")

Can you uncomment it by removing the # character.

Directly underneath the line put:

return

to prevent the rest of the script to run.

Try running that please. Any error?

Posted (edited)
3 minutes ago, Amything said:

In app.py, inside the main() function. There is this line:

# print(f"Emby System Info: {emby.get_system_info()}")

Can you uncomment it by removing the # character.

Directly underneath the line put:

return

to prevent the rest of the script to run.

Try running that please. Any error?

There you go :)

 

(venv) root@Tower:/mnt/user/appdata/MDBList-Collection-Creator# python app.py
Emby System Info: {'SystemUpdateLevel': 'Release', 'OperatingSystemDisplayName': 'Unix', 'HasPendingRestart': False, 'IsShuttingDown': False, 'HasImageEnhancers': True, 'OperatingSystem': 'Linux', 'SupportsLibraryMonitor': True, 'SupportsLocalPortConfiguration': True, 'SupportsWakeServer': False, 'WebSocketPortNumber': 8096, 'CompletedInstallations': [], 'CanSelfRestart': True, 'CanSelfUpdate': False, 'CanLaunchWebBrowser': False, 'HttpServerPortNumber': 8096, 'SupportsHttps': False, 'HttpsPortNumber': 8920, 'HasUpdateAvailable': False, 'SupportsAutoRunAtStartup': False, 'HardwareAccelerationRequiresPremiere': True, 'WakeOnLanInfo': [{'MacAddress': '0242AC120009', 'BroadcastAddress': '255.255.255.255', 'Port': 9}], 'LocalAddresses': [], 'RemoteAddresses': [], 'ServerName': '2698250c3575', 'Version': '4.8.8.0', 'Id': 'f8e279df4fba4753b610d6ab8a4a41f9'}

 

Edited by Deniax
Posted
3 hours ago, Deniax said:

There you go :)

OK, I thought your connection to Emby Api was not working but seems good! I just updated the script to give better errors for your case. Could you give it a shot and report back? If you have a Github account I would appreciate it if you post over there https://github.com/jonjonsson/Emby-MDBList-Collection-Creator/issues

  • Like 1
Posted (edited)
1 hour ago, Amything said:

OK, I thought your connection to Emby Api was not working but seems good! I just updated the script to give better errors for your case. Could you give it a shot and report back? If you have a Github account I would appreciate it if you post over there https://github.com/jonjonsson/Emby-MDBList-Collection-Creator/issues

Ok, I think my error was just a user mistake, but your extra debug output in the help , helped pinpoint me the problem :)

root@Tower:/mnt/user/appdata/MDBList-Collection-Creator# python app.py
Error occurred while getting Emby system info, check your configuration. Check your Emby url and port, user ID and API key: HTTPSConnectionPool(host='example.com', port=8096): Max retries exceeded with url: /emby/System/Info (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x150a9fcb3f80>: Failed to establish a new connection: [Errno 101] Network is unreachable'))
root@Tower:/mnt/user/appdata/MDBList-Collection-Creator
root@Tower:/mnt/user/appdata/MDBList-Collection-Creator# python app.py
Collection Popular movies of the week does not exist. Will create it.

Basically it told there Emby userID , and I filled in the config just the username, not the ID. And sure, in the config file it's clearly written, but I still skipped it, and the error message the new version gave, was great and solved my issue!

Thank you!
 

Edited by Deniax
  • Like 2
  • 2 weeks later...
Posted (edited)

Is there any way to disable the "Sort Title" function, I like to sort my collections myself and each time the scan runs it resets my own order. Thanks ahead of time for this plugin, been looking for something like this and wish I knew about it sooner, ty!

Edited by Danijjel
Posted
15 minutes ago, Danijjel said:

Is there any way to disable the "Sort Title" function, I like to sort my collections myself and each time the scan runs it resets my own order. Thanks ahead of time for this plugin, been looking for something like this and wish I knew about it sooner, ty!

Hey, glad it's helpful!

To disable items inside collections changing sort order set the following to false in the config file:

update_items_sort_names_default_value = False

Also make sure to set update_items_sort_names to false for each MDBList (or just delete the line after changing the above):

# Set update_items_sort_names to false for each mdblist
Source = https://mdblist.com/lists/xinefq/trending-movie
Frequency = 100
update_items_sort_names = False

If you mean you want to disable the ordering of the collections themselves in the config file you should find the following in config file

# Change Sort Name of Collections so that those that get modified are at the top
update_collection_sort_name = False

Set that to false. This will disable the collections themselves ordering by newest modified. Now that that I think about it, it will not reset your sort name back if you set it to false, I'll fix that later. Until then you have to edit Collection sort name in Metadata yourself or just delete the collection in Emby and run the script again. 

Posted
8 hours ago, Amything said:

If you mean you want to disable the ordering of the collections themselves in the config file you should find the following in config file

# Change Sort Name of Collections so that those that get modified are at the top
update_collection_sort_name = False 

Ah, I missed it, thank you very much for this.

When the script would finish it would throw out this error which would prevent it from auto updating.
 
Spoiler

Traceback (most recent call last):
  File "C:\Users\PC\Desktop\Emby Collection Creation\app.py", line 330, in <module>
    main()
  File "C:\Users\PC\Desktop\Emby Collection Creation\app.py", line 315, in main
    refresher.process_collection(
  File "C:\Users\PC\Desktop\Emby Collection Creation\refresher.py", line 54, in process_collection
    created_date = datetime.fromisoformat(
ValueError: Invalid isoformat string: '2024-08-16T14:11:22.0000000+00:00'



I used ChatGPT from here as I can't code. ChatGPT responded with this
 
Spoiler

"The ValueError you’re encountering is due to the datetime.fromisoformat() function not being able to handle the date string '2024-08-16T14:11:22.0000000+00:00' because it contains too many decimal places in the fractional seconds (seven zeros instead of the expected three).
Solutions
Here are two solutions to address this issue:
Option 1: Truncate the Fractional Seconds
You can modify the string to ensure it only has three decimal places:"


I went on to fix what I could using it's suggestions then I got this error
 
Spoiler

"The TypeError you’re encountering indicates that you are trying to subtract an "offset-aware" datetime (which includes timezone information) from an "offset-naive" datetime (which does not). To fix this, you need to ensure both datetime objects have the same timezone awareness.
Solution
You can make the current_date offset-aware by using the datetime.now() function with a timezone. Here’s how to modify your process_collection method:"



It spit out this version of "refresher.py"

Spoiler

from datetime import datetime, timezone
from dateutil import parser


class Refresher:
    """
    A class that represents a refresher for processing collections. Helps keeping the ratings in the collections
    up to date by refreshing items that are newly added or newly premiered.

    Attributes:
        emby (object): An instance of the Emby class.
        seconds_between_requests (int): The number of seconds between each request.
        processed_items (list): A list of already processed item IDs so they don't get processed again.
    """

    def __init__(self, emby):
        self.emby = emby
        self.seconds_between_requests = 1
        self.processed_items = []

    def process_collection(
        self,
        category_id: int,
        max_days_since_added: int,
        max_days_since_premiered: int,
        show_rating_change: bool = False,
    😞
        """
        Process a collection based on specified criteria.
        Both max_days_since_added and max_days_since_premiered must be satisfied for an item to be refreshed.

        Args:
            category_id (int): The ID of the category to process.
            max_days_since_added (int): Will be refreshed if the item was added to Emby less than this number of days ago.
            max_days_since_premiered (int): Will be refreshed if the item premiered less than this number of days ago.
            show_rating_change (bool): If True, will print the rating change for each item, requires an additional API request for each item.
        """

        items_in_collection = self.emby.get_items_in_collection(
            category_id, ["PremiereDate", "DateCreated", "CommunityRating"]
        )

        # Use UTC for current date
        current_date = datetime.now(timezone.utc)

        for item in items_in_collection:
            if item["Id"] in self.processed_items:
                continue

            self.processed_items.append(item["Id"])

            created_date = parser.isoparse(item["DateCreated"])  # Use dateutil to parse
            premier_date = None

            if item["PremiereDate"] is None:
                print(f"Premiere date missing. Setting date to now: {item['Id']} {item['Name']}")
                premier_date = current_date
            else:
                premier_date = parser.isoparse(item["PremiereDate"])  # Use dateutil to parse

            # Calculate days difference
            days_since_created = (current_date - created_date).days
            days_since_premiered = (current_date - premier_date).days

            if days_since_premiered > max_days_since_premiered:
                continue

            if days_since_created > max_days_since_added:
                continue

            r = self.emby.refresh_item(item["Id"])
            if r is True:
                print(f"    {item['Name']}")
                if not show_rating_change:
                    continue
                old_rating = item["CommunityRating"]
                item = self.emby.get_item(item["Id"])  # Get new rating
                if "CommunityRating" not in item:
                    item["CommunityRating"] = 0
                new_rating = item["CommunityRating"]
                print(f"    Rating change {old_rating} -> {new_rating}")
            else:
                print(f"ERROR: Item refresh fail: {item['Id']} {item['Name']}")


def main():
    pass


if __name__ == "__main__":
    main()



Which fixed all my issues and now "Waiting 6 hours for next refresh." is displayed at the end of the scan! Not sure if this is useful or not for anyone who may read this so I'll leave it up?

Either way thanks Amything!

  • Thanks 1
Posted
On 18/09/2024 at 08:16, Danijjel said:

When the script would finish it would throw out this error

OK interesting. I can´t replicate this. "ValueError: Invalid isoformat string: '2024-08-16T14:11:22.0000000+00:00'".

That is a valid isoformat string for me. What python version do you have? (python.exe --version)

  • 4 weeks later...
Posted (edited)

Hey, updated to version 1.7. There are no breaking changes from any older versions.

You can have seasonal collections now. Optionally specify a period of the year to show a collection for. For example only show a collection during Christmas every year. You can also specify an end date so a collection does not show again after a specific date, useful for something like this years Oscars collection that you don't want to be hanging about forever. A Halloween example in config.cfg:

# Example using a list that should only show during a specific period like Halloween. 
# Example: active_between = 2024-09-30, 2024-12-01
# Where first number sequence is date from and second is date to.
# Usually you want to skip the year so that it shows yearly. 
# Example: active_between = 09-30, 11-01.
[Best of Halloween]
Source = https://mdblist.com/lists/hdlists/the-top-100-halloween-movies-of-all-time
active_between = 09-30, 11-01
Frequency = 100
update_items_sort_names = False

 

Edited by Amything
  • Thanks 2
Posted
9 hours ago, Amything said:

Hey, updated to version 1.7. There are no breaking changes from any older versions.

You can have seasonal collections now. Optionally specify a period of the year to show a collection for. For example only show a collection during Christmas every year. You can also specify an end date so a collection does not show again after a specific date, useful for something like this years Oscars collection that you don't want to be hanging about forever. A Halloween example in config.cfg:

# Example using a list that should only show during a specific period like Halloween. 
# Example: active_between = 2024-09-30, 2024-12-01
# Where first number sequence is date from and second is date to.
# Usually you want to skip the year so that it shows yearly. 
# Example: active_between = 09-30, 11-01.
[Best of Halloween]
Source = https://mdblist.com/lists/hdlists/the-top-100-halloween-movies-of-all-time
active_between = 09-30, 11-01
Frequency = 100
update_items_sort_names = False

 

Love it :)  A nice update - thanks !

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...