Browse Source

Subdirectories for providers

pull/1/merge
Ruud 14 years ago
parent
commit
2b88e08dd5
  1. 13
      couchpotato/core/loader.py
  2. 0
      couchpotato/core/providers/movie/__init__.py
  3. 0
      couchpotato/core/providers/movie/imdb/__init__.py
  4. 0
      couchpotato/core/providers/movie/imdb/main.py
  5. 0
      couchpotato/core/providers/movie/themoviedb/__init__.py
  6. 0
      couchpotato/core/providers/movie/themoviedb/main.py
  7. 0
      couchpotato/core/providers/nzb/__init__.py
  8. 0
      couchpotato/core/providers/nzb/newzbin/__init__.py
  9. 0
      couchpotato/core/providers/nzb/newzbin/main.py
  10. 0
      couchpotato/core/providers/nzb/newznab/__init__.py
  11. 0
      couchpotato/core/providers/nzb/newznab/main.py
  12. 0
      couchpotato/core/providers/nzb/nzbmatrix/__init__.py
  13. 0
      couchpotato/core/providers/nzb/nzbmatrix/main.py
  14. 124
      couchpotato/core/providers/nzb/nzbmatrix/nzbmatrix.py
  15. 0
      couchpotato/core/providers/nzb/nzbs/__init__.py
  16. 0
      couchpotato/core/providers/nzb/nzbs/main.py
  17. 0
      couchpotato/core/providers/subtitle/__init__.py
  18. 0
      couchpotato/core/providers/torrent/__init__.py
  19. 0
      couchpotato/core/providers/torrent/thepiratebay/__init__.py
  20. 0
      couchpotato/core/providers/torrent/thepiratebay/main.py
  21. 0
      couchpotato/core/providers/trailer/__init__.py

13
couchpotato/core/loader.py

@ -14,11 +14,18 @@ class Loader:
def preload(self, root = ''):
core = os.path.join(root, 'couchpotato', 'core')
providers = os.path.join(root, 'couchpotato', 'core', 'providers')
self.paths = {
'plugin' : ('couchpotato.core.plugins', os.path.join(root, 'couchpotato', 'core', 'plugins')),
'provider' : ('couchpotato.core.providers', os.path.join(root, 'couchpotato', 'core', 'providers')),
'notifications' : ('couchpotato.core.notifications', os.path.join(root, 'couchpotato', 'core', 'notifications')),
'plugin' : ('couchpotato.core.plugins', os.path.join(core, 'plugins')),
'notifications' : ('couchpotato.core.notifications', os.path.join(core, 'notifications')),
'downloaders' : ('couchpotato.core.downloaders', os.path.join(root, 'couchpotato', 'core', 'downloaders')),
'movie_provider' : ('couchpotato.core.providers.movie', os.path.join(providers, 'movie')),
'nzb_provider' : ('couchpotato.core.providers.nzb', os.path.join(providers, 'nzb')),
'torrent_provider' : ('couchpotato.core.providers.torrent', os.path.join(providers, 'torrent')),
'trailer_provider' : ('couchpotato.core.providers.trailer', os.path.join(providers, 'trailer')),
'subtitle_provider' : ('couchpotato.core.providers.subtitle', os.path.join(providers, 'subtitle')),
}
for type, tuple in self.paths.iteritems():

0
couchpotato/core/providers/movie/__init__.py

0
couchpotato/core/providers/imdb/__init__.py → couchpotato/core/providers/movie/imdb/__init__.py

0
couchpotato/core/providers/imdb/main.py → couchpotato/core/providers/movie/imdb/main.py

0
couchpotato/core/providers/themoviedb/__init__.py → couchpotato/core/providers/movie/themoviedb/__init__.py

0
couchpotato/core/providers/themoviedb/main.py → couchpotato/core/providers/movie/themoviedb/main.py

0
couchpotato/core/providers/nzb/__init__.py

0
couchpotato/core/providers/newzbin/__init__.py → couchpotato/core/providers/nzb/newzbin/__init__.py

0
couchpotato/core/providers/newzbin/main.py → couchpotato/core/providers/nzb/newzbin/main.py

0
couchpotato/core/providers/newznab/__init__.py → couchpotato/core/providers/nzb/newznab/__init__.py

0
couchpotato/core/providers/newznab/main.py → couchpotato/core/providers/nzb/newznab/main.py

0
couchpotato/core/providers/nzbmatrix/__init__.py → couchpotato/core/providers/nzb/nzbmatrix/__init__.py

0
couchpotato/core/providers/nzbmatrix/main.py → couchpotato/core/providers/nzb/nzbmatrix/main.py

124
couchpotato/core/providers/nzb/nzbmatrix/nzbmatrix.py

@ -0,0 +1,124 @@
from app.config.cplog import CPLog
from app.lib.provider.yarr.base import nzbBase
from dateutil.parser import parse
from urllib import urlencode
from urllib2 import URLError
import time
log = CPLog(__name__)
class nzbMatrix(nzbBase):
"""Api for NZBMatrix"""
name = 'NZBMatrix'
downloadUrl = 'https://api.nzbmatrix.com/v1.1/download.php?id=%s%s'
detailUrl = 'https://nzbmatrix.com/nzb-details.php?id=%s&hit=1'
searchUrl = 'http://rss.nzbmatrix.com/rss.php'
catIds = {
42: ['720p', '1080p'],
2: ['cam', 'ts', 'dvdrip', 'tc', 'r5', 'scr'],
54: ['brrip'],
1: ['dvdr']
}
catBackupId = 2
timeBetween = 10 # Seconds
def __init__(self, config):
log.info('Using NZBMatrix provider')
self.config = config
def conf(self, option):
return self.config.get('NZBMatrix', option)
def enabled(self):
return self.conf('enabled') and self.config.get('NZB', 'enabled') and self.conf('username') and self.conf('apikey')
def find(self, movie, quality, type, retry = False):
self.cleanCache();
results = []
if not self.enabled() or not self.isAvailable(self.searchUrl):
return results
catId = self.getCatId(type)
arguments = urlencode({
'term': movie.imdb,
'subcat': catId,
'username': self.conf('username'),
'apikey': self.conf('apikey'),
'searchin': 'weblink',
'english': 1 if self.conf('english') else 0,
})
url = "%s?%s" % (self.searchUrl, arguments)
cacheId = str(movie.imdb) + '-' + str(catId)
singleCat = (len(self.catIds.get(catId)) == 1 and catId != self.catBackupId)
try:
cached = False
if(self.cache.get(cacheId)):
data = True
cached = True
log.info('Getting RSS from cache: %s.' % cacheId)
else:
log.info('Searching: %s' % url)
data = self.urlopen(url)
self.cache[cacheId] = {
'time': time.time()
}
except (IOError, URLError):
log.error('Failed to open %s.' % url)
return results
if data:
try:
try:
if cached:
xml = self.cache[cacheId]['xml']
else:
xml = self.getItems(data)
self.cache[cacheId]['xml'] = xml
except:
log.debug('No valid xml or to many requests.. You never know with %s.' % self.name)
return results
for nzb in xml:
title = self.gettextelement(nzb, "title")
if 'error' in title.lower(): continue
id = int(self.gettextelement(nzb, "link").split('&')[0].partition('id=')[2])
size = self.gettextelement(nzb, "description").split('<br /><b>')[2].split('> ')[1]
date = str(self.gettextelement(nzb, "description").split('<br /><b>')[3].partition('Added:</b> ')[2])
new = self.feedItem()
new.id = id
new.type = 'nzb'
new.name = title
new.date = int(time.mktime(parse(date).timetuple()))
new.size = self.parseSize(size)
new.url = self.downloadLink(id)
new.detailUrl = self.detailLink(id)
new.content = self.gettextelement(nzb, "description")
new.score = self.calcScore(new, movie)
new.checkNZB = True
if new.date > time.time() - (int(self.config.get('NZB', 'retention')) * 24 * 60 * 60):
if self.isCorrectMovie(new, movie, type, imdbResults = True, singleCategory = singleCat):
results.append(new)
log.info('Found: %s' % new.name)
else:
log.info('Found outside retention: %s' % new.name)
return results
except SyntaxError:
log.error('Failed to parse XML response from NZBMatrix.com')
return results
def getApiExt(self):
return '&username=%s&apikey=%s' % (self.conf('username'), self.conf('apikey'))

0
couchpotato/core/providers/nzbs/__init__.py → couchpotato/core/providers/nzb/nzbs/__init__.py

0
couchpotato/core/providers/nzbs/main.py → couchpotato/core/providers/nzb/nzbs/main.py

0
couchpotato/core/providers/subtitle/__init__.py

0
couchpotato/core/providers/torrent/__init__.py

0
couchpotato/core/providers/thepiratebay/__init__.py → couchpotato/core/providers/torrent/thepiratebay/__init__.py

0
couchpotato/core/providers/thepiratebay/main.py → couchpotato/core/providers/torrent/thepiratebay/main.py

0
couchpotato/core/providers/trailer/__init__.py

Loading…
Cancel
Save