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

Library editing updates #837

Merged
merged 48 commits into from
Jan 6, 2022
Merged

Library editing updates #837

merged 48 commits into from
Jan 6, 2022

Conversation

blacktwin
Copy link
Collaborator

@blacktwin blacktwin commented Sep 27, 2021

Description

Adding convenience methods to add and remove location(s) (paths) to a library. Updating library add() method to allow for muliple locations on creation of library.

Fixes or addresses #827

Example

plex = PlexServer(PLEX_URL, PLEX_TOKEN, session=sess)

locations = ["D:\\plexlibraries\\shows",
             "D:\\plexlibraries\\shows_optimized"]

plex.library.add(name='Test Library', type='show', agent='tv.plex.agents.series',
                      scanner='Plex TV Series', location=locations, language='U')
					  
testLibrary = plex.library.section('Test Library')
testLibrary.removeLocations(locations[0])
testLibrary.addLocations(locations[0])

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

@blacktwin blacktwin marked this pull request as draft September 27, 2021 15:21
@blacktwin
Copy link
Collaborator Author

TODO: Add tests

plexapi/library.py Outdated Show resolved Hide resolved
plexapi/library.py Outdated Show resolved Hide resolved
plexapi/library.py Show resolved Hide resolved
plexapi/library.py Outdated Show resolved Hide resolved
plexapi/library.py Outdated Show resolved Hide resolved
plexapi/library.py Outdated Show resolved Hide resolved
plexapi/library.py Outdated Show resolved Hide resolved
plexapi/library.py Outdated Show resolved Hide resolved
plexapi/library.py Outdated Show resolved Hide resolved
plexapi/library.py Show resolved Hide resolved
@blacktwin
Copy link
Collaborator Author

blacktwin commented Dec 19, 2021

Still needs tests.

  • Create library with multiple paths with an invalid path
  • Create library with multiple paths with valid paths
  • Add path(s) to test library with valid paths
  • Add path(s) to test library with an invalid path
  • Remove path(s) to test library with valid paths
  • Remove path(s) to test library with an invalid path

plexapi/library.py Outdated Show resolved Hide resolved
plexapi/library.py Outdated Show resolved Hide resolved
plexapi/library.py Outdated Show resolved Hide resolved
plexapi/library.py Outdated Show resolved Hide resolved
plexapi/library.py Outdated Show resolved Hide resolved
Tests:
 Create library with multiple paths with valid paths
 Create library with multiple paths with an invalid path
 Create library with no path
 Add path(s) to test library with an invalid path
 Remove path(s) to test library with an invalid path
 Remove path(s) to test library with valid paths
 Add path(s) to test library with valid paths
@blacktwin blacktwin marked this pull request as ready for review December 20, 2021 14:30
Copy link
Collaborator

@JonnyWong16 JonnyWong16 left a comment

Choose a reason for hiding this comment

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

Few more tests:

  • BadRequest when trying to remove all locations.
  • edit directly with kwargs['location'].
  • addLocations with a Path object.
  • removeLocations with a Path object.
  • isBrowsable with a Path object.

plexapi/library.py Outdated Show resolved Hide resolved
plexapi/library.py Outdated Show resolved Hide resolved
@blacktwin
Copy link
Collaborator Author

I don't think we should include Path object for adding or removing locations. plex.browse('path/to/stuff') returns a list of the Path objects from in the queried path but not the Path object for the queried path. This will either fail if the queried path does not have any subfolder or would result in adding each subfolder instead of the queried path when using .addLocation(Path).

plexapi/library.py Outdated Show resolved Hide resolved
tests/test_library.py Outdated Show resolved Hide resolved
plexapi/library.py Show resolved Hide resolved
@blacktwin blacktwin merged commit 1d77f32 into master Jan 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants