Skip to content

Commit

Permalink
Fixed EZTV plugin (#291)
Browse files Browse the repository at this point in the history
* Fixed EZTV plugin

It requires a post parameter in order to get magnet links

* Added retrieve_url function to eztv plugin so that it works for everybody

* Try helpers.py's retrieve_url first, then fallback to urllib if it doesn't support POST

* Attempt to satisfy linter

* Reverted failed attempt at satisfying the linter

* Appease linter, second attempt
  • Loading branch information
ducalex authored Aug 17, 2024
1 parent 1652207 commit cfe98da
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
27 changes: 23 additions & 4 deletions nova3/engines/eztv.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#VERSION: 1.14
#VERSION: 1.15
# AUTHORS: nindogo
# CONTRIBUTORS: Diego de las Heras ([email protected])

import urllib.error
import urllib.parse
import urllib.request
from html.parser import HTMLParser

from novaprinter import prettyPrinter
Expand All @@ -10,7 +13,7 @@

class eztv(object):
name = "EZTV"
url = 'https://eztv.re'
url = 'https://eztvx.to/'
supported_categories = {'all': 'all', 'tv': 'tv'}

class MyHtmlParser(HTMLParser):
Expand Down Expand Up @@ -59,9 +62,25 @@ def handle_endtag(self, tag):
prettyPrinter(self.current_item)
self.in_table_row = False

def do_query(self, what):
url = f"{self.url}/search/{what.replace('%20', '-')}"
data = b"layout=def_wlinks"
try:
return retrieve_url(url, request_data=data)
except TypeError:
# Older versions of retrieve_url did not support request_data/POST, se we must do the
# request ourselves...
user_agent = 'Mozilla/5.0 (X11; Linux x86_64; rv:125.0) Gecko/20100101 Firefox/125.0'
req = urllib.request.Request(url, data, {'User-Agent': user_agent})
try:
response = urllib.request.urlopen(req) # nosec B310
return response.read().decode('utf-8')
except urllib.error.URLError as errno:
print(f"Connection error: {errno.reason}")
return ""

def search(self, what, cat='all'):
query = self.url + '/search/' + what.replace('%20', '-')
eztv_html = retrieve_url(query)
eztv_html = self.do_query(what)

eztv_parser = self.MyHtmlParser(self.url)
eztv_parser.feed(eztv_html)
Expand Down
2 changes: 1 addition & 1 deletion nova3/engines/versions.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
eztv: 1.14
eztv: 1.15
jackett: 4.0
limetorrents: 4.7
piratebay: 3.3
Expand Down

0 comments on commit cfe98da

Please sign in to comment.