-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
107 lines (90 loc) · 4.78 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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.media._base.providers.torrent.base import TorrentProvider
from couchpotato.core.media.movie.providers.base import MovieProvider
import traceback
log = CPLog(__name__)
class Quorks(TorrentProvider, MovieProvider):
urls = {
'test' : 'https://quorks.to',
'login' : 'https://quorks.to/takelogin.php',
'login_check': 'https://quorks.to/index.php',
'detail' : 'https://quorks.to/details.php?id=%s',
'search' : 'https://quorks.to/browse.php?c%d=%d&search=%s&dead=active',
'download' : 'https://quorks.to/%s',
}
cat_ids = [
([28], ['720p', '1080p']),
([2], ['cam', 'ts', 'tc', 'r5', 'scr', 'dvdrip', 'brrip']),
([3], ['dvdr']),
]
http_time_between_calls = 1 #seconds
cat_backup_id = None
def _searchOnTitle(self, title, movie, quality, results):
log.debug('Searching Quorks for %s' % (title))
url = self.urls['search'] % (self.getCatId(quality)[0], self.getCatId(quality)[0], 'title:"' + title.replace(':', '') + '"')
data = self.getHTMLData(url)
log.debug('Received data from Quorks')
if data:
log.debug('Data is valid from Quorks')
html = BeautifulSoup(data)
try:
result_table = html.find('table', attrs = {'id' : 'browsetable'})
if not result_table:
log.debug('No table results from Quorks')
return
torrents = result_table.find_all('tr', attrs = {'class' : 'browse'})
for result in torrents:
entry = result.find_all('table')
entry = entry[0].find_all('tr')
entry = entry[0].find_all('a')
details = entry[0]
release_name = details['title']
words = title.lower().replace(':',' ').split()
if self.conf('ignore_year'):
index = release_name.lower().find(words[-1] if words[-1] != 'the' else words[-2]) + len(words[-1] if words[-1] != 'the' else words[-2]) +1
index2 = index + 7
if not str(movie['info']['year']) in release_name[index:index2]:
release_name = release_name[0:index] + '(' + str(movie['info']['year']) + ').' + release_name[index:]
if 'the' not in release_name.lower() and (words[-1] == 'the' or words[0] == 'the'):
release_name = 'the.' + release_name
link = entry[0]
try:
url = entry[2] # 1 is torrent file, 2 is MagnetLink.
except:
log.debug('Quorks release %s found without MagnetLink. Ignoring' % (release_name))
continue
seed = result.find_all('b')
seeders = [item for item in seed if 'seeders' in item.find('a')['href']]
num_seeders = 0
num_leechers = 0
if len(seeders) > 0:
num_seeders = tryInt(seeders[0].get_text())
leechers = [item for item in seed if 'snatchers' in item.find('a')['href']]
if len(leechers) > 0:
num_leechers = tryInt(leechers[0].get_text())
size = [ item.get_text() for item in result.find_all('td') if ('GB' in item.get_text()) or ('MB' in item.get_text()) or ('KB' in item.get_text())]
results.append({
'id': result['torrentid'],
'name': release_name,
'url': self.urls['download'] % url['href'],
'detail_url': self.urls['download'] % details['href'],
'size': self.parseSize(size[0].replace(',','.')),
'seeders': num_seeders,
'leechers': num_leechers,
})
except:
log.error('Failed to parse Quorks: %s' % (traceback.format_exc()))
def getLoginParams(self):
log.debug('Getting login params for Quorks')
return {
'username': self.conf('username'),
'password': self.conf('password'),
'login': 'Einloggen!',
}
def loginSuccess(self, output):
log.debug('Checking login success for Quorks: %s' % ('True' if ('logout.php' in output.lower() or 'Willkommen zurück' in output.lower()) else 'False'))
return 'logout.php' in output.lower() or 'Willkommen zurück' in output.lower()
loginCheckSuccess = loginSuccess