-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
thomas
committed
Oct 6, 2024
1 parent
22eb009
commit 99bfc14
Showing
3 changed files
with
53 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import bs4 | ||
import requests | ||
import json | ||
from utils.base_plugin import ListScraper | ||
|
||
class JellyfinAPI(ListScraper): | ||
'''Generate collections based on Jellyfin API queries''' | ||
|
||
_alias_ = 'jellyfin_api' | ||
|
||
def get_list(list_id, config=None): | ||
'''Call jellyfin API | ||
list_id should be a dict to pass to https://api.jellyfin.org/#tag/Items/operation/GetItems | ||
''' | ||
params = { | ||
"enableTotalRecordCount": "false", | ||
"enableImages": "false", | ||
"Recursive": "true", | ||
"fields": ["ProviderIds", "ProductionYear"] | ||
} | ||
params = {**params, **list_id} | ||
|
||
res = requests.get(f'{config["server_url"]}/Users/{config["user_id"]}/Items',headers={"X-Emby-Token": config["api_key"]}, params=params) | ||
|
||
items = [] | ||
for item in res.json()["Items"]: | ||
items.append({ | ||
"title": item["Name"], | ||
"release_year": item.get("ProductionYear", None), | ||
"media_type": item["Type"], | ||
"imdb_id": item["ProviderIds"].get("Imdb", None) | ||
}) | ||
|
||
return { | ||
"name": f"{list_id}", | ||
"description": "Movies which match the jellyfin API query: {list_id}", | ||
"items": items | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters