Userscript provider parsers

This commit is contained in:
Ruud
2011-10-12 13:47:00 +02:00
parent f719a5fd65
commit 3103a24a55
7 changed files with 13 additions and 162 deletions
@@ -1,4 +1,5 @@
from couchpotato.core.event import addEvent, fireEvent from couchpotato.core.event import addEvent, fireEvent
from couchpotato.core.helpers.variable import getImdb
from couchpotato.core.logger import CPLog from couchpotato.core.logger import CPLog
from couchpotato.core.plugins.base import Plugin from couchpotato.core.plugins.base import Plugin
from urlparse import urlparse from urlparse import urlparse
@@ -42,7 +43,11 @@ class UserscriptBase(Plugin):
return return
def getMovie(self, url): def getMovie(self, url):
return None data = self.urlopen(url)
return self.getInfo(getImdb(data))
def getInfo(self, identifier):
return fireEvent('movie.info', identifier = identifier, merge = True)
def getInclude(self): def getInclude(self):
return self.includes return self.includes
@@ -21,6 +21,4 @@ class IMDB(UserscriptBase):
return 'IMDB url is a TV Show' return 'IMDB url is a TV Show'
identifier = re.search('(?P<id>tt[0-9{7}]+)', url).group('id') identifier = re.search('(?P<id>tt[0-9{7}]+)', url).group('id')
movie = fireEvent('movie.info', identifier = identifier, merge = True) return fireEvent('movie.info', identifier = identifier, merge = True)
return movie
@@ -4,38 +4,3 @@ from couchpotato.core.providers.userscript.base import UserscriptBase
class MovieMeter(UserscriptBase): class MovieMeter(UserscriptBase):
includes = ['http://*.moviemeter.nl/film/*', 'http://moviemeter.nl/film/*'] includes = ['http://*.moviemeter.nl/film/*', 'http://moviemeter.nl/film/*']
#CouchPotato['moviemeter.nl'] = (function(){
#
# function isMovie(){
# var pattern = /[^/]+\/?$/;
# var html = document.getElementsByTagName('h1')[0].innerHTML
# matched = location.href.match(pattern);
# return null != matched;
# }
#
# function getId(){
# var pattern = /imdb\.com\/title\/tt(\d+)/;
# var html = document.getElementsByTagName('html')[0].innerHTML;
# var imdb_id = html.match(pattern)[1];
# return imdb_id;
#
# }
#
# function getYear(){
# var pattern = /(\d+)[^\d]*$/;
# var html = document.getElementsByTagName('h1')[0].innerHTML;
# var year = html.match(pattern)[1];
# return year;
#
# }
#
# function constructor(){
# if(isMovie()){
# lib.osd(getId(), getYear());
# }
# }
#
# return constructor;
#
#})();
@@ -4,37 +4,3 @@ from couchpotato.core.providers.userscript.base import UserscriptBase
class ShareThe(UserscriptBase): class ShareThe(UserscriptBase):
includes = ['http://*.sharethe.tv/movies/*', 'http://sharethe.tv/movies/*'] includes = ['http://*.sharethe.tv/movies/*', 'http://sharethe.tv/movies/*']
#CouchPotato['sharethe.tv'] = (function(){
#
# function isMovie(){
# var pattern = /movies\/[^/]+\/?$/;
# matched = location.href.match(pattern);
# return null != matched;
# }
#
# function getId(){
# var pattern = /imdb\.com\/title\/tt(\d+)/;
# var html = document.getElementsByTagName('html')[0].innerHTML;
# var imdb_id = html.match(pattern)[1];
# return imdb_id;
#
# }
#
# function getYear(){
# var pattern = /(\d+)[^\d]*$/;
# var html = document.getElementsByTagName('html')[0].innerHTML;
# var year = html.match(pattern)[1];
# return year;
#
# }
#
# function constructor(){
# if(isMovie()){
# lib.osd(getId(), getYear());
# }
# }
#
# return constructor;
#
#})();
@@ -1,31 +1,13 @@
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 TMDB(UserscriptBase): class TMDB(UserscriptBase):
includes = ['http://www.themoviedb.org/movie/*'] includes = ['http://www.themoviedb.org/movie/*']
#CouchPotato['themoviedb.org'] = (function(){ def getMovie(self, url):
# match = re.search('(?P<id>\d+)', url)
# var obj = this; movie = fireEvent('movie.info_by_tmdb', id = match.group('id'), merge = True)
# return self.getInfo(movie['imdb'])
# function getId() {
#
# name = document.title.substr(0, document.title.indexOf("TMDb")-3).replace(/ /g, "+");
# lib.search(name, getYear())
#
# }
#
# function getYear(){
# var year = document.getElementById("year").innerHTML;
# year = year.substr(1, year.length-2);
# return year;
# }
#
# function constructor(){
# getId();
# }
#
# return constructor;
#
#})();
@@ -5,33 +5,3 @@ class Trakt(UserscriptBase):
includes = ['http://trakt.tv/movie/*', 'http://*.trakt.tv/movie/*'] includes = ['http://trakt.tv/movie/*', 'http://*.trakt.tv/movie/*']
excludes = ['http://trakt.tv/movie/*/*', 'http://*.trakt.tv/movie/*/*'] excludes = ['http://trakt.tv/movie/*/*', 'http://*.trakt.tv/movie/*/*']
#CouchPotato['trakt.tv'] = (function(){
#
# var imdb_input = null;
# var year_input = null;
#
# function isMovie(){
# imdb_input = document.getElementById("meta-imdb-id");
# year_input = document.getElementById("meta-year");
# return (null != imdb_input) && (null != year_input);
# }
#
# function getId(){
# return imdb_input.value.substr(2);
# }
#
# function getYear(){
# return year_input.value;
#
# }
#
# function constructor(){
# if(isMovie()){
# lib.osd(getId(), getYear());
# }
# }
#
# return constructor;
#
#})();
@@ -4,38 +4,3 @@ from couchpotato.core.providers.userscript.base import UserscriptBase
class WHiWA(UserscriptBase): class WHiWA(UserscriptBase):
includes = ['http://whiwa.net/stats/movie/*'] includes = ['http://whiwa.net/stats/movie/*']
#CouchPotato['whiwa.net'] = (function(){
#
# function isMovie(){
# var pattern = /[^/]+\/?$/;
# var html = document.getElementsByTagName('h3')[0].innerHTML
# var matched = location.href.match(pattern);
# return null != matched;
# }
#
# function getId(){
# var pattern = /imdb\.com\/title\/tt(\d+)/;
# var html = document.getElementsByTagName('html')[0].innerHTML;
# var imdb_id = html.match(pattern)[1];
# return imdb_id;
#
# }
#
# function getYear(){
# var pattern = /(\d+)[^\d]*$/;
# var html = document.getElementsByTagName('h3')[0].innerHTML;
# var year = html.match(pattern)[1];
# return year;
#
# }
#
# function constructor(){
# if(isMovie()){
# lib.osd(getId(), getYear());
# }
# }
#
# return constructor;
#
#})();