Skip to content

Feature: Add label methods, properties to Episodes - #868

Closed
glensc wants to merge 2 commits into
pushingkarmaorg:masterfrom
glensc:episode-label
Closed

Feature: Add label methods, properties to Episodes#868
glensc wants to merge 2 commits into
pushingkarmaorg:masterfrom
glensc:episode-label

Conversation

@glensc

@glenscglensc commented Jan 10, 2022

Copy link
Copy Markdown
Contributor

Description

Seems LabelMixin was added to Album, Collection, Show, and Movie, but left out of Episode.

My testing with 1.24.3.5033-757abe6b4 shows that Episodes can also have labels.

>>>episode.addLabel(['skip-pts'])
>>>episode= (fetchepisodeagain)
>>>print(episode.labels)
[<Label:/library/sections/2/:Skip-pts>]

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated the docstring for new or existing methods
  • I have added tests when applicable

@JonnyWong16

JonnyWong16 commented Jan 10, 2022

Copy link
Copy Markdown
Collaborator

Labels were not added to episodes because you can't add them in the Plex UI.

There may be unexpected issues/bugs with sharing label restrictions because Plex isn't designed to support episodes.

@glensc

glensc commented Jan 10, 2022

Copy link
Copy Markdown
ContributorAuthor

Additionally, seems Plex doesn't find any matches for episodes even you can do filter episodes by label (Under Advanced Filters)

image

@JonnyWong16

Copy link
Copy Markdown
Collaborator

The Label filter is for shows (show.label).

image

@meisnate12

meisnate12 commented Jan 10, 2022

Copy link
Copy Markdown
Contributor

so as far as i can tell episode.label does work in the filter string but you cant do it though the UI or through any of the standard ways to make a smart collection using the plexapi but i was able to get it working with the following code. You could do something similar if you want it to be in a search. Use it at your own risk.

fromplexapi.serverimportPlexServerfromplexapiimportutilsPLEX_URL=""PLEX_TOKEN=""PLEX_LIBRARY=""EPISODE_LABEL=""COLLECTION_NAME=""ps=PlexServer(PLEX_URL, PLEX_TOKEN, timeout=600)
lib=next((sforsinps.library.sections() ifs.title==PLEX_LIBRARY), None)
iflib:
key=Noneforchoiceinlib.listFilterChoices("label"):
ifchoice.title==EPISODE_LABEL:
key=choice.keybreakifkey:
args= {
"type": 4,
"title": COLLECTION_NAME,
"smart": 1,
"sectionId": lib.key,
"uri": f"server://{ps.machineIdentifier}/com.plexapp.plugins.library/library/sections/{lib.key}/all?type=4&episode.label={key}"
}
ps.query(f"/library/collections{utils.joinArgs(args)}", method=ps._session.post)

Comment threadplexapi/video.py Outdated
Comment threadplexapi/video.py
@JonnyWong16

Copy link
Copy Markdown
Collaborator

Add test.

https://github.com/pkkid/python-plexapi/blob/master/tests/test_video.py#L1151

test_mixins.edit_label(episode)

@glensc

Copy link
Copy Markdown
ContributorAuthor

Test added 874d6e2

@glensc

Copy link
Copy Markdown
ContributorAuthor

Are the errors really from this PR?


=================================== FAILURES ===================================
_______________ test_library_section_totalViewSize[anonymously] ________________
Traceback (most recent call last):
File "/home/runner/work/python-plexapi/python-plexapi/tests/test_library.py", line 98, in test_library_section_totalViewSize
assert tvshows.totalViewSize() == 3
AssertionError: assert 2 == 3
+2
-3
________________ test_library_editAdvanced_default[anonymously] ________________
Traceback (most recent call last):
File "/home/runner/work/python-plexapi/python-plexapi/plexapi/library.py", line 655, in editAdvanced
enums = idEnums[settingID]
KeyError: 'collectionMode'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/runner/work/python-plexapi/python-plexapi/tests/test_library.py", line 417, in test_library_editAdvanced_default
movies.editAdvanced(collectionMode=0)
File "/home/runner/work/python-plexapi/python-plexapi/plexapi/library.py", line 657, in editAdvanced
raise NotFound('%s not found in %s' % (value, list(idEnums.keys())))
plexapi.exceptions.NotFound: 0 not found in ['hidden', 'enableCinemaTrailers', 'country', 'originalTitles', 'localizedArtwork', 'useLocalAssets', 'respectTags', 'useExternalExtras', 'skipNonTrailerExtras', 'useRedbandTrailers', 'includeExtrasWithLocalizedSubtitles', 'includeAdultContent', 'autoCollectionThreshold', 'ratingsSource', 'enableBIFGeneration']
_______________________ test_server_search[anonymously] ________________________
Traceback (most recent call last):
File "/home/runner/work/python-plexapi/python-plexapi/tests/test_server.py", line 149, in test_server_search
assert plex.search(title)
AssertionError: assert []
+ where [] = <bound method PlexServer.search of <PlexServer:http://127.0.0.1:324>>('Elephants Dream')
+ where <bound method PlexServer.search of <PlexServer:http://127.0.0.1:324>> = <PlexServer:http://127.0.0.1:324>.search
_____________ test_that_reload_return_the_same_object[anonymously] _____________
Traceback (most recent call last):
File "/home/runner/work/python-plexapi/python-plexapi/tests/test_video.py", line 1172, in test_that_reload_return_the_same_object
movie_search = plex.search("Elephants Dream")[0]
IndexError: list index out of range

@glensc

Copy link
Copy Markdown
ContributorAuthor

EDIT: nevermind, the last CI job has passed OK:

@JonnyWong16

Copy link
Copy Markdown
Collaborator

Combined into PR #872 so it's all in one PR.

@glensc
glensc deleted the episode-label branch February 28, 2022 15:19
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@glensc@JonnyWong16@meisnate12