• Login
  • Register
  • Login Register
    Login
    Username/Email:
    Password:
    Or login with a social network below
  • Forum
  • Website
  • GitHub
  • Status
  • Translation
  • Features
  • Team
  • Rules
  • Help
  • Feeds
User Links
  • Login
  • Register
  • Login Register
    Login
    Username/Email:
    Password:
    Or login with a social network below

    Useful Links Forum Website GitHub Status Translation Features Team Rules Help Feeds
    Jellyfin Forum Development Feature Requests Create collections within seconds based on lists from mdblist

     
    • 0 Vote(s) - 0 Average

    Create collections within seconds based on lists from mdblist

    python script
    soy_titooo
    Offline

    Junior Member

    Posts: 12
    Threads: 4
    Joined: 2023 Jul
    Reputation: 0
    #1
    2023-10-04, 12:09 PM (This post was last modified: 2023-10-04, 12:15 PM by soy_titooo. Edited 4 times in total.)
    The following script I did with chatgpt works Emby. It does not work with Jellyfin , but I'm sure it'd be very easy to port it to jellyfin. I just don't know how to....

    Here is a python script that would create a collection with the top movies of the week (again, it works in Emby but not jellyfin)

    Code:
    import requests
    import json
    import subprocess
    from urllib.parse import quote

    # URL of the JSON file containing movie data
    json_url = "https://mdblist.com/lists/garycrawfordgc/top-movies-of-the-week/json/"

    # Fetch the JSON data from the URL
    response = requests.get(json_url)

    if response.status_code == 200:
        # Parse the JSON data
        movie_data = json.loads(response.text)

        # Extract IMDb IDs from the JSON data and add the "imdb." prefix
        imdb_ids = ["imdb." + movie["imdb_id"] for movie in movie_data]

        # Construct the IMDb IDs string for the Emby API request
        imdb_ids_str = "%2C".join(imdb_ids)

        # Define your Emby API key
        emby_api_key = 'YOUR-EMBY-API-KEY'

        # Build the Emby API URL with the IMDb IDs
        emby_api_url = f"https://YOUR-EMBY-DOMAIN-OR-IPADDRESS/emby/Items?Recursive=true&AnyProviderIdEquals={imdb_ids_str}&api_key={emby_api_key}"

        # Print the Emby API URL
        print("Emby API URL:", emby_api_url)

        # Execute the curl command to get movie data from Emby
        subprocess.run(["curl", emby_api_url])

        ### SECOND PART
        # Extract the movie IDs from the Emby API URL JSON dataA
        emby_response = requests.get(emby_api_url)
        emby_data = emby_response.json()

        movie_ids = [item['Id'] for item in emby_data['Items']]

        # Create a comma-separated string of movie IDs
        movie_ids_str = '%2C'.join(map(str, movie_ids))

        # Define the collection name (without %20)
        collection_name = 'Top Movies of the week'

        # Encode the collection name with %20
        encoded_collection_name = quote(collection_name)

        # Construct the curl command to create the collection
        curl_command = f'curl -X POST "https://YOUR-EMBY-DOMAIN-OR-IPADDRESS/emby/Collections?Name={encoded_collection_name}&Ids={movie_ids_str}&api_key={emby_api_key}" -H "accept: application/json"'

        # Print the curl command
        print("Curl command:", curl_command)

        # Execute the curl command
        subprocess.run(curl_command, shell=True)

    else:
        print("Failed to fetch JSON data")

    Additional comments:
    1-You might want to replace json_url by the mdblist url of a different list. Then you'll also want to modify the collection_name line
    2-Replace YOUR-EMBY-API-KEY by your actual api key that you can find in your emby settings
    3- Replace YOUR-EMBY-DOMAIN-OR-IPADDRESS with your server details (there are two lines where you need to do that)

    I got this idea from this thread on emby forums https://emby.media/community/index.php?/...rt/page/2/

    There are some guys that apparently managed to do more than I did, and probably even better but they don't seem interested on sharing their code.

    I'm hoping this community is more open minded and someone can take port it to Jellyfin and take it to the next level (eg: add collections to a main screen row like Top Picks plugin does with its own collection)
    « Next Oldest | Next Newest »

    Users browsing this thread: 1 Guest(s)


    Messages In This Thread
    Create collections within seconds based on lists from mdblist - by soy_titooo - 2023-10-04, 12:09 PM
    RE: Create collections within seconds based on lists from mdblist - by mcarlton00 - 2023-10-05, 12:56 PM
    RE: Create collections within seconds based on lists from mdblist - by soy_titooo - 2023-10-10, 09:11 AM
    RE: Create collections within seconds based on lists from mdblist - by Yankees4life - 2023-10-13, 02:10 AM
    RE: Create collections within seconds based on lists from mdblist - by soy_titooo - 2023-10-13, 11:43 PM
    RE: Create collections within seconds based on lists from mdblist - by soy_titooo - 2023-10-14, 11:00 AM
    RE: Create collections within seconds based on lists from mdblist - by Yankees4life - 2023-10-14, 06:19 PM
    RE: Create collections within seconds based on lists from mdblist - by soy_titooo - 2023-10-15, 07:13 AM
    RE: Create collections within seconds based on lists from mdblist - by Yankees4life - 2023-10-18, 07:33 PM

    • View a Printable Version
    • Subscribe to this thread
    Forum Jump:

    Home · Team · Help · Contact
    © Designed by D&D - Powered by MyBB
    L


    Jellyfin

    The Free Software Media System

    Linear Mode
    Threaded Mode