Doc string update description and examples

print settings enabled --add and disabled --remove
fixed issue where filters would be wiped if --add --remove were used
This commit is contained in:
Blacktwin 2018-08-13 07:57:30 -04:00
parent 8c3781728a
commit 970535057d

View File

@ -3,12 +3,12 @@
Share or unshare libraries. Share or unshare libraries.
optional arguments: optional arguments:
-h, --help show this help message and exit -h, --help Show this help message and exit
--share To share libraries to user. --share To share libraries to user.
--shared Display user's share settings. --shared Display user's share settings.
--unshare To unshare all libraries from user. --unshare To unshare all libraries from user.
--add Add additional libraries to user. --add Share additional libraries or enable settings to user.
--remove Remove shared libraries from user. --remove Remove shared libraries or disable settings from user.
--user [ ...] Space separated list of case sensitive names to process. Allowed names are: --user [ ...] Space separated list of case sensitive names to process. Allowed names are:
(choices: All users names) (choices: All users names)
--allUsers Select all users. --allUsers Select all users.
@ -71,6 +71,12 @@ Usage:
plex_api_share.py --restore --user USER plex_api_share.py --restore --user USER
- Only restore USER's Plex shares and settings from backup json file - Only restore USER's Plex shares and settings from backup json file
plex_api_share.py --user USER --add --sync
- Enable sync feature for USER
plex_api_share.py --user USER --remove --sync
- Disable sync feature for USER
Excluding; Excluding;
@ -197,21 +203,32 @@ def share(user, sections, allowSync, camera, channels, filterMovies, filterTelev
plex.myPlexAccount().updateFriend(user=user, server=plex, sections=sections, allowSync=allowSync, plex.myPlexAccount().updateFriend(user=user, server=plex, sections=sections, allowSync=allowSync,
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)) if sections:
if plex.myPlexSubscription == True: print('{user}\'s updated shared libraries: \n{sections}'.format(sections=sections, user=user))
_sync = 'Sync: {} '.format(allowSync) if allowSync == True:
_camera = 'Camera Upload: {} '.format(camera) print('Sync: Enabled')
_channels = 'Channels: {} '.format(channels) if allowSync == False:
_filterMovies = 'Movie Filters: {} '.format(filterMovies) print('Sync: Disabled')
_filterTelevision = 'TV Filters: {} '.format(filterTelevision) if camera == True:
_filterMusic = 'Music Filter: {} '.format(filterMusic) print('Camera Upload: Enabled')
print('Settings: {}{}{}{}{}{}'. if camera == False:
format(_sync if allowSync else None, print('Camera Upload: Disabled')
_camera if camera else None, if channels == True:
_channels if channels else None, print('Plugins: Enabled')
_filterMovies if filterMovies else None, if channels == False:
_filterTelevision if filterTelevision else None, print('Plugins: Disabled')
_filterMusic if filterMusic else None)) if filterMovies:
print('Movie Filters: {}'.format(filterMovies))
if filterMovies == {}:
print('Movie Filters:')
if filterTelevision:
print('Show Filters: {}'.format(filterTelevision))
if filterTelevision == {}:
print('Show Filters:')
if filterMusic:
print('Music Filters: {}'.format(filterMusic))
if filterMusic == {} and filterMusic != None:
print('Music Filters:')
def unshare(user, sections): def unshare(user, sections):
@ -232,9 +249,9 @@ if __name__ == "__main__":
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('--add', default=False, action='store_true', parser.add_argument('--add', default=False, action='store_true',
help='Add additional libraries.') help='Share additional libraries or enable settings to user..')
parser.add_argument('--remove', default=False, action='store_true', parser.add_argument('--remove', default=False, action='store_true',
help='Remove existing libraries.') help='Remove shared libraries or disable settings from user.')
parser.add_argument('--user', nargs='+', choices=user_lst, metavar='', parser.add_argument('--user', nargs='+', choices=user_lst, metavar='',
help='Space separated list of case sensitive names to process. Allowed names are: \n' help='Space separated list of case sensitive names to process. Allowed names are: \n'
'(choices: %(choices)s)') '(choices: %(choices)s)')
@ -292,9 +309,9 @@ if __name__ == "__main__":
sync = None sync = None
camera = None camera = None
channels = None channels = None
filterMovies = {} filterMovies = None
filterTelevision = {} filterTelevision = None
filterMusic = {} filterMusic = None
try: try:
if opts.kill: if opts.kill:
kill = opts.kill kill = opts.kill
@ -304,15 +321,20 @@ if __name__ == "__main__":
camera = opts.camera camera = opts.camera
if opts.channels: if opts.channels:
channels = opts.channels channels = opts.channels
if opts.movieLabels or opts.movieRatings:
filterMovies = {}
if opts.movieLabels: if opts.movieLabels:
filterMovies['label'] = opts.movieLabels filterMovies['label'] = opts.movieLabels
if opts.movieRatings: if opts.movieRatings:
filterMovies['contentRating'] = opts.movieRatings filterMovies['contentRating'] = opts.movieRatings
if opts.tvLabels or opts.tvRatings:
filterTelevision = {}
if opts.tvLabels: if opts.tvLabels:
filterTelevision['label'] = opts.tvLabels filterTelevision['label'] = opts.tvLabels
if opts.tvRatings: if opts.tvRatings:
filterTelevision['contentRating'] = opts.tvRatings filterTelevision['contentRating'] = opts.tvRatings
if opts.musicLabels: if opts.musicLabels:
filterMusic = {}
filterMusic['label'] = opts.musicLabels filterMusic['label'] = opts.musicLabels
except AttributeError: except AttributeError:
print('No Plex Pass moving on...') print('No Plex Pass moving on...')