forked from bernard57/qBittorrent_search_engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcinecalidad.py
89 lines (76 loc) · 3.27 KB
/
cinecalidad.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
#VERSION: 1.0
#AUTHORS: mauricci
from helpers import retrieve_url
from helpers import download_file, retrieve_url
from novaprinter import prettyPrinter
import re
try:
#python3
from html.parser import HTMLParser
except ImportError:
#python2
from HTMLParser import HTMLParser
class cinecalidad(object):
url = 'https://www.cinecalidad.to'
name = 'CineCalidad'
supported_categories = {'all': 'all'}
class MyHTMLParser(HTMLParser):
def __init__(self):
HTMLParser.__init__(self)
self.url = 'https://www.cinecalidad.to'
self.insideDataDiv = False
self.insideTitleDiv = False
self.fullResData = []
self.singleResData = self.getSingleData()
def getSingleData(self):
return {'name':'-1','seeds':'-1','leech':'-1','size':'-1','link':'-1','desc_link':'-1','engine_url':self.url}
def handle_starttag(self, tag, attrs):
Dict = dict(attrs)
if tag == 'div' and Dict.get('id','') == 'content_inside':
self.insideDataDiv = True
if self.insideDataDiv and tag == 'div' and Dict.get('class','') == 'in_title':
self.insideTitleDiv = True
if self.insideDataDiv and tag == 'a' and len(attrs) > 0 and 'href' in Dict:
self.singleResData['desc_link'] = Dict['href']
self.singleResData['link'] = self.singleResData['desc_link']
def handle_endtag(self, tag):
self.insideTitleDiv = False
if len(self.singleResData) > 0:
#ignore trash stuff
if self.singleResData['name'] != '-1':
prettyPrinter(self.singleResData)
self.fullResData.append(self.singleResData)
self.singleResData = self.getSingleData()
def handle_data(self, data):
if self.insideTitleDiv:
self.singleResData['name'] = data.strip()
def feed(self,html):
HTMLParser.feed(self,html)
self.insideDataDiv = False
self.insideTitleDiv = False
def download_torrent(self, info):
html = retrieve_url(info)
#first we retrive the link for the second page, then the magnet link
torrPage2Link = re.search('(\/protect.+?)[\'\"]',html)
if torrPage2Link and len(torrPage2Link.groups()) > 0:
html2 = retrieve_url(self.url + torrPage2Link.group(1))
magnet = re.search('(magnet\:\?.+?)[\'\"]',html2)
if magnet and len(magnet.groups()) > 0:
print(magnet.group(1) + ' '+ info)
# DO NOT CHANGE the name and parameters of this function
# This function will be the one called by nova2.py
def search(self, what, cat='all'):
currCat = self.supported_categories[cat]
what = what.replace('%20','+')
parser = self.MyHTMLParser()
#analyze firt 10 pages
for currPage in range(1,11):
url = self.url+'/page/{1}/?s={0}'.format(what,currPage)
#print(url)
html = retrieve_url(url)
parser.feed(html)
#print(parser.fullResData)
parser.close()
if __name__ == "__main__":
c = cinecalidad()
c.search('tomb%20raider')