From 63f46fae757227de79c4b47ab063ba1a6b27c790 Mon Sep 17 00:00:00 2001 From: Ruud Date: Sat, 19 May 2012 00:45:28 +0200 Subject: [PATCH] Extra check for imdb file. close #273 --- couchpotato/core/helpers/variable.py | 4 ++-- couchpotato/core/plugins/scanner/main.py | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/couchpotato/core/helpers/variable.py b/couchpotato/core/helpers/variable.py index 29e4bf4..bf5b236 100644 --- a/couchpotato/core/helpers/variable.py +++ b/couchpotato/core/helpers/variable.py @@ -77,9 +77,9 @@ def cleanHost(host): return host -def getImdb(txt): +def getImdb(txt, check_inside = True): - if os.path.isfile(txt): + if check_inside and os.path.isfile(txt): output = open(txt, 'r') txt = output.read() output.close() diff --git a/couchpotato/core/plugins/scanner/main.py b/couchpotato/core/plugins/scanner/main.py index 0a220bc..76e243e 100644 --- a/couchpotato/core/plugins/scanner/main.py +++ b/couchpotato/core/plugins/scanner/main.py @@ -443,7 +443,7 @@ class Scanner(Plugin): log.debug('Found movie via CP tag: %s' % cur_file) break - # Check and see if nfo contains the imdb-id + # Check and see if nfo or filenames contains the imdb-id if not imdb_id: try: for nfo_file in files['nfo']: @@ -454,6 +454,16 @@ class Scanner(Plugin): except: pass + try: + for filetype in files: + for filetype_file in files[filetype]: + imdb_id = getImdb(filetype_file, check_inside = False) + if imdb_id: + log.debug('Found movie via imdb in filename: %s' % nfo_file) + break + except: + pass + # Check if path is already in db if not imdb_id: db = get_session()