2023-10-14, 11:00 AM
(2023-10-13, 11:43 PM)soy_titooo Wrote: @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 ps1 script:
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.