Speed up Userscript by not using BeautifulSoup. fix #796

This commit is contained in:
Ruud
2012-09-04 23:10:34 +02:00
parent 012ae9769a
commit b62afc63f1
2 changed files with 40 additions and 13 deletions
@@ -1,5 +1,9 @@
from bs4 import BeautifulSoup
from couchpotato.core.logger import CPLog
from couchpotato.core.providers.userscript.base import UserscriptBase
import traceback
log = CPLog(__name__)
class AlloCine(UserscriptBase):
@@ -15,11 +19,17 @@ class AlloCine(UserscriptBase):
except:
return
html = BeautifulSoup(data)
title = html.find('title').contents[0].strip()
split = title.split(') - ')
name = None
year = None
name = split[0][:-5].strip()
year = split[0][-4:]
try:
start = data.find('<title>')
end = data.find('</title>', start)
page_title = data[start + len('<title>'):end].strip().split('-')
name = page_title[0].strip()
year = page_title[1].strip()[-4:]
return self.search(name, year)
except:
log.error('Failed parsing page for title and year: %s', traceback.format_exc())
return self.search(name, year)