From 48eda3571321cdfcfcd8b684ad9e46199ea591cd Mon Sep 17 00:00:00 2001 From: Ni Ndogo Date: Mon, 22 Jan 2024 23:55:12 +0300 Subject: [PATCH 1/4] Update eztv.py There are some changes on the EZTV websites that make the script fail. This resolves it. --- nova3/engines/eztv.py | 75 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 3 deletions(-) diff --git a/nova3/engines/eztv.py b/nova3/engines/eztv.py index ea45d5d..b8e94fa 100644 --- a/nova3/engines/eztv.py +++ b/nova3/engines/eztv.py @@ -1,12 +1,62 @@ -#VERSION: 1.14 +#VERSION: 1.15 # AUTHORS: nindogo # CONTRIBUTORS: Diego de las Heras (ngosang@hotmail.es) from html.parser import HTMLParser +import random +import http.cookiejar +import urllib.request +import urllib.parse + from novaprinter import prettyPrinter -from helpers import retrieve_url +policy = http.cookiejar.DefaultCookiePolicy() +global_cookie_jar = http.cookiejar.CookieJar(policy) + +def random_user_agent(): + _USER_AGENT_TPL = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Safari/537.36' + _CHROME_VERSIONS = ( + '90.0.4430.212', + '90.0.4430.24', + '90.0.4430.70', + '90.0.4430.72', + '90.0.4430.85', + '90.0.4430.93', + '91.0.4472.101', + '91.0.4472.106', + '91.0.4472.114', + '91.0.4472.124', + '91.0.4472.164', + '91.0.4472.19', + '91.0.4472.77', + '92.0.4515.107', + '92.0.4515.115', + '92.0.4515.131', + '92.0.4515.159', + '92.0.4515.43', + '93.0.4556.0', + '93.0.4577.15', + '93.0.4577.63', + '93.0.4577.82', + '94.0.4606.41', + '94.0.4606.54', + '94.0.4606.61', + '94.0.4606.71', + '94.0.4606.81', + '94.0.4606.85', + '95.0.4638.17', + '95.0.4638.50', + '95.0.4638.54', + '95.0.4638.69', + '95.0.4638.74', + '96.0.4664.18', + '96.0.4664.45', + '96.0.4664.55', + '96.0.4664.93', + '97.0.4692.20', + ) + return _USER_AGENT_TPL % random.choice(_CHROME_VERSIONS) class eztv(object): name = "EZTV" @@ -59,9 +109,28 @@ def handle_endtag(self, tag): prettyPrinter(self.current_item) self.in_table_row = False + def retrieve_url(self, url, data=None): + opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(global_cookie_jar)) + opener.addheaders = [('User-Agent', random_user_agent())] + if not data: + req = urllib.request.Request(url) + else: + req = urllib.request.Request(url, data=data) + + with opener.open(req) as response: + parsed = urllib.parse.urlparse(response.url) + self.url = parsed.scheme + "://" + parsed.hostname + return response.read().decode('utf-8') + def search(self, what, cat='all'): + + _ = self.retrieve_url(self.url) + + data = {'layout':'def_wlinks'} + data = urllib.parse.urlencode(data).encode('utf-8') + query = self.url + '/search/' + what.replace('%20', '-') - eztv_html = retrieve_url(query) + eztv_html = self.retrieve_url(query, data) eztv_parser = self.MyHtmlParser(self.url) eztv_parser.feed(eztv_html) From 0b5a928acca7a5a5017c6afc6e9d726e8082716b Mon Sep 17 00:00:00 2001 From: Ni Ndogo Date: Mon, 22 Jan 2024 23:56:19 +0300 Subject: [PATCH 2/4] Update versions.txt Forgot to change this file --- nova3/engines/versions.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova3/engines/versions.txt b/nova3/engines/versions.txt index bfeb834..dc64415 100644 --- a/nova3/engines/versions.txt +++ b/nova3/engines/versions.txt @@ -1,4 +1,4 @@ -eztv: 1.14 +eztv: 1.15 jackett: 4.0 limetorrents: 4.7 piratebay: 3.2 From 5c0463a2afa63bdba27156dad17c9a1bc19091f2 Mon Sep 17 00:00:00 2001 From: Ni Ndogo Date: Tue, 23 Jan 2024 00:05:24 +0300 Subject: [PATCH 3/4] Update eztv.py Changed the random choice to the secrets library --- nova3/engines/eztv.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nova3/engines/eztv.py b/nova3/engines/eztv.py index b8e94fa..433dc65 100644 --- a/nova3/engines/eztv.py +++ b/nova3/engines/eztv.py @@ -4,7 +4,7 @@ from html.parser import HTMLParser -import random +import secrets import http.cookiejar import urllib.request import urllib.parse @@ -56,7 +56,7 @@ def random_user_agent(): '96.0.4664.93', '97.0.4692.20', ) - return _USER_AGENT_TPL % random.choice(_CHROME_VERSIONS) + return _USER_AGENT_TPL % secrets.choice(_CHROME_VERSIONS) class eztv(object): name = "EZTV" From 34a83bd6442f426effc657be90e0ca766d44398f Mon Sep 17 00:00:00 2001 From: Ni Ndogo Date: Tue, 23 Jan 2024 00:17:29 +0300 Subject: [PATCH 4/4] Update eztv.py Responding to our linting overlords --- nova3/engines/eztv.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/nova3/engines/eztv.py b/nova3/engines/eztv.py index 433dc65..ab8c1d4 100644 --- a/nova3/engines/eztv.py +++ b/nova3/engines/eztv.py @@ -14,8 +14,12 @@ policy = http.cookiejar.DefaultCookiePolicy() global_cookie_jar = http.cookiejar.CookieJar(policy) + def random_user_agent(): - _USER_AGENT_TPL = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Safari/537.36' + + _USER_AGENT_TPL = '''Mozilla/5.0 (Windows NT 10.0; Win64; x64)\ + AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s \ + Safari/537.36''' _CHROME_VERSIONS = ( '90.0.4430.212', '90.0.4430.24', @@ -58,6 +62,7 @@ def random_user_agent(): ) return _USER_AGENT_TPL % secrets.choice(_CHROME_VERSIONS) + class eztv(object): name = "EZTV" url = 'https://eztv.re' @@ -126,9 +131,9 @@ def search(self, what, cat='all'): _ = self.retrieve_url(self.url) - data = {'layout':'def_wlinks'} + data = {'layout': 'def_wlinks'} data = urllib.parse.urlencode(data).encode('utf-8') - + query = self.url + '/search/' + what.replace('%20', '-') eztv_html = self.retrieve_url(query, data)