Skip to content

Library Hubs and Music Stations - #518

Merged
Hellowlol merged 35 commits into
masterfrom
library_hubs
Oct 1, 2020
Merged

Library Hubs and Music Stations#518
Hellowlol merged 35 commits into
masterfrom
library_hubs

Conversation

@blacktwin

@blacktwinblacktwin commented Jun 22, 2020

Copy link
Copy Markdown
Collaborator

Adding Station support as requested in #361

Adding Library Hubs. Returns "More By {ARTIST}" or "Rediscover"

  • New feature (non-breaking change which adds functionality)

@blacktwin

Copy link
Copy Markdown
CollaboratorAuthor

Code snippets:

foryinplex.library.section('Music').filterFields(mediaType='album'):
print(vars(y))
break"""{ '_data': <Element 'Field' at 0x0000022F716CF638>, '_details_key': '', '_initpath': '/library/sections/27/all?type=9', '_server': <PlexServer:http://127.0.0.1:324>, 'key': 'album.title', 'operators': [ <Operator:=:contains>, <Operator:!=:does-not-contain>, <Operator:==:is>, <Operator:!==:is-not>, <Operator:<=:begins-with>, <Operator:>=:ends-with>], 'subType': None, 'title': 'Album Title', 'type': 'string'}"""forsortinplex.library.section('TV Shows')._sorts():
print(vars(sort))
break"""{ '_data': <Element 'Directory' at 0x0000022F716C73B8>, '_details_key': '', '_initpath': '/library/sections/3/sorts', '_server': <PlexServer:http://127.0.0.1:324>, 'defaultDirection': 'asc', 'descKey': 'titleSort:desc', 'firstCharacterKey': '/library/sections/3/firstCharacter', 'key': 'titleSort', 'title': 'Title'}"""forfirstinplex.library.section('Movies').firstCharacter():
print(vars(first))
break"""{ '_data': <Element 'Directory' at 0x0000022F716D69A8>, '_details_key': '', '_initpath': '/library/sections/2/firstCharacter', '_server': <PlexServer:http://127.0.0.1:324>, 'key': '%23', 'size': '16', 'title': '#'}"""

@blacktwin

Copy link
Copy Markdown
CollaboratorAuthor

With the removal of the hardcoded ALLOWED_FILTERSALLOWED_SORT and BOOLEAN_FILTER searching and syncing may take longer and cause an additional query but the upside should be that these lists are now dynamic.

Comment threadplexapi/library.py Outdated
data = self._server.query(key)
for meta in data.iter('Meta'):
for metaType in meta.iter('Type'):
if mediaType and metaType.attrib.get('type') == mediaType:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simplify this one.

if not mediatype or ...

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that one was tripping me up. I'm repeating the same for loop for both but I get the mediaType isolated when called. I'll move this PR to draft while I figure it out. I'm open to suggestions, of course.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What your doing is fine, but just use the or so you check both conditions at the same time.

Comment threadplexapi/library.py Outdated
self.firstCharacterKey = data.attrib.get('firstCharacterKey')


class Field(PlexObject):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have a class called Field. Maybe change the name or atleast make a better docstring.

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yeah docstrings need updated. I based the name off the xml tagging. Technically they can both exist after 3746b4e . But, yeah, I can change it.

@blacktwin

blacktwin commented Jul 2, 2020

Copy link
Copy Markdown
CollaboratorAuthor

folders and subfolders method is kinda neat.

foriteminplex.library.section('Music').folders():
forsubinitem.subfolders():
fortrackinsub.subfolders():
print(vars(track))

We can get to the media item through the /folder endpoint.

@blacktwinblacktwin mentioned this pull request Sep 9, 2020
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.4%) to 71.221% when pulling 4f96838 on library_hubs into 737401b on master.

@blacktwin

Copy link
Copy Markdown
CollaboratorAuthor

With the exception of the decrease in coverage, this PR is gtg.

@Hellowlol
Hellowlol merged commit 6a5981c into masterOct 1, 2020
@jjlawrenjjlawren mentioned this pull request Nov 1, 2020
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@blacktwin@coveralls@Hellowlol