for_search, imdb_match added to class
This commit is contained in:
1 parent
dfd522d7b9
commit
a60b227e81
3 files changed
+103
-120
No files matched your search
@@ -3,6 +3,9 @@ from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.plugins.base import Plugin
|
||||
from couchpotato.environment import Env
|
||||
from urlparse import urlparse
|
||||
from urllib import quote_plus
|
||||
from couchpotato.core.helpers.encoding import simplifyString
|
||||
|
||||
import re
|
||||
import time
|
||||
|
||||
@@ -105,5 +108,24 @@ class YarrProvider(Provider):
|
||||
|
||||
return [self.cat_backup_id]
|
||||
|
||||
def imdb_match(self, url, imdb_id):
|
||||
""" Searches for imdb_id in url of webpage """
|
||||
log.info('Finding if imbd_id(%s) is found in url: %s' % (imdb_id, url))
|
||||
try:
|
||||
data = self.urlopen(url)
|
||||
except:
|
||||
log.error('Failed to open %s.' % url)
|
||||
return False
|
||||
imdb_id_alt = re.sub('tt[0]*', 'tt', imdb_id)
|
||||
data = unicode(data, errors='ignore')
|
||||
if 'imdb.com/title/' + imdb_id in data or 'imdb.com/title/' \
|
||||
+ imdb_id_alt in data:
|
||||
return True
|
||||
return False
|
||||
|
||||
def for_search(self, string):
|
||||
""" Prepare string for search, removing all characters that might confuse search engine"""
|
||||
return quote_plus(simplifyString(string))
|
||||
|
||||
def found(self, new):
|
||||
log.info('Found: score(%(score)s) on %(provider)s: %(name)s', new)
|
||||
Reference in new issue
Block a user