Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make docstrings consistent #33

Merged
merged 4 commits into from
Dec 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 44 additions & 49 deletions jellyfin_apiclient_python/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ def videos(self, handler):
def artwork(self, item_id, art, max_width, ext="jpg", index=None):
params = {"MaxWidth": max_width, "format": ext}
handler = ("Items/%s/Images/%s" % (item_id, art) if index is None
else "Items/%s/Images/%s/%s" % (item_id, art, index)
)
else "items/%s/images/%s/%s" % (item_id, art, index)
)

return self._get_url(handler, params)

Expand Down Expand Up @@ -294,46 +294,35 @@ def search_media_items(self, term=None, year=None, media=None, limit=20, parent_
Search for media using terms, production year(s) and media type

Args:
>>> term: str
>>> year: int
>>> media: str
>>> limit: int
>>> parent_id: str
term (str):
year (int):
media (str):
limit (int):
parent_id (str):

Returns:
>>> dict

Raises:
>>> None
dict

Example:

-

INPUT:
>>> client.jellyfin.search_media_items(term='The Lion King', year=1994, media='Movie', limit=1)

-

OUTPUT:
>>> 'Items':
[
{
'Name': 'The Lion King',
...
'ProductionYear': 1994
...
'Type': 'Movie'
}
]
>>> result = client.jellyfin.search_media_items(term='The Lion King', year=1994, media='Movie', limit=1)
>>> result['Items']
[
{
'Name': 'The Lion King',
...
'ProductionYear': 1994
...
'Type': 'Movie'
}
]
"""
return self.user_items(params={
'searchTerm': term,
'years': year,
'Recursive': True,
'IncludeItemTypes': media,
'Limit': limit,
'parentId':parent_id
'parentId': parent_id,
})

def get_channels(self):
Expand Down Expand Up @@ -430,13 +419,13 @@ def refresh_item(self, item_id, recursive=True, image_refresh='FullRefresh', met
- You may also configure the refresh manually by passing a value for each parameter.

Args:
>>> item_id: str or list
>>> recursive: bool
>>> image_refresh: str 'Default' or 'ValidationOnly' or 'FullRefresh'
>>> image_refresh: str 'Default' or 'ValidationOnly' or 'FullRefresh'
>>> replace_images: bool
>>> replace_metadata: bool
>>> preset: str 'missing' or 'replace'
item_id (str | List[str]): one or more items to refresh
recursive (bool):
image_refresh (str): 'Default' or 'ValidationOnly' or 'FullRefresh'
image_refresh (str): 'Default' or 'ValidationOnly' or 'FullRefresh'
replace_images (bool):
replace_metadata (bool)
preset (str): 'missing' or 'replace'

Examples:
>>> client.jellyfin.refresh_item('123456abcd', preset='missing')
Expand Down Expand Up @@ -478,7 +467,6 @@ def refresh_item(self, item_id, recursive=True, image_refresh='FullRefresh', met
# If item_id is a single string, just refresh that item
return self.items("/%s/Refresh" % item_id, "POST", params=params)


def favorite(self, item_id, option=True):
return self.users("/FavoriteItems/%s" % item_id, "POST" if option else "DELETE")

Expand Down Expand Up @@ -507,10 +495,13 @@ def remote_playpause(self, id):
return self.remote(id, "PlayPause")

def remote_seek(self, id, ticks, params={}, json={}):
"""Set the volume on the sessions.
"""
Seek to a specific position in the specified session.

@id: The session id to control
@ticks: The position (in ticks) to seek to"""
Args:
id (int): The session id to control
ticks (int): The position (in ticks) to seek to
"""
return self.remote(
id, "Seek", params={"seekPositionTicks": ticks, **params}, json=json
)
Expand All @@ -526,9 +517,10 @@ def remote_play_media(
):
"""Instruct the session to play some media

@id: The session id to control
@item_ids: A list of items to play
@command: When to play. (*PlayNow*, PlayNext, PlayLast, PlayInstantMix, PlayShuffle)
Args:
id (str): The session id to control
item_ids (List[str]): A list of items to play
command (str): When to play. (*PlayNow*, PlayNext, PlayLast, PlayInstantMix, PlayShuffle)
"""
return self.remote(
id,
Expand All @@ -538,10 +530,13 @@ def remote_play_media(
)

def remote_set_volume(self, id: str, volume: int, json={}):
"""Set the volume on the sessions.
"""
Set the volume on the sessions.

@id: The session id to control
@volume: The volume normalized from 0 to 100"""
Args:
id (int): The session id to control
volume (int): The volume normalized from 0 to 100
"""
return self.command(id, "SetVolume", json={"Volume": volume, **json})

def remote_mute(self, id):
Expand Down Expand Up @@ -651,7 +646,7 @@ def login(self, server_url, username, password=""):
LOG.debug(headers)

return {}
except Exception as e: # Find exceptions for likely cases i.e, server timeout, etc
except Exception as e: # Find exceptions for likely cases i.e, server timeout, etc
LOG.error(e)

return {}
Expand Down