Skip to content

Add support for plex library env variable#49

Open
jwmoss wants to merge 3 commits intoalex-phillips:masterfrom
jwmoss:patch-1
Open

Add support for plex library env variable#49
jwmoss wants to merge 3 commits intoalex-phillips:masterfrom
jwmoss:patch-1

Conversation

@jwmoss
Copy link
Copy Markdown
Contributor

@jwmoss jwmoss commented Dec 6, 2020

No description provided.

@jwmoss jwmoss mentioned this pull request Dec 6, 2020
@alex-phillips
Copy link
Copy Markdown
Owner

alex-phillips commented Dec 7, 2020

This is great! Instead of your changes in get_server_section, I think you need to add a check for the CLI argument vs the environment variable before we initialize the plex instance. See line 120 of your PR. Do something like:

    if args.library or PLEX_LIBRARY:
        plex = Plex(args.library or PLEX_LIBRARY)
    else:
        plex = Plex()

(untested) but I think that would work.

@@ -140,6 +142,10 @@ def main():
# keyword_matches = [] # unused list?

for medium in plex.media:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@alex-phillips How does this look?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Just about there! Instead of adding in a new initialization of Plex, you should just include the conditional logic above around like 120ish where we are already checking for args.library. Just add in args.library or PLEX_LIBRARY at that location.

if not sections:
print('No available sections.')
sys.exit()
sections = [ _ for _ in server.library.sections() if _.type in {'movie'} ]
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@jwmoss Looks like some extra whitespace got in here and python's bombing on it.

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.

2 participants