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

New continuous parameter, Plex will automatically play the next episode in the series. #131979

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
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 @@ 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
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