diff --git a/libs/meido.py b/libs/meido.py index 582e2a6..6908745 100644 --- a/libs/meido.py +++ b/libs/meido.py @@ -5,12 +5,19 @@ class driver(): self.endpoint = endpoin self.image_endpoint = image self.static_endpoint = static + self.sess = requests.Session() def get_boards(self): return self.wrap_route("/boards.json") def get_threads(self, board): return self.wrap_route(f"/{board}/threads.json") def get_catalog(self, board): return self.wrap_route(f"/{board}/catalog.json") + def get_archive(self, board): + return self.wrap_route(f"/{board}/archive.json") + def get_page(self, board, page): + return self.wrap_route(f"/{board}/{page}.json") + def get_thread(self, board, thread_id): + return self.wrap_route(f"/{board}/thread/{thread_id}.json") def wrap_route(self, route): - return json.loads(requests.get(self.endpoint+route).text) + return json.loads(self.sess.get(self.endpoint+route).text) instance = driver("https://a.4cdn.org", "https://i.4cdn.org", "https://s.4cdn.org") \ No newline at end of file diff --git a/libs/sand.py b/libs/sand.py new file mode 100644 index 0000000..d7971aa --- /dev/null +++ b/libs/sand.py @@ -0,0 +1 @@ +box = {} \ No newline at end of file diff --git a/plugins/dpt.py b/plugins/dpt.py index ccf5aa0..ac1f02e 100644 --- a/plugins/dpt.py +++ b/plugins/dpt.py @@ -1,3 +1,9 @@ depends = ["bprint", "meido"] def run(l): - l["bprint"].p(f"found {len(l['meido'].instance.get_boards())} boards") \ No newline at end of file + pages = l['meido'].instance.get_catalog("g") + for page in pages: + for thread in page["threads"]: + if not thread.get("sub"): continue + if "/dpt/" in thread["sub"]: + l["sand"].box["dpt"] = thread["no"] + l["bprint"].p(f"found /dpt/! thread no: {thread['no']}") diff --git a/plugins/sandbox_web.py b/plugins/sandbox_web.py new file mode 100644 index 0000000..a49df85 --- /dev/null +++ b/plugins/sandbox_web.py @@ -0,0 +1,19 @@ +depends = ["bprint", "sand"] + +from http.server import BaseHTTPRequestHandler, HTTPServer + +def run(l): + class MyServer(BaseHTTPRequestHandler): + def do_GET(self): + self.send_response(200) + self.send_header("Content-type", "text/html") + self.end_headers() + self.wfile.write(bytes("komand'r", "utf-8")) + self.wfile.write(bytes("", "utf-8")) + server = HTTPServer(("localhost", 8080), MyServer) + l["bprint"].p("started sandbox server at port 8080") + server.serve_forever()#TODO: SUPPRESS THE LOGGING FROM THE WEBSERVER (AND ONLY THE WEBSERVER) + server.server_close() \ No newline at end of file