Skip to content
Closed
Show file tree
Hide file tree
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
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 @@
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]

Check warning on line 174 in homeassistant/components/plex/models.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/plex/models.py#L174

Added line #L174 was not covered by tests
return getattr(media, "viewOffset", 0)
return 0

@property
Expand Down
8 changes: 6 additions & 2 deletions homeassistant/components/plex/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,16 +193,20 @@ 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=1 if shuffle else 0,
continuous=1 if continuous else 0,
)
return PlexMediaSearchResult(playqueue, content)

Expand Down