Merge branch 'refs/heads/georgewhewell-hdbits-api' into develop
This commit is contained in:
commit
4d02a969c2
2 files changed
+34
-35
No files matched your search
@@ -22,11 +22,6 @@ config = [{
|
|||||||
'name': 'username',
|
'name': 'username',
|
||||||
'default': '',
|
'default': '',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
'name': 'password',
|
|
||||||
'default': '',
|
|
||||||
'type': 'password',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
'name': 'passkey',
|
'name': 'passkey',
|
||||||
'default': '',
|
'default': '',
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
from bs4 import BeautifulSoup
|
|
||||||
from couchpotato.core.helpers.variable import tryInt
|
from couchpotato.core.helpers.variable import tryInt
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.providers.torrent.base import TorrentProvider
|
from couchpotato.core.providers.torrent.base import TorrentProvider
|
||||||
|
|
||||||
|
import re
|
||||||
|
import json
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
log = CPLog(__name__)
|
log = CPLog(__name__)
|
||||||
@@ -11,49 +13,51 @@ class HDBits(TorrentProvider):
|
|||||||
|
|
||||||
urls = {
|
urls = {
|
||||||
'test': 'https://hdbits.org/',
|
'test': 'https://hdbits.org/',
|
||||||
'login': 'https://hdbits.org/login/doLogin/',
|
'detail': 'https://hdbits.org/details.php?id=%s',
|
||||||
'detail': 'https://hdbits.org/details.php?id=%s&source=browse',
|
'download': 'https://hdbits.org/download.php?id=%s&passkey=%s',
|
||||||
'search': 'https://hdbits.org/json_search.php?imdb=%s',
|
'api': 'https://hdbits.org/api/torrents'
|
||||||
'download': 'https://hdbits.org/download.php/%s.torrent?id=%s&passkey=%s&source=details.browse',
|
|
||||||
'login_check': 'http://hdbits.org/inbox.php',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
http_time_between_calls = 1 #seconds
|
http_time_between_calls = 1 #seconds
|
||||||
|
|
||||||
|
def _post_query(self, **params):
|
||||||
|
|
||||||
|
post_data = {
|
||||||
|
'username': self.conf('username'),
|
||||||
|
'passkey': self.conf('passkey')
|
||||||
|
}
|
||||||
|
post_data.update(params)
|
||||||
|
|
||||||
|
try:
|
||||||
|
result = self.getJsonData(self.urls['api'], data = json.dumps(post_data))
|
||||||
|
|
||||||
|
if result:
|
||||||
|
if result['status'] != 0:
|
||||||
|
log.error('Error searching hdbits: %s' % result['message'])
|
||||||
|
else:
|
||||||
|
return result['data']
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
def _search(self, movie, quality, results):
|
def _search(self, movie, quality, results):
|
||||||
|
|
||||||
data = self.getJsonData(self.urls['search'] % movie['library']['identifier'])
|
match = re.match(r'tt(\d{7})', movie['library']['identifier'])
|
||||||
|
|
||||||
|
data = self._post_query(imdb = {'id': match.group(1)})
|
||||||
|
|
||||||
if data:
|
if data:
|
||||||
try:
|
try:
|
||||||
for result in data:
|
for result in data:
|
||||||
results.append({
|
results.append({
|
||||||
'id': result['id'],
|
'id': result['id'],
|
||||||
'name': result['title'],
|
'name': result['name'],
|
||||||
'url': self.urls['download'] % (result['id'], result['id'], self.conf('passkey')),
|
'url': self.urls['download'] % (result['id'], self.conf('passkey')),
|
||||||
'detail_url': self.urls['detail'] % result['id'],
|
'detail_url': self.urls['detail'] % result['id'],
|
||||||
'size': self.parseSize(result['size']),
|
'size': self.parseSize(result['size']),
|
||||||
'seeders': tryInt(result['seeder']),
|
'seeders': tryInt(result['seeders']),
|
||||||
'leechers': tryInt(result['leecher'])
|
'leechers': tryInt(result['leechers'])
|
||||||
})
|
})
|
||||||
|
|
||||||
except:
|
except:
|
||||||
log.error('Failed getting results from %s: %s', (self.getName(), traceback.format_exc()))
|
log.error('Failed getting results from %s: %s', (self.getName(), traceback.format_exc()))
|
||||||
|
|
||||||
def getLoginParams(self):
|
|
||||||
data = self.getHTMLData('https://hdbits.org/login', cache_timeout = 0)
|
|
||||||
|
|
||||||
bs = BeautifulSoup(data)
|
|
||||||
secret = bs.find('input', attrs = {'name': 'lol'})['value']
|
|
||||||
|
|
||||||
return {
|
|
||||||
'uname': self.conf('username'),
|
|
||||||
'password': self.conf('password'),
|
|
||||||
'returnto': '/',
|
|
||||||
'lol': secret
|
|
||||||
}
|
|
||||||
|
|
||||||
def loginSuccess(self, output):
|
|
||||||
return '/logout.php' in output.lower()
|
|
||||||
|
|
||||||
loginCheckSuccess = loginSuccess
|
|
||||||
Reference in new issue
Block a user