Speed up Userscript by not using BeautifulSoup. fix #796
This commit is contained in:
1 parent
012ae9769a
commit
b62afc63f1
2 files changed
+40
-13
No files matched your search
@@ -1,6 +1,10 @@
|
||||
from bs4 import BeautifulSoup
|
||||
from couchpotato.core.event import fireEvent
|
||||
from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.providers.userscript.base import UserscriptBase
|
||||
import re
|
||||
import traceback
|
||||
|
||||
log = CPLog(__name__)
|
||||
|
||||
|
||||
class RottenTomatoes(UserscriptBase):
|
||||
|
||||
@@ -16,7 +20,20 @@ class RottenTomatoes(UserscriptBase):
|
||||
except:
|
||||
return
|
||||
|
||||
html = BeautifulSoup(data)
|
||||
title = html.find('span', {'itemprop':'name'}).text
|
||||
info = fireEvent('scanner.name_year', title, single = True)
|
||||
return self.search(info['name'], info['year'])
|
||||
try:
|
||||
name = None
|
||||
year = None
|
||||
metas = re.findall("property=\"(video:release_date|og:title)\" content=\"([^\"]*)\"", data)
|
||||
|
||||
for meta in metas:
|
||||
mname, mvalue = meta
|
||||
if mname == 'og:title':
|
||||
name = mvalue.decode('unicode_escape')
|
||||
elif mname == 'video:release_date':
|
||||
year = mvalue[:4]
|
||||
|
||||
if name and year:
|
||||
return self.search(name, year)
|
||||
|
||||
except:
|
||||
log.error('Failed parsing page for title and year: %s', traceback.format_exc())
|
||||
Reference in new issue
Block a user