-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy patheztv.py
120 lines (94 loc) · 3.65 KB
/
eztv.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
108
109
110
111
112
113
114
115
116
117
118
119
120
#VERSION: 0.2
#AUTHORS: nindogo
import re
import logging
import copy
logging.basicConfig(level=logging.DEBUG)
logging.getLogger(__name__)
try:
# python3
from html.parser import HTMLParser
except ImportError:
# python2
from HTMLParser import HTMLParser
# qBt
from novaprinter import prettyPrinter
from helpers import retrieve_url, download_file
#others
import re
URL = "https://eztv.ag"
globalResponse=[]
class eztvHtmlParser(HTMLParser):
A, TD, TR, HREF, TABLE, SCRIPT= ('a', 'td', 'tr', 'href', 'table', 'script')
inTableRow = False
inTable = False
current_item = {}
url = URL
# responseCount
# response= []
# can not get these.
current_item['leech'] = -1
current_item['engine_url'] =URL
def handle_starttag(self, tag, attrs):
params = dict(attrs)
myTag = tag
if (params.get('class') == 'forum_header_border' and params.get('name') == 'hover'):
self.inTableRow = True
self.inTable = True
if myTag == self.A and self.inTableRow and params.get('class') == 'magnet':
self.current_item['link'] = params.get('href')
if myTag == self.A and self.inTableRow and params.get('class') == 'epinfo':
self.current_item['desc_link'] = self.url + params.get('href')
a = re.compile(r' \[').split(params.get('title'))[0]
self.current_item['name'] = a
# logging.debug("Params: %s" % params)
if myTag == self.TD and params.get('class') == 'forum_thread_post_end' and params.get('align') == 'center':
globalResponse.append(dict(self.current_item))
self.inTable = False
self.inTableRow = False
def handle_data(self, data):
if self.inTableRow and (data.endswith('MB') or data.endswith('GB') or data.endswith('KB')):
self.current_item['size'] = data
print(data)
# pass
if self.inTableRow and (data.isalnum() or (data == '-')):
if data.isalnum():
self.current_item['seeds'] = int(data)
elif data == '-':
self.current_item['seeds'] = 0
# if self.inTableRow and (data.endswith('[eztv]')):
# self.current_item['name'] = data
def handle_endtag(self, tag):
myTag = tag
if self.inTableRow and myTag == self.TR:
self.inTableRow = False
# prettyPrinter(self.current_item)
# print(len(self.current_item))'
if myTag == self.TABLE:
self.inTable = False
if self.inTable:
# response.append(self.current_item)
print(len(globalResponse))
elif not self.inTable:
# print('this is response',response)
# logging.debug('ending')
# return response
pass
class eztv(object):
logging.debug("Class Initiated")
name = "EZTV"
supported_categories = {'tv': 'tv', 'all': 'all'}
url = 'https://eztv.ag/'
def search(self,what,cat='all'):
logging.debug("Searching")
query = what.replace('%20','-')
query = ('https://eztv.ag/search/' + query)
eztvParser = eztvHtmlParser()
eztvHtml = retrieve_url(query)
eztvParser.feed(eztvHtml)
for k in globalResponse:
prettyPrinter(k)
eztvParser.close()
if __name__ == '__main__':
z = eztv()
z.search('Acre', 'all')