From c9f0c56f85efc8d0f759dbb1210f33e30ce17df3 Mon Sep 17 00:00:00 2001 From: Felix Almeida Date: Thu, 16 Apr 2015 20:34:07 -0400 Subject: [PATCH] Added EZTV. --- resources/language/Catalan/strings.po | 4 +++ resources/language/English/strings.po | 6 +++- resources/language/German/strings.po | 6 +++- resources/language/Hungarian/strings.po | 4 +++ resources/language/Korean/strings.po | 4 +++ resources/language/Russian/strings.po | 4 +++ resources/language/Spanish/strings.po | 4 +++ resources/lib/gui.py | 1 + resources/lib/search.py | 42 ++++++++++++++++++++++--- 9 files changed, 68 insertions(+), 7 deletions(-) diff --git a/resources/language/Catalan/strings.po b/resources/language/Catalan/strings.po index bda77f5..2722e27 100644 --- a/resources/language/Catalan/strings.po +++ b/resources/language/Catalan/strings.po @@ -109,6 +109,10 @@ msgctxt "#32207" msgid "Search LimeTorrents" msgstr "" +msgctxt "#32208" +msgid "Search EZTV" +msgstr "" + msgctxt "#32290" msgid "Searching..." msgstr "" diff --git a/resources/language/English/strings.po b/resources/language/English/strings.po index 98dc818..19a9601 100644 --- a/resources/language/English/strings.po +++ b/resources/language/English/strings.po @@ -123,7 +123,11 @@ msgctxt "#32207" msgid "Search LimeTorrents" msgstr "" -#empty strings from id 32208 to 32289 +msgctxt "#32208" +msgid "Search EZTV" +msgstr "" + +#empty strings from id 32209 to 32289 msgctxt "#32290" msgid "Searching..." diff --git a/resources/language/German/strings.po b/resources/language/German/strings.po index e6c310f..2ee237a 100644 --- a/resources/language/German/strings.po +++ b/resources/language/German/strings.po @@ -122,7 +122,11 @@ msgctxt "#32207" msgid "Search LimeTorrents" msgstr "LimeTorrents durchsuchen" -# empty strings from id 208 to 289 +msgctxt "#32208" +msgid "Search EZTV" +msgstr "EZTV durchsuchen" + +# empty strings from id 209 to 289 msgctxt "#32290" msgid "Searching..." msgstr "Suche läuft..." diff --git a/resources/language/Hungarian/strings.po b/resources/language/Hungarian/strings.po index 3bcf380..2742668 100644 --- a/resources/language/Hungarian/strings.po +++ b/resources/language/Hungarian/strings.po @@ -109,6 +109,10 @@ msgctxt "#32207" msgid "Search LimeTorrents" msgstr "" +msgctxt "#32208" +msgid "Search EZTV" +msgstr "" + msgctxt "#32290" msgid "Searching..." msgstr "" diff --git a/resources/language/Korean/strings.po b/resources/language/Korean/strings.po index 1447eef..30b0538 100644 --- a/resources/language/Korean/strings.po +++ b/resources/language/Korean/strings.po @@ -109,6 +109,10 @@ msgctxt "#32207" msgid "Search LimeTorrents" msgstr "" +msgctxt "#32208" +msgid "Search EZTV" +msgstr "" + msgctxt "#32290" msgid "Searching..." msgstr "" diff --git a/resources/language/Russian/strings.po b/resources/language/Russian/strings.po index 60c8ca3..c5dd303 100644 --- a/resources/language/Russian/strings.po +++ b/resources/language/Russian/strings.po @@ -109,6 +109,10 @@ msgctxt "#32207" msgid "Search LimeTorrents" msgstr "Искать на LimeTorrents" +msgctxt "#32208" +msgid "Search EZTV" +msgstr "Искать на EZTV" + msgctxt "#32290" msgid "Searching..." msgstr "Поиск..." diff --git a/resources/language/Spanish/strings.po b/resources/language/Spanish/strings.po index 6a24062..141ed9b 100644 --- a/resources/language/Spanish/strings.po +++ b/resources/language/Spanish/strings.po @@ -109,6 +109,10 @@ msgctxt "#32207" msgid "Search LimeTorrents" msgstr "Buscar en LimeTorrents" +msgctxt "#32208" +msgid "Search EZTV" +msgstr "Buscar en EZTV" + msgctxt "#32290" msgid "Searching..." msgstr "Buscando..." diff --git a/resources/lib/gui.py b/resources/lib/gui.py index 284e495..3e65d42 100644 --- a/resources/lib/gui.py +++ b/resources/lib/gui.py @@ -117,6 +117,7 @@ class TransmissionGUI(xbmcgui.WindowXMLDialog): (_(32205), search.L337x), (_(32206), search.YTS), (_(32207), search.Lime), + (_(32208), search.EZTV), ] selected = xbmcgui.Dialog().select(_(32000), [i[0] for i in engines]) if selected < 0: diff --git a/resources/lib/search.py b/resources/lib/search.py index 957ab33..a090336 100644 --- a/resources/lib/search.py +++ b/resources/lib/search.py @@ -2,7 +2,7 @@ import sys import re import socket from urllib2 import urlopen, Request, URLError, HTTPError -from urllib import quote, quote_plus +from urllib import quote, quote_plus, urlencode from BeautifulSoup import BeautifulSoup, BeautifulStoneSoup socket.setdefaulttimeout(15) @@ -152,9 +152,41 @@ class Lime(Search): 'leechers': int(leechers) }) return torrents +class EZTV(Search): + def __init__(self): + self.user_agent = 'Mozilla/5.0' + self.uri_prefix = 'https://eztv.ch' + self.search_uri = self.uri_prefix + '/search/' + def search(self, terms): + torrents = [] + data = {'SearchString': '', 'SearchString1': terms, 'search': 'Search'} + req = Request(self.search_uri, urlencode(data)) + req.add_header('User-Agent', self.user_agent) + f = urlopen(req) + soup = BeautifulStoneSoup(f.read()) + for (c, item) in enumerate(soup.findAll('a', {'class': 'magnet'})): + if c == 30: break + info = item.findPrevious('a') + link = self.uri_prefix + info['href'] + item_req = Request(link) + item_req.add_header('User-Agent', self.user_agent) + item_f = urlopen(item_req) + item_soup = BeautifulStoneSoup(item_f.read()) + sp = item_soup.findAll('span', {'class': re.compile('^stat_')}) + if sp: + sp = [int(i.text.replace(',', '')) for i in sp] + else: + sp = [0, 0] + torrents.append({ + 'url': item['href'], + 'name': info.text, + 'seeds': sp[0], + 'leechers': sp[1] + }) + return torrents if __name__ == '__main__': - sites = [Mininova(), TPB(), Kickass(), L337x(), YTS(), Lime()] + sites = [Mininova(), TPB(), Kickass(), L337x(), YTS(), Lime(), EZTV()] terms = 'transmission' if len(sys.argv) > 1: terms = sys.argv[1] @@ -165,6 +197,6 @@ if __name__ == '__main__': print 'Total found = ' + str(len(torrents)) for counter, file in enumerate(torrents): print '[{:3},{:3}] {:33} "{:33}"'.format(file['seeds'], file['leechers'], - file['name'][:33], file['url'][:33]) - if counter == 4: - break + file['name'].encode('ascii', 'replace')[:33], + file['url'][:33]) + if counter == 9: break