From 780c42f9b8073ea6dfd09c949b781073e3de3a44 Mon Sep 17 00:00:00 2001 From: JoeamAmier Date: Sat, 26 Aug 2023 10:56:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/Download.py | 5 +++++ source/Image.py | 2 +- source/Video.py | 2 +- source/__init__.py | 8 ++++---- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/source/Download.py b/source/Download.py index 5f2b0f3..5a4f1bf 100644 --- a/source/Download.py +++ b/source/Download.py @@ -1,8 +1,13 @@ +from pathlib import Path + + class Download: def __init__( self, + path, headers: dict, proxies=None, ): + self.root = Path(path) self.headers = headers self.proxies = { "http": proxies, diff --git a/source/Image.py b/source/Image.py index dccd727..fd682d4 100644 --- a/source/Image.py +++ b/source/Image.py @@ -5,7 +5,7 @@ class Image: IMAGE_API = "https://sns-img-qc.xhscdn.com/" IMAGE_ID = compile(r'"traceId":"(.*?)"') - def __init__(self, html: str): + def __init__(self, html): self.html = html def get_image_link(self, url: str, download: bool): diff --git a/source/Video.py b/source/Video.py index 734d6d2..61574b3 100644 --- a/source/Video.py +++ b/source/Video.py @@ -4,7 +4,7 @@ from re import compile class Video: VIDEO_ID = compile(r'"masterUrl":"(.*?)"') - def __init__(self, html: str): + def __init__(self, html): self.html = html def get_video_link(self, url: str, download: bool): diff --git a/source/__init__.py b/source/__init__.py index 665eb64..f8d7913 100644 --- a/source/__init__.py +++ b/source/__init__.py @@ -1,6 +1,6 @@ +from .Download import Download from .Html import Html from .Image import Image -from .Params import Params from .Video import Video HEADERS = { @@ -11,10 +11,10 @@ HEADERS = { class XHS: def __init__(self, path="./", headers=None, proxies=None, timeout=10): - self.params = Params(path) self.html = Html(headers or HEADERS, proxies, timeout) - self.image = Image(self.html, self.params) - self.video = Video(self.html, self.params) + self.image = Image(self.html) + self.video = Video(self.html) + self.download = Download(path, self.html.headers, proxies) self._cookie = "" def get_image(self, url: str, download=False):