changing method to simplify what is being exported
This commit is contained in:
parent
8ede33d83d
commit
cfe4182f0a
@ -720,35 +720,40 @@ def create_title(jbop, libraries, days, filters, search, limit):
|
|||||||
return title
|
return title
|
||||||
|
|
||||||
|
|
||||||
def object_cleaner(item):
|
def export_min(item):
|
||||||
"""
|
"""
|
||||||
Removes any protected attributes from a PlexAPI object.
|
|
||||||
Returns the object's attributes into a nested dict
|
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
item (object): A PlexAPI object
|
item: class
|
||||||
|
A Playlist item
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
item_dict
|
export_dict
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
if item.isPartialObject:
|
if item.isPartialObject:
|
||||||
item.reload()
|
item.reload()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
export_dict = dict()
|
||||||
item_dict = vars(item)
|
item_dict = vars(item)
|
||||||
|
guids = []
|
||||||
|
if item.TYPE in ['track', 'episode']:
|
||||||
|
export_list = ['grandparentGuid', 'grandparentTitle', 'parentGuid', 'parentTitle', 'guid', 'title', 'guids']
|
||||||
|
else:
|
||||||
|
export_list = ['guid', 'title', 'guids']
|
||||||
|
for export in item_dict.items():
|
||||||
|
if export[0] in export_list:
|
||||||
|
if export[0] == 'guids':
|
||||||
|
for guid in export[1]:
|
||||||
|
guids.append(guid.id)
|
||||||
|
export_dict.update({'guids': guids})
|
||||||
|
else:
|
||||||
|
export_dict.update(dict([export]))
|
||||||
|
|
||||||
for k in list(item_dict):
|
return export_dict
|
||||||
if k.startswith('_'):
|
|
||||||
del item_dict[k]
|
|
||||||
continue
|
|
||||||
if isinstance(item_dict[k], list):
|
|
||||||
for _ in item_dict[k]:
|
|
||||||
object_cleaner(_)
|
|
||||||
|
|
||||||
return item_dict
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
@ -957,7 +962,7 @@ if __name__ == "__main__":
|
|||||||
del pl_dict[k]
|
del pl_dict[k]
|
||||||
items = plex.fetchItem(pl.ratingKey).items()
|
items = plex.fetchItem(pl.ratingKey).items()
|
||||||
for item in items:
|
for item in items:
|
||||||
item_dict = object_cleaner(item)
|
item_dict = export_min(item)
|
||||||
pl_dict['items'].append(item_dict)
|
pl_dict['items'].append(item_dict)
|
||||||
|
|
||||||
json_dump = jsonpickle.Pickler(unpicklable=False).flatten(obj=pl_dict)
|
json_dump = jsonpickle.Pickler(unpicklable=False).flatten(obj=pl_dict)
|
||||||
|
Loading…
Reference in New Issue
Block a user