Skip to content

Commit

Permalink
adding continuous parameter and resolving bug in resuming playQueue
Browse files Browse the repository at this point in the history
adding continuous parameter and resolving bug in resuming playQueue
  • Loading branch information
Siemon Geeroms committed Nov 30, 2024
1 parent a0d5fda commit 81b5a6a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 6 additions & 1 deletion homeassistant/components/plex/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import logging

import plexapi.playqueue

from homeassistant.components.media_player import MediaType
from homeassistant.helpers.template import result_as_boolean
from homeassistant.util import dt as dt_util
Expand Down Expand Up @@ -167,7 +169,10 @@ def offset(self) -> int:
if isinstance(resume, str):
resume = result_as_boolean(resume)
if resume:
return self.media.viewOffset
media = self.media
if isinstance(media, plexapi.playqueue.PlayQueue) and len(media.items) > 0:
media = media.items[0]
return getattr(media, 'viewOffset', 0)
return 0

@property
Expand Down
5 changes: 3 additions & 2 deletions homeassistant/components/plex/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,16 +193,17 @@ def process_plex_payload(

search_query = content.copy()
shuffle = search_query.pop("shuffle", 0)
continuous = search_query.pop("continuous", 0)

# Remove internal kwargs before passing copy to plexapi
for internal_key in ("resume", "offset"):
search_query.pop(internal_key, None)

media = plex_server.lookup_media(content_type, **search_query)

if supports_playqueues and (isinstance(media, list) or shuffle):
if supports_playqueues and (isinstance(media, list) or shuffle or continuous):
playqueue = plex_server.create_playqueue(
media, includeRelated=0, shuffle=shuffle
media, includeRelated=0, shuffle=shuffle, continuous=continuous
)
return PlexMediaSearchResult(playqueue, content)

Expand Down

0 comments on commit 81b5a6a

Please sign in to comment.