fixes for non Plex Pass members.

This commit is contained in:
Blacktwin 2018-08-08 11:50:14 -04:00
parent 3cd993aaad
commit f25a881a27

View File

@ -198,8 +198,10 @@ def share(user, sections, allowSync, camera, channels, filterMovies, filterTelev
allowCameraUpload=camera, allowChannels=channels, filterMovies=filterMovies, allowCameraUpload=camera, allowChannels=channels, filterMovies=filterMovies,
filterTelevision=filterTelevision, filterMusic=filterMusic) filterTelevision=filterTelevision, filterMusic=filterMusic)
print('Shared libraries: {sections} with {user}.'.format(sections=sections, user=user)) print('Shared libraries: {sections} with {user}.'.format(sections=sections, user=user))
print('Settings: Sync: {}, Camer Upload: {}, Channels: {}, Movie Filters: {}, TV Filters: {}, Music Filter: {}'. if plex.myPlexSubscription == True:
format(allowSync, camera, channels, filterMovies, filterTelevision, filterMusic)) print('Settings: Sync: {}, Camer Upload: {}, Channels: {}, '
'Movie Filters: {}, TV Filters: {}, Music Filter: {}'.
format(allowSync, camera, channels, filterMovies, filterTelevision, filterMusic))
def unshare(user, sections): def unshare(user, sections):
@ -209,13 +211,6 @@ def unshare(user, sections):
if __name__ == "__main__": if __name__ == "__main__":
movie_ratings = []
show_ratings = []
for movie in movies_keys:
movie_ratings += get_ratings_lst(movie)
for show in show_keys:
show_ratings += get_ratings_lst(show)
timestr = time.strftime("%Y%m%d-%H%M%S") timestr = time.strftime("%Y%m%d-%H%M%S")
parser = argparse.ArgumentParser(description="Share or unshare libraries.", parser = argparse.ArgumentParser(description="Share or unshare libraries.",
@ -226,8 +221,6 @@ if __name__ == "__main__":
help='Display user\'s shared libraries.') help='Display user\'s shared libraries.')
parser.add_argument('--unshare', default=False, action='store_true', parser.add_argument('--unshare', default=False, action='store_true',
help='To unshare all libraries.') help='To unshare all libraries.')
parser.add_argument('--kill', default=False, nargs='?',
help='Kill user\'s current stream(s). Include message to override default message.')
parser.add_argument('--add', default=False, action='store_true', parser.add_argument('--add', default=False, action='store_true',
help='Add additional libraries.') help='Add additional libraries.')
parser.add_argument('--remove', default=False, action='store_true', parser.add_argument('--remove', default=False, action='store_true',
@ -242,27 +235,6 @@ if __name__ == "__main__":
'(choices: %(choices)s') '(choices: %(choices)s')
parser.add_argument('--allLibraries', default=False, action='store_true', parser.add_argument('--allLibraries', default=False, action='store_true',
help='Select all libraries.') help='Select all libraries.')
parser.add_argument('--sync', default=False, action='store_true',
help='Use to allow user to sync content.')
parser.add_argument('--camera', default=False, action='store_true',
help='Use to allow user to upload photos.')
parser.add_argument('--channels', default=False, action='store_true',
help='Use to allow user to utilize installed channels.')
parser.add_argument('--movieRatings', nargs='+', choices=list(set(movie_ratings)), metavar='',
help='Use to add rating restrictions to movie library types.\n'
'Space separated list of case sensitive names to process. Allowed names are: \n'
'(choices: %(choices)s')
parser.add_argument('--movieLabels', nargs='+', metavar='',
help='Use to add label restrictions for movie library types.')
parser.add_argument('--tvRatings', nargs='+', choices=list(set(show_ratings)), metavar='',
help='Use to add rating restrictions for show library types.\n'
'Space separated list of case sensitive names to process. Allowed names are: \n'
'(choices: %(choices)s')
parser.add_argument('--tvLabels', nargs='+', metavar='',
help='Use to add label restrictions for show library types.')
parser.add_argument('--musicLabels', nargs='+', metavar='',
help='Use to add label restrictions for music library types.')
parser.add_argument('--backup', default=False, action='store_true', parser.add_argument('--backup', default=False, action='store_true',
help='Backup share settings from json file.') help='Backup share settings from json file.')
parser.add_argument('--restore', type = str, choices = json_check, parser.add_argument('--restore', type = str, choices = json_check,
@ -270,24 +242,70 @@ if __name__ == "__main__":
'Filename of json file to use.\n' 'Filename of json file to use.\n'
'(choices: %(choices)s)') '(choices: %(choices)s)')
# For Plex Pass members
if plex.myPlexSubscription == True:
movie_ratings = []
show_ratings = []
for movie in movies_keys:
movie_ratings += get_ratings_lst(movie)
for show in show_keys:
show_ratings += get_ratings_lst(show)
parser.add_argument('--kill', default=False, nargs='?',
help='Kill user\'s current stream(s). Include message to override default message.')
parser.add_argument('--sync', default=False, action='store_true',
help='Use to allow user to sync content.')
parser.add_argument('--camera', default=False, action='store_true',
help='Use to allow user to upload photos.')
parser.add_argument('--channels', default=False, action='store_true',
help='Use to allow user to utilize installed channels.')
parser.add_argument('--movieRatings', nargs='+', choices=list(set(movie_ratings)), metavar='',
help='Use to add rating restrictions to movie library types.\n'
'Space separated list of case sensitive names to process. Allowed names are: \n'
'(choices: %(choices)s')
parser.add_argument('--movieLabels', nargs='+', metavar='',
help='Use to add label restrictions for movie library types.')
parser.add_argument('--tvRatings', nargs='+', choices=list(set(show_ratings)), metavar='',
help='Use to add rating restrictions for show library types.\n'
'Space separated list of case sensitive names to process. Allowed names are: \n'
'(choices: %(choices)s')
parser.add_argument('--tvLabels', nargs='+', metavar='',
help='Use to add label restrictions for show library types.')
parser.add_argument('--musicLabels', nargs='+', metavar='',
help='Use to add label restrictions for music library types.')
opts = parser.parse_args() opts = parser.parse_args()
users = '' users = ''
libraries = '' libraries = ''
# Plex Pass additional share options
kill = False
sync = False
camera = False
channels = False
filterMovies = {} filterMovies = {}
filterTelevision = {} filterTelevision = {}
filterMusic = {} filterMusic = {}
try:
# Setting additional share options if opts.kill:
if opts.movieLabels: kill = opts.kill
filterMovies['label'] = opts.movieLabels if opts.sync:
if opts.movieRatings: sync = opts.sync
filterMovies['contentRating'] = opts.movieRatings if opts.camera:
if opts.tvLabels: camera = opts.camera
filterTelevision['label'] = opts.tvLabels if opts.channels:
if opts.tvRatings: channels = opts.channels
filterTelevision['contentRating'] = opts.tvRatings if opts.movieLabels:
if opts.musicLabels: filterMovies['label'] = opts.movieLabels
filterMusic['label'] = opts.musicLabels if opts.movieRatings:
filterMovies['contentRating'] = opts.movieRatings
if opts.tvLabels:
filterTelevision['label'] = opts.tvLabels
if opts.tvRatings:
filterTelevision['contentRating'] = opts.tvRatings
if opts.musicLabels:
filterMusic['label'] = opts.musicLabels
except AttributeError:
print('No Plex Pass moving on...')
# Defining users # Defining users
if opts.allUsers and not opts.user: if opts.allUsers and not opts.user:
@ -316,28 +334,28 @@ if __name__ == "__main__":
user_shares = find_shares(user) user_shares = find_shares(user)
if libraries: if libraries:
if opts.share: if opts.share:
share(user, libraries, opts.sync, opts.camera, opts.channels, filterMovies, filterTelevision, share(user, libraries, sync, camera, channels, filterMovies, filterTelevision,
filterMusic) filterMusic)
if opts.add and user_shares['sections']: if opts.add and user_shares['sections']:
libraries = libraries + user_shares['sections'] libraries = libraries + user_shares['sections']
libraries = list(set(libraries)) libraries = list(set(libraries))
share(user, libraries, opts.sync, opts.camera, opts.channels, filterMovies, filterTelevision, share(user, libraries, sync, camera, channels, filterMovies, filterTelevision,
filterMusic) filterMusic)
if opts.remove and user_shares['sections']: if opts.remove and user_shares['sections']:
libraries = [sect for sect in user_shares['sections'] if sect not in libraries] libraries = [sect for sect in user_shares['sections'] if sect not in libraries]
share(user, libraries, opts.sync, opts.camera, opts.channels, filterMovies, filterTelevision, share(user, libraries, sync, camera, channels, filterMovies, filterTelevision,
filterMusic) filterMusic)
if opts.shared: if opts.shared:
user_json = json.dumps(user_shares, indent=4, sort_keys=True) user_json = json.dumps(user_shares, indent=4, sort_keys=True)
print('Current share settings for {}: {}'.format(user, user_json)) print('Current share settings for {}: {}'.format(user, user_json))
if opts.unshare and opts.kill: if opts.unshare and kill:
kill_session(user, opts.kill) kill_session(user, kill)
time.sleep(3) time.sleep(3)
unshare(user, sections_lst) unshare(user, sections_lst)
elif opts.unshare: elif opts.unshare:
unshare(user, sections_lst) unshare(user, sections_lst)
elif opts.kill: elif kill:
kill_session(user, opts.kill) kill_session(user, kill)
if opts.backup: if opts.backup:
print('Backing up share information...') print('Backing up share information...')