Skip to content

Edit Library and Show's Advanced Settings - #507

Merged
Hellowlol merged 20 commits into
masterfrom
show_advanced_setting
Oct 2, 2020
Merged

Edit Library and Show's Advanced Settings#507
Hellowlol merged 20 commits into
masterfrom
show_advanced_setting

Conversation

@blacktwin

@blacktwinblacktwin commented Jun 5, 2020

Copy link
Copy Markdown
Collaborator

Allow for editing a show's advanced settings

show.editAdvanced(showOrdering='aired', autoDeletionItemPolicyWatchedLibrary=0)

Allow for editing a library's advanced settings

library.editAdvanced(enableBIFGeneration=0, collectionMode=2)

allow for editing a show's advanced settings using kwargs
allows for defaulting all advanced settings
@blacktwin

blacktwin commented Jun 5, 2020

Copy link
Copy Markdown
CollaboratorAuthor

I can move/add these methods to settings.Preferences if I carry over the show's key into settings.Preferences's _initpath.

defpreferences(self):
""" Returns a list of :class:`~plexapi.settings.Preferences` objects. """items= []
data=self._server.query(self._details_key)
foritemindata.iter('Preferences'):
foreleminitem:
setting=settings.Preferences(data=elem, server=self._server)
setting._initpath=self.keyitems.append(setting)
returnitems

This way the settings could be updated from the show object in mass or from the preference object.

@blacktwin

Copy link
Copy Markdown
CollaboratorAuthor

I should add some tests to this. Switch settings, reload, assert.

@blacktwin
blacktwin marked this pull request as draft June 6, 2020 18:03
@blacktwinblacktwin changed the title Edit Show's Advanced SettingsEdit Library and Show's Advanced SettingsJun 10, 2020
@blacktwin
blacktwin marked this pull request as ready for review June 18, 2020 14:02
@blacktwinblacktwin mentioned this pull request Jun 22, 2020
@blacktwin
blacktwin requested review from Hellowlol and pkkidJuly 2, 2020 18:12
@blacktwin

Copy link
Copy Markdown
CollaboratorAuthor

@Hellowlol this should be ready for review.

Comment threadplexapi/settings.py Outdated
if self.type == 'int':
url = key + '%s=%s' % (self.id, self.default)
else:
url = key + '%s=%s' % (self.id, self.default.decode())

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.

Is it still needed to decode this? py2 has been dropped.

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.

.default is a value so it also is a byte that is either an int or str.

Comment threadplexapi/video.py Outdated
try:
enumValues = [int(x) for x in preferences.get(settingID)]
except ValueError:
enumValues = [x.decode() for x in preferences.get(settingID)]

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.

same again, why do we need to decode?

@blacktwinblacktwinJul 28, 2020

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.

The .value can be classed as a byte that is either an int or str. Majority of the time they're int-1, 1, 2 something like that.

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.

_bool_cast=lambdax: Trueifx=='true'orx=='1'elseFalse_bool_str=lambdax: str(x).lower()
_str=lambdax: str(x).encode('utf-8') # py2 dependant?TYPES= {
'bool': {'type': bool, 'cast': _bool_cast, 'tostr': _bool_str},
'double': {'type': float, 'cast': float, 'tostr': _str},
'int': {'type': int, 'cast': int, 'tostr': _str},
'text': {'type': str, 'cast': _str , 'tostr': _str},
}

Updating the the tostr: _str references to tostr: str should resolve the issue.

@jjlawren

Copy link
Copy Markdown
Collaborator

Calling PlexServer.settings.get("FriendlyName") is returning an empty value for some reason in this test, and only for this PR. Could one of the changes/tests be inadvertently clearing it somehow? Or maybe it just needs a reload() at the start of the failing test?

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.4%) to 72.024% when pulling 0123904 on show_advanced_setting into 737401b on master.

py2 support has been dropped. returning str instead of bytes now due to 5045ddc
@blacktwin

Copy link
Copy Markdown
CollaboratorAuthor

This PR should be gtg.

@Hellowlol
Hellowlol merged commit 163d94d into masterOct 2, 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.

4 participants

@blacktwin@jjlawren@coveralls@Hellowlol