file import cleanup

This commit is contained in:
j 2010-01-23 10:57:06 +11:00
parent bf9a91280e
commit d77acd43cd
3 changed files with 11 additions and 8 deletions

View file

@ -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'):

View file

@ -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):

View file

@ -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]