• 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
    #5
    2023-10-13, 11:43 PM (This post was last modified: 2023-10-14, 10:59 AM by soy_titooo. Edited 3 times in total.)
    @Yankees4life

    Thanks for your reply. I googled your username + GitHub to see the scripts you did and I managed to copy it and modifiy  so I could have one script to create a collecion of Top 10 Trending Movies in Trakt (using mdblist) . Here is the Code:

    Code:
    # Set variables
    $jellyfinServerURL = "http://myjellyfin.tld/jellyfin"
    $jellyfinAPIKey = "my-jellyfin-spi-key"
    $libraryId = ""  # Replace with your library ID
    $collectionName = "- Trending Movies (Trakt)"
    $minRating = 2
    $minYear = 2022

    # Fetch the JSON from the URL
    $jsonURL = "https://mdblist.com/lists/titooo7/top-10-trending-trakt/json"
    $json = Invoke-RestMethod -Uri $jsonURL

    # Extract movie titles from the JSON
    $movieTitles = $json | ForEach-Object { $_.title }

    # Loop through libraries and create collections
    # Assume you have one library with ID $libraryId
    # You can modify the loop for multiple libraries if needed
    Write-Host "Creating collection: $($collectionName)"

    # Get list of items in library
    $itemsURL = "$jellyfinServerURL/items?ParentId=$libraryId&IncludeItemTypes=Movie&api_key=$jellyfinAPIKey&Recursive=true"
    $itemsResponse = Invoke-RestMethod -Uri $itemsURL -Method Get
    $items = $itemsResponse.Items | Where-Object { $movieTitles -contains $_.Name -and $_.PremiereDate.Year -ge $minYear -and $_.CommunityRating -ge $minRating }

    # Create collection
    if ($items.Count -gt 0) {
        $itemIDs = $items.Id -join ","
        $collectionURL = "$jellyfinServerURL/Collections?Name=$collectionName&Ids=$itemIDs&api_key=$jellyfinAPIKey"
        $collectionResponse = Invoke-RestMethod -Uri $collectionURL -Method Post
        Write-Host "Collection created with $($items.Count) movies."
    } else {
        Write-Host "No matching movies found in the library."
    }

    Again, it was chatgpt who helped me to modify your script to fit my purpose. I'm sure it could be better but..It works! Maybe one day I'll learn to do It myself, lol.

    Only annoying part is duplicated movies on Collections due to the different versiond of the movie being presente several times in the same library, but that seems an issue that Jellyfin Autocollection plugin can't fix yet.
    1
    « 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