Fix Library.add() method to properly apply advanced settings (#1384)

* Fixing how advanced settings params are set and adding a prefix & when appending advanced settings. Update parts append to use f-string

* Adding basic test to include Advanced settings.

* lint fix

* fix failing test

* lint fix in test

* Update test_library.py

Add section deletion after testing
This commit is contained in:
blacktwin 2024-03-31 18:40:17 -04:00 committed by GitHub
parent d51022d683
commit 5b5d4c66ab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 28 additions and 1 deletions

View file

@ -383,7 +383,8 @@ class Library(PlexObject):
part = (f'/library/sections?name={quote_plus(name)}&type={type}&agent={agent}'
f'&scanner={quote_plus(scanner)}&language={language}&{urlencode(locations, doseq=True)}')
if kwargs:
part += urlencode(kwargs)
prefs_params = {f'prefs[{k}]': v for k, v in kwargs.items()}
part += f'&{urlencode(prefs_params)}'
return self._server.query(part, method=self._server._session.post)
def history(self, maxresults=None, mindate=None):

View file

@ -193,6 +193,32 @@ def test_library_add_edit_delete(plex, movies, photos):
assert section not in plex.library.sections()
def test_library_add_advanced_settings(plex, movies):
# Create Other Videos library = No external metadata scanning
section_name = "plexapi_test_advanced_section"
movie_location = movies.locations[0]
advanced_settings = {"enableCinemaTrailers": 0,
"enableBIFGeneration": 0,
"augmentWithProviderContent": 0,
"enableCreditsMarkerGeneration": 0}
plex.library.add(
name=section_name,
type="movie",
agent="com.plexapp.agents.none",
scanner="Plex Video Files Scanner",
language="xn",
location=[movie_location],
**advanced_settings
)
section = plex.library.section(section_name)
assert section.title == section_name
for setting in section.settings():
if setting.value != setting.default:
assert advanced_settings.get(setting.id) == setting.value
section.delete()
assert section not in plex.library.sections()
def test_library_Library_cleanBundle(plex):
plex.library.cleanBundles()