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)
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)
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)