Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jellyfin/jellyfin-apiclient-python
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 778134420d50b91f0a4b85f9c88b71095b770eca
Choose a base ref
..
head repository: jellyfin/jellyfin-apiclient-python
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 9b7542158331ebdbb9b040c4595d3447dc70af0e
Choose a head ref
Showing with 59 additions and 1 deletion.
  1. +59 −1 jellyfin_apiclient_python/api.py
60 changes: 59 additions & 1 deletion jellyfin_apiclient_python/api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# -*- coding: utf-8 -*-
"""
For API info see:
https://api.jellyfin.org/
"""
from typing import List
from datetime import datetime
import requests
@@ -115,6 +119,33 @@ def users(self, handler="", action="GET", params=None, json=None):
else:
return self._get("Users/{UserId}%s" % handler, params)

def media_folders(self, params=None):
return self._get("Library/MediaFolders/", params)

def virtual_folders(self, action="GET", params=None, json=None):
if action == "POST":
return self._post("Library/VirtualFolders", json, params)
elif action == "DELETE":
return self._delete("Library/VirtualFolders", params)
else:
return self._get("Library/VirtualFolders", params)

def physical_paths(self, params=None):
return self._get("Library/PhysicalPaths/", params)

def folder_contents(self, abspath="/", params=None, json=None):
params = {} if params is None else params.copy()
params['path'] = abspath
params['includeFiles'] = params.get('includeFiles', True)
params['includeDirectories'] = params.get('includeDirectories', True)
return self._get("Environment/DirectoryContents", params)

def refresh_library(self):
"""
Starts a library scan.
"""
return self._post("Library/Refresh")

def items(self, handler="", action="GET", params=None, json=None):
if action == "POST":
return self._post("Items%s" % handler, json, params)
@@ -796,6 +827,33 @@ def new_sync_play_v2(self, group_name):
})


class ExperimentalAPIMixin:
"""
This is a location for testing proposed additions to the API Client.
"""

def identify(client, item_id, provider_ids):
"""
Remote search for item metadata given one or more provider id.
This method requires an authenticated user with elevated permissions
[RemoveProviderSearch]_.
Args:
item_id (str): item uuid to identify and update metadata for.
provider_ids (Dict):
maps providers to the content id. (E.g. {"Imdb": "tt1254207"})
Valid keys will depend on available providers. Common ones are:
"Tvdb" and "Imdb".
References:
.. [RemoveProviderSearch] https://api.jellyfin.org/#tag/ItemLookup/operation/ApplySearchCriteria
"""
body = {'ProviderIds': provider_ids}
return client.jellyfin.items('/RemoteSearch/Apply/' + item_id, action='POST', params=None, json=body)


class CollectionAPIMixin:
"""
Methods for creating and modifying collections.
@@ -878,7 +936,7 @@ def remove_collection_items(self, collection_id, item_ids=None):


class API(InternalAPIMixin, BiggerAPIMixin, GranularAPIMixin,
SyncPlayAPIMixin, CollectionAPIMixin):
SyncPlayAPIMixin, ExperimentalAPIMixin, CollectionAPIMixin):
"""
The Jellyfin Python API client containing all api calls to the server.