From 6bae3869da70669a3e8fad2729e47316ba2d003a Mon Sep 17 00:00:00 2001 From: philhabell Date: Mon, 26 Oct 2020 00:28:11 +0000 Subject: [PATCH] Adding sfw filter to tph module and updating readme --- README.rst | 3 ++- we_get/modules/the_pirate_bay.py | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index 6cb11a0..1ba856b 100644 --- a/README.rst +++ b/README.rst @@ -73,7 +73,8 @@ Options -f --filter= Match text or regular expression in the torrent name. -n --results= Number of results to retrieve. -S --sort-type= Sort torrents by name/seeds [default: seeds]. --c --config= Load config file. +-c --config= Load config file + --sfw restrict results to safe for work content (the_pirate_bay only) ===================== ===================================================== Video options diff --git a/we_get/modules/the_pirate_bay.py b/we_get/modules/the_pirate_bay.py index cea7471..bebcc20 100644 --- a/we_get/modules/the_pirate_bay.py +++ b/we_get/modules/the_pirate_bay.py @@ -10,7 +10,7 @@ BASE_URL = "https://www1.thepiratebay3.to" SEARCH_LOC = "/s/?q=" LIST_LOC = "/top/all" - +SFW_FILTER = "&audio=on&video=on&apps=on&games=on&other=on&category=0" class the_pirate_bay(object): """ the_pirate_bay module for we-get. @@ -24,6 +24,7 @@ def __init__(self, pargs): self.module = Module() self.parse_pargs() self.items = dict() + self.filter = "" def parse_pargs(self): for opt in self.pargs: @@ -32,6 +33,8 @@ def parse_pargs(self): self.search_query = self.pargs[opt][0].replace(' ', '-') elif opt == "--list": self.action = "list" + if opt == "--sfw": + self.filter = SFW_FILTER def _parse_data(self, data): soup = BeautifulSoup(data, 'html.parser') @@ -55,7 +58,7 @@ def _parse_data(self, data): }) def search(self): - url = f"{BASE_URL}{SEARCH_LOC}{self.search_query}" + url = f"{BASE_URL}{SEARCH_LOC}{self.search_query}{self.filter}" data = self.module.http_get_request(url) self._parse_data(data) return self.items