79 changed files with 959 additions and 611 deletions
@ -1,136 +0,0 @@ |
|||||
from urlparse import parse_qs |
|
||||
import re |
|
||||
import traceback |
|
||||
|
|
||||
from bs4 import BeautifulSoup |
|
||||
from couchpotato.core.helpers.encoding import tryUrlencode, toUnicode |
|
||||
from couchpotato.core.helpers.variable import tryInt |
|
||||
from couchpotato.core.logger import CPLog |
|
||||
from couchpotato.core.media._base.providers.torrent.base import TorrentMagnetProvider |
|
||||
import six |
|
||||
|
|
||||
|
|
||||
log = CPLog(__name__) |
|
||||
|
|
||||
|
|
||||
class Base(TorrentMagnetProvider): |
|
||||
|
|
||||
urls = { |
|
||||
'test': 'https://publichd.se', |
|
||||
'detail': 'https://publichd.se/index.php?page=torrent-details&id=%s', |
|
||||
'search': 'https://publichd.se/index.php', |
|
||||
} |
|
||||
http_time_between_calls = 0 |
|
||||
|
|
||||
def search(self, movie, quality): |
|
||||
|
|
||||
if not quality.get('hd', False): |
|
||||
return [] |
|
||||
|
|
||||
return super(Base, self).search(movie, quality) |
|
||||
|
|
||||
def _search(self, media, quality, results): |
|
||||
|
|
||||
query = self.buildUrl(media) |
|
||||
|
|
||||
params = tryUrlencode({ |
|
||||
'page': 'torrents', |
|
||||
'search': query, |
|
||||
'active': 1, |
|
||||
}) |
|
||||
|
|
||||
data = self.getHTMLData('%s?%s' % (self.urls['search'], params)) |
|
||||
|
|
||||
if data: |
|
||||
|
|
||||
try: |
|
||||
soup = BeautifulSoup(data) |
|
||||
|
|
||||
results_table = soup.find('table', attrs = {'id': 'bgtorrlist2'}) |
|
||||
entries = results_table.find_all('tr') |
|
||||
|
|
||||
for result in entries[2:len(entries) - 1]: |
|
||||
info_url = result.find(href = re.compile('torrent-details')) |
|
||||
download = result.find(href = re.compile('magnet:')) |
|
||||
|
|
||||
if info_url and download: |
|
||||
|
|
||||
url = parse_qs(info_url['href']) |
|
||||
|
|
||||
results.append({ |
|
||||
'id': url['id'][0], |
|
||||
'name': six.text_type(info_url.string), |
|
||||
'url': download['href'], |
|
||||
'detail_url': self.urls['detail'] % url['id'][0], |
|
||||
'size': self.parseSize(result.find_all('td')[7].string), |
|
||||
'seeders': tryInt(result.find_all('td')[4].string), |
|
||||
'leechers': tryInt(result.find_all('td')[5].string), |
|
||||
'get_more_info': self.getMoreInfo |
|
||||
}) |
|
||||
|
|
||||
except: |
|
||||
log.error('Failed getting results from %s: %s', (self.getName(), traceback.format_exc())) |
|
||||
|
|
||||
def getMoreInfo(self, item): |
|
||||
|
|
||||
cache_key = 'publichd.%s' % item['id'] |
|
||||
description = self.getCache(cache_key) |
|
||||
|
|
||||
if not description: |
|
||||
|
|
||||
try: |
|
||||
full_description = self.urlopen(item['detail_url']) |
|
||||
html = BeautifulSoup(full_description) |
|
||||
nfo_pre = html.find('div', attrs = {'id': 'torrmain'}) |
|
||||
description = toUnicode(nfo_pre.text) if nfo_pre else '' |
|
||||
except: |
|
||||
log.error('Failed getting more info for %s', item['name']) |
|
||||
description = '' |
|
||||
|
|
||||
self.setCache(cache_key, description, timeout = 25920000) |
|
||||
|
|
||||
item['description'] = description |
|
||||
return item |
|
||||
|
|
||||
|
|
||||
config = [{ |
|
||||
'name': 'publichd', |
|
||||
'groups': [ |
|
||||
{ |
|
||||
'tab': 'searcher', |
|
||||
'list': 'torrent_providers', |
|
||||
'name': 'PublicHD', |
|
||||
'description': 'Public Torrent site with only HD content. See <a href="https://publichd.se/">PublicHD</a>', |
|
||||
'wizard': True, |
|
||||
'options': [ |
|
||||
{ |
|
||||
'name': 'enabled', |
|
||||
'type': 'enabler', |
|
||||
'default': True, |
|
||||
}, |
|
||||
{ |
|
||||
'name': 'seed_ratio', |
|
||||
'label': 'Seed ratio', |
|
||||
'type': 'float', |
|
||||
'default': 1, |
|
||||
'description': 'Will not be (re)moved until this seed ratio is met.', |
|
||||
}, |
|
||||
{ |
|
||||
'name': 'seed_time', |
|
||||
'label': 'Seed time', |
|
||||
'type': 'int', |
|
||||
'default': 40, |
|
||||
'description': 'Will not be (re)moved until this seed time (in hours) is met.', |
|
||||
}, |
|
||||
{ |
|
||||
'name': 'extra_score', |
|
||||
'advanced': True, |
|
||||
'label': 'Extra Score', |
|
||||
'type': 'int', |
|
||||
'default': 0, |
|
||||
'description': 'Starting score for each release found via this provider.', |
|
||||
} |
|
||||
], |
|
||||
}, |
|
||||
], |
|
||||
}] |
|
@ -1,14 +0,0 @@ |
|||||
from couchpotato.core.logger import CPLog |
|
||||
from couchpotato.core.event import fireEvent |
|
||||
from couchpotato.core.media._base.providers.torrent.publichd import Base |
|
||||
from couchpotato.core.media.movie.providers.base import MovieProvider |
|
||||
|
|
||||
log = CPLog(__name__) |
|
||||
|
|
||||
autoload = 'PublicHD' |
|
||||
|
|
||||
|
|
||||
class PublicHD(MovieProvider, Base): |
|
||||
|
|
||||
def buildUrl(self, media): |
|
||||
return fireEvent('library.query', media, single = True).replace(':', '') |
|
@ -1,69 +0,0 @@ |
|||||
import time |
|
||||
|
|
||||
from couchpotato.core.helpers.encoding import toUnicode |
|
||||
from couchpotato.core.logger import CPLog |
|
||||
from couchpotato.core.notifications.base import Notification |
|
||||
|
|
||||
|
|
||||
log = CPLog(__name__) |
|
||||
|
|
||||
autoload = 'Boxcar' |
|
||||
|
|
||||
|
|
||||
class Boxcar(Notification): |
|
||||
|
|
||||
url = 'https://boxcar.io/devices/providers/7MNNXY3UIzVBwvzkKwkC/notifications' |
|
||||
|
|
||||
def notify(self, message = '', data = None, listener = None): |
|
||||
if not data: data = {} |
|
||||
|
|
||||
try: |
|
||||
message = message.strip() |
|
||||
|
|
||||
data = { |
|
||||
'email': self.conf('email'), |
|
||||
'notification[from_screen_name]': self.default_title, |
|
||||
'notification[message]': toUnicode(message), |
|
||||
'notification[from_remote_service_id]': int(time.time()), |
|
||||
} |
|
||||
|
|
||||
self.urlopen(self.url, data = data) |
|
||||
except: |
|
||||
log.error('Check your email and added services on boxcar.io') |
|
||||
return False |
|
||||
|
|
||||
log.info('Boxcar notification successful.') |
|
||||
return True |
|
||||
|
|
||||
def isEnabled(self): |
|
||||
return super(Boxcar, self).isEnabled() and self.conf('email') |
|
||||
|
|
||||
|
|
||||
config = [{ |
|
||||
'name': 'boxcar', |
|
||||
'groups': [ |
|
||||
{ |
|
||||
'tab': 'notifications', |
|
||||
'list': 'notification_providers', |
|
||||
'name': 'boxcar', |
|
||||
'options': [ |
|
||||
{ |
|
||||
'name': 'enabled', |
|
||||
'default': 0, |
|
||||
'type': 'enabler', |
|
||||
}, |
|
||||
{ |
|
||||
'name': 'email', |
|
||||
'description': 'Your Boxcar registration emailaddress.' |
|
||||
}, |
|
||||
{ |
|
||||
'name': 'on_snatch', |
|
||||
'default': 0, |
|
||||
'type': 'bool', |
|
||||
'advanced': True, |
|
||||
'description': 'Also send message when movie is snatched.', |
|
||||
}, |
|
||||
], |
|
||||
} |
|
||||
], |
|
||||
}] |
|
Loading…
Reference in new issue