Debian Codegraph @

README.md

raw symbols SCIP
1 # Jellyfin ApiClient Python
2
3 This is the API client from Jellyfin Kodi extracted as a python package so that other users may use the API without maintaining a fork of the API client. Please note that this API client is not complete. You may have to add API calls to perform certain tasks. Please see **Contributing** below.
4
5 ## Usage
6
7 This client can be installed with `pip3 install jellyfin-apiclient-python` and imported with `import jellyfin_apiclient_python`.
8
9 ### Creating a client
10
11 ```
12 from jellyfin_apiclient_python import JellyfinClient
13 client = JellyfinClient()
14 ```
15
16 You need to set some configuration values before you can connect a server:
17
18 ```
19 client.config.app('your_brilliant_app', '0.0.1', 'machine_name', 'unique_id')
20 client.config.data["auth.ssl"] = True
21 ```
22
23 ### Authenticating to a server
24
25 If you do not have a token, you will need to connect via username and password:
26
27 ```
28 client.auth.connect_to_address('server_url')
29 client.auth.login('server_url', 'username', 'password')
30 ```
31
32 You can then generate a token:
33
34 ```
35 credentials = client.auth.credentials.get_credentials()
36 server = credentials["Servers"][0]
37 server["username"] = 'username'
38 json.dumps(server)
39 ```
40
41 And if you wish then use that token to authenticate in future:
42
43 ```
44 json.loads(credentials)
45 client.authenticate({"Servers": [credentials]}, discover=False)
46 ```
47
48 You can also authenticate using an API key, which is generated on the server.
49 This is different to a device AccessToken, and is set by not configuring a
50 device name, or a device id:
51
52 ```python
53 client.config.data["app.name"] = 'your_brilliant_app'
54 client.config.data["app.version"] = '0.0.1'
55 client.authenticate({"Servers": [{"AccessToken": '<API key here>', "address": '<Server Address>'}]}, discover=False)
56
57 # Some endpoint require a user context event using API Key.
58
59 client.config.data["auth.user_id"] = '<UserID here>'
60 client.authenticate({"Servers": [{"AccessToken": '<API key here>', "address": '<Server Address>'}]}, discover=False)
61 ```
62
63 ### API
64
65 The API is accessed via the `jellyfin` attribute of the client. Return values
66 are a dictionary with 3 members, "Items", "TotalRecordCount" and "StartIndex"
67
68 The easiest way to fetch media objects is by calling `search_media_items`, like
69 so:
70
71 ```python
72 client.jellyfin.search_media_items(term="And Now for Something Completely Different", media="Videos")
73 ```
74
75 For details on what the individual API calls do or how to do a certain task, you will probably find the [Jellyfin MPV Shim](https://github.com/iwalton3/jellyfin-mpv-shim) and [Jellyfin Kodi](https://github.com/jellyfin/jellyfin-kodi) repositories useful.
76
77 ## Running the tests
78
79 The test suite is run via `tox`, and you can install it from PyPi.
80
81 - To run the linter: `tox -elint`
82 - To run the test suite, for Python 3.9: `tox -epy39`
83 - You can run multiple environments, if you wish: `tox -elint,py311`
84
85 ## Changes from Jellyfin Kodi
86
87 - Removal of `websocket.py` (now a dependency to `websocket_client`).
88 - Removal of dependencies on `helper` (from Jellyfin Kodi) and `kodi_six`.
89 - Add `has_attribute` directly to `__init__.py`.
90 - Add API calls:
91 - `get_season` for fetching season metadata.
92 - `get_audio_stream` to read an audio stream into a file
93 - `search_media_items` to search for media items
94 - `audio_url` to return the URL to an audio file
95 - Add parameters `aid=None, sid=None, start_time_ticks=None, is_playback=True` to API call `get_play_info`.
96 - Add timesync manager and SyncPlay API methods.
97 - Remove usage of `six` module.
98 - Add group of `remote_` API calls to remote control another session
99 - Configurable item refreshes allowing custom refresh logic (can also iterate through a list of items)
100 - Add support for authenticating via an API key
101 - Add support for the optional 'date played' parameter in the `item_played` API method
102 - Add API calls `get_userdata_for_item` and `update_userdata_for_item`
103 - Add API call `get_playlist_items` for fetching a playlist's contents in order
104 - Add support for the backup API introduced in Jellyfin 10.11.0
105 - Extend the (currently) experimental `identify` API call to include all parameters supported by Jellyfin
106 - Fix `close_live_stream` sending the stream id as a JSON body; the server binds
107 it from the query string, so the call always failed and leaked the tuner
108 - Add API call `get_user_items`, a named-argument form of the general item query
109 (`GET Users/{UserId}/Items`) that browse UIs otherwise had to build by hand
110 - Add browse API calls `get_resume_items`, `get_random_items`,
111 `get_items_by_person`, `get_album_tracks`, `get_artist_albums`,
112 `get_artist_songs`, `get_genre_songs` and `get_playlists`
113 - Add Live TV API calls `get_programs` and `get_recommended_programs`, and add
114 paging/field/`add_current_program` parameters to `get_channels`, which was
115 previously unbounded (note that `LiveTv/Channels` has no way to skip the
116 total record count, unlike the item endpoints)
117 - Add API calls `get_endpoint_info` (`System/Endpoint`) and
118 `update_user_settings`, the write side of `get_user_settings`
119 - Add API calls `get_chapter_image` and `get_trickplay_tile` for downloading
120 chapter thumbnails and scrubbing-preview tiles
121 - Add parameters `fields`, `enable_image_types`, `image_type_limit` and
122 `enable_total_record_count` to `get_recently_added`, `fields` to `get_items`,
123 and paging/sorting parameters to `get_collections`, `get_artists` and
124 `get_album_artists`
125 - Add parameters `timeout` and `retry` to `sessions`, so a health check can
126 fail fast instead of waiting out the client-wide defaults
127 - Add parameter `include_segment_types` to `get_media_segments`
128
129 ## Contributing
130
131 When contributing, please maintain backward compatibility with existing calls in the API. Adding parameters is
132 fine, but please make sure that they have default options to prevent existing software from breaking. Please
133 also add your changes to the **Changes from Jellyfin Kodi** section.
134
135 If you would like to produce documentation for this API, I would also be interested in accepting pull requests
136 for documentation.