Userscript providers

This commit is contained in:
Ruud
2011-10-12 12:21:03 +02:00
parent e2a373f15a
commit 76f471ad34
3 changed files with 44 additions and 52 deletions
@@ -1,34 +1,27 @@
from beautifulsoup import BeautifulSoup
from couchpotato.core.event import fireEvent
from couchpotato.core.providers.userscript.base import UserscriptBase
class AlloCine(UserscriptBase):
includes = ['http://www.allocine.fr/film/*']
#CouchPotato['allocine.fr'] = (function(){
#
# function isMovie(){
# var pattern = /fichefilm_gen_cfilm=\d+?\.html$/;
# matched = location.href.match(pattern);
# return null != matched;
# }
#
# function getId() {
# var name = document.title.substr(0, document.title.indexOf(" -")).replace(/ /g, "+");
# lib.search(name, getYear())
# }
#
# function getYear(){
# var year = new RegExp("\\d{4}", document.title)
# return year;
# }
#
# function constructor(){
# if(isMovie()){
# lib.osd(getId(), getYear());
# }
# }
#
# return constructor;
#
#})();
def getMovie(self, url):
if not 'fichefilm_gen_cfilm' in url:
return 'Url isn\'t from a movie'
data = self.urlopen(url)
html = BeautifulSoup(data)
title = html.find('title').contents[0].strip()
split = title.split(') - ')
name = split[0][:-5].strip()
year = split[0][-4:]
result = self.search(name, year)
if result:
movie = fireEvent('movie.info', identifier = result.get('imdb'), merge = True)
return movie