Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add eztv search plugin #41

Merged
merged 1 commit into from
Sep 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
77 changes: 77 additions & 0 deletions nova/engines/eztv.py
Original file line number Diff line number Diff line change
@@ -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')
1 change: 1 addition & 0 deletions nova/engines/versions.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
btdb: 1.03
eztv: 1.00
legittorrents: 2.02
piratebay: 2.15
torlock: 2.0
Expand Down
77 changes: 77 additions & 0 deletions nova3/engines/eztv.py
Original file line number Diff line number Diff line change
@@ -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')
1 change: 1 addition & 0 deletions nova3/engines/versions.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
btdb: 1.03
eztv: 1.00
legittorrents: 2.02
piratebay: 2.15
torlock: 2.0
Expand Down