Browse Source

Use CP api for movie check

pull/778/merge
Ruud 12 years ago
parent
commit
4b54113f08
  1. 5
      couchpotato/core/plugins/movie/main.py
  2. 13
      couchpotato/core/providers/movie/couchpotatoapi/main.py

5
couchpotato/core/plugins/movie/main.py

@ -292,9 +292,8 @@ class MoviePlugin(Plugin):
return False return False
else: else:
try: try:
url = 'http://thetvdb.com/api/GetSeriesByRemoteID.php?imdbid=%s' % params.get('identifier') is_movie = fireEvent('movie.is_movie', identifier = params.get('identifier'), single = True)
tvdb = self.getCache('thetvdb.%s' % params.get('identifier'), url = url, show_error = False) if not is_movie:
if tvdb and 'series' in tvdb.lower():
msg = 'Can\'t add movie, seems to be a TV show.' msg = 'Can\'t add movie, seems to be a TV show.'
log.error(msg) log.error(msg)
fireEvent('notify.frontend', type = 'movie.is_tvshow', message = msg) fireEvent('notify.frontend', type = 'movie.is_tvshow', message = msg)

13
couchpotato/core/providers/movie/couchpotatoapi/main.py

@ -17,6 +17,7 @@ class CouchPotatoApi(MovieProvider):
urls = { urls = {
'search': 'https://couchpota.to/api/search/%s/', 'search': 'https://couchpota.to/api/search/%s/',
'info': 'https://couchpota.to/api/info/%s/', 'info': 'https://couchpota.to/api/info/%s/',
'is_movie': 'https://couchpota.to/api/ismovie/%s/',
'eta': 'https://couchpota.to/api/eta/%s/', 'eta': 'https://couchpota.to/api/eta/%s/',
'suggest': 'https://couchpota.to/api/suggest/%s/%s/', 'suggest': 'https://couchpota.to/api/suggest/%s/%s/',
} }
@ -29,6 +30,7 @@ class CouchPotatoApi(MovieProvider):
addEvent('movie.info', self.getInfo, priority = 1) addEvent('movie.info', self.getInfo, priority = 1)
addEvent('movie.search', self.search, priority = 1) addEvent('movie.search', self.search, priority = 1)
addEvent('movie.release_date', self.getReleaseDate) addEvent('movie.release_date', self.getReleaseDate)
addEvent('movie.is_movie', self.isMovie)
def search(self, q, limit = 12): def search(self, q, limit = 12):
@ -44,6 +46,17 @@ class CouchPotatoApi(MovieProvider):
return [] return []
def isMovie(self, identifier = None):
if not identifier:
return
data = self.getJsonData(self.urls['is_movie'] % identifier, headers = self.getRequestHeaders())
if data:
return data.get('is_movie', True)
return True
def getInfo(self, identifier = None): def getInfo(self, identifier = None):
if not identifier: if not identifier:

Loading…
Cancel
Save