smart playlist export/import
This commit is contained in:
parent
39560ce6f5
commit
2ca924e085
@ -76,10 +76,16 @@ optional arguments:
|
|||||||
python playlist_manager.py --action share --allUsers --playlists "My Custom Playlist" "Another Playlist"
|
python playlist_manager.py --action share --allUsers --playlists "My Custom Playlist" "Another Playlist"
|
||||||
|
|
||||||
Export each of an user's Playlists contents to a json file in the root of the script
|
Export each of an user's Playlists contents to a json file in the root of the script
|
||||||
python playlist_manager.py" --action export --user USER --playlists "Most Popular Movies (30 days)" "New Hot"
|
python playlist_manager.py --action export --user USER --playlists "Most Popular Movies (30 days)" "New Hot"
|
||||||
|
|
||||||
Export each of an user's Playlists contents to a csv file in the root of the script
|
Export each of an user's Playlists contents to a csv file in the root of the script
|
||||||
python playlist_manager.py" --action export --user USER --allPlaylists --export csv
|
python playlist_manager.py --action export --user USER --allPlaylists --export csv
|
||||||
|
|
||||||
|
Import a user's exported Playlist json file to the admin's Movies library
|
||||||
|
python playlist_manager.py --action import --self --importJson "User-Title-Playlist.json" --libraries "Movies"
|
||||||
|
|
||||||
|
Import a admin's exported Playlist json file to users shared Movies library
|
||||||
|
python playlist_manager.py --action import --users User1 "Another User" --importJson "User-Title-Playlist.json" --libraries "Movies"
|
||||||
|
|
||||||
Search and Filter;
|
Search and Filter;
|
||||||
|
|
||||||
@ -960,12 +966,15 @@ if __name__ == "__main__":
|
|||||||
playlists = data['all_playlists']
|
playlists = data['all_playlists']
|
||||||
for pl in playlists:
|
for pl in playlists:
|
||||||
logger.info("Exporting {}'s playlist: {}".format(user, pl.title))
|
logger.info("Exporting {}'s playlist: {}".format(user, pl.title))
|
||||||
pl_dict = {'items': []}
|
pl_dict = {'title': pl.title}
|
||||||
pl_dict['title'] = pl.title
|
if pl.smart:
|
||||||
items = plex.fetchItem(pl.ratingKey).items()
|
pl_dict['smartFilters'] = pl.filters()
|
||||||
for item in items:
|
else:
|
||||||
item_dict = export_min(item)
|
pl_dict['items'] = []
|
||||||
pl_dict['items'].append(item_dict)
|
items = plex.fetchItem(pl.ratingKey).items()
|
||||||
|
for item in items:
|
||||||
|
item_dict = export_min(item)
|
||||||
|
pl_dict['items'].append(item_dict)
|
||||||
|
|
||||||
title = pl.title
|
title = pl.title
|
||||||
output_file = '{}-{}-Playlist.{}'.format(user, title, opts.export)
|
output_file = '{}-{}-Playlist.{}'.format(user, title, opts.export)
|
||||||
@ -997,16 +1006,28 @@ if __name__ == "__main__":
|
|||||||
with open(''.join(opts.importJson)) as json_data:
|
with open(''.join(opts.importJson)) as json_data:
|
||||||
import_json = json.load(json_data)
|
import_json = json.load(json_data)
|
||||||
title = import_json['title']
|
title = import_json['title']
|
||||||
items = []
|
section = opts.libraries[0]
|
||||||
for item in import_json['items']:
|
if import_json.get('items'):
|
||||||
import_library = plex.library.section(opts.libraries[0])
|
items = []
|
||||||
plex_guid = item['guid'].rsplit('/', 1)[1]
|
for item in import_json['items']:
|
||||||
item_guid = plex.library.search(guid=item['guid'])
|
import_library = plex.library.section(opts.libraries[0])
|
||||||
items += item_guid
|
plex_guid = item['guid'].rsplit('/', 1)[1]
|
||||||
logger.info("Total items from playlist to import: {}".format(len(items)))
|
item_guid = plex.library.search(guid=item['guid'])
|
||||||
for user in playlist_dict['data']:
|
items += item_guid
|
||||||
logger.info("Importing playlist {} to user {}".format(title, user['user']))
|
logger.info("Total items from playlist to import: {}".format(len(items)))
|
||||||
user['server'].createPlaylist(title, section=opts.libraries[0], items=items)
|
for user in playlist_dict['data']:
|
||||||
|
logger.info("Importing playlist {} to user {}".format(title, user['user']))
|
||||||
|
user['server'].createPlaylist(title, section=section, items=items)
|
||||||
|
else:
|
||||||
|
logger.info("Importing Smart Playlist: {}".format(title))
|
||||||
|
limit = import_json["smartFilters"].get("limit")
|
||||||
|
libtype = import_json["smartFilters"].get("libtype")
|
||||||
|
sort = import_json["smartFilters"].get("sort")
|
||||||
|
filters = import_json["smartFilters"].get("filters")
|
||||||
|
for user in playlist_dict['data']:
|
||||||
|
logger.info("Importing playlist {} to user {}".format(title, user['user']))
|
||||||
|
user['server'].createPlaylist(title, section=section, smart=True, limit=limit,
|
||||||
|
libtype=libtype, sort=sort, filters=filters)
|
||||||
|
|
||||||
|
|
||||||
logger.info("Done.")
|
logger.info("Done.")
|
||||||
|
Loading…
Reference in New Issue
Block a user