From 37ed99d0291fe230fee790126df7ae493a698435 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Fri, 17 Sep 2010 22:23:03 +0200 Subject: [PATCH] add settings.POSTER_PRECEDENCE, update nginx setup --- nginx_gunicorn/pandora.conf | 2 +- pandora/backend/models.py | 15 ++++++++++----- pandora/settings.py | 12 ++---------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/nginx_gunicorn/pandora.conf b/nginx_gunicorn/pandora.conf index 482d8ec4..d5d22ac2 100644 --- a/nginx_gunicorn/pandora.conf +++ b/nginx_gunicorn/pandora.conf @@ -10,5 +10,5 @@ respawn chdir /srv/pandora/pandora -exec /srv/pandora/bin/gunicorn_django -u pandora -g pandora -b 127.0.0.1:8083 -w5 settings.py +exec /srv/pandora/bin/gunicorn_django --daemon -u pandora -g pandora -b 127.0.0.1:8083 -w5 settings.py diff --git a/pandora/backend/models.py b/pandora/backend/models.py index 8fe9b32e..6af279cd 100644 --- a/pandora/backend/models.py +++ b/pandora/backend/models.py @@ -517,13 +517,18 @@ class Movie(models.Model): for f in glob(path.replace('.jpg', '*.jpg')): os.unlink(f) + def prefered_poster_url(self): + if self.poster_url: + return self.poster_url + self.update_poster_urls() + for service in settings.POSTER_PRECEDENCE: + for u in self.poster_urls.filter(service=service).order_by('-height'): + return u.url + return None + def download_poster(self, force=False): if not self.poster or force: - url = self.poster_url - if not url: - self.update_poster_urls() - if self.poster_urls.count() > 0: - url = self.poster_urls.all().order_by('-height')[0].url + url = self.prefered_poster_url() if url: data = ox.net.readUrl(url) if force: diff --git a/pandora/settings.py b/pandora/settings.py index e1261d3c..1fa86d87 100644 --- a/pandora/settings.py +++ b/pandora/settings.py @@ -17,17 +17,8 @@ JSON_DEBUG = True #with apache x-sendfile or lighttpd set this to True XSENDFILE = False +#with nginx X-Accel-Redirect set this to True XACCELREDIRECT = False -# with nginx: -#XACCELREDIRECT=['/srv/pandora/pandora/media/', '/media/'] -''' -this assumes the following configuration: -location /media/ { - internal; - root /srv/pandora/pandora/media/; -} -''' - ADMINS = ( #('admin', 'admin@example.com'), @@ -154,6 +145,7 @@ TRANSMISSON_PASSWORD='transmission' #list of poster services, https://wiki.0x2620.org/wiki/pandora/posterservice POSTER_SERVICES=[] +POSTER_PRECEDENCE=('local', 'criterion.com', 'wikipedia.org', 'impawards.com', 'movieposterdb.com', 'imdb.com', 'allmovie.com', 'other') #0xdb.org #POSTER_SERVICES=['http://data.0xdb.org/poster/']