Userscript providers

This commit is contained in:
Ruud committed 2011-10-12 12:21:03 +02:00
1 parent e2a373f15a
commit 76f471ad34
3 files changed
+44 -52

No files matched your search

@@ -1,34 +1,27 @@
from beautifulsoup import BeautifulSoup
from couchpotato.core.event import fireEvent
from couchpotato.core.providers.userscript.base import UserscriptBase from couchpotato.core.providers.userscript.base import UserscriptBase
class AlloCine(UserscriptBase): class AlloCine(UserscriptBase):
includes = ['http://www.allocine.fr/film/*'] includes = ['http://www.allocine.fr/film/*']
#CouchPotato['allocine.fr'] = (function(){ def getMovie(self, url):
#
# function isMovie(){ if not 'fichefilm_gen_cfilm' in url:
# var pattern = /fichefilm_gen_cfilm=\d+?\.html$/; return 'Url isn\'t from a movie'
# matched = location.href.match(pattern);
# return null != matched; data = self.urlopen(url)
# }
# html = BeautifulSoup(data)
# function getId() { title = html.find('title').contents[0].strip()
# var name = document.title.substr(0, document.title.indexOf(" -")).replace(/ /g, "+"); split = title.split(') - ')
# lib.search(name, getYear())
# } name = split[0][:-5].strip()
# year = split[0][-4:]
# function getYear(){
# var year = new RegExp("\\d{4}", document.title) result = self.search(name, year)
# return year; if result:
# } movie = fireEvent('movie.info', identifier = result.get('imdb'), merge = True)
#
# function constructor(){ return movie
# if(isMovie()){
# lib.osd(getId(), getYear());
# }
# }
#
# return constructor;
#
#})();
@@ -1,29 +1,24 @@
from couchpotato.core.event import fireEvent
from couchpotato.core.providers.userscript.base import UserscriptBase from couchpotato.core.providers.userscript.base import UserscriptBase
import re
class AppleTrailers(UserscriptBase): class AppleTrailers(UserscriptBase):
includes = ['http://trailers.apple.com/trailers/*'] includes = ['http://trailers.apple.com/trailers/*']
#CouchPotato['trailers.apple.com'] = (function(){ def getMovie(self, url):
#
# function getId() { data = self.urlopen(url)
# var name = document.title.substr(0, document.title.indexOf(" -")).replace(/ /g, "+");
# return lib.search(name, getYear()) name = re.search('(?P<id>(var trailerTitle(.+);))', data)
# name = name.group('id').split(' = \'')[1].strip()[:-2].decode('string_escape')
# }
# date = re.search('(?P<id>(var releaseDate(.+);))', data)
# function getYear(){ year = date.group('id').split(' = \'')[1].strip()[:-2]
# var release_date = document.getElementById("view-showtimes").parentNode.innerHTML;
# var year = new RegExp("\\d{4}", release_date) result = self.search(name, year)
# if result:
# return year; movie = fireEvent('movie.info', identifier = result.get('imdb'), merge = True)
# }
# return movie
# function constructor(){
# getId();
# }
#
# return constructor;
#
#})();
@@ -21,8 +21,12 @@ class UserscriptBase(Plugin):
addEvent('userscript.get_movie_via_url', self.belongsTo) addEvent('userscript.get_movie_via_url', self.belongsTo)
def search(self, name, year = None): def search(self, name, year = None):
movie = fireEvent('movie.search', q = '%s %s' % (name, year), limit = 1) movie = fireEvent('movie.search', q = '%s %s' % (name, year), limit = 1, merge = True)
return movie
if len(movie) > 0:
return movie[0]
else:
return None
def belongsTo(self, url): def belongsTo(self, url):