HDBits cleanup
This commit is contained in:
1 parent
2612b50d06
commit
f9471f9b9b
3 files changed
+63
-71
No files matched your search
@@ -31,6 +31,14 @@ config = [{
|
|||||||
'name': 'passkey',
|
'name': 'passkey',
|
||||||
'default': '',
|
'default': '',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'name': 'extra_score',
|
||||||
|
'advanced': True,
|
||||||
|
'label': 'Extra Score',
|
||||||
|
'type': 'int',
|
||||||
|
'default': 0,
|
||||||
|
'description': 'Starting score for each release found via this provider.',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,71 +0,0 @@
|
|||||||
from couchpotato.core.helpers.encoding import tryUrlencode
|
|
||||||
from couchpotato.core.helpers.variable import tryInt
|
|
||||||
from couchpotato.core.logger import CPLog
|
|
||||||
from couchpotato.core.providers.torrent.base import TorrentProvider
|
|
||||||
import traceback
|
|
||||||
from bs4 import BeautifulSoup
|
|
||||||
import requests
|
|
||||||
|
|
||||||
log = CPLog(__name__)
|
|
||||||
|
|
||||||
class HDBits(TorrentProvider):
|
|
||||||
|
|
||||||
urls = {
|
|
||||||
'test' : 'http://www.hdbits.org/',
|
|
||||||
'login' : 'https://hdbits.org/login/dologin/',
|
|
||||||
'detail' : 'http://www.hdbits.org/details.php?id=%s&source=browse',
|
|
||||||
'search' : 'http://www.hdbits.org/json_search.php?imdb=%s',
|
|
||||||
'download' : 'http://hdbits.org/download.php/%s.torrent?id=%s&passkey=%s&source=details.browse',
|
|
||||||
}
|
|
||||||
|
|
||||||
http_time_between_calls = 1 #seconds
|
|
||||||
|
|
||||||
def login(self):
|
|
||||||
try:
|
|
||||||
self.login_opener = requests.Session()
|
|
||||||
payload = {'uname': self.conf('username'), 'password': self.conf('password'), 'lol': self._getLoginSecret()}
|
|
||||||
self.login_opener.post(self.urls['login'], data=payload)
|
|
||||||
|
|
||||||
return True
|
|
||||||
except:
|
|
||||||
log.error('Failed to login')
|
|
||||||
|
|
||||||
return False
|
|
||||||
|
|
||||||
def _search(self, movie, quality, results):
|
|
||||||
log.debug('Session response: %s' % (self.response.cookies))
|
|
||||||
if not self.login_opener and not self.login():
|
|
||||||
return
|
|
||||||
|
|
||||||
imdb_id = movie['library']['identifier']
|
|
||||||
search = self.login_opener.get(self.urls['search'] % (imdb_id))
|
|
||||||
|
|
||||||
j = search.json
|
|
||||||
try:
|
|
||||||
for result in j:
|
|
||||||
url = self.urls['download'] % (result['title'], result['id'], self.conf('passkey'))
|
|
||||||
detail = self.urls['detail'] % result['id']
|
|
||||||
|
|
||||||
results.append({
|
|
||||||
'id': result['id'],
|
|
||||||
'name': result['title'],
|
|
||||||
'url': url,
|
|
||||||
'detail_url': detail,
|
|
||||||
'size': self.parseSize(result['size']),
|
|
||||||
'seeders': tryInt(result['seeder']),
|
|
||||||
'leechers': tryInt(result['leecher'])
|
|
||||||
})
|
|
||||||
|
|
||||||
log.debug('Results: %s' % (results))
|
|
||||||
|
|
||||||
except:
|
|
||||||
log.error('Failed getting results from %s: %s', (self.getName(), traceback.format_exc()))
|
|
||||||
|
|
||||||
def _getLoginSecret(self):
|
|
||||||
r = requests.get('https://hdbits.org/json_search.php')
|
|
||||||
bs = BeautifulSoup(r.text)
|
|
||||||
secret = bs.find('input', attrs = {'name': 'lol'})['value']
|
|
||||||
|
|
||||||
log.debug('Secret key: %s' % (secret))
|
|
||||||
|
|
||||||
return secret
|
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
from bs4 import BeautifulSoup
|
||||||
|
from couchpotato.core.helpers.encoding import tryUrlencode
|
||||||
|
from couchpotato.core.helpers.variable import tryInt
|
||||||
|
from couchpotato.core.logger import CPLog
|
||||||
|
from couchpotato.core.providers.torrent.base import TorrentProvider
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
log = CPLog(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class HDBits(TorrentProvider):
|
||||||
|
|
||||||
|
urls = {
|
||||||
|
'test' : 'https://hdbits.org/',
|
||||||
|
'login' : 'https://hdbits.org/login/doLogin/',
|
||||||
|
'detail' : 'https://hdbits.org/details.php?id=%s&source=browse',
|
||||||
|
'search' : 'https://hdbits.org/json_search.php?imdb=%s',
|
||||||
|
'download' : 'https://hdbits.org/download.php/%s.torrent?id=%s&passkey=%s&source=details.browse',
|
||||||
|
}
|
||||||
|
|
||||||
|
http_time_between_calls = 1 #seconds
|
||||||
|
|
||||||
|
def _search(self, movie, quality, results):
|
||||||
|
|
||||||
|
data = self.getJsonData(self.urls['search'] % movie['library']['identifier'], opener = self.login_opener)
|
||||||
|
|
||||||
|
if data:
|
||||||
|
try:
|
||||||
|
for result in data:
|
||||||
|
results.append({
|
||||||
|
'id': result['id'],
|
||||||
|
'name': result['title'],
|
||||||
|
'url': self.urls['download'] % (result['title'], result['id'], self.conf('passkey')),
|
||||||
|
'detail_url': self.urls['detail'] % result['id'],
|
||||||
|
'size': self.parseSize(result['size']),
|
||||||
|
'seeders': tryInt(result['seeder']),
|
||||||
|
'leechers': tryInt(result['leecher'])
|
||||||
|
})
|
||||||
|
|
||||||
|
except:
|
||||||
|
log.error('Failed getting results from %s: %s', (self.getName(), traceback.format_exc()))
|
||||||
|
|
||||||
|
def getLoginParams(self):
|
||||||
|
data = self.getHTMLData('https://hdbits.org/login')
|
||||||
|
bs = BeautifulSoup(data)
|
||||||
|
secret = bs.find('input', attrs = {'name': 'lol'})['value']
|
||||||
|
|
||||||
|
return tryUrlencode({
|
||||||
|
'uname': self.conf('username'),
|
||||||
|
'password': self.conf('password'),
|
||||||
|
'lol': secret
|
||||||
|
})
|
||||||
|
|
||||||
|
def loginSuccess(self, output):
|
||||||
|
return '/logout.php' in output.lower()
|
||||||
Reference in new issue
Block a user