Catch RecordNotFound error. fix #3373
This commit is contained in:
1 parent
f5f3cfba50
commit
2769fc28d3
1 file changed
+20
-13
@@ -1,6 +1,7 @@
|
|||||||
import traceback
|
import traceback
|
||||||
from string import ascii_lowercase
|
from string import ascii_lowercase
|
||||||
|
|
||||||
|
from CodernityDB.database import RecordNotFound
|
||||||
from couchpotato import tryInt, get_db
|
from couchpotato import tryInt, get_db
|
||||||
from couchpotato.api import addApiView
|
from couchpotato.api import addApiView
|
||||||
from couchpotato.core.event import fireEvent, fireEventAsync, addEvent
|
from couchpotato.core.event import fireEvent, fireEventAsync, addEvent
|
||||||
@@ -119,25 +120,31 @@ class MediaPlugin(MediaBase):
|
|||||||
|
|
||||||
def get(self, media_id):
|
def get(self, media_id):
|
||||||
|
|
||||||
db = get_db()
|
try:
|
||||||
|
db = get_db()
|
||||||
|
|
||||||
imdb_id = getImdb(str(media_id))
|
imdb_id = getImdb(str(media_id))
|
||||||
|
|
||||||
media = None
|
media = None
|
||||||
if imdb_id:
|
if imdb_id:
|
||||||
media = db.get('media', 'imdb-%s' % imdb_id, with_doc = True)['doc']
|
media = db.get('media', 'imdb-%s' % imdb_id, with_doc = True)['doc']
|
||||||
else:
|
else:
|
||||||
media = db.get('id', media_id)
|
media = db.get('id', media_id)
|
||||||
|
|
||||||
if media:
|
if media:
|
||||||
|
|
||||||
# Attach category
|
# Attach category
|
||||||
try: media['category'] = db.get('id', media.get('category_id'))
|
try: media['category'] = db.get('id', media.get('category_id'))
|
||||||
except: pass
|
except: pass
|
||||||
|
|
||||||
media['releases'] = fireEvent('release.for_media', media['_id'], single = True)
|
media['releases'] = fireEvent('release.for_media', media['_id'], single = True)
|
||||||
|
|
||||||
return media
|
return media
|
||||||
|
|
||||||
|
except RecordNotFound:
|
||||||
|
log.error('Media with id "%s" not found', media_id)
|
||||||
|
except:
|
||||||
|
raise
|
||||||
|
|
||||||
def getView(self, id = None, **kwargs):
|
def getView(self, id = None, **kwargs):
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user