|
|
@ -44,15 +44,15 @@ class MediaPlugin(MediaBase): |
|
|
|
'desc': 'List media', |
|
|
|
'params': { |
|
|
|
'type': {'type': 'string', 'desc': 'Media type to filter on.'}, |
|
|
|
'status': {'type': 'array or csv', 'desc': 'Filter movie by status. Example:"active,done"'}, |
|
|
|
'release_status': {'type': 'array or csv', 'desc': 'Filter movie by status of its releases. Example:"snatched,available"'}, |
|
|
|
'limit_offset': {'desc': 'Limit and offset the movie list. Examples: "50" or "50,30"'}, |
|
|
|
'starts_with': {'desc': 'Starts with these characters. Example: "a" returns all movies starting with the letter "a"'}, |
|
|
|
'search': {'desc': 'Search movie title'}, |
|
|
|
'status': {'type': 'array or csv', 'desc': 'Filter media by status. Example:"active,done"'}, |
|
|
|
'release_status': {'type': 'array or csv', 'desc': 'Filter media by status of its releases. Example:"snatched,available"'}, |
|
|
|
'limit_offset': {'desc': 'Limit and offset the media list. Examples: "50" or "50,30"'}, |
|
|
|
'starts_with': {'desc': 'Starts with these characters. Example: "a" returns all media starting with the letter "a"'}, |
|
|
|
'search': {'desc': 'Search media title'}, |
|
|
|
}, |
|
|
|
'return': {'type': 'object', 'example': """{ |
|
|
|
'success': True, |
|
|
|
'empty': bool, any movies returned or not, |
|
|
|
'empty': bool, any media returned or not, |
|
|
|
'media': array, media found, |
|
|
|
}"""} |
|
|
|
}) |
|
|
@ -109,7 +109,7 @@ class MediaPlugin(MediaBase): |
|
|
|
|
|
|
|
try: |
|
|
|
media = get_db().get('id', media_id) |
|
|
|
event = '%s.update_info' % media.get('type') |
|
|
|
event = '%s.update' % media.get('type') |
|
|
|
|
|
|
|
def handler(): |
|
|
|
fireEvent(event, media_id = media_id, on_complete = self.createOnComplete(media_id)) |
|
|
@ -160,10 +160,13 @@ class MediaPlugin(MediaBase): |
|
|
|
'media': media, |
|
|
|
} |
|
|
|
|
|
|
|
def withStatus(self, status, with_doc = True): |
|
|
|
def withStatus(self, status, types = None, with_doc = True): |
|
|
|
|
|
|
|
db = get_db() |
|
|
|
|
|
|
|
if types and not isinstance(types, (list, tuple)): |
|
|
|
types = [types] |
|
|
|
|
|
|
|
status = list(status if isinstance(status, (list, tuple)) else [status]) |
|
|
|
|
|
|
|
for s in status: |
|
|
@ -171,6 +174,10 @@ class MediaPlugin(MediaBase): |
|
|
|
if with_doc: |
|
|
|
try: |
|
|
|
doc = db.get('id', ms['_id']) |
|
|
|
|
|
|
|
if types and doc.get('type') not in types: |
|
|
|
continue |
|
|
|
|
|
|
|
yield doc |
|
|
|
except RecordNotFound: |
|
|
|
log.debug('Record not found, skipping: %s', ms['_id']) |
|
|
@ -178,17 +185,15 @@ class MediaPlugin(MediaBase): |
|
|
|
yield ms |
|
|
|
|
|
|
|
def withIdentifiers(self, identifiers, with_doc = False): |
|
|
|
|
|
|
|
db = get_db() |
|
|
|
|
|
|
|
for x in identifiers: |
|
|
|
try: |
|
|
|
media = db.get('media', '%s-%s' % (x, identifiers[x]), with_doc = with_doc) |
|
|
|
return media |
|
|
|
return db.get('media', '%s-%s' % (x, identifiers[x]), with_doc = with_doc) |
|
|
|
except: |
|
|
|
pass |
|
|
|
|
|
|
|
log.debug('No media found with identifiers: %s', identifiers) |
|
|
|
return False |
|
|
|
|
|
|
|
def list(self, types = None, status = None, release_status = None, status_or = False, limit_offset = None, with_tags = None, starts_with = None, search = None): |
|
|
|
|
|
|
@ -307,9 +312,22 @@ class MediaPlugin(MediaBase): |
|
|
|
def addSingleListView(self): |
|
|
|
|
|
|
|
for media_type in fireEvent('media.types', merge = True): |
|
|
|
def tempList(*args, **kwargs): |
|
|
|
return self.listView(types = media_type, **kwargs) |
|
|
|
addApiView('%s.list' % media_type, tempList) |
|
|
|
tempList = lambda media_type = media_type, *args, **kwargs : self.listView(type = media_type, **kwargs) |
|
|
|
addApiView('%s.list' % media_type, tempList, docs = { |
|
|
|
'desc': 'List media', |
|
|
|
'params': { |
|
|
|
'status': {'type': 'array or csv', 'desc': 'Filter ' + media_type + ' by status. Example:"active,done"'}, |
|
|
|
'release_status': {'type': 'array or csv', 'desc': 'Filter ' + media_type + ' by status of its releases. Example:"snatched,available"'}, |
|
|
|
'limit_offset': {'desc': 'Limit and offset the ' + media_type + ' list. Examples: "50" or "50,30"'}, |
|
|
|
'starts_with': {'desc': 'Starts with these characters. Example: "a" returns all ' + media_type + 's starting with the letter "a"'}, |
|
|
|
'search': {'desc': 'Search ' + media_type + ' title'}, |
|
|
|
}, |
|
|
|
'return': {'type': 'object', 'example': """{ |
|
|
|
'success': True, |
|
|
|
'empty': bool, any """ + media_type + """s returned or not, |
|
|
|
'media': array, media found, |
|
|
|
}"""} |
|
|
|
}) |
|
|
|
|
|
|
|
def availableChars(self, types = None, status = None, release_status = None): |
|
|
|
|
|
|
@ -376,8 +394,7 @@ class MediaPlugin(MediaBase): |
|
|
|
def addSingleCharView(self): |
|
|
|
|
|
|
|
for media_type in fireEvent('media.types', merge = True): |
|
|
|
def tempChar(*args, **kwargs): |
|
|
|
return self.charView(types = media_type, **kwargs) |
|
|
|
tempChar = lambda media_type = media_type, *args, **kwargs : self.charView(type = media_type, **kwargs) |
|
|
|
addApiView('%s.available_chars' % media_type, tempChar) |
|
|
|
|
|
|
|
def delete(self, media_id, delete_from = None): |
|
|
@ -446,9 +463,14 @@ class MediaPlugin(MediaBase): |
|
|
|
def addSingleDeleteView(self): |
|
|
|
|
|
|
|
for media_type in fireEvent('media.types', merge = True): |
|
|
|
def tempDelete(*args, **kwargs): |
|
|
|
return self.deleteView(types = media_type, *args, **kwargs) |
|
|
|
addApiView('%s.delete' % media_type, tempDelete) |
|
|
|
tempDelete = lambda media_type = media_type, *args, **kwargs : self.deleteView(type = media_type, **kwargs) |
|
|
|
addApiView('%s.delete' % media_type, tempDelete, docs = { |
|
|
|
'desc': 'Delete a ' + media_type + ' from the wanted list', |
|
|
|
'params': { |
|
|
|
'id': {'desc': 'Media ID(s) you want to delete.', 'type': 'int (comma separated)'}, |
|
|
|
'delete_from': {'desc': 'Delete ' + media_type + ' from this page', 'type': 'string: all (default), wanted, manage'}, |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
def restatus(self, media_id): |
|
|
|
|
|
|
|