From d77acd43cdf2c14f6fbb6264e06c80766eca4732 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sat, 23 Jan 2010 10:57:06 +1100 Subject: [PATCH] file import cleanup --- oxdb/backend/models.py | 12 +++++++----- oxdb/backend/utils.py | 2 +- oxdb/backend/views.py | 5 +++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/oxdb/backend/models.py b/oxdb/backend/models.py index c9b99f77..4465659e 100644 --- a/oxdb/backend/models.py +++ b/oxdb/backend/models.py @@ -90,16 +90,18 @@ def getMovie(info): info dict with: imdbId, title, director, episode_title, season, series ''' - if 'imdbId' in info: + if 'imdbId' in info and info['imdbId']: try: - movie = models.Movie.byImdbId(imdbId) - except models.Movie.DoesNotExist: - movie = load.loadIMDb(movieId==info['imdbId']) + movie = Movie.byImdbId(info['imdbId']) + except Movie.DoesNotExist: + movie = load.loadIMDb(info['imdbId']) else: - q = Movie.objects.filter(title=info['title'], year=info['director']) + q = Movie.objects.filter(oxdb__title=info['title']) if q.count() > 1: + print "FIXME: check more than title here!!" movie = q[0] else: + print info movie = newMovie(info['title'], info['director'], '') updated = False for key in ('episode_title', 'season', 'year'): diff --git a/oxdb/backend/utils.py b/oxdb/backend/utils.py index 25f2a9c4..b0543ec7 100644 --- a/oxdb/backend/utils.py +++ b/oxdb/backend/utils.py @@ -78,7 +78,7 @@ def oxdb_episode_title(path): episodeTitle = u'' ep = re.compile('.Episode \d+?\.(.*?)\.[a-zA-Z]').findall(path) if ep: - episodeTitle = ep[0][0] + episodeTitle = ep[0] return episodeTitle def oxdb_season_episode(path): diff --git a/oxdb/backend/views.py b/oxdb/backend/views.py index 58b1eb7d..205b1897 100644 --- a/oxdb/backend/views.py +++ b/oxdb/backend/views.py @@ -11,6 +11,7 @@ from django.contrib.auth.models import User from django.shortcuts import render_to_response, get_object_or_404, get_list_or_404 from django.template import RequestContext from django.core.paginator import Paginator +from django import forms from django.http import HttpResponse from django.contrib.auth.decorators import login_required try: @@ -427,8 +428,8 @@ def update_archive(request, archive): print "adding file", oshash, data['path'] f = models.ArchiveFile.get_or_create(archive, oshash) f.update(data) - if not f.movie: - send_bg_message({'findMovie': f.id}) + if not f.file.movie: + send_bg_message({'findMovie': f.file.id}) #FIXME: only add if it was not in File else: f = q[0]