Added "media_id" parameter to "library.tree" event
This commit is contained in:
@@ -78,13 +78,18 @@ class Library(LibraryBase):
|
|||||||
|
|
||||||
return cur
|
return cur
|
||||||
|
|
||||||
def tree(self, media):
|
def tree(self, media = None, media_id = None):
|
||||||
result = media
|
|
||||||
|
|
||||||
db = get_db()
|
db = get_db()
|
||||||
|
|
||||||
|
if media:
|
||||||
|
result = media
|
||||||
|
elif media_id:
|
||||||
|
result = db.get('id', media_id, with_doc = True)
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
# Find children
|
# Find children
|
||||||
items = db.get_many('media_children', media['_id'], with_doc = True)
|
items = db.get_many('media_children', result['_id'], with_doc = True)
|
||||||
keys = []
|
keys = []
|
||||||
|
|
||||||
# Build children arrays
|
# Build children arrays
|
||||||
@@ -94,6 +99,8 @@ class Library(LibraryBase):
|
|||||||
|
|
||||||
if key not in result:
|
if key not in result:
|
||||||
result[key] = {}
|
result[key] = {}
|
||||||
|
elif type(result[key]) is not dict:
|
||||||
|
result[key] = {}
|
||||||
|
|
||||||
if key not in keys:
|
if key not in keys:
|
||||||
keys.append(key)
|
keys.append(key)
|
||||||
@@ -105,6 +112,6 @@ class Library(LibraryBase):
|
|||||||
result[key] = result[key].values()
|
result[key] = result[key].values()
|
||||||
|
|
||||||
# Include releases
|
# Include releases
|
||||||
result['releases'] = fireEvent('release.for_media', media['_id'], single = True)
|
result['releases'] = fireEvent('release.for_media', result['_id'], single = True)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|||||||
Reference in New Issue
Block a user