├── DOWNLOAD_FUNC.py ├── LICENSE ├── README.md ├── UI.py ├── URL.json ├── __pycache__ ├── DOWNLOAD_FUNC.cpython-39.pyc ├── UI.cpython-39.pyc └── resources_rc.cpython-39.pyc ├── config.json ├── main.py ├── recourse ├── logo.ico ├── logo.png ├── pic.png └── qfluentwidgets_logo.png ├── requirements.txt ├── resource.qrc └── resources_rc.py /DOWNLOAD_FUNC.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | Copyright 2023 by RicardoJackMC 5 | Teaching Material Download Manager 使用 GPLv3 许可证 6 | 本文件是 Teaching Material Download Manager 的一部分 7 | 请自行前往 8 | https://github.com/RicardoJackMC/Teaching-Material-Download-Manager 9 | 或 10 | https://gitee.com/RicardoJackMC/Teaching-Material-Download-Manager 11 | 根据版本号校验本文件MD5 12 | """ 13 | 14 | import json 15 | import os 16 | import subprocess 17 | import time 18 | from datetime import datetime 19 | from urllib.parse import urlparse, parse_qs 20 | 21 | import requests 22 | 23 | 24 | class Downloader(): 25 | def __init__(self): 26 | self.RUN = True 27 | self.URL = None # @ 28 | self.chunk_size = None # ! 29 | self.file_size = None 30 | self.url_A = None # ! 31 | self.ID_A = None 32 | self.url_json = None 33 | self.title = None 34 | self.ID_B = None 35 | self.url_B = None 36 | self.url_PDF = None 37 | self.save_path = None # ! 38 | self.save_mode = None # ! 0 为覆盖 1 为加数字后缀 2 为加时间后缀 39 | self.IDM_path = None # ! 40 | self.Aria2_url = None # ! 41 | self.path_PDF = None 42 | self.download_mode = None # ! 0 内置下载 1 IDM 2 Aria2 3 复制链接 43 | self.download_data = {} # @ 44 | self.url_PDF_current_Left = None # @ 通用的网址 45 | self.url_PDF_A_Left = None # @ 仅使用ID_A的网址 46 | self.url_json_Left = None # @ 47 | self.url_PDF_B_Left = None # @ 仅使用ID_B的网址 48 | self.warning = False 49 | self.queue = None # @ 50 | self.queue_admin = None # @ 51 | self.queue_command = None # @ 52 | self.KEY = [] # @ 53 | self.KEY_admin = [] # @ 54 | 55 | if os.path.isfile('.\\URL.json'): 56 | with open('.\\URL.json', 'r') as f: 57 | self.URL = json.load(f) 58 | 59 | self.url_PDF_current_Left = self.URL['url_PDF_current_Left'] 60 | self.url_PDF_A_Left = self.URL['url_PDF_A_Left'] 61 | self.url_json_Left = self.URL['url_json_Left'] 62 | self.url_PDF_B_Left = self.URL['url_PDF_B_Left'] 63 | 64 | def run(self): # 入口 65 | pre_key = None 66 | while self.RUN: 67 | print('getting command') 68 | try: 69 | print('running d') 70 | command = self.queue_command.get() 71 | if command == 'CLOSE': 72 | self.RUN = False 73 | if 'command' in command and command['command']['key'] != pre_key: 74 | pre_key = command['command']['key'] 75 | self.url_A = command['command']['url_A'] 76 | self.save_mode = command['command']['save_mode'] 77 | self.save_path = command['command']['save_path'] 78 | if not self.save_path.endswith('\\'): 79 | self.save_path = self.save_path + '\\' 80 | self.IDM_path = command['command']['IDM_path'] 81 | self.Aria2_url = command['command']['Aria2_url'] 82 | self.download_mode = command['command']['download_mode'] 83 | self.chunk_size = command['command']['chunk_size'] 84 | 85 | self.warning = False 86 | self.ID_B = None 87 | self.title = None 88 | self.file_size = None 89 | 90 | result = self.get_ID_A() 91 | if result: 92 | self.verify_url_json() 93 | result = self.verify_url_PDF() 94 | print('va', result) 95 | if result: 96 | # 扫了一圈, 在这里设置保存路径最好 97 | if self.title is None: 98 | self.title = 'pdf' 99 | self.path_PDF = self.save_path + self.title + '.pdf' 100 | if not self.save_mode == 0: 101 | n = 0 102 | while os.path.exists(self.path_PDF): 103 | if self.save_mode == 1: 104 | n += 1 105 | self.path_PDF = self.save_path + self.title + ' ' + '(' + str(n) + ')' + '.pdf' 106 | elif self.save_mode == 2: 107 | self.path_PDF = self.save_path + self.title + ' ' + str(datetime.now()).replace( 108 | ':', 109 | '-') + '.pdf' 110 | if self.download_mode == 0: 111 | result = self.download_PDF() 112 | elif self.download_mode == 1: 113 | result = self.IDM_download() 114 | elif self.download_mode == 2: 115 | result = self.Aria2_download() 116 | elif self.download_mode == 3: 117 | download_url = {'title': self.title, 'download_url': self.url_PDF} 118 | self.admin_producer('download_url', download_url) 119 | self.download_data_update('FINISH', FINISH_STATE=self.warning) 120 | result = True 121 | print('result', result) 122 | if result: 123 | if self.warning: 124 | self.admin_producer('result', 'warning') 125 | else: 126 | self.admin_producer('result', 'normal') 127 | else: 128 | self.admin_producer('result', 'error') 129 | else: 130 | self.admin_producer('result', 'error') 131 | else: 132 | self.admin_producer('result', 'ID_A error') 133 | except: 134 | pass 135 | 136 | def return_basic_info(self, type_info, info): 137 | data_info = {type_info: info} 138 | self.producer('basic_info', data_info) 139 | 140 | def admin_producer(self, type_info, info): 141 | KEY_admin = time.time() 142 | while KEY_admin in self.KEY_admin: 143 | KEY_admin += 0.000001 144 | data_info = {type_info: info, 'KEY': KEY_admin} 145 | self.queue_admin.put(data_info) 146 | self.KEY_admin.append(KEY_admin) 147 | 148 | def producer(self, type_info, info): 149 | KEY = time.time() 150 | while KEY in self.KEY: 151 | KEY += 0.000001 152 | data_info = {type_info: info, 'KEY': KEY} 153 | self.queue.put(data_info) 154 | self.KEY.append(KEY) 155 | 156 | def download_data_update(self, info, FINISH_STATE=None): 157 | if FINISH_STATE is not None: 158 | if FINISH_STATE: 159 | info = 'FINISH WARNING' 160 | elif not FINISH_STATE: 161 | info = 'FINISH NORMAL' 162 | key = time.time() 163 | while key in self.download_data: 164 | key += 0.000001 165 | self.download_data[key] = info 166 | self.producer('download_data', self.download_data) 167 | 168 | def get_ID_A(self): 169 | self.producer('state', 'getting ID_A...') 170 | time.sleep(0.5) 171 | self.download_data_update('trying to get ID_A from: ' + self.url_A) 172 | if 'tchMaterial' in self.url_A and 'contentId=' in self.url_A: 173 | try: 174 | ID_A_query_params = parse_qs(urlparse(self.url_A).query) 175 | self.ID_A = ID_A_query_params['contentId'][0] 176 | self.download_data_update('successfully getting ID_A: ' + self.ID_A + ' from: ' + self.url_A) 177 | self.return_basic_info('ID_A', self.ID_A) 178 | time.sleep(0.5) 179 | return True 180 | except: 181 | self.download_data_update('failed to get ID_A from: ' + self.url_A) 182 | self.download_data_update('FINISH ERROR') 183 | return False 184 | else: 185 | self.download_data_update('failed to get ID_A from: ' + self.url_A) 186 | self.download_data_update('FINISH ERROR') 187 | return False 188 | 189 | def verify_url_json(self): 190 | self.producer('state', 'getting json file...') 191 | time.sleep(0.5) 192 | for i in self.url_json_Left: 193 | self.url_json = i + self.ID_A + '.json' 194 | self.download_data_update('trying to get json file from: ' + self.url_json) 195 | try: 196 | if requests.head(self.url_json).status_code == 200: 197 | self.download_data_update('successfully getting json file from: ' + self.url_json) 198 | self.download_data_update('trying to getting title or ID_B from:' + self.url_json) 199 | get_title_result = self.get_title() 200 | get_ID_B_result = self.get_ID_B() 201 | if get_title_result and get_ID_B_result: 202 | self.return_basic_info('json_url', self.url_json) 203 | time.sleep(0.5) 204 | return True # 如果有ID_B和title就可以结束辣 205 | else: # 如果其中一项没有就继续尝试 206 | self.warning = True 207 | else: 208 | self.download_data_update( 209 | 'can not get json file from: ' + self.url_json + ' status_code: ' + str(requests.head( 210 | self.url_json).status_code)) 211 | except requests.exceptions.RequestException as e: 212 | self.download_data_update('can not get json file from: ' + self.url_json + ' because: ' + str(e)) 213 | self.warning = True 214 | self.url_json = None 215 | return False 216 | 217 | def get_title(self): 218 | self.producer('state', 'getting title...') 219 | time.sleep(0.5) 220 | book_title = None 221 | book_vision = None 222 | if self.url_json is not None and self.title is None: 223 | data_json = requests.get(self.url_json).json() 224 | try: 225 | book_title = data_json["title"] # 获取名字 226 | book_title_get = True 227 | except: 228 | self.download_data_update('can not get book_title from: ' + self.url_json) 229 | self.warning = True 230 | book_title_get = False 231 | try: 232 | book_vision = data_json['tag_list'][2]['tag_name'] # 获取版本 233 | book_vision_get = True 234 | except: 235 | self.download_data_update('can not get book_vision from: ' + self.url_json) 236 | self.warning = True 237 | book_vision_get = False 238 | if book_vision_get or book_title_get: 239 | self.title = book_title + ' ' + book_vision 240 | 241 | self.download_data_update('successfully getting title: ' + self.title + ' from: ' + self.url_json) 242 | self.return_basic_info('title', self.title) 243 | time.sleep(0.5) 244 | return True 245 | else: 246 | return False 247 | 248 | def get_ID_B(self): 249 | self.producer('state', 'getting ID_B...') 250 | time.sleep(0.5) 251 | if self.url_json is not None and self.ID_B is None: # 避免重复获取ID_B 252 | data_json = requests.get(self.url_json).json() 253 | # 获取ID_B 254 | try: 255 | self.url_B = data_json['custom_properties']['thumbnails'][0] 256 | url_B_LEFT, url_B_TEMP = self.url_B.split('document/') 257 | self.ID_B, url_B_RIGHT = url_B_TEMP.split('/image') 258 | self.download_data_update('successfully getting ID_B: ' + self.ID_B + ' from: ' + self.url_json) 259 | self.return_basic_info('ID_B', self.ID_B) 260 | time.sleep(0.5) 261 | return True 262 | except: 263 | self.download_data_update('can not get ID_B at: ' + self.url_json) 264 | self.warning = True 265 | self.ID_B = None 266 | return False 267 | 268 | def verify_url_PDF(self): 269 | self.producer('state', 'verifying...') 270 | time.sleep(0.5) 271 | # 测试ID_A的网址 272 | self.url_PDF_A_Left = self.url_PDF_current_Left + self.url_PDF_A_Left 273 | for i in self.url_PDF_A_Left: 274 | self.url_PDF = i + '/esp/assets_document/' + self.ID_A + '.pkg/pdf.pdf' 275 | try: 276 | response = requests.head(self.url_PDF) 277 | if response.status_code == 200: 278 | self.file_size = int(response.headers["Content-Length"]) 279 | if self.file_size > 1024: 280 | self.download_data_update('successfully verifying url: ' + self.url_PDF + ' from: ' + self.ID_A) 281 | return True 282 | else: 283 | self.download_data_update( 284 | 'can not verify url: ' + self.url_PDF + ' because of: ' + self.file_size) 285 | self.warning = True 286 | else: 287 | self.download_data_update( 288 | 'can not verify url: ' + self.url_PDF + ' status_code: ' + str(requests.head( 289 | self.url_PDF).status_code)) 290 | except requests.exceptions.RequestException as e: 291 | self.download_data_update('can not verify url: ' + self.url_PDF + ' because: ' + str(e)) 292 | self.warning = True 293 | for i in self.url_PDF_current_Left: 294 | self.url_PDF = i + '/esp/assets/' + self.ID_A + '.pkg/pdf.pdf' 295 | try: 296 | response = requests.head(self.url_PDF) 297 | if response.status_code == 200: 298 | self.file_size = int(response.headers["Content-Length"]) 299 | if self.file_size > 1024: 300 | self.download_data_update('successfully verifying url: ' + self.url_PDF + ' from: ' + self.ID_A) 301 | return True 302 | else: 303 | self.download_data_update( 304 | 'can not verify url: ' + self.url_PDF + ' because of: ' + self.file_size) 305 | self.warning = True 306 | else: 307 | self.download_data_update( 308 | 'can not verify url: ' + self.url_PDF + ' status_code: ' + str(requests.head( 309 | self.url_PDF).status_code)) 310 | except requests.exceptions.RequestException as e: 311 | self.download_data_update('can not verify url: ' + self.url_PDF + ' because: ' + str(e)) 312 | self.warning = True 313 | if self.ID_B is not None: 314 | self.url_PDF_B_Left = self.url_PDF_current_Left + self.url_PDF_B_Left 315 | for i in self.url_PDF_B_Left: 316 | self.url_PDF = i + '/65/document/' + self.ID_B + '/pdf.pdf' 317 | try: 318 | response = requests.head(self.url_PDF) 319 | if response.status_code == 200: 320 | file_size = int(response.headers["Content-Length"]) 321 | if file_size > 1024: 322 | self.download_data_update( 323 | 'successfully verifying url: ' + self.url_PDF + ' from: ' + self.ID_B) 324 | return True 325 | else: 326 | self.download_data_update( 327 | 'can not verify url: ' + self.url_PDF + ' because of: ' + file_size) 328 | self.warning = True 329 | else: 330 | self.download_data_update( 331 | 'can not verify url: ' + self.url_PDF + ' status_code: ' + str(requests.head( 332 | self.url_PDF).status_code)) 333 | except requests.exceptions.RequestException as e: 334 | self.download_data_update('can not verify url: ' + self.url_PDF + ' because: ' + str(e)) 335 | self.warning = True 336 | self.download_data_update('FINISH ERROR') 337 | return False 338 | 339 | def download_PDF(self): 340 | self.producer('state', 'downloading...') 341 | time.sleep(0.5) 342 | try: 343 | downloaded_size = 0 344 | with open(self.path_PDF, 'wb') as file: 345 | for chunk in requests.get(self.url_PDF, stream=True).iter_content(chunk_size=self.chunk_size): 346 | if chunk: 347 | file.write(chunk) 348 | downloaded_size += len(chunk) 349 | pre_progress = None 350 | progress = int((downloaded_size / self.file_size) * 100) 351 | if pre_progress != progress: 352 | self.producer('progress', progress) 353 | pre_progress = progress 354 | if os.path.exists(self.path_PDF): 355 | self.download_data_update('successfully saving: ' + self.path_PDF) 356 | self.download_data_update('FINISH', FINISH_STATE=self.warning) 357 | return True 358 | else: 359 | self.download_data_update('failed to save: ' + self.path_PDF + ' there is nothing saved!') 360 | self.download_data_update('FINISH ERROR') 361 | return False 362 | except Exception as e: 363 | self.download_data_update('failed to save: ' + self.path_PDF + ' because: ' + str(e)) 364 | self.download_data_update('FINISH ERROR') 365 | return False 366 | 367 | def IDM_download(self): 368 | self.producer('state', 'sending to IDM...') 369 | time.sleep(0.5) 370 | print(self.IDM_path) 371 | command_1 = [f"{self.IDM_path}", "/d", f"{self.url_PDF}", "/p", f"{self.save_path}", f"/f", 372 | f"{os.path.basename(self.path_PDF)}"] 373 | command_data = '' 374 | for i in command_1: 375 | command_data = command_data + i + ' ' 376 | process = subprocess.Popen(command_1, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 377 | return_code = process.wait() 378 | stdout, stderr = process.communicate() 379 | if return_code == 0: 380 | self.download_data_update('successfully run: ' + command_data) 381 | self.download_data_update('FINISH', FINISH_STATE=self.warning) 382 | return True 383 | else: 384 | self.download_data_update( 385 | 'failed to run: ' + command_data + ' return code: ' + str(return_code) + ' stderr: ' + str(stderr)) 386 | self.download_data_update('FINISH ERROR') 387 | return False 388 | 389 | def Aria2_download(self): 390 | self.producer('state', 'sending to Aria2...') 391 | time.sleep(0.5) 392 | url_list = [self.url_PDF] 393 | payload = { 394 | "jsonrpc": "2.0", 395 | "id": "1", 396 | "method": "aria2.addUri", 397 | "params": [url_list, {"dir": self.save_path, "out": os.path.basename(self.path_PDF)}] 398 | } 399 | headers = {"Content-Type": "application/json"} 400 | try: 401 | response = requests.post(self.Aria2_url, data=json.dumps(payload), headers=headers) 402 | if response.status_code == 200: 403 | result = response.json() 404 | if 'result' in result: 405 | self.download_data_update("added " + self.url_PDF + " to " + self.Aria2_url + " successfully.") 406 | self.download_data_update('FINISH', FINISH_STATE=self.warning) 407 | return True 408 | elif 'error' in result: 409 | self.download_data_update("Error: " + result['error']['message']) 410 | self.download_data_update('FINISH ERROR') 411 | return False 412 | else: 413 | self.download_data_update( 414 | "failed to communicate with Aria2 server, status_code : " + str(response.status_code)) 415 | self.download_data_update('FINISH ERROR') 416 | return False 417 | except Exception as e: 418 | self.download_data_update( 419 | "failed to communicate with Aria2 server, because : " + str(e)) 420 | self.download_data_update('FINISH ERROR') 421 | return False 422 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | logo 3 |

4 |

5 | Teaching-Material-Download-Manager 6 |

7 |

8 | 优雅地下载电子教材 9 |

10 |

11 | for Ver.1.1.0_202308281300 12 |

13 |

14 | 15 | GPLv3 16 | 17 | 18 | Platform Windows 19 | 20 | 21 | Python 3.9.13 22 | 23 |

24 |

25 | 源代码: GitHub 仓库 | Gitee 仓库 26 |

27 |

28 | 下载地址: GitHub release | Gitee release | 123网盘 29 |

30 |

31 | 如果你的设备不受支持, 可以查看下载原理自行获取教材下载链接! 32 |

33 |

34 | logo 35 |

36 | 37 | 38 | 39 | ## 食用方法🍕 40 | 41 | ### 想开盖即食 ? 42 | 43 | 从 [Github release](https://github.com/RicardoJackMC/Teaching-Material-Download-Manager/releases) 或 [Gitee release](https://gitee.com/RicardoJackMC/Teaching-Material-Download-Manager/releases) 页面选择最新版本, 点击`Teaching-Material-Download-Manager.zip`, 或者前往 [123网盘](https://www.123pan.com/s/Y59qVv-uuubd.html) 选择最新版本的文件夹, 下载`Teaching-Material-Download-Manager.zip`, 下载完成后解压, 双击`main.exe`即可使用. 具体操作可以去B站看[演示视频](https://www.bilibili.com/video/BV1xH4y1Q7aM/) 44 | 45 | ### 想食用源码 ? 46 | 47 | 下载完源码后解压, (有需要的记得先激活虚拟环境) 在 cmd 中用`cd`转到`main.py`所在的目录, 然后运行 48 | 49 | ``` 50 | pip install -r requirements.txt 51 | ``` 52 | 53 | 然后, ENJOY YOURSELF ! ! ! 54 | 55 | > **Note** 56 | > 本软件的开发环境如下 57 | > 58 | > Python 3.9.13 59 | > 60 | > PyQt5 5.15.9 61 | > 62 | > requests 2.31.0 63 | > 64 | > PyQt-Fluent-Widgets 1.1.9 65 | 66 | ## 敏感行为🛡️ 67 | 68 | 本软件的某些行为可能会被杀毒软件识别为危险行为, 下表列出了程序的敏感行为 69 | 70 | | 行为 | 触发方式 | 具体描述 | 71 | | ------------------------------------------------------------ | :----------------------------------------------------------- | ------------------------------------------------------------ | 72 | | 对与 main.exe 同个目录下的的 config.json 进行读取与写入 | 当软件第一次启动时, 或当用户更改任意设置使自动触发 | 位于与 main.exe 同一目录下的 config.json 为本软件的配置文件, 上面记载了用户对软件的设置, 例如: 是否开启队列, 是否开启自动下载等. | 73 | | 对与 main.exe 同个目录下的的 URL.json 进行读取 | 当软件启动时 | 与 main.exe 同个目录下的的 URL.json 记载了多个智慧教育网站的 api (网址), 用于生成最终的下载链接 | 74 | | 将 JSON 文件保存至用户指定的位置 | 当用户点击“导出下载日志按钮时”在用户选定保存位置后触发 | 被保存的 JSON 文件为软件的下载日志, 上面记载了下载时的信息, 例如: 未能获取要保存的教材 pdf 文件标题的原因, 下载失败文件的链接等. 用户可以自行决定是否生成 JSON 文件, JSON 文件的保存位置, 以及是否将 JSON 文件自行发送给开发者 | 75 | | 与多个智慧教育平台 api (网址)通讯 | 当处理任意任务时, 自动触发, 使用到 api (网址)详见[下载原理](#pt1-下载原理) | 软件需要与多个网站通讯才可获得 ID_B, 教材 pdf 文件的标题, 教材下载链接及下载教材, 具体通讯的网站可查看[下载原理](#pt1-下载原理) | 76 | | 与 https://api.github.com/repos/RicardoJackMC/Teaching-Material-Download-Manager/releases/latest 和 https://gitee.com/api/v5/repos/RicardoJackMC/Teaching-Material-Download-Manager/releases/latest 通讯 | 当用户点击“检查更新”时触发 | 这两个链接为 GitHub 和 Gitee 的 api, 软件通过此 api 获取版本号判断是否有新版本 | 77 | | 读取注册表: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize 下 AppsUseLightTheme 的值 | 每次当软件启动时自动触发 | 判断软件是否应启用暗黑模式使其与系统应用的外观同步 | 78 | | 读取注册表: HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM 下 AccentColor 的值 | 每次当软件启动时自动触发 | 设置软件的主题色使其与系统应用同步 | 79 | 80 | ## 软件原理📒 81 | 82 | ### Pt.1 下载原理 83 | 84 | #### · 基础 85 | 86 | 研究发现教材详情页网址的组成如下 87 | 88 | ```url 89 | https://basic.smartedu.cn/tchMaterial/detail?contentType=assets_document&contentId={id}&catalogType=tchMaterial&subCatalog=tchMaterial 90 | ``` 91 | 92 | 我们把 {id} 的值记为 ID_A 93 | 94 | 可以发现使用 ID_A 的值替换下列网址中的 {ID_A} 后形成的新网址即为 pdf 教材教材的下载链接: 95 | 96 | | 使用ID_A的下载链接 | 97 | | ------------------------------------------------------------ | 98 | | https://r1-ndr.ykt.cbern.com.cn/edu_product/esp/assets_document/{ID_A}.pkg/pdf.pdf | 99 | | https://r2-ndr.ykt.cbern.com.cn/edu_product/esp/assets_document/{ID_A}.pkg/pdf.pdf | 100 | | https://r3-ndr.ykt.cbern.com.cn/edu_product/esp/assets_document/{ID_A}.pkg/pdf.pdf | 101 | | https://c1.ykt.cbern.com.cn/edu_product/esp/assets_document/{ID_A}.pkg/pdf.pdf | 102 | | https://r1-ndr.ykt.cbern.com.cn/edu_product/esp/assets/{ID_A}.pkg/pdf.pdf | 103 | | https://r2-ndr.ykt.cbern.com.cn/edu_product/esp/assets/{ID_A}.pkg/pdf.pdf | 104 | | https://r3-ndr.ykt.cbern.com.cn/edu_product/esp/assets/{ID_A}.pkg/pdf.pdf | 105 | 106 | 例如: 107 | 108 | ```url 109 | https://basic.smartedu.cn/tchMaterial/detail?contentType=assets_document&contentId=b8e9a3fe-dae7-49c0-86cb-d146f883fd8e&catalogType=tchMaterial&subCatalog=tchMaterial 110 | ``` 111 | 112 | 其中 ID_A 的值为: 113 | 114 | ```ID_A 115 | b8e9a3fe-dae7-49c0-86cb-d146f883fd8e 116 | ``` 117 | 118 | 则该教材有以下下载链接: 119 | 120 | | 示例下载链接 | 121 | | ------------------------------------------------------------ | 122 | | https://r1-ndr.ykt.cbern.com.cn/edu_product/esp/assets_document/b8e9a3fe-dae7-49c0-86cb-d146f883fd8e.pkg/pdf.pdf | 123 | | https://r2-ndr.ykt.cbern.com.cn/edu_product/esp/assets_document/b8e9a3fe-dae7-49c0-86cb-d146f883fd8e.pkg/pdf.pdf | 124 | | https://r3-ndr.ykt.cbern.com.cn/edu_product/esp/assets_document/b8e9a3fe-dae7-49c0-86cb-d146f883fd8e.pkg/pdf.pdf | 125 | | https://c1.ykt.cbern.com.cn/edu_product/esp/assets_document/b8e9a3fe-dae7-49c0-86cb-d146f883fd8e.pkg/pdf.pdf | 126 | | * https://r1-ndr.ykt.cbern.com.cn/edu_product/esp/assets/b8e9a3fe-dae7-49c0-86cb-d146f883fd8e.pkg/pdf.pdf | 127 | | * https://r2-ndr.ykt.cbern.com.cn/edu_product/esp/assets/b8e9a3fe-dae7-49c0-86cb-d146f883fd8e.pkg/pdf.pdf | 128 | | * https://r3-ndr.ykt.cbern.com.cn/edu_product/esp/assets/b8e9a3fe-dae7-49c0-86cb-d146f883fd8e.pkg/pdf.pdf | 129 | 130 | 至此, 该教材已有 4 个下载链接. 131 | 132 | > **Note** 133 | > 在上述例子中, 前面带星号的下载链接已经不可用, 但是在下载 https://basic.smartedu.cn/tchMaterial/detail?contentType=assets_document&contentId=2600a906-afca-43bc-9070-5d962b92c85c&catalogType=tchMaterial&subCatalog=tchMaterial 时, 前面不带星号的下载链接不可用, 但是带星号的下载链接可以使用, 固本软件仍保留带星号的下载链接 134 | 135 | #### · 高阶 136 | 137 | 使用 ID_A 的值替换下列网址中的 {ID_A} 后形成的新网址为 JSON 文件: 138 | 139 | | JSON文件链接 | 140 | | ------------------------------------------------------------ | 141 | | https://s-file-3.ykt.cbern.com.cn/zxx/ndrs/resources/tch_material/details/{ID_A}.json | 142 | | https://s-file-2.ykt.cbern.com.cn/zxx/ndrs/resources/tch_material/details/{ID_A}.json | 143 | | https://s-file-1.ykt.cbern.com.cn/zxx/ndrs/resources/tch_material/details/{ID_A}.json | 144 | 145 | 此时, 可以在此 JSON 中获得教材的标题, 版本和 ID_B, 其中, 如果将 JSON 文件保存为一个名为 json_data 的 Python 字典, 则可以通过: 146 | 147 | ```python 148 | json_data["title"] # 获取教材标题 149 | json_data['tag_list'][2]['tag_name'] # 获取教材版本 150 | json_data['custom_properties']['thumbnails'][0] # 获取教材的图片, 我们把它记为url_B, 我们会用url_B获取ID_B 151 | ``` 152 | 153 | 其中, url_B 组成通常如下: 154 | 155 | ```url 156 | https://r3-ndr.ykt.cbern.com.cn/edu_product/65/document/{id}/image/1.jpg 157 | ``` 158 | 159 | 我们把上述网址 {id} 的值记为 ID_B 160 | 161 | > **Note** 162 | > 这仅仅只是其中的一种获取 ID_B 的方法, 据开发者所知还有其他更稳定的方法可以获取 ID_B 163 | 164 | 可以发现使用 ID_B 的值替换下列网址中的 {ID_B} 后形成的新网址即为 pdf 教材教材的下载链接: 165 | 166 | | 使用 ID_B 的下载链接 | 167 | | ------------------------------------------------------------ | 168 | | https://v1.ykt.cbern.com.cn/65/document/{ID_B}/pdf.pdf | 169 | | https://v2.ykt.cbern.com.cn/65/document/{ID_B}/pdf.pdf | 170 | | https://v3.ykt.cbern.com.cn/65/document/{ID_B}/pdf.pdf | 171 | | https://r1-ndr.ykt.cbern.com.cn/edu_product/65/document/{ID_B}/pdf.pdf | 172 | | https://r2-ndr.ykt.cbern.com.cn/edu_product/65/document/{ID_B}/pdf.pdf | 173 | | https://r3-ndr.ykt.cbern.com.cn/edu_product/65/document/{ID_B}/pdf.pdf | 174 | 175 | > **Warning** 176 | > 通过 JSON 获取的 ID_B, 教材标题, 教材版本出错的可能性较大, 不同的教材对应的 JSON 文件基本都具有差异, 尽管差异很小, 也会造成程序无法正确获取 ID_B, 教材标题, 教材版本. 177 | 178 | 仍然以[基础](#-基础)中使用的教材为例子, 可从以下链接获取 JSON 文件 179 | 180 | | JSON文件链接 | 181 | | ------------------------------------------------------------ | 182 | | https://s-file-3.ykt.cbern.com.cn/zxx/ndrs/resources/tch_material/details/b8e9a3fe-dae7-49c0-86cb-d146f883fd8e.json | 183 | | https://s-file-2.ykt.cbern.com.cn/zxx/ndrs/resources/tch_material/details/b8e9a3fe-dae7-49c0-86cb-d146f883fd8e.json | 184 | | https://s-file-1.ykt.cbern.com.cn/zxx/ndrs/resources/tch_material/details/b8e9a3fe-dae7-49c0-86cb-d146f883fd8e.json | 185 | 186 | 讲 JSON 文件保存为名为 json_data 的 Python 字典, 则 187 | 188 | ```py 189 | print(json_data["title"]) 190 | # 输出 普通高中教科书·语文必修 上册 191 | print(json_data['tag_list'][2]['tag_name']) 192 | # 输出 统编版 193 | print(json_data['custom_properties']['thumbnails'][0]) 194 | # 输出 https://r1-ndr.ykt.cbern.com.cn/edu_product/65/document/7a69755810bb492c9e44f94a213b7e5e/image/1.jpg 195 | ``` 196 | 197 | 通过 url_B 获取 ID_B 为 198 | 199 | ```ID_B 200 | 7a69755810bb492c9e44f94a213b7e5e 201 | ``` 202 | 203 | 则可获得以下下载链接: 204 | 205 | | 示例下载链接 | 206 | | ------------------------------------------------------------ | 207 | | https://v1.ykt.cbern.com.cn/65/document/7a69755810bb492c9e44f94a213b7e5e/pdf.pdf | 208 | | https://v2.ykt.cbern.com.cn/65/document/7a69755810bb492c9e44f94a213b7e5e/pdf.pdf | 209 | | https://v3.ykt.cbern.com.cn/65/document/7a69755810bb492c9e44f94a213b7e5e/pdf.pdf | 210 | | https://r1-ndr.ykt.cbern.com.cn/edu_product/65/document/7a69755810bb492c9e44f94a213b7e5e/pdf.pdf | 211 | | https://r2-ndr.ykt.cbern.com.cn/edu_product/65/document/7a69755810bb492c9e44f94a213b7e5e/pdf.pdf | 212 | | https://r3-ndr.ykt.cbern.com.cn/edu_product/65/document/7a69755810bb492c9e44f94a213b7e5e/pdf.pdf | 213 | 214 | 综上所述, 一个教材目前最多有 13 个下载链接. 215 | 216 | #### · 总结 217 | 218 | 一个教材最多有 13 个下载链接, 若您的设备不支持本软件, 建议使用[基础](#-基础)中的操作自行获取下载链接, 同时, 建议使用程序自动化完成[高阶](#-高阶)中的操作获取下载链接. 如果发现下载链接失效了或发现新的下载链接, 请发邮件到 ricardojackmc@gmail.com 告诉作者, 谢谢啦 ! 219 | 220 | ### Pt.2 运行原理 221 | 222 | 本软件使用多进程 (multiprocessing) + 多线程 (QThread) 的方式运行 223 | 224 | 主进程 UI_Process 负责 UI 界面的刷新, 另有下载进程 Manager_Process 专门负责下载功能 225 | 226 | 使用 multiprocessing 中的 Queue 实现进程间的通讯, 其中 queue 负责向 UI_Process 传递下载进度, 下载状态等基本信息, queue_admin 负责向 UI_Process 传递结束指令, 下载链接, queue_command 负责向 Manager_Process 传递下载的配置项以及关闭指令 227 | 228 | 主进程下又有子线程 normal_info, admin_info 专门监听 queue 和 queue_admin, 另外还有子线程 update_func 专门负责检查软件更新. 229 | 230 | ## 软件前瞻 (前方大型画饼现场)🍪 231 | 232 | 此外, 作者正在研究 智慧教育平台的课程的下载方法, 以及国家智慧教育读书平台, Library Genesis, Sci-Hub, Z-Library 等网站的下载方法. 233 | 234 | 可能会在下个版本支持 智慧教育平台课程 和 国家智慧教育读书平台 的下载. 235 | 236 | (要开学啦, 开学后作者不一定更新, 可能要寒假才可以更新😥) 237 | 238 | ## 许可证🏛️ 239 | 240 | Teaching-Material-Download-Manager 使用 [GPLv3](https://github.com/RicardoJackMC/Teaching-Material-Download-Manager/blob/main/LICENSE) 许可证. 241 | 242 | Copyright 2023 by RicardoJackMC 243 | 244 | > **Note** 245 | > 如果您是在阅读[软件原理](#软件原理)或软件源码后自行编写程序然后分发, 则您的程序可以不必使用使用 [GPLv3](https://github.com/RicardoJackMC/Teaching-Material-Download-Manager/blob/main/LICENSE) 许可证. 246 | 247 | ## 坚决反对日本排放福岛核污染水!!!☢️ 248 | 249 | > **Warning** 250 | > 本条目不涉及歧视或引战, 更与政治无关 ! ! ! 本条与整个人类的存亡有关 ! ! ! 251 | 252 | 首先, 对于 国内外舆论迫使日本政府停止排放福岛核污染水 这一可能事件, 本人持消极态度 253 | 254 | 并且, 对于 我们普通人通过各种努力与斗争迫使日本政府停止排放福岛核污染水 这一可能事件, 本人同样持消极态度 255 | 256 | **但是, 不代表本人会消极应对此事!!!** 257 | 258 | **普通人的力量太小, 不能改变什么, 但是, 群众的力量是强大的** 259 | 260 | **我们也许不能改变日本排放福岛核污染水这一事实, 但是我们可以通过自己的行动, 让自己的子孙, 或者说, 人类的后代记住这件事!!!使他们不至于消失得这么不明不白!!!** 261 | 262 | 当然, 最好的结果是 迫使日本政府停止排放福岛核污染水 (尽管可能性很小) 263 | 264 | **但是即使可能性很小, 我们也要去尝试, 去斗争!!!** 265 | 266 | **本人这样做不是为了挑起任何冲突与矛盾, 也不想看到任何歧视与暴力的发生, 本人始终坚信, 日本人民, 甚至是日本政府内部, 仍然有人知道这件事的危害, 仍然有人在试图制止这一切的继续!!!** 267 | 268 | **本人的诉求十分简单:** 269 | 270 | **1. 日本政府停止继续通过排海的方式处理福岛核污染水, 使用更负责任的方式处理福岛核污染水 (本人清楚的知道实现这一条的概率很低)** 271 | 272 | **2. 若第一条未能实现, 本人希望全人类都能记住, 在公元2023年8月24日, 日本正式启动福岛核污染水排海 (本人将致力于实现本条诉求)** 273 | 274 | 最后祝愿各位顺利可以成功通关地球OL😶‍🌫️!!! 275 | -------------------------------------------------------------------------------- /UI.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | Copyright 2023 by RicardoJackMC 5 | Teaching Material Download Manager 使用 GPLv3 许可证 6 | 本文件是 Teaching Material Download Manager 的一部分 7 | 请自行前往 8 | https://github.com/RicardoJackMC/Teaching-Material-Download-Manager 9 | 或 10 | https://gitee.com/RicardoJackMC/Teaching-Material-Download-Manager 11 | 根据版本号校验本文件MD5 12 | """ 13 | 14 | # Form implementation generated from reading ui file 'UI.ui' 15 | # 16 | # Created by: PyQt5 UI code generator 5.15.9 17 | # 18 | # WARNING: Any manual changes made to this file will be lost when pyuic5 is 19 | # run again. Do not edit this file unless you know what you are doing. 20 | 21 | import json 22 | import os 23 | import sys 24 | import time 25 | import webbrowser 26 | import winreg 27 | from functools import partial 28 | import requests 29 | import resources_rc 30 | 31 | from PyQt5 import QtCore, QtGui, QtWidgets 32 | from PyQt5.QtCore import Qt, QThread, pyqtSignal, QCoreApplication, QPoint, QEvent 33 | from PyQt5.QtGui import QColor, QPainter, QIcon, QPixmap 34 | from PyQt5.QtWidgets import QFileDialog, QTableWidgetItem, QListWidgetItem, QWidget, QPushButton, \ 35 | QVBoxLayout, QHBoxLayout, QLabel 36 | from qfluentwidgets import BodyLabel, ComboBox, HyperlinkButton, IndeterminateProgressRing, LineEdit, ListWidget, \ 37 | ToolButton, ProgressRing, PushButton, SegmentedWidget, SpinBox, SwitchButton, TableWidget, TextEdit, FluentIcon, \ 38 | Dialog, InfoBarIcon, Flyout, InfoBarPosition, InfoBar, setThemeColor, RoundMenu, Action, MenuAnimationType, \ 39 | TransparentToolButton, CardWidget, IconWidget, CaptionLabel, SubtitleLabel, StateToolTip 40 | 41 | DISPLAY_MODE = 0 42 | 43 | 44 | class RoundWindow(QWidget): 45 | 46 | def __init__(self, parent=None): 47 | super(RoundWindow, self).__init__(parent) 48 | self.border_width = 8 49 | 50 | def paintEvent(self, event): 51 | global DISPLAY_MODE 52 | pat = QPainter(self) 53 | pat.setRenderHint(pat.Antialiasing) 54 | if DISPLAY_MODE == 1: 55 | pat.setBrush(QColor(243, 243, 243, 255)) 56 | else: 57 | pat.setBrush(QColor(32, 32, 32, 255)) 58 | pat.setPen(Qt.transparent) 59 | 60 | rect = self.rect() 61 | rect.setLeft(9) 62 | rect.setTop(9) 63 | rect.setWidth(rect.width() - 9) 64 | rect.setHeight(rect.height() - 9) 65 | pat.drawRoundedRect(rect, 15, 15) 66 | 67 | 68 | class update_func(QThread): 69 | return_result = pyqtSignal(str) 70 | 71 | def __init__(self): 72 | super().__init__() 73 | self.version = 'Ver.1.1.0_202308281300' 74 | self.api = None 75 | self.result = 'False' 76 | 77 | def run(self): 78 | try: 79 | response = requests.get(self.api) 80 | data = response.json() 81 | latest_version = data['tag_name'] 82 | if self.version != latest_version: 83 | self.result = 'True' 84 | else: 85 | self.result = 'False' 86 | except: 87 | self.result = 'Error' 88 | self.return_result.emit(self.result) 89 | 90 | 91 | class normal_info(QThread): 92 | # 负责与下载进程通讯的线程 93 | get_info_signal = pyqtSignal() # 从主线程获取信息, 以及通知主线程完成下载所需的设置 94 | update_state_signal = pyqtSignal(str) # 更新下载状态, 即基本信息里的state 95 | update_progress_signal = pyqtSignal(int) # 更新下载进度, 即基本信息里的那个圈圈 96 | update_download_data_signal = pyqtSignal(dict) # 更新下载日志 97 | update_basic_info = pyqtSignal(dict) # 更新基本信息 98 | 99 | def __init__(self): 100 | super().__init__() 101 | self.pre_KEY = [] 102 | self.Manager_start = False # 一个旗标变量, 目的是达到自动下载的效果 103 | self.setting_finish = False # 同样是旗标变量, 确保从主线程获取完整的信息以及确保主进程已完成下载所需的设置 104 | self.command = {} # 发送给下载进程的下载参数 105 | self.queue = None 106 | self.pre_progress = None 107 | 108 | def run(self): 109 | self.filter() 110 | 111 | def producer(self, type_info, info): 112 | data_info = {type_info: info} 113 | self.queue.put(data_info) 114 | 115 | def filter(self): 116 | # 用于区分来自下载进程的命令 117 | # 这是为了应对Queue的特性, 防止重复执行 118 | while True: 119 | print('queue running') 120 | try: 121 | info = self.queue.get() 122 | if 'KEY' in info: 123 | if info['KEY'] not in self.pre_KEY: 124 | self.pre_KEY.append(info['KEY']) 125 | if 'state' in info: 126 | self.update_state_signal.emit(info['state']) 127 | if 'progress' in info: 128 | if info['progress'] != self.pre_progress: 129 | self.update_progress_signal.emit(info['progress']) 130 | self.pre_progress = info['progress'] 131 | if 'download_data' in info: 132 | self.update_download_data_signal.emit(info['download_data']) 133 | if 'basic_info' in info: 134 | self.update_basic_info.emit(info['basic_info']) 135 | except: 136 | pass 137 | 138 | 139 | class admin_info(QThread): 140 | finish_signal = pyqtSignal(str) # 完成下载 141 | return_download_url = pyqtSignal(dict) # 把pdf的下载链接更新到文本框 142 | 143 | def __init__(self): 144 | super().__init__() 145 | self.Manager_start = False 146 | self.queue_admin = None 147 | self.finish = False 148 | self.pre_KEY = [] 149 | 150 | def run(self): 151 | while True: 152 | print('admin running') 153 | info_admin = self.queue_admin.get() 154 | if 'KEY' in info_admin: 155 | if info_admin['KEY'] not in self.pre_KEY: 156 | if 'result' in info_admin: 157 | self.finish_signal.emit(info_admin['result']) 158 | self.finish = True 159 | if 'download_url' in info_admin: 160 | self.return_download_url.emit(info_admin['download_url']) 161 | 162 | 163 | class AppCard(CardWidget): 164 | """ App card """ 165 | 166 | def __init__(self, icon, title, content, state=None, parent=None): 167 | 168 | super().__init__(parent) 169 | self.parent_ = parent 170 | self.update_api = [{'text': '通过GitHub检查更新', 171 | 'url': 'https://api.github.com/repos/RicardoJackMC/Teaching-Material-Download-Manager/releases/latest'}, 172 | {'text': '通过Gitee检查更新 (推荐)', 173 | 'url': 'https://gitee.com/api/v5/repos/RicardoJackMC/Teaching-Material-Download-Manager/releases/latest'} 174 | ] 175 | self.feedback_url = [{'text': '前往GitHub上提出Issue', 176 | 'url': 'https://github.com/RicardoJackMC/Teaching-Material-Download-Manager/issues'}, 177 | {'text': '前往Gitee提出Issue (推荐)', 178 | 'url': 'https://gitee.com/RicardoJackMC/Teaching-Material-Download-Manager/issues'}, 179 | {'text': '通过邮件暴击作者 (推荐)', 180 | 'url': 'mailto:ricardojackmc@gmail.com'} 181 | ] 182 | self.repos_url = [ 183 | {'text': '前往GitHub仓库', 184 | 'url': 'https://github.com/RicardoJackMC/Teaching-Material-Download-Manager'}, 185 | {'text': '前往Gitee仓库 (推荐)', 186 | 'url': 'https://gitee.com/RicardoJackMC/Teaching-Material-Download-Manager'} 187 | ] 188 | self.dictionary = {'more_update': self.update_api, 189 | 'more_code': self.repos_url, 190 | 'more_feedback': self.feedback_url} 191 | self.iconWidget = IconWidget(icon) 192 | self.titleLabel = BodyLabel(title, self) 193 | self.contentLabel = CaptionLabel(content, self) 194 | self.tranparentToolButton = TransparentToolButton(FluentIcon.MORE, self) 195 | 196 | self.hBoxLayout = QHBoxLayout(self) 197 | self.vBoxLayout = QVBoxLayout() 198 | 199 | self.setFixedHeight(73) 200 | self.iconWidget.setFixedSize(20, 20) 201 | self.contentLabel.setTextColor("#606060", "#d2d2d2") 202 | self.tranparentToolButton.setFixedWidth(32) 203 | self.hBoxLayout.addWidget(self.tranparentToolButton, 0, Qt.AlignRight) 204 | 205 | self.hBoxLayout.setContentsMargins(20, 11, 11, 11) 206 | self.hBoxLayout.setSpacing(15) 207 | self.hBoxLayout.addWidget(self.iconWidget) 208 | 209 | self.vBoxLayout.setContentsMargins(0, 0, 0, 0) 210 | self.vBoxLayout.setSpacing(0) 211 | self.vBoxLayout.addWidget(self.titleLabel, 0, Qt.AlignVCenter) 212 | self.vBoxLayout.addWidget(self.contentLabel, 0, Qt.AlignVCenter) 213 | self.vBoxLayout.setAlignment(Qt.AlignVCenter) 214 | self.hBoxLayout.addLayout(self.vBoxLayout) 215 | 216 | self.hBoxLayout.addStretch(1) 217 | self.hBoxLayout.addWidget(self.tranparentToolButton, 0, Qt.AlignRight) 218 | 219 | self.tranparentToolButton.clicked.connect(partial(self.button_signal, state)) 220 | 221 | self.update_func = update_func() 222 | self.update_func.return_result.connect(self.update_slot) 223 | 224 | def button_signal(self, state): 225 | if state in self.dictionary: 226 | self.more_menu(state) 227 | else: 228 | self.open_url(state) 229 | 230 | def open_url(self, url): 231 | if 'latest' in url: 232 | self.update_soft(url) 233 | else: 234 | webbrowser.open_new(url) 235 | 236 | def update_soft(self, api): 237 | self.update_func.api = api 238 | self.parent_.state_tool_tip_func() 239 | self.update_func.start() 240 | 241 | def update_slot(self, result): 242 | self.parent_.state_tool_tip_func() 243 | self.parent_.analyze_result(result) 244 | 245 | def more_menu(self, state): 246 | menu = RoundMenu(parent=self) 247 | for item in self.dictionary[state]: 248 | action = Action(FluentIcon.SHARE, item['text'], self) 249 | action.triggered.connect(partial(self.open_url, item['url'])) 250 | menu.addAction(action) 251 | x = (self.tranparentToolButton.width() - menu.sizeHint().width()) // 2 + 10 252 | pos = self.tranparentToolButton.mapToGlobal(QPoint(x, self.tranparentToolButton.height())) 253 | menu.exec(pos) 254 | 255 | 256 | class AboutWindow(RoundWindow, QWidget): 257 | 258 | def __init__(self, parent=None): 259 | super().__init__(parent) 260 | self.stateTooltip = None 261 | 262 | def setupUi(self, QWidget): 263 | self.setObjectName("About") 264 | self.setWindowTitle('About') 265 | self.setWindowIcon(QIcon(':/recourse/logo.ico')) 266 | self.resize(1010, 714) 267 | self.setWindowFlag(QtCore.Qt.FramelessWindowHint) 268 | self.setAttribute(QtCore.Qt.WA_TranslucentBackground) 269 | 270 | self.centralwidget = QtWidgets.QWidget(self) 271 | 272 | QtCore.QMetaObject.connectSlotsByName(self) 273 | 274 | ICON = QLabel(self.centralwidget) 275 | ICON.setGeometry(QtCore.QRect(405, 40, 200, 200)) 276 | pixmap = QPixmap(':/recourse/logo.png') 277 | ICON.setPixmap(pixmap) 278 | ICON.setScaledContents(True) 279 | 280 | title = SubtitleLabel('Teaching Material Download Manager', self.centralwidget) 281 | title.setGeometry(QtCore.QRect(330, 230, 350, 30)) 282 | 283 | copyright_label = BodyLabel('Copyright 2023 by RicardoJackMC', self.centralwidget) 284 | copyright_label.setGeometry(QtCore.QRect(397, 260, 211, 20)) 285 | 286 | version = CaptionLabel('Ver.1.1.0_202308281300', self.centralwidget) 287 | version.setGeometry(QtCore.QRect(439, 284, 127, 10)) 288 | 289 | tip = CaptionLabel('请前往本项目GitHub仓库获取更新或根据版本号校验MD5', self.centralwidget) 290 | tip.setGeometry(QtCore.QRect(348, 295, 310, 20)) 291 | 292 | fight = BodyLabel('!! 坚决反对日本排放福岛核污染水 !!', self.centralwidget) 293 | fight.setGeometry(QtCore.QRect(395, 18, 220, 20)) 294 | 295 | Subtitle_1 = BodyLabel('关于本软件', self.centralwidget) 296 | Subtitle_1.setGeometry(QtCore.QRect(41, 344, 460, 30)) 297 | 298 | card_about_update = AppCard(FluentIcon.CERTIFICATE, "检查更新", 299 | "点击右侧“...”检查更新", 300 | 'more_update', self) 301 | card_about_update.setGeometry(QtCore.QRect(40, 374, 460, 80)) 302 | 303 | card_about_gpl = AppCard(FluentIcon.CERTIFICATE, "本软件使用 GPLv3 许可证", 304 | "点击右侧“...”阅读GPLv3许可证原文", 305 | 'https://www.gnu.org/licenses/gpl-3.0.html#license-text', self.centralwidget) 306 | card_about_gpl.setGeometry(QtCore.QRect(40, 449, 460, 80)) 307 | 308 | card_source_code = AppCard(FluentIcon.CODE, "获取源代码", 309 | "点击右侧“...”访问本软件仓库", 310 | 'more_code', 311 | self.centralwidget) 312 | card_source_code.setGeometry(QtCore.QRect(40, 524, 460, 80)) 313 | 314 | card_feedback = AppCard(FluentIcon.FEEDBACK, "反馈", 315 | "点击右侧“...”联系作者", 316 | state='more_feedback', parent=self.centralwidget) 317 | card_feedback.setGeometry(QtCore.QRect(40, 599, 460, 80)) 318 | 319 | Subtitle_2 = BodyLabel('支持', self.centralwidget) 320 | Subtitle_2.setGeometry(QtCore.QRect(510, 344, 460, 30)) 321 | 322 | card_website = AppCard(FluentIcon.HOME_FILL, "惰猫の小窝", 323 | "点击右侧“...”前往作者的个人网站", 324 | 'https://ricardojackmc.github.io/', self.centralwidget) 325 | card_website.setGeometry(QtCore.QRect(510, 374, 460, 80)) 326 | 327 | card_qfluentwidgets = AppCard(':/recourse/qfluentwidgets_logo.png', "PyQt-Fluent-Widgets", 328 | '本软件界面基于此项目开发, 点击右侧“...”前往该项目GitHub仓库', 329 | 'https://github.com/zhiyiYo/PyQt-Fluent-Widgets', self.centralwidget) 330 | card_qfluentwidgets.setGeometry(QtCore.QRect(510, 449, 460, 30)) 331 | 332 | card_icon = AppCard(FluentIcon.GITHUB, "fluentui-system-icons", 333 | "本软件图标基于此项目制作, 点击右侧“...”前往该项目GitHub仓库", 334 | "https://github.com/microsoft/fluentui-system-icons", self.centralwidget) 335 | card_icon.setGeometry(QtCore.QRect(510, 524, 460, 30)) 336 | 337 | pushButton_close = QPushButton(self.centralwidget) 338 | pushButton_close.setGeometry(QtCore.QRect(20, 20, 15, 15)) 339 | pushButton_close.setMinimumSize(QtCore.QSize(15, 15)) 340 | pushButton_close.setMaximumSize(QtCore.QSize(15, 15)) 341 | pushButton_close.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor)) 342 | pushButton_close.setFocusPolicy(QtCore.Qt.NoFocus) 343 | pushButton_close.setStyleSheet( 344 | "QPushButton{background:#F76677;border-radius:7px;}\n" 345 | "QPushButton:hover{background:red;}") 346 | pushButton_close.setText("") 347 | pushButton_close.setObjectName("pushButton_close") 348 | 349 | pushButton_maximize = QPushButton(self.centralwidget) 350 | pushButton_maximize.setGeometry(QtCore.QRect(40, 20, 15, 15)) 351 | pushButton_maximize.setMinimumSize(QtCore.QSize(15, 15)) 352 | pushButton_maximize.setMaximumSize(QtCore.QSize(15, 15)) 353 | pushButton_maximize.setFocusPolicy(QtCore.Qt.NoFocus) 354 | pushButton_maximize.setStyleSheet( 355 | "QPushButton{background:#F7D674;border-radius:7px;}\n" 356 | "QPushButton:hover{background:yellow;}") 357 | pushButton_maximize.setText("") 358 | pushButton_maximize.setObjectName("pushButton_maximize") 359 | pushButton_maximize.setEnabled(False) 360 | 361 | pushButton_minimize = QPushButton(self.centralwidget) 362 | pushButton_minimize.setGeometry(QtCore.QRect(60, 20, 15, 15)) 363 | pushButton_minimize.setMinimumSize(QtCore.QSize(15, 15)) 364 | pushButton_minimize.setMaximumSize(QtCore.QSize(15, 15)) 365 | pushButton_minimize.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor)) 366 | pushButton_minimize.setFocusPolicy(QtCore.Qt.NoFocus) 367 | pushButton_minimize.setStyleSheet( 368 | "QPushButton{background:#6DDF6D;border-radius:7px;}\n" 369 | "QPushButton:hover{background:green;}") 370 | pushButton_minimize.setText("") 371 | pushButton_minimize.setObjectName("pushButton_minimize") 372 | 373 | pushButton_close.clicked.connect(self.close) 374 | pushButton_minimize.clicked.connect(self.showMinimized) 375 | 376 | def state_tool_tip_func(self): 377 | if self.stateTooltip: 378 | self.stateTooltip.setContent('完成!!!') 379 | self.stateTooltip.setState(True) 380 | self.stateTooltip = None 381 | else: 382 | self.stateTooltip = StateToolTip('正在检查更新', '检查更新中...', self) 383 | self.stateTooltip.move(700, 30) 384 | self.stateTooltip.show() 385 | 386 | def analyze_result(self, result): 387 | if result == 'True': 388 | title = '发现新版本!!!' 389 | content = """可以前往本项目仓库或网盘下载新版本哦!""" 390 | w = Dialog(title, content, self) 391 | w.yesButton.setText('知道辣!') 392 | w.cancelButton.setVisible(False) 393 | if w.exec(): 394 | pass 395 | elif result == 'False': 396 | title = '当前版本是最新版!!!' 397 | content = """当前版本是最新版呢!如果有bug记得告诉作者哦!""" 398 | w = Dialog(title, content, self) 399 | w.yesButton.setText('知道辣!') 400 | w.cancelButton.setVisible(False) 401 | if w.exec(): 402 | pass 403 | elif result == 'Error': 404 | title = '无法检查更新!!!' 405 | content = """建议检查网络设置!如果发现bug记得告诉作者哦!""" 406 | w = Dialog(title, content, self) 407 | w.yesButton.setText('知道辣!') 408 | w.cancelButton.setVisible(False) 409 | if w.exec(): 410 | pass 411 | 412 | def mousePressEvent(self, event): 413 | if event.button() == Qt.LeftButton: 414 | self.mouse_flag = True 415 | self.mouse_Position = event.globalPos() - self.pos() 416 | event.accept() 417 | 418 | def mouseMoveEvent(self, QMouseEvent): 419 | if Qt.LeftButton and self.mouse_flag: 420 | self.move(QMouseEvent.globalPos() - self.mouse_Position) 421 | QMouseEvent.accept() 422 | 423 | def mouseReleaseEvent(self, QMouseEvent): 424 | self.mouse_flag = False 425 | 426 | 427 | class Ui_MainWindow(RoundWindow): 428 | def __init__(self): 429 | super().__init__() 430 | self.queue = None 431 | self.queue_admin = None 432 | self.queue_command = None 433 | 434 | def setupUi(self, MainWindow): 435 | print('setup') 436 | if os.path.isfile('.\\config.json'): 437 | with open('.\\config.json', 'r') as f: 438 | self.config = json.load(f) 439 | 440 | self.folder = self.config['folder'] 441 | self.save_mode = self.config['save_mode'] 442 | self.download_mode = self.config['download_mode'] 443 | self.IDM_path = self.config['IDM_path'] 444 | self.Aria2_url = self.config['Aria2_url'] 445 | self.chunk_size = self.config['chunk_size'] 446 | self.SegmentedWidget_show = self.config['SegmentedWidget_show'] 447 | self.open_folder = self.config['open_folder'] 448 | self.first_open = self.config['first_open'] 449 | 450 | self.download_data = {} 451 | self.command = {} 452 | self.list = [] 453 | self.Download_running = False 454 | self.Task_running = False 455 | self.download_url_display = "## 此项仅选择“获取下载链接”时可用" 456 | self.title = None 457 | self.list_finish = [] 458 | 459 | self.setObjectName("Main") 460 | self.setWindowTitle("Teaching Material Download Manager") 461 | self.setWindowIcon(QIcon(':/recourse/logo.ico')) 462 | self.resize(1000, 540) 463 | 464 | self.setWindowFlag(QtCore.Qt.FramelessWindowHint) 465 | self.setAttribute(QtCore.Qt.WA_TranslucentBackground) 466 | theme_color = self.get_windows_theme_color() 467 | if theme_color is not None: 468 | setThemeColor(QColor(theme_color[0], theme_color[1], theme_color[2])) 469 | 470 | self.SegmentedWidget = SegmentedWidget(self) 471 | self.SegmentedWidget.setGeometry(QtCore.QRect(510, 40, 450, 35)) 472 | self.SegmentedWidget.setMaximumSize(QtCore.QSize(16777215, 16777215)) 473 | self.SegmentedWidget.setObjectName("SegmentedWidget") 474 | 475 | self.IndeterminateProgressRing = IndeterminateProgressRing(self) 476 | self.IndeterminateProgressRing.setGeometry(QtCore.QRect(835, 95, 125, 125)) 477 | self.IndeterminateProgressRing.setMinimumSize(QtCore.QSize(125, 125)) 478 | self.IndeterminateProgressRing.setMaximumSize(QtCore.QSize(125, 125)) 479 | self.IndeterminateProgressRing.setProperty("value", 0) 480 | self.IndeterminateProgressRing.setTextVisible(False) 481 | self.IndeterminateProgressRing.setObjectName("IndeterminateProgressRing") 482 | self.IndeterminateProgressRing.stop() 483 | 484 | self.TableWidget_info = TableWidget(self) 485 | self.TableWidget_info.setGeometry(QtCore.QRect(510, 95, 305, 125)) 486 | self.TableWidget_info.setMaximumSize(QtCore.QSize(16777215, 16777215)) 487 | self.TableWidget_info.setAutoFillBackground(False) 488 | self.TableWidget_info.setLineWidth(1) 489 | self.TableWidget_info.setGridStyle(QtCore.Qt.SolidLine) 490 | self.TableWidget_info.setWordWrap(True) 491 | self.TableWidget_info.setObjectName("TableWidget_info") 492 | self.TableWidget_info.setColumnCount(2) 493 | self.TableWidget_info.setRowCount(5) 494 | 495 | item = QtWidgets.QTableWidgetItem() 496 | item.setText("title") 497 | self.TableWidget_info.setVerticalHeaderItem(0, item) 498 | item = QtWidgets.QTableWidgetItem() 499 | item.setText("ID_A") 500 | self.TableWidget_info.setVerticalHeaderItem(1, item) 501 | item = QtWidgets.QTableWidgetItem() 502 | item.setText("json_url") 503 | self.TableWidget_info.setVerticalHeaderItem(2, item) 504 | item = QtWidgets.QTableWidgetItem() 505 | item.setText("ID_B") 506 | self.TableWidget_info.setVerticalHeaderItem(3, item) 507 | item = QtWidgets.QTableWidgetItem() 508 | item.setText("state") 509 | self.TableWidget_info.setVerticalHeaderItem(4, item) 510 | item = QtWidgets.QTableWidgetItem() 511 | self.TableWidget_info.setHorizontalHeaderItem(0, item) 512 | item = QtWidgets.QTableWidgetItem() 513 | self.TableWidget_info.setHorizontalHeaderItem(1, item) 514 | item = QtWidgets.QTableWidgetItem() 515 | self.TableWidget_info.setItem(0, 0, item) 516 | item = QtWidgets.QTableWidgetItem() 517 | self.TableWidget_info.setItem(1, 0, item) 518 | item = QtWidgets.QTableWidgetItem() 519 | self.TableWidget_info.setItem(2, 0, item) 520 | item = QtWidgets.QTableWidgetItem() 521 | self.TableWidget_info.setItem(3, 0, item) 522 | item = QtWidgets.QTableWidgetItem() 523 | self.TableWidget_info.setItem(4, 0, item) 524 | 525 | self.TableWidget_info.horizontalHeader().setVisible(False) 526 | self.TableWidget_info.horizontalHeader().setDefaultSectionSize(82) 527 | self.TableWidget_info.verticalHeader().setVisible(False) 528 | self.TableWidget_info.verticalHeader().setDefaultSectionSize(25) 529 | self.TableWidget_info.verticalHeader().setMinimumSectionSize(25) 530 | self.TableWidget_info.verticalHeader().setMaximumSectionSize(25) 531 | 532 | self.TableWidget_finished = TableWidget(self) 533 | self.TableWidget_finished.setGeometry(QtCore.QRect(510, 225, 450, 238)) 534 | self.TableWidget_finished.setObjectName("TableWidget_finished") 535 | self.TableWidget_finished.setColumnCount(8) 536 | self.TableWidget_finished.setRowCount(1) 537 | self.TableWidget_finished.horizontalHeader().hide() 538 | self.TableWidget_finished.verticalHeader().hide() 539 | self.TableWidget_finished.installEventFilter(self) 540 | 541 | self.ProgressRing = ProgressRing(self) 542 | self.ProgressRing.setGeometry(QtCore.QRect(835, 95, 125, 125)) 543 | self.ProgressRing.setMinimumSize(QtCore.QSize(125, 125)) 544 | self.ProgressRing.setMaximumSize(QtCore.QSize(125, 125)) 545 | self.ProgressRing.setMaximum(100) 546 | self.ProgressRing.setTextVisible(False) 547 | self.ProgressRing.setObjectName("ProgressRing") 548 | 549 | self.HyperlinkButton_export = HyperlinkButton(self) 550 | self.HyperlinkButton_export.setGeometry(QtCore.QRect(510, 95, 215, 31)) 551 | self.HyperlinkButton_export.setObjectName("HyperlinkButton_export") 552 | 553 | self.HyperlinkButton_clear = HyperlinkButton(self) 554 | self.HyperlinkButton_clear.setGeometry(QtCore.QRect(735, 95, 215, 31)) 555 | self.HyperlinkButton_clear.setObjectName("HyperlinkButton_clear") 556 | 557 | self.HyperlinkButton_about = HyperlinkButton(self) 558 | self.HyperlinkButton_about.setGeometry(QtCore.QRect(510, 463, 450, 32)) 559 | self.HyperlinkButton_about.setObjectName("HyperlinkButton_about") 560 | 561 | self.ListWidget_data = ListWidget(self) 562 | self.ListWidget_data.setGeometry(QtCore.QRect(510, 146, 450, 297)) 563 | self.ListWidget_data.setObjectName("ListWidget_data") 564 | 565 | self.LineEdit_url = LineEdit(self) 566 | self.LineEdit_url.setGeometry(QtCore.QRect(40, 40, 450, 33)) 567 | self.LineEdit_url.setObjectName("LineEdit_url") 568 | 569 | self.PushButton_add = PushButton(self) 570 | self.PushButton_add.setGeometry(QtCore.QRect(40, 285, 450, 32)) 571 | self.PushButton_add.setObjectName("PushButton_add") 572 | 573 | self.ComboBox_mode = ComboBox(self) 574 | self.ComboBox_mode.setGeometry(QtCore.QRect(40, 83, 450, 32)) 575 | self.ComboBox_mode.setObjectName("ComboBox_mode") 576 | for i in range(4): 577 | self.ComboBox_mode.addItem('') 578 | 579 | self.SwitchButton_open = SwitchButton(self) 580 | self.SwitchButton_open.setGeometry(QtCore.QRect(270, 210, 220, 22)) 581 | self.SwitchButton_open.setMinimumSize(QtCore.QSize(220, 22)) 582 | self.SwitchButton_open.setMaximumSize(QtCore.QSize(220, 33)) 583 | self.SwitchButton_open.setLayoutDirection(QtCore.Qt.RightToLeft) 584 | self.SwitchButton_open.setAutoFillBackground(False) 585 | self.SwitchButton_open.setChecked(True) 586 | self.SwitchButton_open.setObjectName("SwitchButton_open") 587 | 588 | self.BodyLabel_open = BodyLabel(self) 589 | self.BodyLabel_open.setGeometry(QtCore.QRect(40, 210, 361, 22)) 590 | self.BodyLabel_open.setObjectName("BodyLabel_open") 591 | 592 | self.SpinBox_size = SpinBox(self) 593 | self.SpinBox_size.setGeometry(QtCore.QRect(270, 242, 177, 33)) 594 | self.SpinBox_size.setMaximum(1000000) 595 | self.SpinBox_size.setSingleStep(1) 596 | self.SpinBox_size.setProperty("value", 1024) 597 | self.SpinBox_size.setObjectName("SpinBox_size") 598 | 599 | self.BodyLabel_size = BodyLabel(self) 600 | self.BodyLabel_size.setGeometry(QtCore.QRect(40, 242, 201, 33)) 601 | self.BodyLabel_size.setObjectName("BodyLabel_size") 602 | 603 | self.LineEdit_path = LineEdit(self) 604 | self.LineEdit_path.setGeometry(QtCore.QRect(40, 167, 364, 33)) 605 | self.LineEdit_path.setObjectName("LineEdit_path") 606 | 607 | self.ToolButton_path_ok = ToolButton(FluentIcon.ACCEPT, self) 608 | self.ToolButton_path_ok.setGeometry(QtCore.QRect(457, 167, 33, 33)) 609 | self.ToolButton_path_ok.setText("") 610 | self.ToolButton_path_ok.setObjectName("ToolButton_path_ok") 611 | 612 | self.ToolButton_path_find = ToolButton(FluentIcon.MORE, self) 613 | self.ToolButton_path_find.setGeometry(QtCore.QRect(414, 167, 33, 33)) 614 | self.ToolButton_path_find.setText("") 615 | self.ToolButton_path_find.setObjectName("ToolButton_path_find") 616 | 617 | self.TextEdit = TextEdit(self) 618 | self.TextEdit.setGeometry(QtCore.QRect(510, 95, 450, 348)) 619 | self.TextEdit.setObjectName("TextEdit") 620 | self.TextEdit.setMarkdown(self.download_url_display) 621 | 622 | self.TableWidget = TableWidget(self) 623 | self.TableWidget.setGeometry(QtCore.QRect(40, 327, 450, 169)) 624 | self.TableWidget.setObjectName("TableWidget") 625 | self.TableWidget.setColumnCount(8) 626 | self.TableWidget.setRowCount(1) 627 | self.TableWidget.horizontalHeader().hide() 628 | self.TableWidget.verticalHeader().hide() 629 | self.TableWidget.installEventFilter(self) 630 | 631 | self.ToolButton_size = ToolButton(FluentIcon.QUESTION, self) 632 | self.ToolButton_size.setGeometry(QtCore.QRect(457, 242, 33, 33)) 633 | self.ToolButton_size.setObjectName("ToolButton_size") 634 | 635 | self.ComboBox_same = ComboBox(self) 636 | self.ComboBox_same.setGeometry(QtCore.QRect(270, 125, 220, 32)) 637 | self.ComboBox_same.setObjectName("ComboBox_same") 638 | for i in range(3): 639 | self.ComboBox_same.addItem('') 640 | 641 | self.BodyLabel_same = BodyLabel(self) 642 | self.BodyLabel_same.setGeometry(QtCore.QRect(40, 125, 220, 32)) 643 | self.BodyLabel_same.setObjectName("BodyLabel_same") 644 | 645 | self.ToolButton_path_find_IDM = ToolButton(FluentIcon.MORE, self) 646 | self.ToolButton_path_find_IDM.setGeometry(QtCore.QRect(414, 210, 33, 33)) 647 | self.ToolButton_path_find_IDM.setText("") 648 | self.ToolButton_path_find_IDM.setObjectName("ToolButton_path_find_IDM") 649 | 650 | self.LineEdit_path_IDM = LineEdit(self) 651 | self.LineEdit_path_IDM.setGeometry(QtCore.QRect(40, 210, 364, 33)) 652 | self.LineEdit_path_IDM.setObjectName("LineEdit_path_IDM") 653 | 654 | self.ToolButton_path_ok_IDM = ToolButton(FluentIcon.ACCEPT, self) 655 | self.ToolButton_path_ok_IDM.setGeometry(QtCore.QRect(457, 210, 33, 33)) 656 | self.ToolButton_path_ok_IDM.setText("") 657 | self.ToolButton_path_ok_IDM.setObjectName("ToolButton_path_ok_IDM") 658 | 659 | self.LineEdit_url_aria2 = LineEdit(self) 660 | self.LineEdit_url_aria2.setGeometry(QtCore.QRect(40, 210, 407, 33)) 661 | self.LineEdit_url_aria2.setObjectName("LineEdit_url_aria2") 662 | 663 | self.ToolButton_url_aria2_ok = ToolButton(FluentIcon.ACCEPT, self) 664 | self.ToolButton_url_aria2_ok.setGeometry(QtCore.QRect(457, 210, 33, 33)) 665 | self.ToolButton_url_aria2_ok.setText("") 666 | self.ToolButton_url_aria2_ok.setObjectName("ToolButton_url_aria2_ok") 667 | 668 | self.pushButton_close = QPushButton(self) 669 | self.pushButton_close.setGeometry(QtCore.QRect(20, 20, 15, 15)) 670 | self.pushButton_close.setMinimumSize(QtCore.QSize(15, 15)) 671 | self.pushButton_close.setMaximumSize(QtCore.QSize(15, 15)) 672 | self.pushButton_close.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor)) 673 | self.pushButton_close.setFocusPolicy(QtCore.Qt.NoFocus) 674 | self.pushButton_close.setStyleSheet( 675 | "QPushButton{background:#F76677;border-radius:7px;}\n" 676 | "QPushButton:hover{background:red;}") 677 | self.pushButton_close.setText("") 678 | self.pushButton_close.setObjectName("pushButton_close") 679 | 680 | self.pushButton_maximize = QPushButton(self) 681 | self.pushButton_maximize.setGeometry(QtCore.QRect(40, 20, 15, 15)) 682 | self.pushButton_maximize.setMinimumSize(QtCore.QSize(15, 15)) 683 | self.pushButton_maximize.setMaximumSize(QtCore.QSize(15, 15)) 684 | self.pushButton_maximize.setFocusPolicy(QtCore.Qt.NoFocus) 685 | self.pushButton_maximize.setStyleSheet( 686 | "QPushButton{background:#F7D674;border-radius:7px;}\n" 687 | "QPushButton:hover{background:yellow;}") 688 | self.pushButton_maximize.setText("") 689 | self.pushButton_maximize.setObjectName("pushButton_maximize") 690 | self.pushButton_maximize.setEnabled(False) 691 | 692 | self.pushButton_minimize = QPushButton(self) 693 | self.pushButton_minimize.setGeometry(QtCore.QRect(60, 20, 15, 15)) 694 | self.pushButton_minimize.setMinimumSize(QtCore.QSize(15, 15)) 695 | self.pushButton_minimize.setMaximumSize(QtCore.QSize(15, 15)) 696 | self.pushButton_minimize.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor)) 697 | self.pushButton_minimize.setFocusPolicy(QtCore.Qt.NoFocus) 698 | self.pushButton_minimize.setStyleSheet( 699 | "QPushButton{background:#6DDF6D;border-radius:7px;}\n" 700 | "QPushButton:hover{background:green;}") 701 | self.pushButton_minimize.setText("") 702 | self.pushButton_minimize.setObjectName("pushButton_minimize") 703 | 704 | self.Normal_Info = normal_info() 705 | self.Normal_Info.queue = self.queue 706 | 707 | self.Normal_Info.update_state_signal.connect(self.update_state_slot) 708 | self.Normal_Info.update_progress_signal.connect(self.update_progress_slot) 709 | self.Normal_Info.update_download_data_signal.connect(self.update_download_data_slot) 710 | self.Normal_Info.update_basic_info.connect(self.update_basic_info) 711 | self.Normal_Info.start() 712 | 713 | self.Admin_Info = admin_info() 714 | self.Admin_Info.queue_admin = self.queue_admin 715 | self.Admin_Info.finish_signal.connect(self.download_finish) 716 | self.Admin_Info.return_download_url.connect(self.update_download_url) 717 | self.Admin_Info.start() 718 | 719 | self.retranslateUi() 720 | 721 | QtCore.QMetaObject.connectSlotsByName(self) 722 | 723 | self.ComboBox_mode.currentIndexChanged.connect(self.ComboBox_mode_change) 724 | self.ComboBox_same.currentIndexChanged.connect(self.ComboBox_same_change) 725 | self.LineEdit_path.textChanged.connect(self.LineEdit_path_change) 726 | self.LineEdit_path.returnPressed.connect(self.confirm_folder) 727 | self.ToolButton_path_ok.clicked.connect(self.confirm_folder) 728 | self.ToolButton_path_find.clicked.connect(self.choose_folder) 729 | self.SwitchButton_open.checkedChanged.connect(self.switch_change) 730 | self.SpinBox_size.valueChanged[int].connect(self.chunk_size_change) 731 | self.ToolButton_size.clicked.connect(self.chunk_size_dialog) 732 | self.LineEdit_path_IDM.textChanged.connect(self.LineEdit_path_IDM_change) 733 | self.LineEdit_path_IDM.returnPressed.connect(self.confirm_IDM_path) 734 | self.ToolButton_path_ok_IDM.clicked.connect(self.confirm_IDM_path) 735 | self.ToolButton_path_find_IDM.clicked.connect(self.choose_IDM_path) 736 | self.LineEdit_url_aria2.returnPressed.connect(self.LineEdit_url_aria2_change) 737 | self.ToolButton_url_aria2_ok.clicked.connect(self.LineEdit_url_aria2_change) 738 | self.HyperlinkButton_clear.clicked.connect(self.clear_download_data) 739 | self.HyperlinkButton_export.clicked.connect(self.export_download_data) 740 | self.HyperlinkButton_about.clicked.connect(self.about) 741 | self.PushButton_add.clicked.connect(self.add_command) 742 | self.LineEdit_url.returnPressed.connect(self.add_command) 743 | self.pushButton_close.clicked.connect(self.close) 744 | self.pushButton_minimize.clicked.connect(self.showMinimized) 745 | self.TableWidget.setContextMenuPolicy(Qt.CustomContextMenu) 746 | self.TableWidget.customContextMenuRequested.connect(self.show_list_menu) 747 | self.TableWidget_finished.setContextMenuPolicy(Qt.CustomContextMenu) 748 | self.TableWidget_finished.customContextMenuRequested.connect(self.show_finish_menu) 749 | 750 | self.SegmentedWidget.setCurrentItem(self.SegmentedWidget_show) 751 | if self.SegmentedWidget_show == 'basic_info': 752 | self.show_basic_info() 753 | elif self.SegmentedWidget_show == 'download_link': 754 | self.show_download_link() 755 | elif self.SegmentedWidget_show == 'download_data': 756 | self.show_download_data() 757 | self.ComboBox_mode.setCurrentIndex(self.download_mode) 758 | self.ComboBox_same.setCurrentIndex(self.save_mode) 759 | self.confirm_folder(source='start') 760 | self.SwitchButton_open.setChecked(self.open_folder) 761 | self.SpinBox_size.setValue(self.chunk_size) 762 | self.confirm_IDM_path(source='start') 763 | self.LineEdit_url_aria2_change(source='start') 764 | self.ComboBox_mode_change(self.download_mode) 765 | self.ComboBox_same_change(self.save_mode) 766 | 767 | def retranslateUi(self): 768 | self._translate = QtCore.QCoreApplication.translate 769 | self.setWindowTitle(self._translate("Teaching Material Download Manager", "Teaching Material Download Manager")) 770 | header = ['链接', '下载模式', '保存路径', '当出现相同文件时', 'chunk_size', 'IDM位置', 'Aria2地址', 771 | '完成下载后是否打开文件夹'] 772 | for index, i in enumerate(header): 773 | self.TableWidget.setItem(0, index, QTableWidgetItem(i)) 774 | self.TableWidget_finished.setItem(0, index, QTableWidgetItem(i)) 775 | self.TableWidget.item(0, index).setFlags(self.TableWidget.item(0, index).flags() & ~Qt.ItemIsSelectable) 776 | self.TableWidget_finished.item(0, index).setFlags( 777 | self.TableWidget_finished.item(0, index).flags() & ~Qt.ItemIsSelectable) 778 | item = self.TableWidget_info.horizontalHeaderItem(0) 779 | item.setText(self._translate("MainWindow", "新建列")) 780 | item = self.TableWidget_info.horizontalHeaderItem(1) 781 | item.setText(self._translate("MainWindow", "新建列")) 782 | __sortingEnabled = self.TableWidget_info.isSortingEnabled() 783 | self.TableWidget_info.setSortingEnabled(False) 784 | item = self.TableWidget_info.item(0, 0) 785 | item.setText(self._translate("MainWindow", "title")) 786 | item.setFlags(item.flags() & ~Qt.ItemIsSelectable) 787 | item = self.TableWidget_info.item(1, 0) 788 | item.setText(self._translate("MainWindow", "ID_A")) 789 | item.setFlags(item.flags() & ~Qt.ItemIsSelectable) 790 | item = self.TableWidget_info.item(2, 0) 791 | item.setText(self._translate("MainWindow", "json_url")) 792 | item.setFlags(item.flags() & ~Qt.ItemIsSelectable) 793 | item = self.TableWidget_info.item(3, 0) 794 | item.setText(self._translate("MainWindow", "ID_B")) 795 | item.setFlags(item.flags() & ~Qt.ItemIsSelectable) 796 | item = self.TableWidget_info.item(4, 0) 797 | item.setText(self._translate("MainWindow", "state")) 798 | item.setFlags(item.flags() & ~Qt.ItemIsSelectable) 799 | self.TableWidget_info.setSortingEnabled(__sortingEnabled) 800 | for index in range(5): 801 | self.TableWidget_info.item(index, 0).setFlags( 802 | self.TableWidget_info.item(index, 0).flags() & ~Qt.ItemIsSelectable) 803 | self.ProgressRing.setFormat(self._translate("MainWindow", "")) 804 | self.HyperlinkButton_export.setText(self._translate("MainWindow", "导出下载日志")) 805 | self.HyperlinkButton_clear.setText(self._translate("MainWindow", "清空下载日志")) 806 | self.HyperlinkButton_about.setText(self._translate("MainWindow", "关于本软件")) 807 | self.PushButton_add.setText(self._translate("MainWindow", "下载")) 808 | self.SwitchButton_open.setOnText(self._translate("MainWindow", "打开")) 809 | self.SwitchButton_open.setOffText(self._translate("MainWindow", "不打开")) 810 | self.BodyLabel_open.setText(self._translate("MainWindow", "下载完成后是否打开文件夹: ")) 811 | self.BodyLabel_size.setText(self._translate("MainWindow", "设置chunk_size的大小(单位KB): ")) 812 | self.BodyLabel_same.setText(self._translate("MainWindow", "当出现同名文件时:")) 813 | self.ComboBox_same.setItemText(0, self._translate("MainWindow", "覆盖")) 814 | self.ComboBox_same.setItemText(1, self._translate("MainWindow", "添加数字后缀")) 815 | self.ComboBox_same.setItemText(2, self._translate("MainWindow", "添加时间后缀")) 816 | self.ComboBox_mode.setItemText(0, self._translate("MainWindow", "使用软件内建下载")) 817 | self.ComboBox_mode.setItemText(1, self._translate("MainWindow", "调用IDM下载器下载")) 818 | self.ComboBox_mode.setItemText(2, self._translate("MainWindow", "发送到Aria2服务器下载")) 819 | self.ComboBox_mode.setItemText(3, self._translate("MainWindow", "仅获取下载链接")) 820 | self.SegmentedWidget.addItem('basic_info', '基本信息', onClick=self.show_basic_info) 821 | self.SegmentedWidget.addItem('download_link', '下载链接', onClick=self.show_download_link) 822 | self.SegmentedWidget.addItem('download_data', '下载日志', onClick=self.show_download_data) 823 | self.LineEdit_url.setPlaceholderText(self._translate("MainWindow", "输入教材的网址")) 824 | self.LineEdit_path.setPlaceholderText( 825 | self._translate("MainWindow", "在这里输入保存教材的文件夹地址,或点击...选择文件夹")) 826 | self.LineEdit_path_IDM.setPlaceholderText( 827 | self._translate("MainWindow", "在这里输入IDMan.exe的位置,或点击...选择")) 828 | self.LineEdit_url_aria2.setPlaceholderText(self._translate("MainWindow", "在这里输入Aria2服务器地址")) 829 | 830 | def mousePressEvent(self, event): 831 | if event.button() == Qt.LeftButton: 832 | self.mouse_flag = True 833 | self.mouse_Position = event.globalPos() - self.pos() 834 | event.accept() 835 | 836 | def mouseMoveEvent(self, QMouseEvent): 837 | if Qt.LeftButton and self.mouse_flag: 838 | self.move(QMouseEvent.globalPos() - self.mouse_Position) 839 | QMouseEvent.accept() 840 | 841 | def mouseReleaseEvent(self, QMouseEvent): 842 | self.mouse_flag = False 843 | 844 | def closeEvent(self, event): 845 | title = '是否退出软件' 846 | content = """请确认所有下载任务已完成, 否则可能会导致下载失败!!!""" 847 | w = Dialog(title, content, self) 848 | if w.exec(): 849 | self.queue_command.put('CLOSE') 850 | event.accept() 851 | QCoreApplication.quit() 852 | sys.exit() 853 | else: 854 | event.ignore() 855 | 856 | def welcome_dialog(self): 857 | if self.first_open == 1: 858 | title = '欢迎使用 Teaching Material Download Manager' 859 | content = """请认真阅读以下内容, 如果您不同意以下任意内容, 请立即退出本软件:\n\n 1.本软件使用GPLv3许可证, 请根据GPLv3许可证正确行使您拥有的关于\n 本软件的权力以及您应履行的义务, 您可以点击“关于此软件”并在弹出 860 | 的窗口中阅读 GPLv3 的原文。\n\n 2.请尊重教材编者和作者的劳动果实, 在中华人民共和国的法律范围内\n 使用本软件及电子教材。""" 861 | w = Dialog(title, content, self) 862 | w.yesButton.setText('同意') 863 | w.cancelButton.setText('不同意') 864 | if w.exec(): 865 | self.first_open = False 866 | self.save_config('first_open', self.first_open) 867 | else: 868 | self.queue_command.put('CLOSE') 869 | QCoreApplication.quit() 870 | sys.exit() 871 | 872 | def download_finish(self, state): 873 | self.Task_running = False 874 | self.IndeterminateProgressRing.stop() 875 | self.ProgressRing.setValue(0) 876 | self.ProgressRing.setTextVisible(False) 877 | 878 | self.display = self.title 879 | if self.display is None: 880 | self.display = self.list[0]['url_A'] 881 | self.TableWidget_finished.setRowCount(self.TableWidget_finished.rowCount() + 1) 882 | for item in range(8): 883 | i = self.TableWidget.item(1, item).text() 884 | self.TableWidget_finished.setItem(self.TableWidget_finished.rowCount() - 1, item, 885 | QTableWidgetItem(i)) 886 | 887 | self.TableWidget_finished.resizeColumnsToContents() 888 | self.TableWidget_finished.resizeRowsToContents() 889 | self.TableWidget.removeRow(1) 890 | if self.list[0]['open_folder'] and self.list[0]['download_mode'] == 0: 891 | os.startfile(self.list[0]['save_path']) 892 | self.list_finish.append(self.list[0]) 893 | self.list.pop(0) 894 | 895 | for i in range(5): 896 | self.TableWidget_info.setItem(i, 1, QTableWidgetItem('')) 897 | if state == 'normal': 898 | self.successful_info(self.display) 899 | elif state == 'warning': 900 | self.warning_info(self.display) 901 | elif state == 'error': 902 | self.error_info(self.display) 903 | elif state == 'ID_A error': 904 | self.ID_A_ERROR_info(self.display) 905 | 906 | if len(self.list) != 0: 907 | self.start() 908 | else: 909 | self.Download_running = False 910 | 911 | def successful_info(self, url): 912 | InfoBar.success( 913 | title='成功处理', 914 | content="已成功处理:" + url, 915 | orient=Qt.Horizontal, 916 | isClosable=True, 917 | position=InfoBarPosition.BOTTOM_RIGHT, 918 | duration=18000, 919 | parent=self 920 | ) 921 | 922 | def ID_A_ERROR_info(self, url): 923 | InfoBar.error( 924 | title='网址错误', 925 | content="无法处理:" + url + "请输入正确的网址后再试一次", 926 | orient=Qt.Horizontal, 927 | isClosable=True, 928 | position=InfoBarPosition.BOTTOM_RIGHT, 929 | duration=20000, 930 | parent=self 931 | ) 932 | 933 | def error_info(self, url): 934 | InfoBar.error( 935 | title='处理失败', 936 | content="无法处理:" + url + "建议检查网络连接, 并在试一次,\n若你想支持本软件的开发, 请导出下载日志并将其发送到 ricardojackmc@gmail.com", 937 | orient=Qt.Horizontal, 938 | isClosable=True, 939 | position=InfoBarPosition.BOTTOM_RIGHT, 940 | duration=20000, 941 | parent=self 942 | ) 943 | 944 | def warning_info(self, url): 945 | InfoBar.warning( 946 | title='成功处理, 但出现了一些问题', 947 | content="处理 " + url + " 时出现了一些问题,\n但是如你所见, 文件应该已经成功保存到此电脑或成功发送至指定下载器,\n若你想支持本软件的开发, 请导出下载日志并将其发送到 ricardojackmc@gmail.com", 948 | orient=Qt.Horizontal, 949 | isClosable=True, 950 | position=InfoBarPosition.BOTTOM_RIGHT, 951 | duration=20000, 952 | parent=self 953 | ) 954 | 955 | def update_basic_info(self, info): 956 | if 'title' in info: 957 | self.TableWidget_info.setItem(0, 1, QTableWidgetItem(info['title'])) 958 | self.title = info['title'] 959 | elif 'ID_A' in info: 960 | self.TableWidget_info.setItem(1, 1, QTableWidgetItem(info['ID_A'])) 961 | elif 'json_url' in info: 962 | self.TableWidget_info.setItem(2, 1, QTableWidgetItem(info['json_url'])) 963 | elif 'ID_B' in info: 964 | self.TableWidget_info.setItem(3, 1, QTableWidgetItem(info['ID_B'])) 965 | self.TableWidget_info.resizeColumnsToContents() 966 | self.TableWidget_info.resizeRowsToContents() 967 | 968 | def add_command(self): 969 | 970 | element = {} 971 | key = ['url_A', 'download_mode', 'save_path', 'save_mode', 'chunk_size', 'IDM_path', 'Aria2_url', 'open_folder'] 972 | value = [self.LineEdit_url.text(), self.download_mode, self.folder, self.save_mode, self.chunk_size, 973 | self.IDM_path, self.Aria2_url, self.open_folder] 974 | self.TableWidget.setRowCount(self.TableWidget.rowCount() + 1) 975 | for index, item in enumerate(value): 976 | self.TableWidget.setItem(self.TableWidget.rowCount() - 1, index, QTableWidgetItem(str(item))) 977 | element[key[index]] = item 978 | 979 | self.list.append(element) 980 | self.LineEdit_url.clear() 981 | self.TableWidget.resizeColumnsToContents() 982 | self.TableWidget.resizeRowsToContents() 983 | 984 | if not self.Download_running: 985 | self.Download_running = True 986 | self.start() 987 | 988 | def start(self): 989 | self.confirm_folder(source='chosen', state='force') 990 | if self.list[0]['download_mode'] == 1: 991 | self.confirm_IDM_path(source='chosen', state='force') 992 | self.command = self.list[0] 993 | self.TableWidget.selectRow(1) 994 | self.IndeterminateProgressRing.start() 995 | self.ProgressRing.setFormat('loading...') 996 | self.ProgressRing.setTextVisible(True) 997 | self.command['key'] = time.time() 998 | data_info = {'command': self.command} 999 | self.queue_command.put(data_info) 1000 | self.Task_running = True 1001 | 1002 | def update_download_data_slot(self, data): 1003 | for key in data.keys(): 1004 | if key not in self.download_data: 1005 | item = QListWidgetItem(data[key]) 1006 | self.ListWidget_data.addItem(item) 1007 | self.ListWidget_data.setCurrentItem(item) 1008 | self.ListWidget_data.scrollToItem(item, QtWidgets.QAbstractItemView.PositionAtBottom) 1009 | self.download_data.update(data) 1010 | 1011 | def update_download_url(self, data): 1012 | self.download_url_display = self.download_url_display + '\n \n#### · ' + data['title'] + ' :\n' + data[ 1013 | 'download_url'] 1014 | self.TextEdit.setMarkdown(self.download_url_display) 1015 | 1016 | def update_progress_slot(self, value): 1017 | self.IndeterminateProgressRing.stop() 1018 | if self.Task_running: 1019 | self.ProgressRing.setValue(value) 1020 | self.ProgressRing.setFormat('已下载: ' + '%p%') 1021 | 1022 | def update_state_slot(self, info): 1023 | self.TableWidget_info.setItem(4, 1, QTableWidgetItem(info)) 1024 | 1025 | def save_config(self, config_type, info): 1026 | self.config[config_type] = info 1027 | with open('config.json', 'w') as f: 1028 | json.dump(self.config, f) 1029 | 1030 | def show_basic_info(self): 1031 | self.SegmentedWidget_show = 'basic_info' 1032 | self.save_config('SegmentedWidget_show', self.SegmentedWidget_show) 1033 | self.set_basic_info(True) 1034 | self.set_download_link(False) 1035 | self.set_download_data(False) 1036 | 1037 | def show_download_link(self): 1038 | self.SegmentedWidget_show = 'download_link' 1039 | self.save_config('SegmentedWidget_show', self.SegmentedWidget_show) 1040 | self.set_basic_info(False) 1041 | self.set_download_link(True) 1042 | self.set_download_data(False) 1043 | 1044 | def show_download_data(self): 1045 | self.SegmentedWidget_show = 'download_data' 1046 | self.save_config('SegmentedWidget_show', self.SegmentedWidget_show) 1047 | self.set_basic_info(False) 1048 | self.set_download_link(False) 1049 | self.set_download_data(True) 1050 | 1051 | def set_basic_info(self, state): 1052 | self.TableWidget_info.setVisible(state) 1053 | self.TableWidget_finished.setVisible(state) 1054 | self.ProgressRing.setVisible(state) 1055 | self.IndeterminateProgressRing.setVisible(state) 1056 | 1057 | def set_download_data(self, state): 1058 | self.HyperlinkButton_export.setVisible(state) 1059 | self.HyperlinkButton_clear.setVisible(state) 1060 | self.ListWidget_data.setVisible(state) 1061 | 1062 | def set_download_link(self, state): 1063 | self.TextEdit.setVisible(state) 1064 | 1065 | def ComboBox_mode_change(self, index): 1066 | self.download_mode = index 1067 | self.save_config('download_mode', self.download_mode) 1068 | if index == 0: 1069 | self.show_basic_download() 1070 | elif index == 1: 1071 | self.show_IDM_download() 1072 | elif index == 2: 1073 | self.show_Aria2_download() 1074 | elif index == 3: 1075 | self.show_PDF_link() 1076 | 1077 | def show_basic_download(self): 1078 | self.set_bottom_setting(True) 1079 | self.set_basic_download(True) 1080 | self.set_IDM_download(False) 1081 | self.set_Aria2_download(False) 1082 | 1083 | def show_IDM_download(self): 1084 | self.set_bottom_setting(True) 1085 | self.set_basic_download(False) 1086 | self.set_IDM_download(True) 1087 | self.set_Aria2_download(False) 1088 | 1089 | def show_Aria2_download(self): 1090 | self.set_bottom_setting(True) 1091 | self.set_basic_download(False) 1092 | self.set_IDM_download(False) 1093 | self.set_Aria2_download(True) 1094 | 1095 | def show_PDF_link(self): 1096 | self.set_bottom_setting(False) 1097 | self.set_basic_download(False) 1098 | self.set_IDM_download(False) 1099 | self.set_Aria2_download(False) 1100 | self.set_PDF_link() 1101 | 1102 | def set_bottom_setting(self, state): 1103 | self.BodyLabel_same.setVisible(state) 1104 | self.ComboBox_same.setVisible(state) 1105 | self.LineEdit_path.setVisible(state) 1106 | self.ToolButton_path_ok.setVisible(state) 1107 | self.ToolButton_path_find.setVisible(state) 1108 | 1109 | def set_basic_download(self, state): 1110 | self.SwitchButton_open.setVisible(state) 1111 | self.BodyLabel_open.setVisible(state) 1112 | self.BodyLabel_size.setVisible(state) 1113 | self.SpinBox_size.setVisible(state) 1114 | self.ToolButton_size.setVisible(state) 1115 | 1116 | def set_IDM_download(self, state): 1117 | self.LineEdit_path_IDM.setVisible(state) 1118 | self.ToolButton_path_ok_IDM.setVisible(state) 1119 | self.ToolButton_path_find_IDM.setVisible(state) 1120 | 1121 | def set_Aria2_download(self, state): 1122 | self.LineEdit_url_aria2.setVisible(state) 1123 | self.ToolButton_url_aria2_ok.setVisible(state) 1124 | 1125 | def set_PDF_link(self): 1126 | self.SegmentedWidget.setCurrentItem('download_link') 1127 | self.show_download_link() 1128 | 1129 | def ComboBox_same_change(self, index): 1130 | self.save_mode = index 1131 | self.save_config('save_mode', self.save_mode) 1132 | 1133 | def confirm_folder(self, source=None, state=None): 1134 | if source == 'start': 1135 | if os.path.isdir(self.folder): 1136 | self.LineEdit_path.setText(self.folder) 1137 | self.save_config('folder', self.folder) 1138 | self.ToolButton_path_ok.setEnabled(False) 1139 | elif source == 'chosen': 1140 | if os.path.isdir(self.folder): 1141 | self.LineEdit_path.setText(self.folder) 1142 | self.save_config('folder', self.folder) 1143 | self.ToolButton_path_ok.setEnabled(False) 1144 | if state == 'force': 1145 | if not os.path.isdir(self.list[0]['save_path']): 1146 | self.list[0]['save_path'] = self.folder 1147 | else: 1148 | self.path_wrong_warning_dialog(state=state) 1149 | else: 1150 | if os.path.isdir(self.LineEdit_path.text()): 1151 | self.folder = self.LineEdit_path.text() 1152 | self.save_config('folder', self.folder) 1153 | self.ToolButton_path_ok.setEnabled(False) 1154 | else: 1155 | self.path_wrong_warning_dialog() 1156 | 1157 | def path_wrong_warning_dialog(self, state=None): 1158 | title = '当前路径不可用' 1159 | content = """点击下方OK按钮后在弹出的窗口中浏览并选择文件夹""" 1160 | w = Dialog(title, content, self) 1161 | if w.exec(): 1162 | self.choose_folder(state=state) 1163 | else: 1164 | if state == 'force': 1165 | self.confirm_folder(source='chosen', state=state) 1166 | 1167 | def choose_folder(self, state=None): 1168 | chosen_fold = QtWidgets.QFileDialog.getExistingDirectory(None, "选取文件夹", 1169 | os.path.expanduser('~') + '\\document') 1170 | if chosen_fold: 1171 | if not chosen_fold.endswith('\\'): 1172 | self.folder = chosen_fold + '\\' 1173 | self.confirm_folder(source='chosen', state=state) 1174 | 1175 | def LineEdit_path_change(self): 1176 | self.ToolButton_path_ok.setEnabled(True) 1177 | 1178 | def switch_change(self): 1179 | self.open_folder = self.SwitchButton_open.isChecked() 1180 | self.save_config('open_folder', self.open_folder) 1181 | 1182 | def chunk_size_change(self, value): 1183 | self.chunk_size = value 1184 | self.save_config('chunk_size', self.chunk_size) 1185 | 1186 | def chunk_size_dialog(self): 1187 | Flyout.create( 1188 | icon=InfoBarIcon.INFORMATION, 1189 | title='什么是 chunk_size ? 如何设置 chunk_size ?', 1190 | content="软件会把PDF文件切成很多“小块”, 再下载这些小块, chunk_size 就是这些“小块”的大小.\nchunk_size 过大可能会导致内存占用增加, chunk_size 过小则会导致下载速度太慢.\n此处建议综合考虑自己电脑的内存大小, 网速和内存占用情况合理设置 chunk_size 的大小.", 1191 | target=self.ToolButton_size, 1192 | parent=self, 1193 | isClosable=True 1194 | ) 1195 | 1196 | def confirm_IDM_path(self, source=None, state=None): 1197 | if source == 'start': 1198 | if os.path.isfile(self.IDM_path) and os.path.basename(self.IDM_path) == 'IDMan.exe': 1199 | self.LineEdit_path_IDM.setText(self.IDM_path) 1200 | self.ToolButton_path_ok_IDM.setEnabled(False) 1201 | elif source == 'chosen': 1202 | if os.path.isfile(self.IDM_path) and os.path.basename(self.IDM_path) == 'IDMan.exe': 1203 | self.LineEdit_path_IDM.setText(self.IDM_path) 1204 | self.ToolButton_path_ok_IDM.setEnabled(False) 1205 | if state == 'force': 1206 | if not os.path.isfile(self.list[0]['IDM_path']) and os.path.basename( 1207 | self.list[0]['IDM_path']) == 'IDMan.exe': 1208 | self.list[0]['IDM_path'] = self.IDM_path 1209 | self.save_config('IDM_path', self.IDM_path) 1210 | else: 1211 | self.IDM_path_wrong_warning_dialog(state=state) 1212 | else: 1213 | if os.path.isfile(self.IDM_path) and os.path.basename(self.IDM_path) == 'IDMan.exe': 1214 | self.LineEdit_path_IDM.setText(self.IDM_path) 1215 | self.ToolButton_path_ok_IDM.setEnabled(False) 1216 | self.save_config('IDM_path', self.IDM_path) 1217 | else: 1218 | self.IDM_path_wrong_warning_dialog() 1219 | 1220 | def IDM_path_wrong_warning_dialog(self, state=None): 1221 | title = '请配置正确的IDMan.exe的位置' 1222 | content = """点击下方OK按钮后在弹出的窗口中浏览并选择IDMan.exe""" 1223 | w = Dialog(title, content, self) 1224 | if w.exec(): 1225 | self.choose_IDM_path(state=state) 1226 | else: 1227 | self.ToolButton_path_ok_IDM.setEnabled(True) 1228 | if state == 'force': 1229 | self.confirm_IDM_path(source='chosen', state=state) 1230 | 1231 | def choose_IDM_path(self, state=None): 1232 | file_name, _ = QFileDialog.getOpenFileName(self, '选取IDMan.exe', '', 'IDMan.exe (IDMan.exe)') 1233 | if file_name: 1234 | if os.path.isfile(file_name) and os.path.basename(file_name) == 'IDMan.exe': 1235 | self.IDM_path = file_name 1236 | self.confirm_IDM_path(source='chosen', state=state) 1237 | 1238 | def LineEdit_path_IDM_change(self): 1239 | self.ToolButton_path_ok_IDM.setEnabled(True) 1240 | self.IDM_path = self.LineEdit_path_IDM.text() 1241 | 1242 | def LineEdit_url_aria2_change(self, source=None): 1243 | if source == 'start': 1244 | self.LineEdit_url_aria2.setText(self.Aria2_url) 1245 | else: 1246 | self.Aria2_url = self.LineEdit_url_aria2.text() 1247 | self.save_config('Aria2_url', self.Aria2_url) 1248 | 1249 | def clear_download_data(self): 1250 | self.download_data = {} 1251 | self.ListWidget_data.clear() 1252 | 1253 | def export_download_data(self): 1254 | try: 1255 | exported_data = QtWidgets.QFileDialog.getSaveFileName(self, 1256 | "导出下载日志", 1257 | os.path.expanduser('~') + '\\document\\', 1258 | "JSON文件 (*.json)") 1259 | with open(exported_data[0], 'w') as f: 1260 | json.dump(self.download_data, f) 1261 | except: 1262 | pass 1263 | 1264 | def eventFilter(self, source, event): 1265 | if event.type() == QEvent.KeyPress: 1266 | if source == self.TableWidget: 1267 | if event.key() == Qt.Key_Delete: 1268 | self.delete_item() 1269 | return True 1270 | if source == self.TableWidget_finished: 1271 | if event.key() == Qt.Key_Delete: 1272 | self.delete_item_finished() 1273 | return True 1274 | if event.modifiers() == Qt.ControlModifier and event.key() == Qt.Key_R: 1275 | self.redo_item() 1276 | return True 1277 | return super().eventFilter(source, event) 1278 | 1279 | def redo_item(self): 1280 | selected_items = self.TableWidget_finished.selectedItems() 1281 | if selected_items: 1282 | title = '是否重新处理选中项' 1283 | content = '将选中的项重新添加至队列' 1284 | w = Dialog(title, content, self) 1285 | if w.exec(): 1286 | selected_items = self.TableWidget_finished.selectedItems() 1287 | # 获取选中项所在的行号并移除行 1288 | remove = set() 1289 | for item in selected_items: 1290 | row = item.row() 1291 | remove.add(row) 1292 | # 将行从最大索引向最小索引的顺序删除,以防止索引无效 1293 | for row in sorted(remove, reverse=True): 1294 | self.TableWidget.setRowCount(self.TableWidget.rowCount() + 1) 1295 | for index in range(8): 1296 | i = self.TableWidget_finished.item(row, index).text() 1297 | self.TableWidget.setItem(self.TableWidget.rowCount() - 1, index, QTableWidgetItem(i)) 1298 | self.TableWidget_finished.removeRow(row) 1299 | self.list.append(self.list_finish[row - 1]) 1300 | self.list_finish.pop(row - 1) 1301 | self.TableWidget_finished.clearSelection() 1302 | if not self.Download_running: 1303 | self.start() 1304 | else: 1305 | pass 1306 | 1307 | def delete_item_finished(self): 1308 | selected_items = self.TableWidget_finished.selectedItems() 1309 | if selected_items: 1310 | title = '是否删除选中项' 1311 | content = '此操作不可逆' 1312 | w = Dialog(title, content, self) 1313 | if w.exec(): 1314 | selected_items = self.TableWidget_finished.selectedItems() 1315 | # 获取选中项所在的行号并移除行 1316 | remove = set() 1317 | for item in selected_items: 1318 | row = item.row() 1319 | remove.add(row) 1320 | # 将行从最大索引向最小索引的顺序删除,以防止索引无效 1321 | for row in sorted(remove, reverse=True): 1322 | self.TableWidget_finished.removeRow(row) 1323 | self.list_finish.pop(row - 1) 1324 | self.TableWidget_finished.clearSelection() 1325 | else: 1326 | pass 1327 | 1328 | def show_finish_menu(self, pos): 1329 | 1330 | global_pos = self.TableWidget_finished.mapToGlobal(pos) 1331 | menu = RoundMenu(parent=self) 1332 | menu.setEnabled(True) 1333 | menu.setEnabled(True) 1334 | delete = Action(FluentIcon.DELETE, '删除所选项', shortcut='Delete') 1335 | delete.triggered.connect(self.delete_item_finished) 1336 | redo = Action(FluentIcon.CANCEL, '重新处理所选项', shortcut='Ctrl+R') 1337 | redo.triggered.connect(self.redo_item) 1338 | menu.addAction(delete) 1339 | menu.addAction(redo) 1340 | menu.exec(global_pos, aniType=MenuAnimationType.DROP_DOWN) 1341 | 1342 | def delete_item(self): 1343 | selected_items = self.TableWidget.selectedItems() 1344 | if selected_items: 1345 | title = '是否删除选中项' 1346 | content = '此操作不可逆, 且此操作对于正在处理的任务无效' 1347 | w = Dialog(title, content, self) 1348 | if w.exec(): 1349 | selected_items = self.TableWidget.selectedItems() 1350 | # 获取选中项所在的行号并移除行 1351 | remove = set() 1352 | for item in selected_items: 1353 | row = item.row() 1354 | remove.add(row) 1355 | # 将行从最大索引向最小索引的顺序删除,以防止索引无效 1356 | for row in sorted(remove, reverse=True): 1357 | if not row == 1: 1358 | self.TableWidget.removeRow(row) 1359 | self.list.pop(row - 1) 1360 | self.TableWidget.clearSelection() 1361 | else: 1362 | pass 1363 | 1364 | def show_list_menu(self, pos): 1365 | 1366 | global_pos = self.TableWidget.mapToGlobal(pos) 1367 | menu = RoundMenu(parent=self) 1368 | delete = Action(FluentIcon.DELETE, '删除所选项') 1369 | delete.triggered.connect(self.delete_item) 1370 | menu.addAction(delete) 1371 | menu.exec(global_pos, aniType=MenuAnimationType.DROP_DOWN) 1372 | 1373 | def about(self): 1374 | self.about_window = AboutWindow() 1375 | self.about_window.setupUi(QWidget) 1376 | self.about_window.show() 1377 | 1378 | def get_windows_theme_color(self): 1379 | try: 1380 | key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, r"Software\Microsoft\Windows\DWM") 1381 | value, type_ = winreg.QueryValueEx(key, "AccentColor") 1382 | winreg.CloseKey(key) 1383 | if type_ == winreg.REG_DWORD: 1384 | r = value % 256 1385 | g = (value >> 8) % 256 1386 | b = (value >> 16) % 256 1387 | theme_color = [r, g, b] 1388 | else: 1389 | theme_color = None 1390 | except: 1391 | theme_color = None 1392 | return theme_color 1393 | 1394 | def set_DISPLAY_MODE(self): 1395 | global DISPLAY_MODE 1396 | try: 1397 | key_path = r"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize" 1398 | with winreg.OpenKey(winreg.HKEY_CURRENT_USER, key_path) as key: 1399 | value_name = "AppsUseLightTheme" 1400 | value, _ = winreg.QueryValueEx(key, value_name) 1401 | DISPLAY_MODE = value 1402 | except: 1403 | DISPLAY_MODE = 1 1404 | -------------------------------------------------------------------------------- /URL.json: -------------------------------------------------------------------------------- 1 | {"url_json_Left": ["https://s-file-3.ykt.cbern.com.cn/zxx/ndrs/resources/tch_material/details/", "https://s-file-2.ykt.cbern.com.cn/zxx/ndrs/resources/tch_material/details/", "https://s-file-1.ykt.cbern.com.cn/zxx/ndrs/resources/tch_material/details/"], "url_PDF_current_Left": ["https://r1-ndr.ykt.cbern.com.cn/edu_product", "https://r2-ndr.ykt.cbern.com.cn/edu_product", "https://r3-ndr.ykt.cbern.com.cn/edu_product"], "url_PDF_A_Left": ["https://c1.ykt.cbern.com.cn/edu_product"], "url_PDF_B_Left": ["https://v1.ykt.cbern.com.cn", "https://v2.ykt.cbern.com.cn", "https://v3.ykt.cbern.com.cn"]} -------------------------------------------------------------------------------- /__pycache__/DOWNLOAD_FUNC.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RicardoJackMC/Teaching-Material-Download-Manager/d7b467e8300158a13b4f0c4fbca520a315c83a1c/__pycache__/DOWNLOAD_FUNC.cpython-39.pyc -------------------------------------------------------------------------------- /__pycache__/UI.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RicardoJackMC/Teaching-Material-Download-Manager/d7b467e8300158a13b4f0c4fbca520a315c83a1c/__pycache__/UI.cpython-39.pyc -------------------------------------------------------------------------------- /__pycache__/resources_rc.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RicardoJackMC/Teaching-Material-Download-Manager/d7b467e8300158a13b4f0c4fbca520a315c83a1c/__pycache__/resources_rc.cpython-39.pyc -------------------------------------------------------------------------------- /config.json: -------------------------------------------------------------------------------- 1 | {"download_mode": 1, "Aria2_url": "", "open_folder": true, "folder": "", "save_mode": 1, "first_open": true, "chunk_size": 1024, "IDM_path": "", "SegmentedWidget_show": "basic_info"} -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | Copyright 2023 by RicardoJackMC 5 | Teaching Material Download Manager 使用 GPLv3 许可证 6 | 本文件是 Teaching Material Download Manager 的一部分 7 | 请自行前往 8 | https://github.com/RicardoJackMC/Teaching-Material-Download-Manager 9 | 或 10 | https://gitee.com/RicardoJackMC/Teaching-Material-Download-Manager 11 | 根据版本号校验本文件MD5 12 | """ 13 | import multiprocessing 14 | 15 | import UI 16 | import DOWNLOAD_FUNC 17 | from multiprocessing import Process, Queue, freeze_support 18 | import sys 19 | from PyQt5 import QtCore, QtWidgets 20 | from PyQt5.QtCore import Qt 21 | from PyQt5.QtWidgets import QWidget, QApplication 22 | from qfluentwidgets import setTheme, Theme 23 | 24 | 25 | def start_ui(queue, queue_admin, queue_command): 26 | print('ui') 27 | QApplication.setHighDpiScaleFactorRoundingPolicy(Qt.HighDpiScaleFactorRoundingPolicy.PassThrough) 28 | QApplication.setAttribute(Qt.AA_EnableHighDpiScaling) 29 | QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps) 30 | QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling) 31 | app = QtWidgets.QApplication(sys.argv) 32 | ui = UI.Ui_MainWindow() 33 | ui.queue = queue 34 | ui.queue_admin = queue_admin 35 | ui.queue_command = queue_command 36 | 37 | ui.set_DISPLAY_MODE() 38 | if UI.DISPLAY_MODE == 1: 39 | setTheme(Theme.LIGHT) 40 | else: 41 | setTheme(Theme.DARK) 42 | 43 | ui.setupUi(QWidget) 44 | ui.show() 45 | ui.welcome_dialog() 46 | app.exec_() 47 | 48 | 49 | def start_manager(queue, queue_admin, queue_command): 50 | print('manager') 51 | manager = DOWNLOAD_FUNC.Downloader() 52 | manager.queue = queue 53 | manager.queue_admin = queue_admin 54 | manager.queue_command = queue_command 55 | manager.run() 56 | 57 | 58 | if __name__ == '__main__': 59 | freeze_support() 60 | queue = Queue() 61 | queue_admin = Queue() 62 | queue_command = Queue() 63 | Manager_Process = Process(target=start_manager, args=(queue, queue_admin, queue_command,)) 64 | UI_Process = Process(target=start_ui, args=(queue, queue_admin, queue_command,)) 65 | Manager_Process.start() 66 | UI_Process.start() 67 | Manager_Process.join() 68 | UI_Process.join() 69 | -------------------------------------------------------------------------------- /recourse/logo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RicardoJackMC/Teaching-Material-Download-Manager/d7b467e8300158a13b4f0c4fbca520a315c83a1c/recourse/logo.ico -------------------------------------------------------------------------------- /recourse/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RicardoJackMC/Teaching-Material-Download-Manager/d7b467e8300158a13b4f0c4fbca520a315c83a1c/recourse/logo.png -------------------------------------------------------------------------------- /recourse/pic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RicardoJackMC/Teaching-Material-Download-Manager/d7b467e8300158a13b4f0c4fbca520a315c83a1c/recourse/pic.png -------------------------------------------------------------------------------- /recourse/qfluentwidgets_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RicardoJackMC/Teaching-Material-Download-Manager/d7b467e8300158a13b4f0c4fbca520a315c83a1c/recourse/qfluentwidgets_logo.png -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | PyQt5==5.15.9 2 | requests==2.31.0 3 | PyQt-Fluent-Widgets==1.1.9 -------------------------------------------------------------------------------- /resource.qrc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RicardoJackMC/Teaching-Material-Download-Manager/d7b467e8300158a13b4f0c4fbca520a315c83a1c/resource.qrc --------------------------------------------------------------------------------