diff --git a/nova/engines/eztv.py b/nova/engines/eztv.py new file mode 100644 index 0000000..05a8c8f --- /dev/null +++ b/nova/engines/eztv.py @@ -0,0 +1,77 @@ +#VERSION: 1.00 +#AUTHORS: nindogo +#CONTRIBUTORS: Diego de las Heras (ngosang@hotmail.es) + +try: + # python3 + from html.parser import HTMLParser +except ImportError: + # python2 + from HTMLParser import HTMLParser + +# qBt +from novaprinter import prettyPrinter +from helpers import retrieve_url + +class eztv(object): + name = "EZTV" + url = 'https://eztv.ag' + supported_categories = {'all': 'all', 'tv': 'tv'} + + class MyHtmlParser(HTMLParser): + A, TD, TR, TABLE = ('a', 'td', 'tr', 'table') + + """ Sub-class for parsing results """ + def __init__(self, url): + HTMLParser.__init__(self) + self.url = url + + self.in_table_row = False + self.current_item = {} + + def handle_starttag(self, tag, attrs): + params = dict(attrs) + + if (params.get('class') == 'forum_header_border' and params.get('name') == 'hover'): + self.in_table_row = True + self.current_item = {} + self.current_item['leech'] = -1 + self.current_item['engine_url'] = self.url + + if tag == self.A and self.in_table_row and params.get('class') == 'magnet': + self.current_item['link'] = params.get('href') + + if tag == self.A and self.in_table_row and params.get('class') == 'epinfo': + self.current_item['desc_link'] = self.url + params.get('href') + self.current_item['name'] = params.get('title').split(' (')[0] + + if tag == self.TD and params.get('class') == 'forum_thread_post_end' and params.get('align') == 'center': + prettyPrinter(self.current_item) + self.in_table_row = False + + def handle_data(self, data): + data = data.replace(',', '') + if self.in_table_row and (data.endswith('MB') or data.endswith('GB') or data.endswith('KB')): + self.current_item['size'] = data + + if self.in_table_row and (data.isalnum() or data == '-'): + if data.isalnum(): + self.current_item['seeds'] = int(data) + else: + self.current_item['seeds'] = 0 + + def handle_endtag(self, tag): + if self.in_table_row and tag == self.TR: + self.in_table_row = False + + def search(self, what, cat='all'): + query = self.url + '/search/' + what.replace('%20','-') + eztv_html = retrieve_url(query) + + eztv_parser = self.MyHtmlParser(self.url) + eztv_parser.feed(eztv_html) + eztv_parser.close() + +if __name__ == '__main__': + eztv_se = eztv() + eztv_se.search('Acre', 'all') diff --git a/nova/engines/versions.txt b/nova/engines/versions.txt index 0e78f7a..13233ec 100644 --- a/nova/engines/versions.txt +++ b/nova/engines/versions.txt @@ -1,4 +1,5 @@ btdb: 1.03 +eztv: 1.00 legittorrents: 2.02 piratebay: 2.15 torlock: 2.0 diff --git a/nova3/engines/eztv.py b/nova3/engines/eztv.py new file mode 100644 index 0000000..05a8c8f --- /dev/null +++ b/nova3/engines/eztv.py @@ -0,0 +1,77 @@ +#VERSION: 1.00 +#AUTHORS: nindogo +#CONTRIBUTORS: Diego de las Heras (ngosang@hotmail.es) + +try: + # python3 + from html.parser import HTMLParser +except ImportError: + # python2 + from HTMLParser import HTMLParser + +# qBt +from novaprinter import prettyPrinter +from helpers import retrieve_url + +class eztv(object): + name = "EZTV" + url = 'https://eztv.ag' + supported_categories = {'all': 'all', 'tv': 'tv'} + + class MyHtmlParser(HTMLParser): + A, TD, TR, TABLE = ('a', 'td', 'tr', 'table') + + """ Sub-class for parsing results """ + def __init__(self, url): + HTMLParser.__init__(self) + self.url = url + + self.in_table_row = False + self.current_item = {} + + def handle_starttag(self, tag, attrs): + params = dict(attrs) + + if (params.get('class') == 'forum_header_border' and params.get('name') == 'hover'): + self.in_table_row = True + self.current_item = {} + self.current_item['leech'] = -1 + self.current_item['engine_url'] = self.url + + if tag == self.A and self.in_table_row and params.get('class') == 'magnet': + self.current_item['link'] = params.get('href') + + if tag == self.A and self.in_table_row and params.get('class') == 'epinfo': + self.current_item['desc_link'] = self.url + params.get('href') + self.current_item['name'] = params.get('title').split(' (')[0] + + if tag == self.TD and params.get('class') == 'forum_thread_post_end' and params.get('align') == 'center': + prettyPrinter(self.current_item) + self.in_table_row = False + + def handle_data(self, data): + data = data.replace(',', '') + if self.in_table_row and (data.endswith('MB') or data.endswith('GB') or data.endswith('KB')): + self.current_item['size'] = data + + if self.in_table_row and (data.isalnum() or data == '-'): + if data.isalnum(): + self.current_item['seeds'] = int(data) + else: + self.current_item['seeds'] = 0 + + def handle_endtag(self, tag): + if self.in_table_row and tag == self.TR: + self.in_table_row = False + + def search(self, what, cat='all'): + query = self.url + '/search/' + what.replace('%20','-') + eztv_html = retrieve_url(query) + + eztv_parser = self.MyHtmlParser(self.url) + eztv_parser.feed(eztv_html) + eztv_parser.close() + +if __name__ == '__main__': + eztv_se = eztv() + eztv_se.search('Acre', 'all') diff --git a/nova3/engines/versions.txt b/nova3/engines/versions.txt index 0e78f7a..13233ec 100644 --- a/nova3/engines/versions.txt +++ b/nova3/engines/versions.txt @@ -1,4 +1,5 @@ btdb: 1.03 +eztv: 1.00 legittorrents: 2.02 piratebay: 2.15 torlock: 2.0