Skip to content

Conversation

@JonnyWong16
Copy link
Collaborator

@JonnyWong16 JonnyWong16 commented Nov 16, 2020

Description

Add the ability to browse the Plex server system file directories through the Plex API. This uses the /services/browse endpoint when browsing to add a folder to a library.

browse

New methods

plexapi.server.PlexServer.browse(path)

  • Browse the system file path using the Plex API.

Example

from plexapi.server import PlexServer
plex = PlexServer('http://localhost:32400', token='xxxxxxxxxxxxxxxxxxxx')

# List all folders and files in a single path
print(plex.browse('/media/Movies'))

plexapi.server.PlexServer.walk(path)

  • Walk the system file tree using the Plex API similar to os.walk.

Example

from plexapi.server import PlexServer
plex = PlexServer('http://localhost:32400', token='xxxxxxxxxxxxxxxxxxxx')

# Walk through all folders and files in the library locations
for location in plex.library.section('Movies').locations:
    for root, folders, files in plex.walk(location):
        print(root, folders, files)

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • 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

@Hellowlol
Copy link
Collaborator

Looks very nice!

@fcassirer
Copy link

Hello. Apologies in advance as I am not familiar with the Plex API capabilities for access restriction, ACLS etc, assuming there is some ability to limit scope via the token. A capability such as this would seem ripe for mischief if not carefully sandboxed. Are there security considerations that should be looked at here?

@Hellowlol
Copy link
Collaborator

@fcassirer I havn’t any done consideration regarding the security. We are only exposing the this for a api. We authenticate using plex own api

@Hellowlol Hellowlol merged commit ae59620 into pushingkarmaorg:master Nov 23, 2020
JonnyWong16 added a commit to JonnyWong16/python-plexapi that referenced this pull request Dec 4, 2020
Add ability to browse and walk the Plex server system file directories
@JonnyWong16 JonnyWong16 deleted the server_browse branch May 13, 2021 00:28
Sign up for free to 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