dont call external api if no external api is defined

This commit is contained in:
j 2014-11-14 20:23:25 +00:00
parent 9dcd961fff
commit d9a5a75a04

View file

@ -482,10 +482,11 @@ class Item(models.Model):
return streams[0] if streams else None return streams[0] if streams else None
def get_posters(self): def get_posters(self):
index = []
if settings.DATA_SERVICE:
url = self.prefered_poster_url() url = self.prefered_poster_url()
external_posters = self.external_data.get('posters', {}) external_posters = self.external_data.get('posters', {})
services = external_posters.keys() services = external_posters.keys()
index = []
for service in settings.POSTER_PRECEDENCE: for service in settings.POSTER_PRECEDENCE:
if service in services: if service in services:
index.append(service) index.append(service)
@ -494,6 +495,8 @@ class Item(models.Model):
index.append(service) index.append(service)
if settings.URL not in index: if settings.URL not in index:
index.append(settings.URL) index.append(settings.URL)
else:
external_posters = []
posters = [] posters = []
poster = self.path('siteposter.jpg') poster = self.path('siteposter.jpg')
@ -1310,6 +1313,7 @@ class Item(models.Model):
f.write(data) f.write(data)
def prefered_poster_url(self): def prefered_poster_url(self):
if settings.DATA_SERVICE:
external_posters = self.external_data.get('posters', {}) external_posters = self.external_data.get('posters', {})
service = self.poster_source service = self.poster_source
if service and service != settings.URL and service in external_posters: if service and service != settings.URL and service in external_posters: