-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.py
60 lines (51 loc) · 2.38 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#########################################
####nCore CouchPotato TorrentProvider####
############# @by gala ##################
############### 2015 ####################
#########################################
from couchpotato.core.logger import CPLog
from couchpotato.core.helpers.encoding import tryUrlencode
from couchpotato.core.helpers.variable import tryInt
from couchpotato.core.media._base.providers.torrent.base import TorrentProvider
from couchpotato.core.media.movie.providers.base import MovieProvider
import traceback
import json
log = CPLog(__name__)
class nCore(TorrentProvider, MovieProvider):
urls = {
'login': 'https://ncore.cc/login.php',
'search': 'https://ncore.cc/torrents.php?kivalasztott_tipus=%s&mire=%s&miben=name&tipus=kivalasztottak_kozott&submit.x=0&submit.y=0&submit=Ok&tags=&searchedfrompotato=true&jsons=true'
}
http_time_between_calls = 1 # seconds
def _searchOnTitle(self, title, movie, quality, results):
hu_extra_score = 500 if self.conf('prefer_hu') else 0
en_extra_score = 500 if self.conf('prefer_en') else 0
self.doSearch(title, self.conf('hu_categories'), hu_extra_score, results)
self.doSearch(title, self.conf('en_categories'), en_extra_score, results)
def doSearch(self, title, categories, extra_score, results):
url = self.urls['search'] % (categories, tryUrlencode(title))
try:
data = self.getJsonData(url)
log.info('Number of torrents found on nCore = ' + str(data['total_results']))
for d in data['results']:
results.append({
'id': d['torrent_id'],
'leechers': d['leechers'],
'seeders': d['seeders'],
'name': d['release_name'],
'url': d['download_url'],
'detail_url': d['details_url'],
'size': tryInt(d['size']) / (1024 * 1024),
'score': extra_score,
})
except:
log.error('Failed getting results from %s: %s', (self.getName(), traceback.format_exc()))
def getLoginParams(self):
return {
'nev': str(self.conf('username')),
'pass': str(self.conf('password')),
'submitted': 1
}
def successLogin(self, output):
return 'exit.php' in output.lower()
loginCheckSuccess = successLogin