新增英语语言支持

This commit is contained in:
Chreer 2024-01-15 15:12:31 +00:00 committed by yongquan
parent 5c913b6482
commit dab9f0e704
5 changed files with 364 additions and 10 deletions

View File

@ -193,7 +193,7 @@ async with XHS(work_path=work_path,
<tr>
<td align="center">language</td>
<td align="center">str</td>
<td align="center">设置程序语言,目前支持:<code>zh-CN</code></td>
<td align="center">设置程序语言,目前支持:<code>zh-CN</code><code>en-GB</code></td>
<td align="center">zh-CN</td>
</tr>
</tbody>

View File

@ -12,3 +12,240 @@
<img alt="GitHub all releases" src="https://img.shields.io/github/downloads/JoeanAmier/XHS-Downloader/total?style=for-the-badge&color=f759ab">
</div>
<br>
<div align="center">
<p>🔥 <b>Xiaohongshu Artwork Collection Tool</b>: Collect information on Xiaohongshu artworks; Extract the download address of Xiaohongshu artworks; Download the Xiaohongshu watermark-free artwork files!</p>
<p>❤️ The author only releases XHS-Downloader on GitHub, without collaborating with any individuals or websites. Additionally, there are no charging plans for the tool!</p>
</div>
<h1>📑 The Project Features:</h1>
<ul>
<li>✅ Collect Xiaohongshu graphic/text or video artworks' information</li>
<li>✅ Extract Xiaohongshu graphic/text or video artworks' download addresses</li>
<li>✅ Download Xiaohongshu graphic/text or video artworks without watermarks</li>
<li>✅ Supports Tampermonkey user scripts</li>
<li>✅ Batch download account artworks (with user scripts)</li>
<li>✅ Automatically skip already downloaded artworks</li>
<li>✅ Mechanism for handling the integrity of artwork files</li>
<li>✅ Customize the download format for graphic and text artworks</li>
<li>✅ Persistently store artwork information to a file</li>
<li>✅ Store artwork files in a separate folder</li>
<li>☑️ Background monitoring of clipboard for downloading artworks</li>
<li>☑️ Supports API calling functionality</li>
</ul>
<h1>📸 Program Screenshot</h1>
<br>
<p><b>🎥 Click on the image to watch the demo video</b></p>
<a href="https://www.bilibili.com/video/BV1nQ4y137it/"><img src="static/程序运行截图1.png" alt=""></a>
<hr>
<a href="https://www.bilibili.com/video/BV1nQ4y137it/"><img src="static/程序运行截图2.png" alt=""></a>
<h1>🔗 Support Hyperlinks</h1>
<ul>
<li><code>https://www.xiaohongshu.com/explore/artwork's ID</code></li>
<li><code>https://www.xiaohongshu.com/discovery/item/artwork's ID</code></li>
<li><code>https://xhslink.com/share code</code></li>
<br/>
<p><b>The program supports entering multiple artwork links in a single input box, separated by spaces.</b></p>
</ul>
<h1>🪟 About the Terminal</h1>
<p><a href="https://learn.microsoft.com/zh-cn/windows/terminal/install">Windows Terminal</a> (Default terminal in Windows 11) is recommended to run the program for optimal display performance!</p>
<h1>🥣 How to Use</h1>
<p>If you only need to download watermark-free artwork files, <b>Program Running</b> is recommended; If you have other needs, <b>Source Code Running</b> is recommended!</p>
<h2>🖱 Program Running</h2>
<p>Users with Windows 10 or above can go to <a href="https://github.com/JoeanAmier/XHS-Downloader/releases/latest">Releases</a> download the program zip file, unzip it, open the program folder, and double-click <code>main.exe</code> to run the program</p>
<p>If you use the program this way, the default download path for files is: <code>.\_internal\Download</code>; configuration file path: <code>.\_internal\settings.json</code></p>
<h2>⌨️ Source Code Running</h2>
<ol>
<li>Install Python Interpreter with version >= <code>3.12</code></li>
<li>Execute <code>pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt</code> to install the required modules for the program</li>
<li>Download the latest source code or code released in <a href="https://github.com/JoeanAmier/XHS-Downloader/releases/latest">Releases</a> to your local workplace</li>
<li>Run <code>main.py</code> to use the program</li>
</ol>
<h1>🕹 User Script</h1>
<p>If your browser has installed <a href="https://www.tampermonkey.net/">Tampermonkey</a> extension, add <a href="https://raw.githubusercontent.com/JoeanAmier/XHS-Downloader/master/static/XHS-Downloader.js">User script</a>, and you can experience the project's functionalities without downloading the program!</p>
<p>Tip: You can use the XHS-Downloader user script to extract artwork links in batches from web pages. Combine it with the XHS-Downloader program to achieve batch downloading of watermark-free artwork files!</p>
<h2>Script Functionality</h2>
<ul>
<li>Download Xiaohongshu watermark-free artwork files</li>
<li>Extract artwork links from the discovery page</li>
<li>Extract artwork links from account-published content</li>
<li>Extract artwork links from account-collected content</li>
<li>Extract artwork links from account-liked content</li>
</ul>
<h2>Script Screenshot</h2>
<img src="static/用户脚本截图.png" alt="">
<h1>💻 Secondary Development</h1>
<p>If there are other requirements, you can call or modify the program refer to the comments in <code>main.py</code></p>
<pre>
# Example links
error_link = "https://github.com/JoeanAmier/XHS_Downloader"
demo_link = "https://www.xiaohongshu.com/explore/xxxxxxxxxx"
multiple_links = f"{demo_link} {demo_link} {demo_link}"
# Instance object
work_path = "D:\\" # Artwork data/file save root path, default value: project root path
folder_name = "Download" # Artwork file storage folder name (automatically created), default value: Download
user_agent = "" # Request Header: User-Agent
cookie = "" # Xiaohongshu web version Cookie, no need to log in
proxy = None # Network proxy
timeout = 5 # Request data timeout limit, unit: seconds, default value: 10
chunk = 1024 * 1024 * 10 # When downloading files, the size of each data block obtained from the server each time, unit: bytes
max_retry = 2 # Maximum number of retries when requesting data fails, unit: seconds, default value: 5
record_data = False # Whether to record artwork data to a file
image_format = "WEBP" # Graphic artwork file download format, supports: PNG, WEBP
folder_mode = False # Whether to store each artwork's file in a separate folder
async with XHS() as xhs:
pass # Use default parameters
async with XHS(work_path=work_path,
folder_name=folder_name,
user_agent=user_agent,
cookie=cookie,
proxy=proxy,
timeout=timeout,
chunk=chunk,
max_retry=max_retry,
record_data=record_data,
image_format=image_format,
folder_mode=folder_mode,
) as xhs: # Use custom parameters
download = True # Whether to download artwork files, default value: False
# Return detailed information about the artwork, including download addresses
print(await xhs.extract(error_link, download)) # Return an empty dictionary when data retrieval fails
print(await xhs.extract(demo_link, download))
print(await xhs.extract(multiple_links, download)) # Support input of multiple artwork links
</pre>
<h1>⚙️ Configuration File</h1>
<p><code>settings.json</code> in the project's root directory, generated automatically on the first run, and allows customization of certain runtime parameters</p>
<p>If your computer doesn't have a suitable program to edit JSON files, it is recommended to use <a href="https://try8.cn/tool/format/json">JSON Online Tool</a> to edit the content of the configuration file</p>
<table>
<thead>
<tr>
<th align="center">Parameters</th>
<th align="center">Type</th>
<th align="center">Meaning</th>
<th align="center">Default Value</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">work_path</td>
<td align="center">str</td>
<td align="center">Artwork data/file save root path</td>
<td align="center">Project root path</td>
</tr>
<tr>
<td align="center">folder_name</td>
<td align="center">str</td>
<td align="center">Artwork file storage folder name</td>
<td align="center">Download</td>
</tr>
<tr>
<td align="center">user_agent</td>
<td align="center">str</td>
<td align="center">Request Header: User-Agent</td>
<td align="center">Default UA</td>
</tr>
<tr>
<td align="center">cookie</td>
<td align="center">str</td>
<td align="center">Xiaohongshu web version Cookie<b>No need to log in, modification recommended</b></td>
<td align="center">Default Cookie</td>
</tr>
<tr>
<td align="center">proxy</td>
<td align="center">str</td>
<td align="center">Set program proxy</td>
<td align="center">null</td>
</tr>
<tr>
<td align="center">timeout</td>
<td align="center">int</td>
<td align="center">Request data timeout limit, unit: seconds</td>
<td align="center">10</td>
</tr>
<tr>
<td align="center">chunk</td>
<td align="center">int</td>
<td align="center">Size of each data block obtained from the server when downloading files, unit: bytes</td>
<td align="center">1048576(1 MB)</td>
</tr>
<tr>
<td align="center">max_retry</td>
<td align="center">int</td>
<td align="center">Maximum number of retries when requesting data fails, unit: seconds</td>
<td align="center">5</td>
</tr>
<tr>
<td align="center">record_data</td>
<td align="center">bool</td>
<td align="center">Whether to record artwork data to <code>TXT</code> file</td>
<td align="center">false</td>
</tr>
<tr>
<td align="center">image_format</td>
<td align="center">str</td>
<td align="center">Graphic and text artwork file download format, support: <code>PNG</code><code>WEBP</code></td>
<td align="center">PNG</td>
</tr>
<tr>
<td align="center">folder_mode</td>
<td align="center">bool</td>
<td align="center">Whether to store each artwork's file in a separate folder; folder names are consistent with file names</td>
<td align="center">false</td>
</tr>
<tr>
<td align="center">language</td>
<td align="center">str</td>
<td align="center">Set programming language, currently support: <code>zh-CN</code>, <code>en-GB</code></td>
<td align="center">zh-CN</td>
</tr>
</tbody>
</table>
<h1>🌐 Cookie</h1>
<ol>
<li>Open the browser (optional in incognito mode), visit any page on Xiaohongshu</li>
<li>Press <code>F12</code> to open developer tools</li>
<li>Click the <code>Console</code></li>
<li>Input <code>document.cookie</code> then press Enter to confirm</li>
<li>The output content is the Cookie</li>
</ol>
<br>
<img src="static/获取Cookie示意图.png" alt="">
<h1>♥️ Support the Project</h1>
<p>If <b>XHS-Downloader</b> is helpful, please consider giving it a <b>Star</b> ⭐, thank you for your support!</p>
<table>
<thead>
<tr>
<th align="center">WeChat</th>
<th align="center">Alipay</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="./static/微信赞助二维码.png" alt="微信赞助二维码" height="200" width="200"></td>
<td align="center"><img src="./static/支付宝赞助二维码.png" alt="支付宝赞助二维码" height="200" width="200"></td>
</tr>
</tbody>
</table>
<p>If you wish, consider funding additional support for the <b>XHS-Downloader</b>!</p>
<h1>✉️ Contact us</h1>
<ul>
<li>QQ: 2437596031 (please inform intent)</li>
<li>QQ Group: <a href="https://github.com/JoeanAmier/XHS-Downloader/blob/master/static/QQ%E7%BE%A4%E8%81%8A%E4%BA%8C%E7%BB%B4%E7%A0%81.png">Click to obtain the group QR code</a></li>
<li>Email: yonglelolu@gmail.com</li>
</ul>
<p>
<b>If you contact me via email, I may not be able to check and respond promptly. I will do my best to reply to your email within seven days. If there are urgent matters or you need a faster response, please contact me through other means. Thank you for your understanding!</b>
</p>
<p><b>If you're interested in DouYin / TikTok, you can check out my other open-source project <a href="https://github.com/JoeanAmier/TikTokDownloader">TikTokDownloader</a></b></p>
<h1>⚠️ Disclaimer</h1>
<ul>
<li>Users decide on their own how to use this project and bear the risks themselves. The author is not responsible for any losses, liabilities, or risks incurred by users in the use of this project</li>
<li>The code and functionalities provided by the author of this project are developed based on existing knowledge and technology. The author strives to ensure the correctness and security of the code but does not guarantee that the code is completely error-free or defect-free.</li>
<li>Users must strictly adhere to the provisions in <a href="https://github.com/JoeanAmier/XHS-Downloader/blob/master/LICENSE">GNU
General Public License v3.0</a> , and appropriately mention the use of code adhering <a
href="https://github.com/JoeanAmier/XHS-Downloader/blob/master/LICENSE">GNU General Public License
v3.0</a>.
</li>
<li>Under no circumstances shall users associate the author of this project, contributors, or other related parties with the user's usage behavior, or demand that they be held responsible for any losses or damages incurred by the user's use of this project.</li>
<li>Users must independently study relevant laws and regulations when using the code and functionalities of this project and ensure that their usage is legal and compliant. Users are solely responsible for any legal liability and risks resulting from violations of laws and regulations.</li>
<li>The author of this project will not provide a paid version of the XHS-Downloader project, nor will they offer any commercial services related to the XHS-Downloader project.</li>
<li>Any secondary development, modification, or compilation of the program based on this project is unrelated to the original author. The original author is not responsible for any consequences related to secondary development or its results. Users should take full responsibility for any situations that may arise from secondary development on their own.</li>
</ul>
<b>Before using the code and functionalities of this project, please carefully consider and accept the above disclaimer. If you have any questions or disagree with the statement, please do not use the code and functionalities of this project. If you use the code and functionalities of this project, it is considered that you fully understand and accept the above disclaimer, and willingly assume all risks and consequences associated with the use of this project.</b>

View File

@ -55,10 +55,10 @@ def show_state(function):
class Index(Screen):
CSS_PATH = ROOT.joinpath("static/XHS-Downloader.tcss")
BINDINGS = [
Binding(key="q", action="quit", description="退出程序"),
Binding(key="u", action="check_update", description="检查更新"),
Binding(key="m", action="user_script", description="获取脚本"),
Binding(key="s", action="settings", description="程序设置"),
Binding(key="q", action="quit", description="退出程序/Quit"),
Binding(key="u", action="check_update", description="检查更新/Update"),
Binding(key="m", action="user_script", description="获取脚本/Script"),
Binding(key="s", action="settings", description="程序设置/Settings"),
]
def __init__(self, app: XHS, language: Chinese | English):

View File

@ -25,8 +25,8 @@ __all__ = ["Setting"]
class Setting(Screen):
CSS_PATH = ROOT.joinpath("static/XHS-Downloader.tcss")
BINDINGS = [
Binding(key="q", action="quit", description="退出程序"),
Binding(key="b", action="index", description="返回首页"),
Binding(key="q", action="quit", description="退出程序/Quit"),
Binding(key="b", action="index", description="返回首页/Back"),
]
def __init__(self, data: dict, language: Chinese | English):
@ -73,8 +73,7 @@ class Setting(Screen):
Select.from_values(list(LANGUAGE.keys()),
value=self.data["language"],
allow_blank=False,
id="language",
disabled=True, ),
id="language", ),
classes="horizontal-layout"),
Container(
Button(self.prompt.save_button, id="save", ),

View File

@ -4,4 +4,122 @@ __all__ = ["English"]
class English(Chinese):
pass
code: str = "en-GB"
disclaimer: tuple[str] = (
"Disclaimer about XHS-Downloader:",
"",
"1. The user decides on their own use of this project and assumes all risks. The author is not responsible "
"for any losses, liabilities, or risks incurred by the user in using this project.",
"2. The code and features provided by the author of this project are developed based on existing knowledge "
"and technology. The author strives to ensure the correctness and security of the code but does not guarantee "
"that the code is entirely free of errors or defects.",
"3. The user must strictly adhere to the requirements of the GNU General Public License v3.0 when using this "
"project and appropriately acknowledge the use of code licensed under the GNU General Public License v3.0.",
"4. Under no circumstances may the user associate the author, contributors, or other relevant parties of this "
"project with the user's actions, nor demand them to be held responsible for any losses or damages incurred "
"by the user in using this project.",
"5. The user must independently research relevant laws and regulations when using the code and features of "
"this project, ensuring that their use is legal and compliant. Any legal responsibilities and risks arising "
"from violations of laws and regulations are the sole responsibility of the user.",
"6. The author of this project will not offer a paid version of the XHS-Downloader project and will not "
"provide any commercial services related to the XHS-Downloader project.",
"7. Any secondary development, modification, or compilation of programs based on this project is not "
"associated with the original author. The original author is not responsible for any consequences related to "
"secondary development actions or their results. The user is solely responsible for all situations that may "
"arise from secondary development.",
"",
"Before using the code and features of this project, please carefully consider and accept the above "
"disclaimers. If you have any questions or do not agree with the statements above, please refrain from using "
"the code and features of this project. If you proceed to use the code and features of this project, "
"it will be considered that you fully understand and accept the disclaimers mentioned above, and willingly "
"assume all risks and consequences associated with using this project.",
"",
">" * 50,
)
download_link_error: str = "Failed to extract the download address for the Xiaohongshu works files!"
extract_link_failure: str = "Failed to extract the links for Xiaohongshu works!"
invalid_link: str = "No Xiaohongshu works links provided!"
download_failure: str = "Failed to download the Xiaohongshu works files!"
check_update_notification: str = "Checking for new version, please wait..."
development_version_update: str = (
"The current version is a development version, and can be updated to the "
"official version!")
latest_development_version: str = "You are already using the latest development version!"
latest_official_version: str = "You are already using the latest official version!"
check_update_failure: str = "Failed to check for a new version!"
open_source_protocol: str = "Open Source License:"
project_address: str = "Project Address:"
input_box_title: str = "Please enter the link to the Xiaohongshu image/text or video works:"
input_prompt: str = "Separate multiple links with spaces"
download_button: str = "Download images/video files"
paste_button: str = "Read the clipboard"
reset_button: str = "Clear the input box"
exit_program: str = "Exit the program"
check_updates: str = "Check for updates"
get_script: str = "Get the script"
choose_language: str = "Select language"
work_path: str = "Work path:"
folder_name: str = "Folder name:"
user_agent: str = "User-Agent:"
cookie: str = "Cookie:"
proxy: str = "Network proxy:"
timeout: str = "Request timeout limit:"
chunk: str = "Download data block size:"
max_retry: str = "Maximum retry attempts:"
record_data: str = "Record works data"
image_format: str = "Image download format"
folder_mode: str = "Folder archiving mode"
language: str = "Program language"
server: str = "Start local server"
work_path_placeholder: str = "Program root path"
user_agent_placeholder: str = "Default UA"
cookie_placeholder: str = "built-in cookie, it is recommended to set it manually"
proxy_placeholder: str = "No proxy"
save_button: str = "Save configuration"
abandon_button: str = "Discard changes"
@staticmethod
def request_error(url: str) -> str:
return f"Network error, failed to access {url}!"
@staticmethod
def skip_download(name: str) -> str:
return f"{name} already exists, skipping download!"
@staticmethod
def download_success(name: str) -> str:
return f"{name} download successful!"
@staticmethod
def download_error(name: str) -> str:
return f"Network error, {name} download failed!"
@staticmethod
def pending_processing(num: int) -> str:
return f"{num} works from Xiaohongshu are awaiting processing..."
@staticmethod
def start_processing(url: str) -> str:
return f"Start processing the works: {url}"
@staticmethod
def get_data_failure(url: str) -> str:
return f"{url} failed to retrieve data!"
@staticmethod
def extract_data_failure(url: str) -> str:
return f"{url} failed to extract data!"
@staticmethod
def processing_completed(url: str) -> str:
return f"works processing completed: {url}"
@staticmethod
def official_version_update(major: int, minor: int) -> str:
return f"New version detected: {major}.{minor}"