diff --git a/couchpotato/core/helpers/variable.py b/couchpotato/core/helpers/variable.py index 5dc7319f..0c6cfc7d 100644 --- a/couchpotato/core/helpers/variable.py +++ b/couchpotato/core/helpers/variable.py @@ -43,6 +43,22 @@ def cleanHost(host): return host +def getImdb(txt): + + if os.path.isfile(txt): + output = open(txt, 'r') + txt = output.read() + output.close() + + try: + m = re.search('(?Ptt[0-9{7}]+)', txt) + id = m.group('id') + if id: return id + except AttributeError: + pass + + return False + def tryInt(s): try: return int(s) except: return s diff --git a/couchpotato/core/plugins/scanner/main.py b/couchpotato/core/plugins/scanner/main.py index f4e267c3..7535d3a4 100644 --- a/couchpotato/core/plugins/scanner/main.py +++ b/couchpotato/core/plugins/scanner/main.py @@ -1,7 +1,7 @@ from couchpotato import get_session from couchpotato.core.event import fireEvent, addEvent from couchpotato.core.helpers.encoding import toUnicode, simplifyString -from couchpotato.core.helpers.variable import getExt +from couchpotato.core.helpers.variable import getExt, getImdb from couchpotato.core.logger import CPLog from couchpotato.core.plugins.base import Plugin from couchpotato.core.settings.model import File @@ -298,7 +298,7 @@ class Scanner(Plugin): if not imdb_id: try: for nfo_file in files['nfo']: - imdb_id = self.getImdb(nfo_file) + imdb_id = getImdb(nfo_file) if imdb_id: break except: pass @@ -359,22 +359,6 @@ class Scanner(Plugin): return False - def getImdb(self, txt): - - if os.path.isfile(txt): - output = open(txt, 'r') - txt = output.read() - output.close() - - try: - m = re.search('(?Ptt[0-9{7}]+)', txt) - id = m.group('id') - if id: return id - except AttributeError: - pass - - return False - def getMediaFiles(self, files): def test(s):