Skip to content

Commit

Permalink
[132] Add UIDs to episode data returns
Browse files Browse the repository at this point in the history
Will be used in manual per-Episode loading
  • Loading branch information
CollinHeist committed Oct 30, 2024
1 parent 89d5b5a commit 534628c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
24 changes: 20 additions & 4 deletions app/routers/episodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,15 @@ def get_all_episodes_on_connection(
jellyfin_interfaces: InterfaceGroup[int, JellyfinInterface] = Depends(get_jellyfin_interfaces),
plex_interfaces: InterfaceGroup[int, PlexInterface] = Depends(get_plex_interfaces),
) -> list[EpisodeData]:
""""""
"""
Get a list of all episode data for the given Series on the given
Connection.
- series_id: ID of the Series whose Episode data to query.
- interface_id: ID of the Connection to query Episode data from.
- library_name: Name of the library on the associated Connection to
look for Episode data within.
"""

# Get associated Series and Connection
series = get_series(db, series_id, raise_exc=True)
Expand All @@ -338,23 +346,31 @@ def get_all_episodes_on_connection(
)

# Get associated Interface from group
interface = None
interface, uid_attr = None, None
if connection.interface_type == 'Emby':
interface = emby_interfaces[interface_id]
uid_attr = 'emby_id'
elif connection.interface_type == 'Jellyfin':
interface = jellyfin_interfaces[interface_id]
uid_attr = 'jellyfin_id'
elif connection.interface_type == 'Plex':
interface = plex_interfaces[interface_id]
uid_attr = 'plex_id'

# Verify interface is available and valid
if not interface or not interface.active:
if not interface or not interface.active or not uid_attr:
raise HTTPException(
status_code=422,
detail='Interface ID or Connection is invalid'
)

return [
episode_info
EpisodeData(
season_number=episode_info.season_number,
episode_number=episode_info.episode_number,
title=episode_info.title,
uid=getattr(episode_info, uid_attr)[interface_id, library_name]
)
for episode_info, _ in interface.get_all_episodes(
library_name,
series.as_series_info,
Expand Down
1 change: 1 addition & 0 deletions app/schemas/episode.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ class EpisodeData(Base):
season_number: int
episode_number: int
title: str
uid: Any

class Episode(Base):
id: int
Expand Down
1 change: 1 addition & 0 deletions app/templates/js/.types.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@
* @property {number} season_number
* @property {number} episode_number
* @property {string} title
* @property {any} uid
*/

// Fonts -----------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion app/templates/js/series.js
Original file line number Diff line number Diff line change
Expand Up @@ -2120,7 +2120,7 @@ function loadCards(interfaceId, libraryName, reload=false) {

$.ajax({
type: 'PUT',
url: `/api/cards/series/{{series.id}}/load?${params.toString()}`,
url: `/api/cards/series/{{ series.id }}/load?${params.toString()}`,
success: () => {
showInfoToast('Loaded Title Cards');
getStatistics();
Expand Down
2 changes: 1 addition & 1 deletion modules/ref/version_webui
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.0-alpha.12.1-webui131
v2.0-alpha.12.1-webui132

0 comments on commit 534628c

Please sign in to comment.