aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFélix Sipma <gueux@gueux.org>2013-04-16 18:13:07 +0200
committerFélix Sipma <gueux@gueux.org>2013-04-16 18:13:07 +0200
commit9258ae7c74553793df0eb5196575f4b7e5f68552 (patch)
tree5224d425a1486c07c3554b228fb4305e64d06ac5
parent9d6a21c3057365c63181b557b1a3f6568fac3b84 (diff)
pep8 fixes + use symlink name instead of linked file name
-rw-r--r--videodb/helpers.py43
1 files changed, 26 insertions, 17 deletions
diff --git a/videodb/helpers.py b/videodb/helpers.py
index ffd15ff..b87a4a2 100644
--- a/videodb/helpers.py
+++ b/videodb/helpers.py
@@ -1,8 +1,7 @@
-# -*- coding: utf-8 -*-
+# -*- coding: utf-8 -*-
from videodb.models import *
-from imdb import IMDb, IMDbError
-import os, sys, urllib, getopt, ConfigParser, re
-import warnings
+import os
+import re
import logging
from pymediainfo import MediaInfo
import magic
@@ -24,7 +23,7 @@ def create_moviefile(file):
if os.path.isfile(file):
osfile = os.path.realpath(file)
logger.info(" Realpath: %s" % osfile)
- moviefile = MovieFile(filename=os.path.basename(osfile),
+ moviefile = MovieFile(filename=os.path.basename(file),
size=os.path.getsize(osfile),
)
logger.info(" Filename: %s" % moviefile.filename)
@@ -45,7 +44,7 @@ def create_moviefile(file):
logger.info(" Parsing: %s" % osfile)
mediainfo = MediaInfo.parse(osfile)
-
+
# MediaInfo part
for track in mediainfo.tracks:
tracktype = track.track_type
@@ -197,7 +196,13 @@ def create_moviefile(file):
for k in menu.keys():
match = re.match("^(\d+)_(\d+)_(\d+)$", k)
if match:
- positions.append({ 'position': float(match.group(1))*3600 + float(match.group(2))*60 + float(match.group(3)), 'menukey': k })
+ positions.append(
+ {
+ 'position': float(match.group(1)) * 3600 +
+ float(match.group(2)) * 60 +
+ float(match.group(3)),
+ 'menukey': k
+ })
for p in sorted(positions):
logger.info(" Chapter:")
c = Chapter()
@@ -210,10 +215,10 @@ def create_moviefile(file):
logger.info(" Chapterid: %s" % c.chapterid)
logger.info(" Position: %s ms" % c.position)
logger.info(" Name: %s" % c.name)
-
+
else:
logger.warn(' Track "%(id)s" of unknown type: "%(type)s".' %
- { 'id': track.track_id, 'type': track.tracktype })
+ {'id': track.track_id, 'type': track.tracktype})
moviefile.save()
@@ -236,7 +241,6 @@ def get_imdbdata(imdbmovie):
imdbdata['year'] = year
logger.info("Year: %s" % year)
-
# Genre part
imdbdata['genre'] = []
logger.info("Genres:")
@@ -340,7 +344,8 @@ def get_imdbdata(imdbmovie):
imdbdata['director'] += [d]
else:
- logger.warning("WARNING: No director on IMDb for this movie %s" % imdbmovie.movieID)
+ logger.warning("WARNING: No director on IMDb for this movie %s" %
+ imdbmovie.movieID)
# Writer part
imdbdata['writer'] = []
@@ -364,7 +369,8 @@ def get_imdbdata(imdbmovie):
imdbdata['writer'] += [p]
else:
- logger.warning("No writer on IMDb for this movie %s" % imdbmovie.movieID)
+ logger.warning("No writer on IMDb for this movie %s" %
+ imdbmovie.movieID)
# Actor part
imdbdata['actor'] = []
@@ -390,7 +396,7 @@ def get_imdbdata(imdbmovie):
a.save()
# Character and Actor part
- if isinstance(actor.currentRole,list):
+ if isinstance(actor.currentRole, list):
roles = actor.currentRole
else:
roles = [actor.currentRole]
@@ -404,7 +410,8 @@ def get_imdbdata(imdbmovie):
imdbdata['actor'] += [a]
else:
- logger.warning("No actor on IMDb for this movie %s" % imdbmovie.movieID)
+ logger.warning("No actor on IMDb for this movie %s" %
+ imdbmovie.movieID)
# Company part
imdbdata['production_company'] = []
@@ -428,7 +435,8 @@ def get_imdbdata(imdbmovie):
imdbdata['production_company'] += [c]
else:
- logger.warning("No production company on IMDb for this movie %s" % imdbmovie.movieID)
+ logger.warning("No production company on IMDb for this movie %s" %
+ imdbmovie.movieID)
# MovieRuntime part
imdbdata['runtime'] = []
@@ -462,10 +470,11 @@ def get_imdbdata(imdbmovie):
else:
version = runtime
- imdbdata['runtime'] += [{ 'runtime': rtime, 'version': version }]
+ imdbdata['runtime'] += [{'runtime': rtime, 'version': version}]
logger.info(" %s (%s)" % (rtime, version))
else:
- logger.warning("No runtime on IMDb for this movie %s" % imdbmovie.movieID)
+ logger.warning("No runtime on IMDb for this movie %s" %
+ imdbmovie.movieID)
return imdbdata