├── .gitattributes ├── .github └── workflows │ └── main.yml ├── .gitignore ├── .vscode └── launch.json ├── ADC_function.py ├── AV_Data_Capture.py ├── LICENSE ├── README.md ├── actor.py ├── avsox.py ├── config.ini ├── config.py ├── core.py ├── docker ├── Dockerfile ├── config.ini └── docker-compose.yaml ├── fanza.py ├── fc2fans_club.py ├── jav321.py ├── javbus.py ├── javdb.py ├── javlib.py ├── linux_make.py ├── mgstage.py ├── number_parser.py ├── py_to_exe.bat ├── readme ├── This is readms.md's images folder ├── flow_chart2.png ├── readme1.PNG ├── readme2.PNG ├── readme3.PNG ├── readme4.PNG └── single.gif ├── requirements.txt ├── update_check.json └── xcity.py /.gitattributes: -------------------------------------------------------------------------------- 1 | *.py text=auto eol=lf 2 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: PyInstaller 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | branches: 9 | - master 10 | 11 | jobs: 12 | build: 13 | runs-on: ${{ matrix.os }} 14 | strategy: 15 | matrix: 16 | os: [macos-latest, windows-latest, ubuntu-latest] 17 | 18 | steps: 19 | - uses: actions/checkout@v2 20 | 21 | - name: Set up Python 3.7 22 | uses: actions/setup-python@v1 23 | with: 24 | python-version: 3.7 25 | 26 | - name: Install dependencies 27 | run: | 28 | python -m pip install --upgrade pip 29 | pip install -r requirements.txt 30 | 31 | - name: Test number_perser.get_number 32 | run: | 33 | python number_parser.py -v 34 | 35 | # - name: Show cloudsraper package location 36 | # run: | 37 | # python -c 'import cloudscraper as _; print(_.__path__)' 38 | 39 | - name: Build with pyinstaller (windows) 40 | if: matrix.os == 'windows-latest' 41 | run: | 42 | pyinstaller --onefile AV_Data_Capture.py --hidden-import ADC_function.py --hidden-import core.py --add-data='C:\\hostedtoolcache\\windows\\Python\\3.7.6\\x64\\lib\\site-packages\\cloudscraper\\;cloudscraper' 43 | 44 | - name: Build with pyinstaller (mac) 45 | if: matrix.os == 'macos-latest' 46 | run: | 47 | pyinstaller \ 48 | --onefile AV_Data_Capture.py \ 49 | --hidden-import ADC_function.py \ 50 | --hidden-import core.py \ 51 | --add-data='/Users/runner/hostedtoolcache/Python/3.7.6/x64/lib/python3.7/site-packages/cloudscraper/:cloudscraper' 52 | 53 | - name: Build with pyinstaller (ubuntu) 54 | if: matrix.os == 'ubuntu-latest' 55 | run: | 56 | pyinstaller \ 57 | --onefile AV_Data_Capture.py \ 58 | --hidden-import ADC_function.py \ 59 | --hidden-import core.py \ 60 | --add-data='/opt/hostedtoolcache/Python/3.7.6/x64/lib/python3.7/site-packages/cloudscraper/:cloudscraper' 61 | 62 | - name: Copy config.ini 63 | run: | 64 | cp config.ini dist/ 65 | 66 | - name: Upload build artifact 67 | uses: actions/upload-artifact@v1 68 | with: 69 | name: AV_Data_Capture-${{ matrix.os }} 70 | path: dist 71 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | ENV/ 90 | env.bak/ 91 | venv.bak/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | 106 | # movie files 107 | *.mp4 108 | 109 | # success/failed folder 110 | JAV_output/**/* 111 | failed/* -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "AV_Data_Capture", 6 | "type": "python", 7 | "request": "launch", 8 | "program": "${workspaceFolder}/AV_Data_capture.py", 9 | "console": "integratedTerminal" 10 | } 11 | ] 12 | } -------------------------------------------------------------------------------- /ADC_function.py: -------------------------------------------------------------------------------- 1 | import requests 2 | from lxml import etree 3 | import cloudscraper 4 | 5 | import config 6 | 7 | 8 | def get_data_state(data: dict) -> bool: # 元数据获取失败检测 9 | if "title" not in data or "number" not in data: 10 | return False 11 | 12 | if data["title"] is None or data["title"] == "" or data["title"] == "null": 13 | return False 14 | 15 | if data["number"] is None or data["number"] == "" or data["number"] == "null": 16 | return False 17 | 18 | return True 19 | 20 | 21 | def getXpathSingle(htmlcode,xpath): 22 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 23 | result1 = str(html.xpath(xpath)).strip(" ['']") 24 | return result1 25 | 26 | 27 | def get_proxy(proxy: str) -> dict: 28 | if proxy: 29 | proxies = {"http": "http://" + proxy, "https": "https://" + proxy} 30 | else: 31 | proxies = {} 32 | 33 | return proxies 34 | 35 | 36 | # 网页请求核心 37 | def get_html(url, cookies: dict = None, ua: str = None, return_type: str = None): 38 | proxy, timeout, retry_count = config.Config().proxy() 39 | proxies = get_proxy(proxy) 40 | 41 | if ua is None: 42 | headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3100.0 Safari/537.36"} # noqa 43 | else: 44 | headers = {"User-Agent": ua} 45 | 46 | for i in range(retry_count): 47 | try: 48 | if not proxy == '': 49 | result = requests.get(str(url), headers=headers, timeout=timeout, proxies=proxies, cookies=cookies) 50 | else: 51 | result = requests.get(str(url), headers=headers, timeout=timeout, cookies=cookies) 52 | 53 | result.encoding = "utf-8" 54 | 55 | if return_type == "object": 56 | return result 57 | else: 58 | return result.text 59 | 60 | except requests.exceptions.ProxyError: 61 | print("[-]Connect retry {}/{}".format(i + 1, retry_count)) 62 | print('[-]Connect Failed! Please check your Proxy or Network!') 63 | input("Press ENTER to exit!") 64 | exit() 65 | 66 | 67 | def post_html(url: str, query: dict) -> requests.Response: 68 | proxy, timeout, retry_count = config.Config().proxy() 69 | proxies = get_proxy(proxy) 70 | 71 | for i in range(retry_count): 72 | try: 73 | result = requests.post(url, data=query, proxies=proxies) 74 | return result 75 | except requests.exceptions.ProxyError: 76 | print("[-]Connect retry {}/{}".format(i+1, retry_count)) 77 | print("[-]Connect Failed! Please check your Proxy or Network!") 78 | input("Press ENTER to exit!") 79 | exit() 80 | 81 | 82 | def get_javlib_cookie() -> [dict, str]: 83 | proxy, timeout, retry_count = config.Config().proxy() 84 | proxies = get_proxy(proxy) 85 | 86 | raw_cookie = {} 87 | user_agent = "" 88 | 89 | # Get __cfduid/cf_clearance and user-agent 90 | for i in range(retry_count): 91 | try: 92 | raw_cookie, user_agent = cloudscraper.get_cookie_string( 93 | "http://www.m45e.com/", 94 | proxies=proxies 95 | ) 96 | except requests.exceptions.ProxyError: 97 | print("[-] ProxyError, retry {}/{}".format(i+1, retry_count)) 98 | except cloudscraper.exceptions.CloudflareIUAMError: 99 | print("[-] IUAMError, retry {}/{}".format(i+1, retry_count)) 100 | 101 | return raw_cookie, user_agent 102 | -------------------------------------------------------------------------------- /AV_Data_Capture.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | from core import * 3 | from number_parser import get_number 4 | 5 | 6 | def check_update(local_version): 7 | data = json.loads(get_html("https://api.github.com/repos/yoshiko2/AV_Data_Capture/releases/latest")) 8 | 9 | try: 10 | remote = float(data["tag_name"]) 11 | local = float(local_version) 12 | except ValueError: 13 | print("[-] Check update failed! Skipped.") 14 | return 15 | 16 | download_url = data["html_url"] 17 | 18 | if local < remote: 19 | line1 = "* New update " + str(remote) + " *" 20 | print("[*]" + line1.center(54)) 21 | print("[*]" + "↓ Download ↓".center(54)) 22 | print("[*] " + download_url) 23 | print("[*]======================================================") 24 | 25 | 26 | def argparse_function() -> [str, str, bool]: 27 | parser = argparse.ArgumentParser() 28 | parser.add_argument("file", default='', nargs='?', help="Single Movie file path.") 29 | parser.add_argument("-c", "--config", default='config.ini', nargs='?', help="The config file Path.") 30 | parser.add_argument("-a", "--auto-exit", dest='autoexit', action="store_true", help="Auto exit after program complete") 31 | args = parser.parse_args() 32 | 33 | return args.file, args.config, args.autoexit 34 | 35 | def movie_lists(root, escape_folder): 36 | for folder in escape_folder: 37 | if folder in root: 38 | return [] 39 | total = [] 40 | file_type = ['.mp4', '.avi', '.rmvb', '.wmv', '.mov', '.mkv', '.flv', '.ts', '.webm', '.MP4', '.AVI', '.RMVB', '.WMV','.MOV', '.MKV', '.FLV', '.TS', '.WEBM', ] 41 | dirs = os.listdir(root) 42 | for entry in dirs: 43 | f = os.path.join(root, entry) 44 | if os.path.isdir(f): 45 | total += movie_lists(f, escape_folder) 46 | elif os.path.splitext(f)[1] in file_type: 47 | total.append(f) 48 | return total 49 | 50 | 51 | def create_failed_folder(failed_folder): 52 | if not os.path.exists(failed_folder + '/'): # 新建failed文件夹 53 | try: 54 | os.makedirs(failed_folder + '/') 55 | except: 56 | print("[-]failed!can not be make folder 'failed'\n[-](Please run as Administrator)") 57 | os._exit(0) 58 | 59 | 60 | def CEF(path): 61 | try: 62 | files = os.listdir(path) # 获取路径下的子文件(夹)列表 63 | for file in files: 64 | os.removedirs(path + '/' + file) # 删除这个空文件夹 65 | print('[+]Deleting empty folder', path + '/' + file) 66 | except: 67 | a = '' 68 | 69 | 70 | def create_data_and_move(file_path: str, c: config.Config): 71 | # Normalized number, eg: 111xxx-222.mp4 -> xxx-222.mp4 72 | n_number = get_number(file_path) 73 | 74 | try: 75 | print("[!]Making Data for [{}], the number is [{}]".format(file_path, n_number)) 76 | core_main(file_path, n_number, c) 77 | print("[*]======================================================") 78 | except Exception as err: 79 | print("[-] [{}] ERROR:".format(file_path)) 80 | print('[-]', err) 81 | 82 | if c.soft_link(): 83 | print("[-]Link {} to failed folder".format(file_path)) 84 | os.symlink(file_path, str(os.getcwd()) + "/" + conf.failed_folder() + "/") 85 | else: 86 | try: 87 | print("[-]Move [{}] to failed folder".format(file_path)) 88 | shutil.move(file_path, str(os.getcwd()) + "/" + conf.failed_folder() + "/") 89 | except Exception as err: 90 | print('[!]', err) 91 | 92 | 93 | if __name__ == '__main__': 94 | version = '3.4' 95 | 96 | # Parse command line args 97 | single_file_path, config_file, auto_exit = argparse_function() 98 | 99 | # Read config.ini 100 | conf = config.Config(path=config_file) 101 | 102 | version_print = 'Version ' + version 103 | print('[*]================== AV Data Capture ===================') 104 | print('[*]' + version_print.center(54)) 105 | print('[*]======================================================') 106 | 107 | if conf.update_check(): 108 | check_update(version) 109 | 110 | create_failed_folder(conf.failed_folder()) 111 | os.chdir(os.getcwd()) 112 | movie_list = movie_lists(".", re.split("[,,]", conf.escape_folder())) 113 | 114 | # ========== 野鸡番号拖动 ========== 115 | if not single_file_path == '': 116 | create_data_and_move(single_file_path, conf) 117 | CEF(conf.success_folder()) 118 | CEF(conf.failed_folder()) 119 | print("[+]All finished!!!") 120 | input("[+][+]Press enter key exit, you can check the error messge before you exit.") 121 | exit() 122 | # ========== 野鸡番号拖动 ========== 123 | 124 | count = 0 125 | count_all = str(len(movie_list)) 126 | print('[+]Find', count_all, 'movies') 127 | if conf.soft_link(): 128 | print('[!] --- Soft link mode is ENABLE! ----') 129 | for movie_path in movie_list: # 遍历电影列表 交给core处理 130 | count = count + 1 131 | percentage = str(count / int(count_all) * 100)[:4] + '%' 132 | print('[!] - ' + percentage + ' [' + str(count) + '/' + count_all + '] -') 133 | create_data_and_move(movie_path, conf) 134 | 135 | CEF(conf.success_folder()) 136 | CEF(conf.failed_folder()) 137 | print("[+]All finished!!!") 138 | if auto_exit: 139 | exit(0) 140 | input("[+][+]Press enter key exit, you can check the error message before you exit.") 141 | -------------------------------------------------------------------------------- /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 | # AV Data Capture (CLI) 2 | 3 | CLI 版本 4 | 5 | ![](https://img.shields.io/badge/build-passing-brightgreen.svg?style=flat-square) 6 | ![](https://img.shields.io/github/downloads/yoshiko2/av_data_capture/total.svg?style=flat-square) 7 | ![](https://img.shields.io/github/license/yoshiko2/av_data_capture.svg?style=flat-square) 8 | ![](https://img.shields.io/github/release/yoshiko2/av_data_capture.svg?style=flat-square) 9 | ![](https://img.shields.io/badge/Python-3.7-yellow.svg?style=flat-square&logo=python)
10 | [GUI 版本](https://github.com/moyy996/AVDC) 11 | 12 | ![](https://img.shields.io/badge/build-passing-brightgreen.svg?style=flat-square) 13 | ![](https://img.shields.io/github/downloads/moyy996/avdc/total.svg?style=flat-square) 14 | ![](https://img.shields.io/github/license/moyy996/avdc.svg?style=flat-square) 15 | ![](https://img.shields.io/github/release/moyy996/avdc.svg?style=flat-square) 16 | ![](https://img.shields.io/badge/Python-3.6-yellow.svg?style=flat-square&logo=python) 17 | ![](https://img.shields.io/badge/Pyqt-5-blue.svg?style=flat-square)
18 | 19 | 20 | **日本电影元数据 抓取工具 | 刮削器**,配合本地影片管理软件 Emby, Jellyfin, Kodi 等管理本地影片,该软件起到分类与元数据(metadata)抓取作用,利用元数据信息来分类,供本地影片分类整理使用。 21 | #### 本地电影刮削与整理一体化解决方案 22 | 23 | # 目录 24 | * [声明](#声明) 25 | * [FAQ](#FAQ) 26 | * [效果图](#效果图) 27 | * [下载](#下载) 28 | * [如何使用](#如何使用) 29 | * [简要教程](#简要教程) 30 | * [完整文档](#完整文档) 31 | * [运行参数](#运行参数) 32 | * [拖动法/奇葩番号](#拖动法) 33 | * [配置文件选择](#配置文件选择) 34 | * [程序退出选择参数](#程序退出选择参数) 35 | * [模块安装](#模块安装) 36 | * [配置](#配置configini) 37 | * [多目录影片处理](#多目录影片处理) 38 | * [多集影片处理](#多集影片处理) 39 | * [中文字幕处理](#中文字幕处理) 40 | * [异常处理(重要)](#异常处理重要) 41 | * [写在后面](#写在后面) 42 | 43 | # 声明 44 | **当你运行了本软件,即代表你接受了以下条款** 45 | * 本软件仅供**技术交流,学术交流**使用 46 | * 本软件作者编写出该软件旨在学习 Python ,提高编程水平 47 | * 用户在使用本软件前,请用户了解并遵守当地法律法规,如果本软件使用过程中存在违反当地法律法规的行为,请勿使用该软件 48 | * 用户在使用本软件时,若用户在当地产生一切违法行为由用户承担 49 | * 严禁用户将本软件使用于商业和个人其他意图 50 | * 本软件作者yoshiko2保留最终决定权和最终解释权 51 | 52 | **若用户不同意上述条款任意一条,请勿使用本软件** 53 | 54 | --- 55 | **When you run the software, you accept the following terms** 56 | * This software is only for **technical exchange and academic exchange** 57 | * The software author wrote this software to learn Python and improve programming 58 | * Before using this software, please understand and abide by local laws and regulations. If there is any violation of local laws and regulations during the use of this software, please do not use this software 59 | * When the user uses this software, if the user has any illegal acts in the local area, the user shall bear 60 | * It is strictly forbidden for users to use this software for commercial and personal intentions 61 | * The author of this software yoshiko2 reserves the right of final decision and final interpretation 62 | 63 | **If the user does not agree with any of the above terms, please do not use this software** 64 | 65 | # FAQ 66 | ### 软件能下片吗? 67 | * 本软件不提供任何影片下载地址,仅供本地影片分类整理使用 68 | ### 什么是元数据(metadata)? 69 | * 元数据包括了影片的封面,导演,演员,简介,类型...... 70 | ### 软件收费吗? 71 | * 本软件永久免费,**除了作者yìng点以外** 72 | ### 软件运行异常怎么办? 73 | * 认真看 [异常处理(重要)](#异常处理重要) 74 | ### 为什么软件要单线程运行? 75 | * 多线程爬取可能会触发网站反爬机制,同时也违背了些道德,故单线程运行 76 | 77 | # 效果图 78 | **图片来自网络**,图片仅供参考,具体效果请自行联想 79 | ![preview_picture_1](https://i.loli.net/2019/07/04/5d1cf9bb1b08b86592.jpg) 80 | ![preview_picture_2](https://i.loli.net/2019/07/04/5d1cf9bb2696937880.jpg) 81 | 82 | # 下载 83 | [![](https://img.shields.io/badge/%E4%B8%8B%E8%BD%BD-windows-brightgreen.svg?style=for-the-badge&logo=windows)](https://github.com/yoshiko2/AV_Data_Capture/releases) 84 | [![](https://img.shields.io/badge/%E4%B8%8B%E8%BD%BD-linux-blue.svg?style=for-the-badge&logo=linux)](https://github.com/yoshiko2/AV_Data_Capture/releases) 85 | 86 | ### MacOS,FreeBSD等unix系操作系统 | For Advenced User 87 | * 请clone源码包运行,并手动安装Python3环境 88 | 89 | # 如何使用 90 | ## 简要教程: 91 | 1. 把软件拉到和电影的同一目录 92 | 2. 设置 config.ini 文件的代理(路由器拥有自动代理功能的可以把 proxy= 后面内容去掉) 93 | 3. 运行软件等待完成 94 | 4. 把 JAV_output 导入至 Kodi, Emby, Jellyfin 中。 95 | 96 | ## 使用 Docker 97 | Docker容器可以方便在在NAS上使用。 98 | 99 | 1. 将docker目录中的内容下载下来 100 | 2. 构建镜像 `sudo docker-compose build jav` 101 | 3. 运行容器 `JAVUID=$(id -u) JAVGID=$(id -g) JAV_PATH= sudo docker up -d jav` 102 | 4. 容器运行结束后会自动退出,处理好的内容会存入`/organized`, 失败的内容会移入`/failure_output`. 103 | 5. 注意目前容器不支持配置代理。所以必须在路由器上配置好透明代理,或者在build之前自行修改`config.ini`的内容。 104 | 105 | 详细请看以下完整文档 106 | 107 | # 完整文档 108 | 109 | ## 模块安装 110 | 如果运行**源码**版,运行前请安装**Python环境**和安装以下**模块** 111 | 112 | 在终端 cmd/Powershell/Terminal 中输入以下代码来安装模块 113 | 114 | ``` 115 | pip install requests pyquery lxml Beautifulsoup4 pillow 116 | ``` 117 | 118 | ## 配置config.ini 119 | ### 运行模式 120 | ``` 121 | [common] 122 | main_mode=1 123 | ``` 124 | 1为普通模式, 125 | 2为整理模式:仅根据女优把电影命名为番号并分类到女优名称的文件夹下 126 | 127 | ``` 128 | success_output_folder=JAV_outputd 129 | failed_output_folder=failed 130 | ``` 131 | 设置成功输出目录和失败输出目录 132 | 133 | --- 134 | #### 软链接 135 | 方便PT下载完既想刮削又想继续上传的仓鼠党同志 136 | ``` 137 | [common] 138 | soft_link=0 139 | ``` 140 | 1为开启软链接模式 141 | 0为关闭 142 | 143 | --- 144 | ### 网络设置 145 | ``` 146 | [proxy] 147 | proxy=127.0.0.1:1081 148 | timeout=10 149 | retry=3 150 | ``` 151 | #### 针对某些地区的代理设置 152 | ``` 153 | proxy=127.0.0.1:1081 154 | ``` 155 | 156 | 打开```config.ini```,在```[proxy]```下的```proxy```行设置本地代理地址和端口,支持Shadowxxxx/X,V2XXX本地代理端口 157 | 素人系列抓取建议使用日本代理 158 | **路由器拥有自动代理功能的可以把proxy=后面内容去掉** 159 | **本地代理软件开全局模式的用户同上** 160 | **如果遇到tineout错误,可以把文件的proxy=后面的地址和端口删除,并开启代理软件全局模式,或者重启电脑,代理软件,网卡** 161 | 162 | --- 163 | #### 连接超时重试设置 164 | ``` 165 | timeout=10 166 | ``` 167 | 10为超时重试时间 单位:秒 168 | 169 | --- 170 | #### 连接重试次数设置 171 | ``` 172 | retry=3 173 | ``` 174 | 3即为重试次数 175 | 176 | --- 177 | #### 检查更新开关 178 | ``` 179 | [update] 180 | update_check=1 181 | ``` 182 | 0为关闭,1为开启,不建议关闭 183 | 184 | --- 185 | ### 刮削网站优先级 186 | ``` 187 | [priority] 188 | website=javbus,javdb,fanza,xcity,mgstage,fc2,avsox,jav321 189 | ``` 190 | 用```,```英文逗号分开网站,刮削顺序从左往右 191 | 192 | --- 193 | ### 排除指定字符和目录 194 | ``` 195 | [escape] 196 | literals=\ 197 | folders=failed,JAV_output 198 | ``` 199 | 200 | ```literals=``` 标题指定字符删除,例如```iterals=\()```,则删除标题中```\()```字符 201 | ```folders=``` 指定目录,例如```folders=failed,JAV_output```,多目录刮削时跳过failed,JAV_output 202 | 203 | --- 204 | ### 调试模式 205 | ``` 206 | [debug_mode] 207 | switch=1 208 | ``` 209 | 210 | 如要开启调试模式,请手动输入以上代码到```config.ini```中,开启后可在抓取中显示影片元数据 211 | 212 | --- 213 | ### (可选)设置自定义目录和影片重命名规则 214 | ``` 215 | [Name_Rule] 216 | location_rule=actor+'/'+number 217 | naming_rule=number+'-'+title 218 | ``` 219 | 已有默认配置 220 | 221 | --- 222 | ### 命名参数 223 | ``` 224 | title = 片名 225 | actor = 演员 226 | studio = 公司 227 | director = 导演 228 | release = 发售日 229 | year = 发行年份 230 | number = 番号 231 | cover = 封面链接 232 | tag = 类型 233 | outline = 简介 234 | runtime = 时长 235 | ``` 236 | 237 | 上面的参数以下都称之为**变量** 238 | 239 | ### 例子: 240 | 自定义规则方法:有两种元素,变量和字符,无论是任何一种元素之间连接必须要用加号 **+** ,比如:```'naming_rule=['+number+']-'+title```,其中冒号 ' ' 内的文字是字符,没有冒号包含的文字是变量,元素之间连接必须要用加号 **+** 241 | 242 | ### locaton_rule 243 | 该为影片路径规则 244 | 目录结构规则:默认 ```location_rule=actor+'/'+number``` 245 | 246 | **不推荐修改时在这里添加 title**,有时 title 过长,因为 Windows API 问题,抓取数据时新建文件夹容易出错。 247 | 248 | ### naming_rule 249 | 该为媒体库内标题的命名规则规则,NFO文件内标题命名规则 250 | 影片命名规则:默认 ```naming_rule=number+'-'+title``` 251 | 252 | **在 Emby, Kodi等本地媒体库显示的标题,不影响目录结构下影片文件的命名**,依旧是 番号+后缀。 253 | 254 | --- 255 | 256 | ### 更新开关 257 | ``` 258 | [update] 259 | update_check=1 260 | ``` 261 | 262 | 1为开,0为关 263 | 264 | ## 运行参数 265 | 以下运行参数均为可选参数 266 | ### 拖动法 267 | 如果遇到番号比较奇葩的影片,同时存在于可刮削的网站,可用拖动影片之主程序刮削,或者输入以下 268 | ``` 269 | AV_Data_Capture xxx-xxx-xxx.mp4 270 | ``` 271 | ### 配置文件选择 272 | 可以用```-c```或者```--config```选择其他配置文件 273 | 默认值为```config.ini``` 274 | ``` 275 | AV_Data_Capture -c config_other.ini 276 | ``` 277 | ### 程序自动退出 278 | 279 | ``` 280 | AV_Data_Capture -a 281 | ``` 282 | 输入参数即可在刮削结束后自动结束程序 283 | 284 | ## 多集影片处理 285 | **建议使用视频合并合并为一个视频文件** 286 | 可以把多集电影按照集数后缀命名为类似```ssni-xxx-cd1.mp4m,ssni-xxx-cd2.mp4,abp-xxx-CD1.mp4```的规则,只要含有```-CDn./-cdn.```类似命名规则,即可使用分集功能 287 | 288 | ## 中文字幕处理 289 | 290 | 运行 ```AV_Data_capture.py/.exe``` 291 | 292 | 当文件名包含: 293 | 中文,字幕,-c., -C., 处理元数据时会加上**中文字幕**标签 294 | 295 | ## 异常处理(重要) 296 | 297 | ### 请确保软件是完整地!确保ini文件内容是和下载提供ini文件内容的一致的! 298 | --- 299 | ### 关于软件打开就闪退 300 | 可以打开cmd命令提示符,把 ```AV_Data_capture.py/.exe```拖进cmd窗口回车运行,查看错误,出现的错误信息**依据以下条目解决** 301 | 302 | --- 303 | ### 关于 ```Updata_check``` 和 ```JSON``` 相关的错误 304 | 跳转 [网络设置](#网络设置) 305 | 306 | --- 307 | ### 关于字幕文件移动功能 308 | 字幕文件前缀必须与影片文件前缀一致,才可以使用该功能 309 | 310 | --- 311 | ### 关于```FileNotFoundError: [WinError 3] 系统找不到指定的路径。: 'JAV_output''``` 312 | 在软件所在文件夹下新建 JAV_output 文件夹,可能是你没有把软件拉到和电影的同一目录 313 | 314 | --- 315 | ### 关于连接拒绝的错误 316 | 请设置好[代理](#针对某些地区的代理设置) 317 | 318 | --- 319 | ### 关于Nonetype,xpath报错 320 | 同上 321 | 322 | --- 323 | ### 关于番号提取失败或者异常 324 | **可以提取元数据的网站:avsox, javbus, javdb, dmm(fanza), fc2, jav321, mgstage(素人)** 325 | 326 | 目前作者已经完善了番号提取机制,功能较为强大,各大网站的影片请用以下规则命名(dmm(fanza)下载的影片除外) 327 | ``` 328 | COSQ-004.mp4 329 | ``` 330 | 对于dmm(fanza)上下好的电影,请使用影片cid命名,示例如下 331 | ``` 332 | kawd00969.mp4 333 | ``` 334 | 335 | 条件:文件名中间要有下划线或者减号"_","-",没有多余的内容只有番号为最佳,可以让软件更好获取元数据 336 | 对于多影片重命名,可以用 [ReNamer](http://www.den4b.com/products/renamer) 来批量重命名 337 | 338 | 339 | --- 340 | ### 关于PIL/image.py 341 | 暂时无解,可能是网络问题或者pillow模块打包问题,你可以用源码运行(要安装好第一步的模块) 342 | 343 | ### 拖动法 344 | 针对格式比较奇葩的番号 345 | 影片放在和程序同一目录下,拖动至```AV_Data_Capture.exe```,即可完成刮削和整理 346 | 347 | 348 | ### 软件会自动把元数据获取成功的电影移动到 JAV_output 文件夹中,根据演员分类,失败的电影移动到failed文件夹中。 349 | 350 | ### 把JAV_output文件夹导入到 Emby, Kodi中,等待元数据刷新,完成 351 | 352 | ### 关于群晖NAS 353 | 开启 SMB,并在 Windows 上挂载为网络磁盘即可使用本软件,也适用于其他 NAS 354 | 355 | ## 写在后面 356 | 怎么样,看着自己的日本电影被这样完美地管理,是不是感觉成就感爆棚呢? 357 | 358 | **tg官方电报群:[ 点击进群](https://t.me/joinchat/J54y1g3-a7nxJ_-WS4-KFQ)** 359 | 360 | 361 | -------------------------------------------------------------------------------- /actor.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import requests, os 6 | from configparser import RawConfigParser 7 | from base64 import b64encode 8 | from traceback import format_exc 9 | from json import loads 10 | from os.path import exists 11 | 12 | # 检查“actor_photos”文件夹是否就绪 13 | if not exists('actor_photos'): 14 | print('\n“actor_photos” folder lost!Please put it to the same location with program\n') 15 | os.system('pause') 16 | # 读取配置文件,这个ini文件用来给用户设置emby网址和api id 17 | print('Reading ini Setting...') 18 | config_settings = RawConfigParser() 19 | try: 20 | config_settings.read('ap_config.ini', encoding='utf-8-sig') 21 | url_emby = config_settings.get("emby/jellyfin", "website") 22 | api_key = config_settings.get("emby/jellyfin", "api id") 23 | bool_replace = True if config_settings.get("emby/jellyfin", "是否覆盖以前上传的头像?") == '是' else False 24 | except: 25 | print(format_exc()) 26 | print('Cannot read ini files!') 27 | os.system('pause') 28 | print('Read Success!\n') 29 | # 修正用户输入的emby网址,无论是不是带“/” 30 | if not url_emby.endswith('/'): 31 | url_emby += '/' 32 | # 成功的个数 33 | num_suc = 0 34 | num_fail = 0 35 | num_exist = 0 36 | sep = os.sep 37 | try: 38 | print('Getting emby/jellyfin Person`s form...') 39 | # curl -X GET "http://localhost:8096/emby/Persons?api_key=3291434710e342089565ad05b6b2f499" -H "accept: application/json" 40 | # 得到所有“人员” emby api没有细分“演员”还是“导演”“编剧”等等 下面得到的是所有“有关人员” 41 | url_emby_persons = url_emby + 'emby/Persons?api_key=' + api_key # &PersonTypes=Actor 42 | try: 43 | rqs_emby = requests.get(url=url_emby_persons) 44 | except requests.exceptions.ConnectionError: 45 | print('Cannot connect to emby/jellyfin server ,Please check:', url_emby, '\n') 46 | os.system('pause') 47 | except: 48 | print(format_exc()) 49 | print('Unkown Error ,Please submit screenshot to issues', url_emby, '\n') 50 | os.system('pause') 51 | # 401,无权访问 52 | if rqs_emby.status_code == 401: 53 | print('Please check API KEY!\n') 54 | os.system('pause') 55 | # print(rqs_emby.text) 56 | try: 57 | list_persons = loads(rqs_emby.text)['Items'] 58 | except: 59 | print(rqs_emby.text) 60 | print('Error! emby response:') 61 | print('Please submit screenshot to issues!') 62 | os.system('pause') 63 | num_persons = len(list_persons) 64 | print('There are currently' + str(num_persons) + ' People!\n') 65 | # os.system('pause') 66 | # 用户emby中的persons,在“actor_photos”文件夹中,已有头像的,记录下来 67 | f_txt = open("included.txt", 'w', encoding="utf-8") 68 | f_txt.close() 69 | f_txt = open("no_included.txt", 'w', encoding="utf-8") 70 | f_txt.close() 71 | for dic_each_actor in list_persons: 72 | actor_name = dic_each_actor['Name'] 73 | # 头像jpg/png在“actor_photos”中的路径 74 | actor_pic_path = 'actor_photos' + sep + actor_name[0] + sep + actor_name 75 | if exists(actor_pic_path + '.jpg'): 76 | actor_pic_path = actor_pic_path + '.jpg' 77 | header = {"Content-Type": 'image/jpeg', } 78 | elif exists(actor_pic_path + '.png'): 79 | actor_pic_path = actor_pic_path + '.png' 80 | header = {"Content-Type": 'image/png', } 81 | else: 82 | print('>>No image:', actor_name) 83 | f_txt = open("no_included.txt", 'a', encoding="utf-8") 84 | f_txt.write(actor_name + '\n') 85 | f_txt.close() 86 | num_fail += 1 87 | continue 88 | # emby有某个演员,“actor_photos”文件夹也有这个演员的头像,记录一下 89 | f_txt = open("included.txt", 'a', encoding="utf-8") 90 | f_txt.write(actor_name + '\n') 91 | f_txt.close() 92 | # emby有某个演员,已经有他的头像,不再进行下面“上传头像”的操作 93 | if dic_each_actor['ImageTags']: # emby已经收录头像 94 | num_exist += 1 95 | if not bool_replace: # 不需要覆盖已有头像 96 | continue # 那么不进行下面的上传操作 97 | f_pic = open(actor_pic_path, 'rb') # 二进制方式打开图文件 98 | b6_pic = b64encode(f_pic.read()) # 读取文件内容,转换为base64编码 99 | f_pic.close() 100 | url_post_img = url_emby + 'emby/Items/' + dic_each_actor['Id'] + '/Images/Primary?api_key=' + api_key 101 | requests.post(url=url_post_img, data=b6_pic, headers=header) 102 | print('>>Success:', actor_name) 103 | num_suc += 1 104 | 105 | print('\nemby/jellyfin people: ', num_persons, '') 106 | print('include photos: ', num_exist, '') 107 | if bool_replace: 108 | print('Mode:Overwrite existed images') 109 | else: 110 | print('Mode:Skip existed images') 111 | print('Success Upload', num_suc, '个!') 112 | print('No images', num_fail, '个!') 113 | print('Saved to “no_included.txt”\n') 114 | os.system('pause') 115 | except: 116 | print(format_exc()) 117 | os.system('pause') 118 | 119 | 120 | -------------------------------------------------------------------------------- /avsox.py: -------------------------------------------------------------------------------- 1 | import re 2 | from lxml import etree 3 | import json 4 | from bs4 import BeautifulSoup 5 | from ADC_function import * 6 | # import sys 7 | # import io 8 | # sys.stdout = io.TextIOWrapper(sys.stdout.buffer, errors = 'replace', line_buffering = True) 9 | 10 | def getActorPhoto(htmlcode): #//*[@id="star_qdt"]/li/a/img 11 | soup = BeautifulSoup(htmlcode, 'lxml') 12 | a = soup.find_all(attrs={'class': 'avatar-box'}) 13 | d = {} 14 | for i in a: 15 | l = i.img['src'] 16 | t = i.span.get_text() 17 | p2 = {t: l} 18 | d.update(p2) 19 | return d 20 | def getTitle(a): 21 | try: 22 | html = etree.fromstring(a, etree.HTMLParser()) 23 | result = str(html.xpath('/html/body/div[2]/h3/text()')).strip(" ['']") #[0] 24 | return result.replace('/', '') 25 | except: 26 | return '' 27 | def getActor(a): #//*[@id="center_column"]/div[2]/div[1]/div/table/tbody/tr[1]/td/text() 28 | soup = BeautifulSoup(a, 'lxml') 29 | a = soup.find_all(attrs={'class': 'avatar-box'}) 30 | d = [] 31 | for i in a: 32 | d.append(i.span.get_text()) 33 | return d 34 | def getStudio(a): 35 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 36 | result1 = str(html.xpath('//p[contains(text(),"制作商: ")]/following-sibling::p[1]/a/text()')).strip(" ['']").replace("', '",' ') 37 | return result1 38 | def getRuntime(a): 39 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 40 | result1 = str(html.xpath('//span[contains(text(),"长度:")]/../text()')).strip(" ['分钟']") 41 | return result1 42 | def getLabel(a): 43 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 44 | result1 = str(html.xpath('//p[contains(text(),"系列:")]/following-sibling::p[1]/a/text()')).strip(" ['']") 45 | return result1 46 | def getNum(a): 47 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 48 | result1 = str(html.xpath('//span[contains(text(),"识别码:")]/../span[2]/text()')).strip(" ['']") 49 | return result1 50 | def getYear(release): 51 | try: 52 | result = str(re.search('\d{4}',release).group()) 53 | return result 54 | except: 55 | return release 56 | def getRelease(a): 57 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 58 | result1 = str(html.xpath('//span[contains(text(),"发行时间:")]/../text()')).strip(" ['']") 59 | return result1 60 | def getCover(htmlcode): 61 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 62 | result = str(html.xpath('/html/body/div[2]/div[1]/div[1]/a/img/@src')).strip(" ['']") 63 | return result 64 | def getCover_small(htmlcode): 65 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 66 | result = str(html.xpath('//*[@id="waterfall"]/div/a/div[1]/img/@src')).strip(" ['']") 67 | return result 68 | def getTag(a): # 获取演员 69 | soup = BeautifulSoup(a, 'lxml') 70 | a = soup.find_all(attrs={'class': 'genre'}) 71 | d = [] 72 | for i in a: 73 | d.append(i.get_text()) 74 | return d 75 | 76 | def main(number): 77 | a = get_html('https://avsox.host/cn/search/' + number) 78 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 79 | result1 = str(html.xpath('//*[@id="waterfall"]/div/a/@href')).strip(" ['']") 80 | if result1 == '' or result1 == 'null' or result1 == 'None': 81 | a = get_html('https://avsox.host/cn/search/' + number.replace('-', '_')) 82 | print(a) 83 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 84 | result1 = str(html.xpath('//*[@id="waterfall"]/div/a/@href')).strip(" ['']") 85 | if result1 == '' or result1 == 'null' or result1 == 'None': 86 | a = get_html('https://avsox.host/cn/search/' + number.replace('_', '')) 87 | print(a) 88 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 89 | result1 = str(html.xpath('//*[@id="waterfall"]/div/a/@href')).strip(" ['']") 90 | web = get_html(result1) 91 | soup = BeautifulSoup(web, 'lxml') 92 | info = str(soup.find(attrs={'class': 'row movie'})) 93 | dic = { 94 | 'actor': getActor(web), 95 | 'title': getTitle(web).strip(getNum(web)), 96 | 'studio': getStudio(info), 97 | 'outline': '',# 98 | 'runtime': getRuntime(info), 99 | 'director': '', # 100 | 'release': getRelease(info), 101 | 'number': getNum(info), 102 | 'cover': getCover(web), 103 | 'cover_small': getCover_small(a), 104 | 'imagecut': 3, 105 | 'tag': getTag(web), 106 | 'label': getLabel(info), 107 | 'year': getYear(getRelease(info)), # str(re.search('\d{4}',getRelease(a)).group()), 108 | 'actor_photo': getActorPhoto(web), 109 | 'website': result1, 110 | 'source': 'avsox.py', 111 | } 112 | js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'), ) # .encode('UTF-8') 113 | return js 114 | 115 | #print(main('012717_472')) -------------------------------------------------------------------------------- /config.ini: -------------------------------------------------------------------------------- 1 | [common] 2 | main_mode=1 3 | failed_output_folder=failed 4 | success_output_folder=JAV_output 5 | soft_link=0 6 | 7 | [proxy] 8 | proxy=127.0.0.1:1080 9 | timeout=10 10 | retry=3 11 | 12 | [Name_Rule] 13 | location_rule=actor+'/'+number 14 | naming_rule=number+'-'+title 15 | 16 | [update] 17 | update_check=1 18 | 19 | [priority] 20 | website=javbus,javdb,fanza,xcity,mgstage,fc2,avsox,jav321,javlib 21 | 22 | [escape] 23 | literals=\()/ 24 | folders=failed,JAV_output 25 | 26 | [debug_mode] 27 | switch=0 -------------------------------------------------------------------------------- /config.py: -------------------------------------------------------------------------------- 1 | import os 2 | import configparser 3 | 4 | 5 | class Config: 6 | def __init__(self, path: str = "config.ini"): 7 | if os.path.exists(path): 8 | self.conf = configparser.ConfigParser() 9 | self.conf.read(path, encoding="utf-8") 10 | else: 11 | print("[-] Config file not found! Use the default settings") 12 | self.conf = self._default_config() 13 | 14 | def main_mode(self) -> str: 15 | try: 16 | return self.conf.getint("common", "main_mode") 17 | except ValueError: 18 | self._exit("common:main_mode") 19 | 20 | def failed_folder(self) -> str: 21 | return self.conf.get("common", "failed_output_folder") 22 | 23 | def success_folder(self) -> str: 24 | return self.conf.get("common", "success_output_folder") 25 | 26 | def soft_link(self) -> bool: 27 | return self.conf.getboolean("common", "soft_link") 28 | 29 | def proxy(self) -> [str, int, int]: 30 | try: 31 | sec = "proxy" 32 | proxy = self.conf.get(sec, "proxy") 33 | timeout = self.conf.getint(sec, "timeout") 34 | retry = self.conf.getint(sec, "retry") 35 | 36 | return proxy, timeout, retry 37 | except ValueError: 38 | self._exit("common") 39 | 40 | def naming_rule(self) -> str: 41 | return self.conf.get("Name_Rule", "naming_rule") 42 | 43 | def location_rule(self) -> str: 44 | return self.conf.get("Name_Rule", "location_rule") 45 | 46 | def update_check(self) -> bool: 47 | try: 48 | return self.conf.getboolean("update", "update_check") 49 | except ValueError: 50 | self._exit("update:update_check") 51 | 52 | def sources(self) -> str: 53 | return self.conf.get("priority", "website") 54 | 55 | def escape_literals(self) -> str: 56 | return self.conf.get("escape", "literals") 57 | 58 | def escape_folder(self) -> str: 59 | return self.conf.get("escape", "folders") 60 | 61 | def debug(self) -> bool: 62 | return self.conf.getboolean("debug_mode", "switch") 63 | 64 | @staticmethod 65 | def _exit(sec: str) -> None: 66 | print("[-] Read config error! Please check the {} section in config.ini", sec) 67 | input("[-] Press ENTER key to exit.") 68 | exit() 69 | 70 | @staticmethod 71 | def _default_config() -> configparser.ConfigParser: 72 | conf = configparser.ConfigParser() 73 | 74 | sec1 = "common" 75 | conf.add_section(sec1) 76 | conf.set(sec1, "main_mode", "1") 77 | conf.set(sec1, "failed_output_folder", "failed") 78 | conf.set(sec1, "success_output_folder", "JAV_output") 79 | conf.set(sec1, "soft_link", "0") 80 | 81 | sec2 = "proxy" 82 | conf.add_section(sec2) 83 | conf.set(sec2, "proxy", "127.0.0.1:1080") 84 | conf.set(sec2, "timeout", "10") 85 | conf.set(sec2, "retry", "3") 86 | 87 | sec3 = "Name_Rule" 88 | conf.add_section(sec3) 89 | conf.set(sec3, "location_rule", "actor + '/' + number") 90 | conf.set(sec3, "naming_rule", "number + '-' + title") 91 | 92 | sec4 = "update" 93 | conf.add_section(sec4) 94 | conf.set(sec4, "update_check", "1") 95 | 96 | sec5 = "priority" 97 | conf.add_section(sec5) 98 | conf.set(sec5, "website", "javbus,javdb,fanza,xcity,mgstage,fc2,avsox,jav321,xcity") 99 | 100 | sec6 = "escape" 101 | conf.add_section(sec6) 102 | conf.set(sec6, "literals", "\()/") # noqa 103 | conf.set(sec6, "folders", "failed, JAV_output") 104 | 105 | sec7 = "debug_mode" 106 | conf.add_section(sec7) 107 | conf.set(sec7, "switch", "0") 108 | 109 | return conf 110 | 111 | 112 | if __name__ == "__main__": 113 | config = Config() 114 | print(config.main_mode()) 115 | print(config.failed_folder()) 116 | print(config.success_folder()) 117 | print(config.soft_link()) 118 | print(config.proxy()) 119 | print(config.naming_rule()) 120 | print(config.location_rule()) 121 | print(config.update_check()) 122 | print(config.sources()) 123 | print(config.escape_literals()) 124 | print(config.escape_folder()) 125 | print(config.debug()) 126 | -------------------------------------------------------------------------------- /core.py: -------------------------------------------------------------------------------- 1 | import json 2 | import os.path 3 | import re 4 | import shutil 5 | import platform 6 | 7 | from PIL import Image 8 | from ADC_function import * 9 | 10 | # =========website======== 11 | import avsox 12 | import fanza 13 | import fc2fans_club 14 | import jav321 15 | import javbus 16 | import javdb 17 | import mgstage 18 | import xcity 19 | import javlib 20 | 21 | 22 | def escape_path(path, escape_literals: str): # Remove escape literals 23 | backslash = '\\' 24 | for literal in escape_literals: 25 | path = path.replace(backslash + literal, '') 26 | return path 27 | 28 | 29 | def moveFailedFolder(filepath, failed_folder): 30 | print('[-]Move to Failed output folder') 31 | shutil.move(filepath, str(os.getcwd()) + '/' + failed_folder + '/') 32 | return 33 | 34 | 35 | def CreatFailedFolder(failed_folder): 36 | if not os.path.exists(failed_folder + '/'): # 新建failed文件夹 37 | try: 38 | os.makedirs(failed_folder + '/') 39 | except: 40 | print("[-]failed!can not be make Failed output folder\n[-](Please run as Administrator)") 41 | return 42 | 43 | 44 | def get_data_from_json(file_number, filepath, conf: config.Config): # 从JSON返回元数据 45 | """ 46 | iterate through all services and fetch the data 47 | """ 48 | 49 | func_mapping = { 50 | "avsox": avsox.main, 51 | "fc2": fc2fans_club.main, 52 | "fanza": fanza.main, 53 | "javdb": javdb.main, 54 | "javbus": javbus.main, 55 | "mgstage": mgstage.main, 56 | "jav321": jav321.main, 57 | "xcity": xcity.main, 58 | "javlib": javlib.main, 59 | } 60 | 61 | # default fetch order list, from the beginning to the end 62 | sources = conf.sources().split(',') 63 | 64 | # if the input file name matches certain rules, 65 | # move some web service to the beginning of the list 66 | if re.match(r"^\d{5,}", file_number) or ( 67 | "HEYZO" in file_number or "heyzo" in file_number or "Heyzo" in file_number 68 | ): 69 | sources.insert(0, sources.pop(sources.index("avsox"))) 70 | elif re.match(r"\d+\D+", file_number) or ( 71 | "siro" in file_number or "SIRO" in file_number or "Siro" in file_number 72 | ): 73 | sources.insert(0, sources.pop(sources.index("fanza"))) 74 | elif "fc2" in file_number or "FC2" in file_number: 75 | sources.insert(0, sources.pop(sources.index("fc2"))) 76 | 77 | json_data = {} 78 | for source in sources: 79 | json_data = json.loads(func_mapping[source](file_number)) 80 | # if any service return a valid return, break 81 | if get_data_state(json_data): 82 | break 83 | 84 | # Return if data not found in all sources 85 | if not json_data: 86 | print('[-]Movie Data not found!') 87 | moveFailedFolder(filepath, conf.failed_folder()) 88 | return 89 | 90 | # ================================================网站规则添加结束================================================ 91 | 92 | title = json_data['title'] 93 | actor_list = str(json_data['actor']).strip("[ ]").replace("'", '').split(',') # 字符串转列表 94 | release = json_data['release'] 95 | number = json_data['number'] 96 | studio = json_data['studio'] 97 | source = json_data['source'] 98 | runtime = json_data['runtime'] 99 | outline = json_data['outline'] 100 | label = json_data['label'] 101 | year = json_data['year'] 102 | try: 103 | cover_small = json_data['cover_small'] 104 | except: 105 | cover_small = '' 106 | imagecut = json_data['imagecut'] 107 | tag = str(json_data['tag']).strip("[ ]").replace("'", '').replace(" ", '').split(',') # 字符串转列表 @ 108 | actor = str(actor_list).strip("[ ]").replace("'", '').replace(" ", '') 109 | 110 | if title == '' or number == '': 111 | print('[-]Movie Data not found!') 112 | moveFailedFolder(filepath, conf.failed_folder()) 113 | return 114 | 115 | # if imagecut == '3': 116 | # DownloadFileWithFilename() 117 | 118 | # ====================处理异常字符====================== #\/:*?"<>| 119 | title = title.replace('\\', '') 120 | title = title.replace('/', '') 121 | title = title.replace(':', '') 122 | title = title.replace('*', '') 123 | title = title.replace('?', '') 124 | title = title.replace('"', '') 125 | title = title.replace('<', '') 126 | title = title.replace('>', '') 127 | title = title.replace('|', '') 128 | release = release.replace('/', '-') 129 | tmpArr = cover_small.split(',') 130 | if len(tmpArr) > 0: 131 | cover_small = tmpArr[0].strip('\"').strip('\'') 132 | # ====================处理异常字符 END================== #\/:*?"<>| 133 | 134 | location_rule = eval(conf.location_rule()) 135 | 136 | # Process only Windows. 137 | if platform.system() == "Windows": 138 | if 'actor' in conf.location_rule() and len(actor) > 100: 139 | print(conf.location_rule()) 140 | location_rule = eval(conf.location_rule().replace("actor","'多人作品'")) 141 | if 'title' in conf.location_rule() and len(title) > 100: 142 | location_rule = eval(conf.location_rule().replace("title",'number')) 143 | 144 | # 返回处理后的json_data 145 | json_data['title'] = title 146 | json_data['actor'] = actor 147 | json_data['release'] = release 148 | json_data['cover_small'] = cover_small 149 | json_data['tag'] = tag 150 | json_data['naming_rule'] = eval(conf.naming_rule()) 151 | json_data['location_rule'] = location_rule 152 | json_data['year'] = year 153 | json_data['actor_list'] = actor_list 154 | return json_data 155 | 156 | 157 | def get_info(json_data): # 返回json里的数据 158 | title = json_data['title'] 159 | studio = json_data['studio'] 160 | year = json_data['year'] 161 | outline = json_data['outline'] 162 | runtime = json_data['runtime'] 163 | director = json_data['director'] 164 | actor_photo = json_data['actor_photo'] 165 | release = json_data['release'] 166 | number = json_data['number'] 167 | cover = json_data['cover'] 168 | website = json_data['website'] 169 | return title, studio, year, outline, runtime, director, actor_photo, release, number, cover, website 170 | 171 | 172 | def small_cover_check(path, number, cover_small, c_word, conf: config.Config, filepath, failed_folder): 173 | download_file_with_filename(cover_small, number + c_word + '-poster.jpg', path, conf, filepath, failed_folder) 174 | print('[+]Image Downloaded! ' + path + '/' + number + c_word + '-poster.jpg') 175 | 176 | 177 | def create_folder(success_folder, location_rule, json_data, conf: config.Config): # 创建文件夹 178 | title, studio, year, outline, runtime, director, actor_photo, release, number, cover, website= get_info(json_data) 179 | if len(location_rule) > 240: # 新建成功输出文件夹 180 | path = success_folder + '/' + location_rule.replace("'actor'", "'manypeople'", 3).replace("actor","'manypeople'",3) # path为影片+元数据所在目录 181 | else: 182 | path = success_folder + '/' + location_rule 183 | if not os.path.exists(path): 184 | path = escape_path(path, conf.escape_literals()) 185 | try: 186 | os.makedirs(path) 187 | except: 188 | path = success_folder + '/' + location_rule.replace('/[' + number + ']-' + title, "/number") 189 | path = escape_path(path, conf.escape_literals()) 190 | 191 | os.makedirs(path) 192 | return path 193 | 194 | 195 | # =====================资源下载部分=========================== 196 | 197 | # path = examle:photo , video.in the Project Folder! 198 | def download_file_with_filename(url, filename, path, conf: config.Config, filepath, failed_folder): 199 | proxy, timeout, retry_count = conf.proxy() 200 | 201 | for i in range(retry_count): 202 | try: 203 | if not proxy == '': 204 | if not os.path.exists(path): 205 | os.makedirs(path) 206 | headers = { 207 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36'} 208 | r = requests.get(url, headers=headers, timeout=timeout, 209 | proxies={"http": "http://" + str(proxy), "https": "https://" + str(proxy)}) 210 | if r == '': 211 | print('[-]Movie Data not found!') 212 | return 213 | with open(str(path) + "/" + filename, "wb") as code: 214 | code.write(r.content) 215 | return 216 | else: 217 | if not os.path.exists(path): 218 | os.makedirs(path) 219 | headers = { 220 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36'} 221 | r = requests.get(url, timeout=timeout, headers=headers) 222 | if r == '': 223 | print('[-]Movie Data not found!') 224 | return 225 | with open(str(path) + "/" + filename, "wb") as code: 226 | code.write(r.content) 227 | return 228 | except requests.exceptions.RequestException: 229 | i += 1 230 | print('[-]Image Download : Connect retry ' + str(i) + '/' + str(retry_count)) 231 | except requests.exceptions.ConnectionError: 232 | i += 1 233 | print('[-]Image Download : Connect retry ' + str(i) + '/' + str(retry_count)) 234 | except requests.exceptions.ProxyError: 235 | i += 1 236 | print('[-]Image Download : Connect retry ' + str(i) + '/' + str(retry_count)) 237 | except requests.exceptions.ConnectTimeout: 238 | i += 1 239 | print('[-]Image Download : Connect retry ' + str(i) + '/' + str(retry_count)) 240 | print('[-]Connect Failed! Please check your Proxy or Network!') 241 | moveFailedFolder(filepath, failed_folder) 242 | return 243 | 244 | 245 | # 封面是否下载成功,否则移动到failed 246 | def image_download(cover, number, c_word, path, conf: config.Config, filepath, failed_folder): 247 | if download_file_with_filename(cover, number + c_word + '-fanart.jpg', path, conf, filepath, failed_folder) == 'failed': 248 | moveFailedFolder(filepath, failed_folder) 249 | return 250 | 251 | _proxy, _timeout, retry = conf.proxy() 252 | for i in range(retry): 253 | if os.path.getsize(path + '/' + number + c_word + '-fanart.jpg') == 0: 254 | print('[!]Image Download Failed! Trying again. [{}/3]', i + 1) 255 | download_file_with_filename(cover, number + c_word + '-fanart.jpg', path, conf, filepath, failed_folder) 256 | continue 257 | else: 258 | break 259 | if os.path.getsize(path + '/' + number + c_word + '-fanart.jpg') == 0: 260 | return 261 | print('[+]Image Downloaded!', path + '/' + number + c_word + '-fanart.jpg') 262 | shutil.copyfile(path + '/' + number + c_word + '-fanart.jpg',path + '/' + number + c_word + '-thumb.jpg') 263 | 264 | 265 | def print_files(path, c_word, naming_rule, part, cn_sub, json_data, filepath, failed_folder, tag, actor_list, liuchu): 266 | title, studio, year, outline, runtime, director, actor_photo, release, number, cover, website = get_info(json_data) 267 | 268 | try: 269 | if not os.path.exists(path): 270 | os.makedirs(path) 271 | with open(path + "/" + number + part + c_word + ".nfo", "wt", encoding='UTF-8') as code: 272 | print('<?xml version="1.0" encoding="UTF-8" ?>', file=code) 273 | print("<movie>", file=code) 274 | print(" <title>" + naming_rule + "", file=code) 275 | print(" ", file=code) 276 | print(" ", file=code) 277 | print(" " + studio + "+", file=code) 278 | print(" " + year + "", file=code) 279 | print(" " + outline + "", file=code) 280 | print(" " + outline + "", file=code) 281 | print(" " + str(runtime).replace(" ", "") + "", file=code) 282 | print(" " + director + "", file=code) 283 | print(" " + number + c_word + "-poster.jpg", file=code) 284 | print(" " + number + c_word + "-thumb.jpg", file=code) 285 | print(" " + number + c_word + '-fanart.jpg' + "", file=code) 286 | try: 287 | for key in actor_list: 288 | print(" ", file=code) 289 | print(" " + key + "", file=code) 290 | print(" ", file=code) 291 | except: 292 | aaaa = '' 293 | print(" " + studio + "", file=code) 294 | print(" ", file=code) 296 | if cn_sub == '1': 297 | print(" 中文字幕", file=code) 298 | if liuchu == '流出': 299 | print(" 流出", file=code) 300 | try: 301 | for i in tag: 302 | print(" " + i + "", file=code) 303 | except: 304 | aaaaa = '' 305 | try: 306 | for i in tag: 307 | print(" " + i + "", file=code) 308 | except: 309 | aaaaaaaa = '' 310 | if cn_sub == '1': 311 | print(" 中文字幕", file=code) 312 | print(" " + number + "", file=code) 313 | print(" " + release + "", file=code) 314 | print(" " + cover + "", file=code) 315 | print(" " + website + "", file=code) 316 | print("", file=code) 317 | print("[+]Wrote! " + path + "/" + number + part + c_word + ".nfo") 318 | except IOError as e: 319 | print("[-]Write Failed!") 320 | print(e) 321 | moveFailedFolder(filepath, failed_folder) 322 | return 323 | except Exception as e1: 324 | print(e1) 325 | print("[-]Write Failed!") 326 | moveFailedFolder(filepath, failed_folder) 327 | return 328 | 329 | 330 | def cutImage(imagecut, path, number, c_word): 331 | if imagecut == 1: 332 | try: 333 | img = Image.open(path + '/' + number + c_word + '-fanart.jpg') 334 | imgSize = img.size 335 | w = img.width 336 | h = img.height 337 | img2 = img.crop((w / 1.9, 0, w, h)) 338 | img2.save(path + '/' + number + c_word + '-poster.jpg') 339 | print('[+]Image Cutted! ' + path + '/' + number + c_word + '-poster.jpg') 340 | except: 341 | print('[-]Cover cut failed!') 342 | elif imagecut == 0: 343 | shutil.copyfile(path + '/' + number + c_word + '-fanart.jpg',path + '/' + number + c_word + '-poster.jpg') 344 | print('[+]Image Copyed! ' + path + '/' + number + c_word + '-poster.jpg') 345 | 346 | 347 | def paste_file_to_folder(filepath, path, number, c_word, conf: config.Config): # 文件路径,番号,后缀,要移动至的位置 348 | houzhui = str(re.search('[.](AVI|RMVB|WMV|MOV|MP4|MKV|FLV|TS|WEBM|avi|rmvb|wmv|mov|mp4|mkv|flv|ts|webm)$', filepath).group()) 349 | 350 | try: 351 | # 如果soft_link=1 使用软链接 352 | if conf.soft_link(): 353 | os.symlink(filepath, path + '/' + number + c_word + houzhui) 354 | else: 355 | os.rename(filepath, path + '/' + number + c_word + houzhui) 356 | if os.path.exists(os.getcwd() + '/' + number + c_word + '.srt'): # 字幕移动 357 | os.rename(os.getcwd() + '/' + number + c_word + '.srt', path + '/' + number + c_word + '.srt') 358 | print('[+]Sub moved!') 359 | elif os.path.exists(os.getcwd() + '/' + number + c_word + '.ssa'): 360 | os.rename(os.getcwd() + '/' + number + c_word + '.ssa', path + '/' + number + c_word + '.ssa') 361 | print('[+]Sub moved!') 362 | elif os.path.exists(os.getcwd() + '/' + number + c_word + '.sub'): 363 | os.rename(os.getcwd() + '/' + number + c_word + '.sub', path + '/' + number + c_word + '.sub') 364 | print('[+]Sub moved!') 365 | except FileExistsError: 366 | print('[-]File Exists! Please check your movie!') 367 | print('[-]move to the root folder of the program.') 368 | return 369 | except PermissionError: 370 | print('[-]Error! Please run as administrator!') 371 | return 372 | 373 | 374 | def paste_file_to_folder_mode2(filepath, path, multi_part, number, part, c_word, conf): # 文件路径,番号,后缀,要移动至的位置 375 | if multi_part == 1: 376 | number += part # 这时number会被附加上CD1后缀 377 | houzhui = str(re.search('[.](AVI|RMVB|WMV|MOV|MP4|MKV|FLV|TS|WEBM|avi|rmvb|wmv|mov|mp4|mkv|flv|ts|webm)$', filepath).group()) 378 | 379 | try: 380 | if conf.soft_link(): 381 | os.symlink(filepath, path + '/' + number + part + c_word + houzhui) 382 | else: 383 | os.rename(filepath, path + '/' + number + part + c_word + houzhui) 384 | if os.path.exists(number + '.srt'): # 字幕移动 385 | os.rename(number + part + c_word + '.srt', path + '/' + number + part + c_word + '.srt') 386 | print('[+]Sub moved!') 387 | elif os.path.exists(number + part + c_word + '.ass'): 388 | os.rename(number + part + c_word + '.ass', path + '/' + number + part + c_word + '.ass') 389 | print('[+]Sub moved!') 390 | elif os.path.exists(number + part + c_word + '.sub'): 391 | os.rename(number + part + c_word + '.sub', path + '/' + number + part + c_word + '.sub') 392 | print('[+]Sub moved!') 393 | print('[!]Success') 394 | except FileExistsError: 395 | print('[-]File Exists! Please check your movie!') 396 | print('[-]move to the root folder of the program.') 397 | return 398 | except PermissionError: 399 | print('[-]Error! Please run as administrator!') 400 | return 401 | 402 | def get_part(filepath, failed_folder): 403 | try: 404 | if re.search('-CD\d+', filepath): 405 | return re.findall('-CD\d+', filepath)[0] 406 | if re.search('-cd\d+', filepath): 407 | return re.findall('-cd\d+', filepath)[0] 408 | except: 409 | print("[-]failed!Please rename the filename again!") 410 | moveFailedFolder(filepath, failed_folder) 411 | return 412 | 413 | 414 | def debug_print(data: json): 415 | try: 416 | print("[+] ---Debug info---") 417 | for i, v in data.items(): 418 | if i == "outline": 419 | print("[+] -", i, " :", len(v), "characters") 420 | continue 421 | if i == "actor_photo" or i == "year": 422 | continue 423 | print("[+] -", "%-11s" % i, ":", v) 424 | print("[+] ---Debug info---") 425 | except: 426 | pass 427 | 428 | 429 | def core_main(file_path, number_th, conf: config.Config): 430 | # =======================================================================初始化所需变量 431 | multi_part = 0 432 | part = '' 433 | c_word = '' 434 | cn_sub = '' 435 | liuchu = '' 436 | 437 | filepath = file_path # 影片的路径 438 | number = number_th 439 | json_data = get_data_from_json(number, filepath, conf) # 定义番号 440 | 441 | # Return if blank dict returned (data not found) 442 | if not json_data: 443 | return 444 | 445 | if json_data["number"] != number: 446 | # fix issue #119 447 | # the root cause is we normalize the search id 448 | # print_files() will use the normalized id from website, 449 | # but paste_file_to_folder() still use the input raw search id 450 | # so the solution is: use the normalized search id 451 | number = json_data["number"] 452 | imagecut = json_data['imagecut'] 453 | tag = json_data['tag'] 454 | # =======================================================================判断-C,-CD后缀 455 | if '-CD' in filepath or '-cd' in filepath: 456 | multi_part = 1 457 | part = get_part(filepath, conf.failed_folder()) 458 | if '-c.' in filepath or '-C.' in filepath or '中文' in filepath or '字幕' in filepath: 459 | cn_sub = '1' 460 | c_word = '-C' # 中文字幕影片后缀 461 | if '流出' in filepath: 462 | liuchu = '流出' 463 | 464 | # 创建输出失败目录 465 | CreatFailedFolder(conf.failed_folder()) 466 | 467 | # 调试模式检测 468 | if conf.debug(): 469 | debug_print(json_data) 470 | 471 | # 创建文件夹 472 | path = create_folder(conf.success_folder(), json_data['location_rule'], json_data, conf) 473 | 474 | # main_mode 475 | # 1: 刮削模式 / Scraping mode 476 | # 2: 整理模式 / Organizing mode 477 | if conf.main_mode() == 1: 478 | if multi_part == 1: 479 | number += part # 这时number会被附加上CD1后缀 480 | 481 | # 检查小封面 482 | if imagecut == 3: 483 | small_cover_check(path, number, json_data['cover_small'], c_word, conf, filepath, conf.failed_folder()) 484 | 485 | # creatFolder会返回番号路径 486 | image_download(json_data['cover'], number, c_word, path, conf, filepath, conf.failed_folder()) 487 | 488 | # 裁剪图 489 | cutImage(imagecut, path, number, c_word) 490 | 491 | # 打印文件 492 | print_files(path, c_word, json_data['naming_rule'], part, cn_sub, json_data, filepath, conf.failed_folder(), tag, json_data['actor_list'], liuchu) 493 | 494 | # 移动文件 495 | paste_file_to_folder(filepath, path, number, c_word, conf) 496 | elif conf.main_mode() == 2: 497 | # 移动文件 498 | paste_file_to_folder_mode2(filepath, path, multi_part, number, part, c_word, conf) 499 | -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:slim 2 | RUN sed -i 's/deb.debian.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list \ 3 | && sed -i 's/security.debian.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list 4 | RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pip -U \ 5 | && pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple 6 | 7 | RUN apt-get update \ 8 | && apt-get install -y wget ca-certificates \ 9 | && wget -O - 'https://github.com/yoshiko2/AV_Data_Capture/archive/master.tar.gz' | tar xz \ 10 | && mv AV_Data_Capture-master /jav \ 11 | && cd /jav \ 12 | && ( pip install --no-cache-dir -r requirements.txt || true ) \ 13 | && pip install --no-cache-dir requests pyquery lxml Beautifulsoup4 pillow \ 14 | && apt-get purge -y wget 15 | 16 | WORKDIR /jav 17 | -------------------------------------------------------------------------------- /docker/config.ini: -------------------------------------------------------------------------------- 1 | [common] 2 | main_mode=1 3 | failed_output_folder=data/failure_output 4 | success_output_folder=data/organized 5 | soft_link=0 6 | 7 | [proxy] 8 | proxy= 9 | timeout=10 10 | retry=3 11 | 12 | [Name_Rule] 13 | location_rule=actor+'/'+number 14 | naming_rule=number+'-'+title 15 | 16 | [update] 17 | update_check=0 18 | 19 | [escape] 20 | literals=\()/ 21 | folders=data/failure_output,data/organized 22 | 23 | [debug_mode] 24 | switch=0 25 | 26 | [media] 27 | media_warehouse=plex 28 | -------------------------------------------------------------------------------- /docker/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: "2.2" 2 | services: 3 | jav: 4 | user: "${JAVUID}:${JAVGID}" 5 | image: jav:local 6 | build: . 7 | volumes: 8 | - ./config.ini:/jav/config.ini 9 | - ${JAV_PATH}:/jav/data 10 | command: 11 | - python 12 | - /jav/AV_Data_Capture.py 13 | - -a 14 | -------------------------------------------------------------------------------- /fanza.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | # -*- coding: utf-8 -*- 3 | import json 4 | import re 5 | 6 | from lxml import etree 7 | 8 | from ADC_function import * 9 | 10 | # import sys 11 | # import io 12 | # sys.stdout = io.TextIOWrapper(sys.stdout.buffer, errors = 'replace', line_buffering = True) 13 | 14 | 15 | def getTitle(text): 16 | html = etree.fromstring(text, etree.HTMLParser()) 17 | result = html.xpath('//*[@id="title"]/text()')[0] 18 | return result 19 | 20 | 21 | def getActor(text): 22 | # //*[@id="center_column"]/div[2]/div[1]/div/table/tbody/tr[1]/td/text() 23 | html = etree.fromstring(text, etree.HTMLParser()) 24 | result = ( 25 | str( 26 | html.xpath( 27 | "//td[contains(text(),'出演者')]/following-sibling::td/span/a/text()" 28 | ) 29 | ) 30 | .strip(" ['']") 31 | .replace("', '", ",") 32 | ) 33 | return result 34 | 35 | 36 | def getStudio(text): 37 | html = etree.fromstring(text, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 38 | try: 39 | result = html.xpath( 40 | "//td[contains(text(),'メーカー')]/following-sibling::td/a/text()" 41 | )[0] 42 | except: 43 | result = html.xpath( 44 | "//td[contains(text(),'メーカー')]/following-sibling::td/text()" 45 | )[0] 46 | return result 47 | 48 | 49 | def getRuntime(text): 50 | html = etree.fromstring(text, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 51 | result = html.xpath("//td[contains(text(),'収録時間')]/following-sibling::td/text()")[0] 52 | return re.search(r"\d+", str(result)).group() 53 | 54 | 55 | def getLabel(text): 56 | html = etree.fromstring(text, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 57 | try: 58 | result = html.xpath( 59 | "//td[contains(text(),'シリーズ:')]/following-sibling::td/a/text()" 60 | )[0] 61 | except: 62 | result = html.xpath( 63 | "//td[contains(text(),'シリーズ:')]/following-sibling::td/text()" 64 | )[0] 65 | return result 66 | 67 | 68 | def getNum(text): 69 | html = etree.fromstring(text, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 70 | try: 71 | result = html.xpath( 72 | "//td[contains(text(),'品番:')]/following-sibling::td/a/text()" 73 | )[0] 74 | except: 75 | result = html.xpath( 76 | "//td[contains(text(),'品番:')]/following-sibling::td/text()" 77 | )[0] 78 | return result 79 | 80 | 81 | def getYear(getRelease): 82 | try: 83 | result = str(re.search(r"\d{4}", getRelease).group()) 84 | return result 85 | except: 86 | return getRelease 87 | 88 | 89 | def getRelease(text): 90 | html = etree.fromstring(text, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 91 | try: 92 | result = html.xpath( 93 | "//td[contains(text(),'発売日:')]/following-sibling::td/a/text()" 94 | )[0].lstrip("\n") 95 | except: 96 | result = html.xpath( 97 | "//td[contains(text(),'発売日:')]/following-sibling::td/text()" 98 | )[0].lstrip("\n") 99 | if result == "----": 100 | try: 101 | result = html.xpath( 102 | "//td[contains(text(),'配信開始日:')]/following-sibling::td/a/text()" 103 | )[0].lstrip("\n") 104 | except: 105 | try: 106 | result = html.xpath( 107 | "//td[contains(text(),'配信開始日:')]/following-sibling::td/text()" 108 | )[0].lstrip("\n") 109 | except: 110 | pass 111 | return result 112 | 113 | 114 | def getTag(text): 115 | html = etree.fromstring(text, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 116 | try: 117 | result = html.xpath( 118 | "//td[contains(text(),'ジャンル:')]/following-sibling::td/a/text()" 119 | ) 120 | except: 121 | result = html.xpath( 122 | "//td[contains(text(),'ジャンル:')]/following-sibling::td/text()" 123 | ) 124 | return result 125 | 126 | 127 | def getCover(text, number): 128 | html = etree.fromstring(text, etree.HTMLParser()) 129 | cover_number = number 130 | try: 131 | result = html.xpath('//*[@id="' + cover_number + '"]/@href')[0] 132 | except: 133 | # sometimes fanza modify _ to \u0005f for image id 134 | if "_" in cover_number: 135 | cover_number = cover_number.replace("_", r"\u005f") 136 | try: 137 | result = html.xpath('//*[@id="' + cover_number + '"]/@href')[0] 138 | except: 139 | # (TODO) handle more edge case 140 | # print(html) 141 | # raise exception here, same behavior as before 142 | # people's major requirement is fetching the picture 143 | raise ValueError("can not find image") 144 | return result 145 | 146 | 147 | def getDirector(text): 148 | html = etree.fromstring(text, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 149 | try: 150 | result = html.xpath( 151 | "//td[contains(text(),'監督:')]/following-sibling::td/a/text()" 152 | )[0] 153 | except: 154 | result = html.xpath( 155 | "//td[contains(text(),'監督:')]/following-sibling::td/text()" 156 | )[0] 157 | return result 158 | 159 | 160 | def getOutline(text): 161 | html = etree.fromstring(text, etree.HTMLParser()) 162 | try: 163 | result = str(html.xpath("//div[@class='mg-b20 lh4']/text()")[0]).replace( 164 | "\n", "" 165 | ) 166 | if result == "": 167 | result = str(html.xpath("//div[@class='mg-b20 lh4']//p/text()")[0]).replace( 168 | "\n", "" 169 | ) 170 | except: 171 | # (TODO) handle more edge case 172 | # print(html) 173 | return "" 174 | return result 175 | 176 | 177 | def main(number): 178 | # fanza allow letter + number + underscore, normalize the input here 179 | # @note: I only find the usage of underscore as h_test123456789 180 | fanza_search_number = number 181 | # AV_Data_Capture.py.getNumber() over format the input, restore the h_ prefix 182 | if fanza_search_number.startswith("h-"): 183 | fanza_search_number = fanza_search_number.replace("h-", "h_") 184 | 185 | fanza_search_number = re.sub(r"[^0-9a-zA-Z_]", "", fanza_search_number).lower() 186 | 187 | fanza_urls = [ 188 | "https://www.dmm.co.jp/digital/videoa/-/detail/=/cid=", 189 | "https://www.dmm.co.jp/mono/dvd/-/detail/=/cid=", 190 | "https://www.dmm.co.jp/digital/anime/-/detail/=/cid=", 191 | "https://www.dmm.co.jp/mono/anime/-/detail/=/cid=", 192 | "https://www.dmm.co.jp/digital/videoc/-/detail/=/cid=", 193 | "https://www.dmm.co.jp/digital/nikkatsu/-/detail/=/cid=", 194 | ] 195 | chosen_url = "" 196 | for url in fanza_urls: 197 | chosen_url = url + fanza_search_number 198 | htmlcode = get_html(chosen_url) 199 | if "404 Not Found" not in htmlcode: 200 | break 201 | if "404 Not Found" in htmlcode: 202 | return json.dumps({"title": "",}) 203 | try: 204 | # for some old page, the input number does not match the page 205 | # for example, the url will be cid=test012 206 | # but the hinban on the page is test00012 207 | # so get the hinban first, and then pass it to following functions 208 | fanza_hinban = getNum(htmlcode) 209 | data = { 210 | "title": getTitle(htmlcode).strip(), 211 | "studio": getStudio(htmlcode), 212 | "outline": getOutline(htmlcode), 213 | "runtime": getRuntime(htmlcode), 214 | "director": getDirector(htmlcode) if "anime" not in chosen_url else "", 215 | "actor": getActor(htmlcode) if "anime" not in chosen_url else "", 216 | "release": getRelease(htmlcode), 217 | "number": fanza_hinban, 218 | "cover": getCover(htmlcode, fanza_hinban), 219 | "imagecut": 1, 220 | "tag": getTag(htmlcode), 221 | "label": getLabel(htmlcode), 222 | "year": getYear( 223 | getRelease(htmlcode) 224 | ), # str(re.search('\d{4}',getRelease(a)).group()), 225 | "actor_photo": "", 226 | "website": chosen_url, 227 | "source": "fanza.py", 228 | } 229 | except: 230 | data = { 231 | "title": "", 232 | } 233 | js = json.dumps( 234 | data, ensure_ascii=False, sort_keys=True, indent=4, separators=(",", ":") 235 | ) # .encode('UTF-8') 236 | return js 237 | 238 | 239 | def main_htmlcode(number): 240 | # fanza allow letter + number + underscore, normalize the input here 241 | # @note: I only find the usage of underscore as h_test123456789 242 | fanza_search_number = number 243 | # AV_Data_Capture.py.getNumber() over format the input, restore the h_ prefix 244 | if fanza_search_number.startswith("h-"): 245 | fanza_search_number = fanza_search_number.replace("h-", "h_") 246 | 247 | fanza_search_number = re.sub(r"[^0-9a-zA-Z_]", "", fanza_search_number).lower() 248 | 249 | fanza_urls = [ 250 | "https://www.dmm.co.jp/digital/videoa/-/detail/=/cid=", 251 | "https://www.dmm.co.jp/mono/dvd/-/detail/=/cid=", 252 | "https://www.dmm.co.jp/digital/anime/-/detail/=/cid=", 253 | "https://www.dmm.co.jp/mono/anime/-/detail/=/cid=", 254 | "https://www.dmm.co.jp/digital/videoc/-/detail/=/cid=", 255 | "https://www.dmm.co.jp/digital/nikkatsu/-/detail/=/cid=", 256 | ] 257 | chosen_url = "" 258 | for url in fanza_urls: 259 | chosen_url = url + fanza_search_number 260 | htmlcode = get_html(chosen_url) 261 | if "404 Not Found" not in htmlcode: 262 | break 263 | if "404 Not Found" in htmlcode: 264 | return json.dumps({"title": "",}) 265 | return htmlcode 266 | 267 | 268 | if __name__ == "__main__": 269 | # print(main("DV-1562")) 270 | # input("[+][+]Press enter key exit, you can check the error messge before you exit.\n[+][+]按回车键结束,你可以在结束之前查看和错误信息。") 271 | # print(main("ipx292")) 272 | pass 273 | -------------------------------------------------------------------------------- /fc2fans_club.py: -------------------------------------------------------------------------------- 1 | import re 2 | from lxml import etree#need install 3 | import json 4 | import ADC_function 5 | # import sys 6 | # import io 7 | # sys.stdout = io.TextIOWrapper(sys.stdout.buffer, errors = 'replace', line_buffering = True) 8 | 9 | def getTitle(htmlcode): #获取厂商 10 | #print(htmlcode) 11 | html = etree.fromstring(htmlcode,etree.HTMLParser()) 12 | result = str(html.xpath('/html/body/div[2]/div/div[1]/h3/text()')).strip(" ['']") 13 | result2 = str(re.sub('\D{2}2-\d+','',result)).replace(' ','',1) 14 | #print(result2) 15 | return result2 16 | def getActor(htmlcode): 17 | try: 18 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 19 | result = str(html.xpath('/html/body/div[2]/div/div[1]/h5[5]/a/text()')).strip(" ['']") 20 | return result 21 | except: 22 | return '' 23 | def getStudio(htmlcode): #获取厂商 24 | html = etree.fromstring(htmlcode,etree.HTMLParser()) 25 | result = str(html.xpath('/html/body/div[2]/div/div[1]/h5[3]/a[1]/text()')).strip(" ['']") 26 | return result 27 | def getNum(htmlcode): #获取番号 28 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 29 | result = str(html.xpath('/html/body/div[5]/div[1]/div[2]/p[1]/span[2]/text()')).strip(" ['']") 30 | #print(result) 31 | return result 32 | def getRelease(htmlcode2): # 33 | #a=ADC_function.get_html('http://adult.contents.fc2.com/article_search.php?id='+str(number).lstrip("FC2-").lstrip("fc2-").lstrip("fc2_").lstrip("fc2-")+'&utm_source=aff_php&utm_medium=source_code&utm_campaign=from_aff_php') 34 | html=etree.fromstring(htmlcode2,etree.HTMLParser()) 35 | result = str(html.xpath('//*[@id="container"]/div[1]/div/article/section[1]/div/div[2]/dl/dd[4]/text()')).strip(" ['']") 36 | return result 37 | def getCover(htmlcode,number,htmlcode2): #获取厂商 # 38 | #a = ADC_function.get_html('http://adult.contents.fc2.com/article_search.php?id=' + str(number).lstrip("FC2-").lstrip("fc2-").lstrip("fc2_").lstrip("fc2-") + '&utm_source=aff_php&utm_medium=source_code&utm_campaign=from_aff_php') 39 | html = etree.fromstring(htmlcode2, etree.HTMLParser()) 40 | result = str(html.xpath('//*[@id="container"]/div[1]/div/article/section[1]/div/div[1]/a/img/@src')).strip(" ['']") 41 | if result == '': 42 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 43 | result2 = str(html.xpath('//*[@id="slider"]/ul[1]/li[1]/img/@src')).strip(" ['']") 44 | return 'https://fc2club.com' + result2 45 | return 'http:' + result 46 | def getOutline(htmlcode2): #获取番号 # 47 | html = etree.fromstring(htmlcode2, etree.HTMLParser()) 48 | result = str(html.xpath('/html/body/div[1]/div[2]/div[2]/div[1]/div/article/section[4]/p/text()')).strip(" ['']").replace("\\n",'',10000).replace("'",'',10000).replace(', ,','').strip(' ').replace('。,',',') 49 | return result 50 | def getTag(htmlcode): #获取番号 51 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 52 | result = str(html.xpath('/html/body/div[2]/div/div[1]/h5[4]/a/text()')) 53 | return result.strip(" ['']").replace("'",'').replace(' ','') 54 | def getYear(release): 55 | try: 56 | result = re.search('\d{4}',release).group() 57 | return result 58 | except: 59 | return '' 60 | 61 | def getTitle_fc2com(htmlcode): #获取厂商 62 | html = etree.fromstring(htmlcode,etree.HTMLParser()) 63 | result = html.xpath('//*[@id="top"]/div[1]/section[1]/div/section/div[2]/h3/text()')[0] 64 | return result 65 | def getActor_fc2com(htmlcode): 66 | try: 67 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 68 | result = html.xpath('//*[@id="top"]/div[1]/section[1]/div/section/div[2]/ul/li[3]/a/text()')[0] 69 | return result 70 | except: 71 | return '' 72 | def getStudio_fc2com(htmlcode): #获取厂商 73 | try: 74 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 75 | result = str(html.xpath('//*[@id="top"]/div[1]/section[1]/div/section/div[2]/ul/li[3]/a/text()')).strip(" ['']") 76 | return result 77 | except: 78 | return '' 79 | def getNum_fc2com(htmlcode): #获取番号 80 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 81 | result = str(html.xpath('/html/body/div[5]/div[1]/div[2]/p[1]/span[2]/text()')).strip(" ['']") 82 | return result 83 | def getRelease_fc2com(htmlcode2): # 84 | html=etree.fromstring(htmlcode2,etree.HTMLParser()) 85 | result = str(html.xpath('//*[@id="container"]/div[1]/div/article/section[1]/div/div[2]/dl/dd[4]/text()')).strip(" ['']") 86 | return result 87 | def getCover_fc2com(htmlcode2): #获取厂商 # 88 | html = etree.fromstring(htmlcode2, etree.HTMLParser()) 89 | result = str(html.xpath('//*[@id="top"]/div[1]/section[1]/div/section/div[1]/span/img/@src')).strip(" ['']") 90 | return 'http:' + result 91 | def getOutline_fc2com(htmlcode2): #获取番号 # 92 | html = etree.fromstring(htmlcode2, etree.HTMLParser()) 93 | result = str(html.xpath('/html/body/div/text()')).strip(" ['']").replace("\\n",'',10000).replace("'",'',10000).replace(', ,','').strip(' ').replace('。,',',') 94 | return result 95 | def getTag_fc2com(number): #获取番号 96 | htmlcode = str(bytes(ADC_function.get_html('http://adult.contents.fc2.com/api/v4/article/'+number+'/tag?'),'utf-8').decode('unicode-escape')) 97 | result = re.findall('"tag":"(.*?)"', htmlcode) 98 | return result 99 | def getYear_fc2com(release): 100 | try: 101 | result = re.search('\d{4}',release).group() 102 | return result 103 | except: 104 | return '' 105 | 106 | def main(number): 107 | try: 108 | number = number.replace('FC2-', '').replace('fc2-', '') 109 | htmlcode2 = ADC_function.get_html('https://adult.contents.fc2.com/article/'+number+'/') 110 | htmlcode = ADC_function.get_html('https://fc2club.com//html/FC2-' + number + '.html') 111 | actor = getActor(htmlcode) 112 | if getActor(htmlcode) == '': 113 | actor = 'FC2系列' 114 | dic = { 115 | 'title': getTitle(htmlcode), 116 | 'studio': getStudio(htmlcode), 117 | 'year': '',#str(re.search('\d{4}',getRelease(number)).group()), 118 | 'outline': '',#getOutline(htmlcode2), 119 | 'runtime': getYear(getRelease(htmlcode)), 120 | 'director': getStudio(htmlcode), 121 | 'actor': actor, 122 | 'release': getRelease(number), 123 | 'number': 'FC2-'+number, 124 | 'label': '', 125 | 'cover': getCover(htmlcode,number,htmlcode2), 126 | 'imagecut': 0, 127 | 'tag': getTag(htmlcode), 128 | 'actor_photo':'', 129 | 'website': 'https://fc2club.com//html/FC2-' + number + '.html', 130 | 'source':'https://fc2club.com//html/FC2-' + number + '.html', 131 | } 132 | if dic['title'] == '': 133 | htmlcode2 = ADC_function.get_html('https://adult.contents.fc2.com/article/' + number + '/',cookies={'wei6H':'1'}) 134 | actor = getActor(htmlcode) 135 | if getActor(htmlcode) == '': 136 | actor = 'FC2系列' 137 | dic = { 138 | 'title': getTitle_fc2com(htmlcode2), 139 | 'studio': getStudio_fc2com(htmlcode2), 140 | 'year': '', # str(re.search('\d{4}',getRelease(number)).group()), 141 | 'outline': getOutline_fc2com(htmlcode2), 142 | 'runtime': getYear_fc2com(getRelease(htmlcode2)), 143 | 'director': getStudio_fc2com(htmlcode2), 144 | 'actor': actor, 145 | 'release': getRelease_fc2com(number), 146 | 'number': 'FC2-' + number, 147 | 'cover': getCover_fc2com(htmlcode2), 148 | 'imagecut': 0, 149 | 'tag': getTag_fc2com(number), 150 | 'label': '', 151 | 'actor_photo': '', 152 | 'website': 'http://adult.contents.fc2.com/article/' + number + '/', 153 | 'source': 'http://adult.contents.fc2.com/article/' + number + '/', 154 | } 155 | except Exception as e: 156 | # (TODO) better handle this 157 | # print(e) 158 | dic = {"title": ""} 159 | js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'),)#.encode('UTF-8') 160 | return js 161 | 162 | 163 | #print(main('1252953')) 164 | -------------------------------------------------------------------------------- /jav321.py: -------------------------------------------------------------------------------- 1 | import json 2 | from bs4 import BeautifulSoup 3 | from lxml import html 4 | from ADC_function import post_html 5 | 6 | 7 | def main(number: str) -> json: 8 | result = post_html(url="https://www.jav321.com/search", query={"sn": number}) 9 | soup = BeautifulSoup(result.text, "html.parser") 10 | lx = html.fromstring(str(soup)) 11 | 12 | if "/video/" in result.url: 13 | data = parse_info(soup) 14 | dic = { 15 | "title": get_title(lx), 16 | "studio": "", 17 | "year": get_year(data), 18 | "outline": get_outline(lx), 19 | "director": "", 20 | "cover": get_cover(lx), 21 | "imagecut": 1, 22 | "actor_photo": "", 23 | "website": result.url, 24 | "source": "jav321.py", 25 | **data, 26 | } 27 | else: 28 | dic = {} 29 | 30 | return json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':')) 31 | 32 | 33 | def get_title(lx: html.HtmlElement) -> str: 34 | return lx.xpath("/html/body/div[2]/div[1]/div[1]/div[1]/h3/text()")[0].strip() 35 | 36 | 37 | def parse_info(soup: BeautifulSoup) -> dict: 38 | data = soup.select_one("div.row > div.col-md-9") 39 | 40 | if data: 41 | dd = str(data).split("
") 42 | data_dic = {} 43 | for d in dd: 44 | data_dic[get_bold_text(h=d)] = d 45 | 46 | return { 47 | "actor": get_actor(data_dic), 48 | "label": get_label(data_dic), 49 | "tag": get_tag(data_dic), 50 | "number": get_number(data_dic), 51 | "release": get_release(data_dic), 52 | "runtime": get_runtime(data_dic), 53 | } 54 | else: 55 | return {} 56 | 57 | 58 | def get_bold_text(h: str) -> str: 59 | soup = BeautifulSoup(h, "html.parser") 60 | if soup.b: 61 | return soup.b.text 62 | else: 63 | return "UNKNOWN_TAG" 64 | 65 | 66 | def get_anchor_info(h: str) -> str: 67 | result = [] 68 | 69 | data = BeautifulSoup(h, "html.parser").find_all("a", href=True) 70 | for d in data: 71 | result.append(d.text) 72 | 73 | return ",".join(result) 74 | 75 | 76 | def get_text_info(h: str) -> str: 77 | return h.split(": ")[1] 78 | 79 | 80 | def get_cover(lx: html.HtmlElement) -> str: 81 | return lx.xpath("/html/body/div[2]/div[2]/div[1]/p/a/img/@src")[0] 82 | 83 | 84 | def get_outline(lx: html.HtmlElement) -> str: 85 | return lx.xpath("/html/body/div[2]/div[1]/div[1]/div[2]/div[3]/div/text()")[0] 86 | 87 | 88 | def get_actor(data: hash) -> str: 89 | if "女优" in data: 90 | return get_anchor_info(data["女优"]) 91 | else: 92 | return "" 93 | 94 | 95 | def get_label(data: hash) -> str: 96 | if "片商" in data: 97 | return get_anchor_info(data["片商"]) 98 | else: 99 | return "" 100 | 101 | 102 | def get_tag(data: hash) -> str: 103 | if "标签" in data: 104 | return get_anchor_info(data["标签"]) 105 | else: 106 | return "" 107 | 108 | 109 | def get_number(data: hash) -> str: 110 | if "番号" in data: 111 | return get_text_info(data["番号"]) 112 | else: 113 | return "" 114 | 115 | 116 | def get_release(data: hash) -> str: 117 | if "发行日期" in data: 118 | return get_text_info(data["发行日期"]) 119 | else: 120 | return "" 121 | 122 | 123 | def get_runtime(data: hash) -> str: 124 | if "播放时长" in data: 125 | return get_text_info(data["播放时长"]) 126 | else: 127 | return "" 128 | 129 | 130 | def get_year(data: hash) -> str: 131 | if "release" in data: 132 | return data["release"][:4] 133 | else: 134 | return "" 135 | 136 | 137 | if __name__ == "__main__": 138 | print(main("wmc-002")) 139 | -------------------------------------------------------------------------------- /javbus.py: -------------------------------------------------------------------------------- 1 | import re 2 | from pyquery import PyQuery as pq#need install 3 | from lxml import etree#need install 4 | from bs4 import BeautifulSoup#need install 5 | import json 6 | from ADC_function import * 7 | import fanza 8 | 9 | def getActorPhoto(htmlcode): #//*[@id="star_qdt"]/li/a/img 10 | soup = BeautifulSoup(htmlcode, 'lxml') 11 | a = soup.find_all(attrs={'class': 'star-name'}) 12 | d={} 13 | for i in a: 14 | l=i.a['href'] 15 | t=i.get_text() 16 | html = etree.fromstring(get_html(l), etree.HTMLParser()) 17 | p=str(html.xpath('//*[@id="waterfall"]/div[1]/div/div[1]/img/@src')).strip(" ['']") 18 | p2={t:p} 19 | d.update(p2) 20 | return d 21 | def getTitle(htmlcode): #获取标题 22 | doc = pq(htmlcode) 23 | title=str(doc('div.container h3').text()).replace(' ','-') 24 | try: 25 | title2 = re.sub('n\d+-','',title) 26 | return title2 27 | except: 28 | return title 29 | def getStudio(htmlcode): #获取厂商 30 | html = etree.fromstring(htmlcode,etree.HTMLParser()) 31 | result = str(html.xpath('/html/body/div[5]/div[1]/div[2]/p[5]/a/text()')).strip(" ['']") 32 | return result 33 | def getYear(htmlcode): #获取年份 34 | html = etree.fromstring(htmlcode,etree.HTMLParser()) 35 | result = str(html.xpath('/html/body/div[5]/div[1]/div[2]/p[2]/text()')).strip(" ['']") 36 | return result 37 | def getCover(htmlcode): #获取封面链接 38 | doc = pq(htmlcode) 39 | image = doc('a.bigImage') 40 | return image.attr('href') 41 | def getRelease(htmlcode): #获取出版日期 42 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 43 | result = str(html.xpath('/html/body/div[5]/div[1]/div[2]/p[2]/text()')).strip(" ['']") 44 | return result 45 | def getRuntime(htmlcode): #获取分钟 46 | soup = BeautifulSoup(htmlcode, 'lxml') 47 | a = soup.find(text=re.compile('分鐘')) 48 | return a 49 | def getActor(htmlcode): #获取女优 50 | b=[] 51 | soup=BeautifulSoup(htmlcode,'lxml') 52 | a=soup.find_all(attrs={'class':'star-name'}) 53 | for i in a: 54 | b.append(i.get_text()) 55 | return b 56 | def getNum(htmlcode): #获取番号 57 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 58 | result = str(html.xpath('/html/body/div[5]/div[1]/div[2]/p[1]/span[2]/text()')).strip(" ['']") 59 | return result 60 | def getDirector(htmlcode): #获取导演 61 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 62 | result = str(html.xpath('/html/body/div[5]/div[1]/div[2]/p[4]/a/text()')).strip(" ['']") 63 | return result 64 | def getCID(htmlcode): 65 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 66 | #print(htmlcode) 67 | string = html.xpath("//a[contains(@class,'sample-box')][1]/@href")[0].replace('https://pics.dmm.co.jp/digital/video/','') 68 | result = re.sub('/.*?.jpg','',string) 69 | return result 70 | def getOutline(htmlcode): #获取演员 71 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 72 | try: 73 | result = html.xpath("string(//div[contains(@class,'mg-b20 lh4')])").replace('\n','') 74 | return result 75 | except: 76 | return '' 77 | def getSerise(htmlcode): 78 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 79 | result = str(html.xpath('/html/body/div[5]/div[1]/div[2]/p[7]/a/text()')).strip(" ['']") 80 | return result 81 | def getTag(htmlcode): # 获取演员 82 | tag = [] 83 | soup = BeautifulSoup(htmlcode, 'lxml') 84 | a = soup.find_all(attrs={'class': 'genre'}) 85 | for i in a: 86 | if 'onmouseout' in str(i): 87 | continue 88 | tag.append(i.get_text()) 89 | return tag 90 | 91 | def main_uncensored(number): 92 | htmlcode = get_html('https://www.javbus.com/' + number) 93 | if getTitle(htmlcode) == '': 94 | htmlcode = get_html('https://www.javbus.com/' + number.replace('-','_')) 95 | try: 96 | dww_htmlcode = fanza.main_htmlcode(getCID(htmlcode)) 97 | except: 98 | dww_htmlcode = '' 99 | dic = { 100 | 'title': str(re.sub('\w+-\d+-','',getTitle(htmlcode))).replace(getNum(htmlcode)+'-',''), 101 | 'studio': getStudio(htmlcode), 102 | 'year': getYear(htmlcode), 103 | 'outline': getOutline(dww_htmlcode), 104 | 'runtime': getRuntime(htmlcode), 105 | 'director': getDirector(htmlcode), 106 | 'actor': getActor(htmlcode), 107 | 'release': getRelease(htmlcode), 108 | 'number': getNum(htmlcode), 109 | 'cover': getCover(htmlcode), 110 | 'tag': getTag(htmlcode), 111 | 'label': getSerise(htmlcode), 112 | 'imagecut': 0, 113 | 'actor_photo': '', 114 | 'website': 'https://www.javbus.com/' + number, 115 | 'source': 'javbus.py', 116 | } 117 | js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'), ) # .encode('UTF-8') 118 | return js 119 | 120 | 121 | def main(number): 122 | try: 123 | try: 124 | htmlcode = get_html('https://www.javbus.com/' + number) 125 | try: 126 | dww_htmlcode = fanza.main_htmlcode(getCID(htmlcode)) 127 | except: 128 | dww_htmlcode = '' 129 | dic = { 130 | 'title': str(re.sub('\w+-\d+-', '', getTitle(htmlcode))), 131 | 'studio': getStudio(htmlcode), 132 | 'year': str(re.search('\d{4}', getYear(htmlcode)).group()), 133 | 'outline': getOutline(dww_htmlcode), 134 | 'runtime': getRuntime(htmlcode), 135 | 'director': getDirector(htmlcode), 136 | 'actor': getActor(htmlcode), 137 | 'release': getRelease(htmlcode), 138 | 'number': getNum(htmlcode), 139 | 'cover': getCover(htmlcode), 140 | 'imagecut': 1, 141 | 'tag': getTag(htmlcode), 142 | 'label': getSerise(htmlcode), 143 | 'actor_photo': getActorPhoto(htmlcode), 144 | 'website': 'https://www.javbus.com/' + number, 145 | 'source': 'javbus.py', 146 | } 147 | js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, 148 | separators=(',', ':'), ) # .encode('UTF-8') 149 | return js 150 | except: 151 | return main_uncensored(number) 152 | except: 153 | data = { 154 | "title": "", 155 | } 156 | js = json.dumps( 157 | data, ensure_ascii=False, sort_keys=True, indent=4, separators=(",", ":") 158 | ) 159 | return js 160 | -------------------------------------------------------------------------------- /javdb.py: -------------------------------------------------------------------------------- 1 | import re 2 | from lxml import etree 3 | import json 4 | from bs4 import BeautifulSoup 5 | from ADC_function import * 6 | # import sys 7 | # import io 8 | # sys.stdout = io.TextIOWrapper(sys.stdout.buffer, errors = 'replace', line_buffering = True) 9 | 10 | def getTitle(a): 11 | html = etree.fromstring(a, etree.HTMLParser()) 12 | result = html.xpath("/html/body/section/div/h2/strong/text()")[0] 13 | return result 14 | def getActor(a): # //*[@id="center_column"]/div[2]/div[1]/div/table/tbody/tr[1]/td/text() 15 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 16 | result1 = str(html.xpath('//strong[contains(text(),"演員")]/../following-sibling::span/text()')).strip(" ['']") 17 | result2 = str(html.xpath('//strong[contains(text(),"演員")]/../following-sibling::span/a/text()')).strip(" ['']") 18 | return str(result1 + result2).strip('+').replace(",\\xa0", "").replace("'", "").replace(' ', '').replace(',,', '').lstrip(',').replace(',', ', ') 19 | def getActorPhoto(actor): #//*[@id="star_qdt"]/li/a/img 20 | a = actor.split(',') 21 | d={} 22 | for i in a: 23 | p={i:''} 24 | d.update(p) 25 | return d 26 | def getStudio(a): 27 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 28 | result1 = str(html.xpath('//strong[contains(text(),"片商")]/../following-sibling::span/text()')).strip(" ['']") 29 | result2 = str(html.xpath('//strong[contains(text(),"片商")]/../following-sibling::span/a/text()')).strip(" ['']") 30 | return str(result1 + result2).strip('+').replace("', '", '').replace('"', '') 31 | def getRuntime(a): 32 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 33 | result1 = str(html.xpath('//strong[contains(text(),"時長")]/../following-sibling::span/text()')).strip(" ['']") 34 | result2 = str(html.xpath('//strong[contains(text(),"時長")]/../following-sibling::span/a/text()')).strip(" ['']") 35 | return str(result1 + result2).strip('+').rstrip('mi') 36 | def getLabel(a): 37 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 38 | result1 = str(html.xpath('//strong[contains(text(),"系列")]/../following-sibling::span/text()')).strip(" ['']") 39 | result2 = str(html.xpath('//strong[contains(text(),"系列")]/../following-sibling::span/a/text()')).strip(" ['']") 40 | return str(result1 + result2).strip('+').replace("', '", '').replace('"', '') 41 | def getNum(a): 42 | html = etree.fromstring(a, etree.HTMLParser()) 43 | result1 = str(html.xpath('//strong[contains(text(),"番號")]/../following-sibling::span/text()')).strip(" ['']") 44 | result2 = str(html.xpath('//strong[contains(text(),"番號")]/../following-sibling::span/a/text()')).strip(" ['']") 45 | return str(result2 + result1).strip('+') 46 | def getYear(getRelease): 47 | try: 48 | result = str(re.search('\d{4}', getRelease).group()) 49 | return result 50 | except: 51 | return getRelease 52 | def getRelease(a): 53 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 54 | result1 = str(html.xpath('//strong[contains(text(),"時間")]/../following-sibling::span/text()')).strip(" ['']") 55 | result2 = str(html.xpath('//strong[contains(text(),"時間")]/../following-sibling::span/a/text()')).strip(" ['']") 56 | return str(result1 + result2).strip('+') 57 | def getTag(a): 58 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 59 | result1 = str(html.xpath('//strong[contains(text(),"类别")]/../following-sibling::span/text()')).strip(" ['']") 60 | result2 = str(html.xpath('//strong[contains(text(),"类别")]/../following-sibling::span/a/text()')).strip(" ['']") 61 | return str(result1 + result2).strip('+').replace(",\\xa0", "").replace("'", "").replace(' ', '').replace(',,', '').lstrip(',') 62 | def getCover_small(a, index=0): 63 | # same issue mentioned below, 64 | # javdb sometime returns multiple results 65 | # DO NOT just get the firt one, get the one with correct index number 66 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 67 | result = html.xpath("//div[@class='item-image fix-scale-cover']/img/@src")[index] 68 | if not 'https' in result: 69 | result = 'https:' + result 70 | return result 71 | def getCover(htmlcode): 72 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 73 | result = str(html.xpath("//div[contains(@class, 'column-video-cover')]/a/img/@src")).strip(" ['']") 74 | return result 75 | def getDirector(a): 76 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 77 | result1 = str(html.xpath('//strong[contains(text(),"導演")]/../following-sibling::span/text()')).strip(" ['']") 78 | result2 = str(html.xpath('//strong[contains(text(),"導演")]/../following-sibling::span/a/text()')).strip(" ['']") 79 | return str(result1 + result2).strip('+').replace("', '", '').replace('"', '') 80 | def getOutline(htmlcode): 81 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 82 | result = str(html.xpath('//*[@id="introduction"]/dd/p[1]/text()')).strip(" ['']") 83 | return result 84 | def main(number): 85 | try: 86 | number = number.upper() 87 | query_result = get_html('https://javdb.com/search?q=' + number + '&f=all') 88 | html = etree.fromstring(query_result, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 89 | # javdb sometime returns multiple results, 90 | # and the first elememt maybe not the one we are looking for 91 | # iterate all candidates and find the match one 92 | urls = html.xpath('//*[@id="videos"]/div/div/a/@href') 93 | ids =html.xpath('//*[@id="videos"]/div/div/a/div[contains(@class, "uid")]/text()') 94 | correct_url = urls[ids.index(number)] 95 | detail_page = get_html('https://javdb.com' + correct_url) 96 | dic = { 97 | 'actor': getActor(detail_page), 98 | 'title': getTitle(detail_page), 99 | 'studio': getStudio(detail_page), 100 | 'outline': getOutline(detail_page), 101 | 'runtime': getRuntime(detail_page), 102 | 'director': getDirector(detail_page), 103 | 'release': getRelease(detail_page), 104 | 'number': getNum(detail_page), 105 | 'cover': getCover(detail_page), 106 | 'cover_small': getCover_small(query_result, index=ids.index(number)), 107 | 'imagecut': 3, 108 | 'tag': getTag(detail_page), 109 | 'label': getLabel(detail_page), 110 | 'year': getYear(getRelease(detail_page)), # str(re.search('\d{4}',getRelease(a)).group()), 111 | 'actor_photo': getActorPhoto(getActor(detail_page)), 112 | 'website': 'https://javdb.com' + correct_url, 113 | 'source': 'javdb.py', 114 | } 115 | except Exception as e: 116 | # print(e) 117 | dic = {"title": ""} 118 | js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'), ) # .encode('UTF-8') 119 | return js 120 | 121 | # main('DV-1562') 122 | # input("[+][+]Press enter key exit, you can check the error messge before you exit.\n[+][+]按回车键结束,你可以在结束之前查看和错误信息。") 123 | #print(main('ipx-292')) 124 | -------------------------------------------------------------------------------- /javlib.py: -------------------------------------------------------------------------------- 1 | import json 2 | import bs4 3 | from bs4 import BeautifulSoup 4 | from lxml import html 5 | from http.cookies import SimpleCookie 6 | 7 | from ADC_function import get_javlib_cookie, get_html 8 | 9 | 10 | def main(number: str): 11 | raw_cookies, user_agent = get_javlib_cookie() 12 | 13 | # Blank cookies mean javlib site return error 14 | if not raw_cookies: 15 | return json.dumps({}, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':')) 16 | 17 | # Manually construct a dictionary 18 | s_cookie = SimpleCookie() 19 | s_cookie.load(raw_cookies) 20 | cookies = {} 21 | for key, morsel in s_cookie.items(): 22 | cookies[key] = morsel.value 23 | 24 | # Scraping 25 | result = get_html( 26 | "http://www.m45e.com/cn/vl_searchbyid.php?keyword={}".format(number), 27 | cookies=cookies, 28 | ua=user_agent, 29 | return_type="object" 30 | ) 31 | soup = BeautifulSoup(result.text, "html.parser") 32 | lx = html.fromstring(str(soup)) 33 | 34 | if "/?v=jav" in result.url: 35 | dic = { 36 | "title": get_title(lx, soup), 37 | "studio": get_table_el_single_anchor(soup, "video_maker"), 38 | "year": get_table_el_td(soup, "video_date")[:4], 39 | "outline": "", 40 | "director": get_table_el_single_anchor(soup, "video_director"), 41 | "cover": get_cover(lx), 42 | "imagecut": 1, 43 | "actor_photo": "", 44 | "website": result.url, 45 | "source": "javlib.py", 46 | "actor": get_table_el_multi_anchor(soup, "video_cast"), 47 | "label": get_table_el_td(soup, "video_label"), 48 | "tag": get_table_el_multi_anchor(soup, "video_genres"), 49 | "number": get_table_el_td(soup, "video_id"), 50 | "release": get_table_el_td(soup, "video_date"), 51 | "runtime": get_from_xpath(lx, '//*[@id="video_length"]/table/tr/td[2]/span/text()'), 52 | } 53 | else: 54 | dic = {} 55 | 56 | return json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':')) 57 | 58 | 59 | def get_from_xpath(lx: html.HtmlElement, xpath: str) -> str: 60 | return lx.xpath(xpath)[0].strip() 61 | 62 | 63 | def get_table_el_single_anchor(soup: BeautifulSoup, tag_id: str) -> str: 64 | tag = soup.find(id=tag_id).find("a") 65 | 66 | if tag is not None: 67 | return tag.string.strip() 68 | else: 69 | return "" 70 | 71 | 72 | def get_table_el_multi_anchor(soup: BeautifulSoup, tag_id: str) -> str: 73 | tags = soup.find(id=tag_id).find_all("a") 74 | 75 | return process(tags) 76 | 77 | 78 | def get_table_el_td(soup: BeautifulSoup, tag_id: str) -> str: 79 | tags = soup.find(id=tag_id).find_all("td", class_="text") 80 | 81 | return process(tags) 82 | 83 | 84 | def process(tags: bs4.element.ResultSet) -> str: 85 | values = [] 86 | for tag in tags: 87 | value = tag.string 88 | if value is not None and value != "----": 89 | values.append(value) 90 | 91 | return ",".join(x for x in values if x) 92 | 93 | 94 | def get_title(lx: html.HtmlElement, soup: BeautifulSoup) -> str: 95 | title = get_from_xpath(lx, '//*[@id="video_title"]/h3/a/text()') 96 | number = get_table_el_td(soup, "video_id") 97 | 98 | return title.replace(number, "").strip() 99 | 100 | 101 | def get_cover(lx: html.HtmlComment) -> str: 102 | return "http:{}".format(get_from_xpath(lx, '//*[@id="video_jacket_img"]/@src')) 103 | 104 | 105 | if __name__ == "__main__": 106 | # lists = ["DVMC-003", "GS-0167", "JKREZ-001", "KMHRS-010", "KNSD-023"] 107 | lists = ["DVMC-003"] 108 | for num in lists: 109 | print(main(num)) 110 | -------------------------------------------------------------------------------- /linux_make.py: -------------------------------------------------------------------------------- 1 | import os 2 | os.system("pyinstaller --onefile AV_Data_Capture.py --hidden-import ADC_function.py --hidden-import core.py") 3 | os.system("rm -rf ./build") 4 | os.system("rm -rf ./__pycache__") 5 | os.system("rm -rf AV_Data_Capture.spec") 6 | os.system("echo '[Make]Finish'") 7 | -------------------------------------------------------------------------------- /mgstage.py: -------------------------------------------------------------------------------- 1 | import re 2 | from lxml import etree 3 | import json 4 | from bs4 import BeautifulSoup 5 | from ADC_function import * 6 | # import sys 7 | # import io 8 | # sys.stdout = io.TextIOWrapper(sys.stdout.buffer, errors = 'replace', line_buffering = True) 9 | 10 | def getTitle(a): 11 | try: 12 | html = etree.fromstring(a, etree.HTMLParser()) 13 | result = str(html.xpath('//*[@id="center_column"]/div[1]/h1/text()')).strip(" ['']") 14 | return result.replace('/', ',') 15 | except: 16 | return '' 17 | def getActor(a): #//*[@id="center_column"]/div[2]/div[1]/div/table/tbody/tr[1]/td/text() 18 | html = etree.fromstring(a, etree.HTMLParser()) #//table/tr[1]/td[1]/text() 19 | result1=str(html.xpath('//th[contains(text(),"出演:")]/../td/a/text()')).strip(" ['']").strip('\\n ').strip('\\n') 20 | result2=str(html.xpath('//th[contains(text(),"出演:")]/../td/text()')).strip(" ['']").strip('\\n ').strip('\\n') 21 | return str(result1+result2).strip('+').replace("', '",'').replace('"','').replace('/',',') 22 | def getStudio(a): 23 | html = etree.fromstring(a, etree.HTMLParser()) #//table/tr[1]/td[1]/text() 24 | result1=str(html.xpath('//th[contains(text(),"シリーズ:")]/../td/a/text()')).strip(" ['']").strip('\\n ').strip('\\n') 25 | result2=str(html.xpath('//th[contains(text(),"シリーズ:")]/../td/text()')).strip(" ['']").strip('\\n ').strip('\\n') 26 | return str(result1+result2).strip('+').replace("', '",'').replace('"','') 27 | def getRuntime(a): 28 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 29 | result1 = str(html.xpath('//th[contains(text(),"収録時間:")]/../td/a/text()')).strip(" ['']").strip('\\n ').strip('\\n') 30 | result2 = str(html.xpath('//th[contains(text(),"収録時間:")]/../td/text()')).strip(" ['']").strip('\\n ').strip('\\n') 31 | return str(result1 + result2).strip('+').rstrip('mi') 32 | def getLabel(a): 33 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 34 | result1 = str(html.xpath('//th[contains(text(),"シリーズ:")]/../td/a/text()')).strip(" ['']").strip('\\n ').strip( 35 | '\\n') 36 | result2 = str(html.xpath('//th[contains(text(),"シリーズ:")]/../td/text()')).strip(" ['']").strip('\\n ').strip( 37 | '\\n') 38 | return str(result1 + result2).strip('+').replace("', '",'').replace('"','') 39 | def getNum(a): 40 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 41 | result1 = str(html.xpath('//th[contains(text(),"品番:")]/../td/a/text()')).strip(" ['']").strip('\\n ').strip( 42 | '\\n') 43 | result2 = str(html.xpath('//th[contains(text(),"品番:")]/../td/text()')).strip(" ['']").strip('\\n ').strip( 44 | '\\n') 45 | return str(result1 + result2).strip('+') 46 | def getYear(getRelease): 47 | try: 48 | result = str(re.search('\d{4}',getRelease).group()) 49 | return result 50 | except: 51 | return getRelease 52 | def getRelease(a): 53 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 54 | result1 = str(html.xpath('//th[contains(text(),"配信開始日:")]/../td/a/text()')).strip(" ['']").strip('\\n ').strip( 55 | '\\n') 56 | result2 = str(html.xpath('//th[contains(text(),"配信開始日:")]/../td/text()')).strip(" ['']").strip('\\n ').strip( 57 | '\\n') 58 | return str(result1 + result2).strip('+') 59 | def getTag(a): 60 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 61 | result1 = str(html.xpath('//th[contains(text(),"ジャンル:")]/../td/a/text()')).strip(" ['']").strip('\\n ').strip( 62 | '\\n') 63 | result2 = str(html.xpath('//th[contains(text(),"ジャンル:")]/../td/text()')).strip(" ['']").strip('\\n ').strip( 64 | '\\n') 65 | return str(result1 + result2).strip('+').replace("', '\\n",",").replace("', '","").replace('"','') 66 | def getCover(htmlcode): 67 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 68 | result = str(html.xpath('//*[@id="center_column"]/div[1]/div[1]/div/div/h2/img/@src')).strip(" ['']") 69 | # /html/body/div[2]/article[2]/div[1]/div[1]/div/div/h2/img/@src 70 | return result 71 | def getDirector(a): 72 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 73 | result1 = str(html.xpath('//th[contains(text(),"シリーズ")]/../td/a/text()')).strip(" ['']").strip('\\n ').strip( 74 | '\\n') 75 | result2 = str(html.xpath('//th[contains(text(),"シリーズ")]/../td/text()')).strip(" ['']").strip('\\n ').strip( 76 | '\\n') 77 | return str(result1 + result2).strip('+').replace("', '",'').replace('"','') 78 | def getOutline(htmlcode): 79 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 80 | result = str(html.xpath('//p/text()')).strip(" ['']").replace(u'\\n', '').replace("', '', '", '') 81 | return result 82 | def main(number2): 83 | number=number2.upper() 84 | htmlcode=str(get_html('https://www.mgstage.com/product/product_detail/'+str(number)+'/',cookies={'adc':'1'})) 85 | soup = BeautifulSoup(htmlcode, 'lxml') 86 | a = str(soup.find(attrs={'class': 'detail_data'})).replace('\n ','').replace(' ','').replace('\n ','').replace('\n ','') 87 | b = str(soup.find(attrs={'id': 'introduction'})).replace('\n ','').replace(' ','').replace('\n ','').replace('\n ','') 88 | #print(b) 89 | dic = { 90 | 'title': getTitle(htmlcode).replace("\\n",'').replace(' ',''), 91 | 'studio': getStudio(a), 92 | 'outline': getOutline(b), 93 | 'runtime': getRuntime(a), 94 | 'director': getDirector(a), 95 | 'actor': getActor(a), 96 | 'release': getRelease(a), 97 | 'number': getNum(a), 98 | 'cover': getCover(htmlcode), 99 | 'imagecut': 0, 100 | 'tag': getTag(a), 101 | 'label':getLabel(a), 102 | 'year': getYear(getRelease(a)), # str(re.search('\d{4}',getRelease(a)).group()), 103 | 'actor_photo': '', 104 | 'website':'https://www.mgstage.com/product/product_detail/'+str(number)+'/', 105 | 'source': 'mgstage.py', 106 | } 107 | js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'), ) # .encode('UTF-8') 108 | return js 109 | #print(htmlcode) 110 | 111 | if __name__ == '__main__': 112 | print(main('SIRO-4149')) 113 | -------------------------------------------------------------------------------- /number_parser.py: -------------------------------------------------------------------------------- 1 | import os 2 | import re 3 | 4 | 5 | def get_number(filepath: str) -> str: 6 | """ 7 | >>> from number_parser import get_number 8 | >>> get_number("/Users/Guest/AV_Data_Capture/snis-829.mp4") 9 | 'snis-829' 10 | >>> get_number("/Users/Guest/AV_Data_Capture/snis-829-C.mp4") 11 | 'snis-829' 12 | >>> get_number("C:¥Users¥Guest¥snis-829.mp4") 13 | 'snis-829' 14 | >>> get_number("C:¥Users¥Guest¥snis-829-C.mp4") 15 | 'snis-829' 16 | >>> get_number("./snis-829.mp4") 17 | 'snis-829' 18 | >>> get_number("./snis-829-C.mp4") 19 | 'snis-829' 20 | >>> get_number(".¥snis-829.mp4") 21 | 'snis-829' 22 | >>> get_number(".¥snis-829-C.mp4") 23 | 'snis-829' 24 | >>> get_number("snis-829.mp4") 25 | 'snis-829' 26 | >>> get_number("snis-829-C.mp4") 27 | 'snis-829' 28 | """ 29 | filepath = os.path.basename(filepath) 30 | 31 | if '-' in filepath or '_' in filepath: # 普通提取番号 主要处理包含减号-和_的番号 32 | filepath = filepath.replace("_", "-") 33 | filepath.strip('22-sht.me').strip('-HD').strip('-hd') 34 | filename = str(re.sub("\[\d{4}-\d{1,2}-\d{1,2}\] - ", "", filepath)) # 去除文件名中时间 35 | if 'FC2' or 'fc2' in filename: 36 | filename = filename.replace('-PPV', '').replace('PPV-', '').replace('FC2PPV-', 'FC2-').replace('FC2PPV_', 'FC2-') 37 | filename = filename.replace('-ppv', '').replace('ppv-', '').replace('fc2ppv-', 'FC2-').replace('fc2ppv_', 'FC2-') 38 | file_number = re.search(r'\w+-\w+', filename, re.A).group() 39 | return file_number 40 | else: # 提取不含减号-的番号,FANZA CID 41 | try: 42 | return str(re.findall(r'(.+?)\.', str(re.search('([^<>/\\\\|:""\\*\\?]+)\\.\\w+$', filepath).group()))).strip("['']").replace('_', '-') 43 | except: 44 | return re.search(r'(.+?)\.', filepath)[0] 45 | 46 | 47 | if __name__ == "__main__": 48 | import doctest 49 | doctest.testmod(raise_on_error=True) 50 | -------------------------------------------------------------------------------- /py_to_exe.bat: -------------------------------------------------------------------------------- 1 | pyinstaller --onefile AV_Data_Capture.py --hidden-import ADC_function.py --hidden-import core.py 2 | rmdir /s/q build 3 | rmdir /s/q __pycache__ 4 | pause -------------------------------------------------------------------------------- /readme/This is readms.md's images folder: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /readme/flow_chart2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YEreed/AV_Data_Capture/2ca1bafc4179858519939e145b994cab28cff669/readme/flow_chart2.png -------------------------------------------------------------------------------- /readme/readme1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YEreed/AV_Data_Capture/2ca1bafc4179858519939e145b994cab28cff669/readme/readme1.PNG -------------------------------------------------------------------------------- /readme/readme2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YEreed/AV_Data_Capture/2ca1bafc4179858519939e145b994cab28cff669/readme/readme2.PNG -------------------------------------------------------------------------------- /readme/readme3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YEreed/AV_Data_Capture/2ca1bafc4179858519939e145b994cab28cff669/readme/readme3.PNG -------------------------------------------------------------------------------- /readme/readme4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YEreed/AV_Data_Capture/2ca1bafc4179858519939e145b994cab28cff669/readme/readme4.PNG -------------------------------------------------------------------------------- /readme/single.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YEreed/AV_Data_Capture/2ca1bafc4179858519939e145b994cab28cff669/readme/single.gif -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | requests 2 | pyquery 3 | lxml 4 | beautifulsoup4 5 | pillow 6 | pyinstaller 7 | cloudscraper 8 | -------------------------------------------------------------------------------- /update_check.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "3.4", 3 | "version_show": "3.4", 4 | "download": "https://github.com/yoshiko2/AV_Data_Capture/releases" 5 | } 6 | -------------------------------------------------------------------------------- /xcity.py: -------------------------------------------------------------------------------- 1 | import re 2 | from lxml import etree 3 | import json 4 | from bs4 import BeautifulSoup 5 | from ADC_function import * 6 | 7 | 8 | # import sys 9 | # import io 10 | # sys.stdout = io.TextIOWrapper(sys.stdout.buffer, errors = 'replace', line_buffering = True) 11 | 12 | def getTitle(a): 13 | html = etree.fromstring(a, etree.HTMLParser()) 14 | result = html.xpath('//*[@id="program_detail_title"]/text()')[0] 15 | return result 16 | 17 | 18 | def getActor(a): # //*[@id="center_column"]/div[2]/div[1]/div/table/tbody/tr[1]/td/text() 19 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 20 | result1 = html.xpath('//*[@id="avodDetails"]/div/div[3]/div[2]/div/ul[1]/li[3]/a/text()')[0] 21 | return result1 22 | 23 | 24 | def getActorPhoto(actor): # //*[@id="star_qdt"]/li/a/img 25 | a = actor.split(',') 26 | d = {} 27 | for i in a: 28 | p = {i: ''} 29 | d.update(p) 30 | return d 31 | 32 | 33 | def getStudio(a): 34 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 35 | result1 = str(html.xpath('//*[@id="avodDetails"]/div/div[3]/div[2]/div/ul[1]/li[4]/a/span/text()')).strip(" ['']") 36 | result2 = str(html.xpath('//strong[contains(text(),"片商")]/../following-sibling::span/a/text()')).strip(" ['']") 37 | return str(result1 + result2).strip('+').replace("', '", '').replace('"', '') 38 | 39 | 40 | def getRuntime(a): 41 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 42 | result1 = str(html.xpath('//*[@id="avodDetails"]/div/div[3]/div[2]/div/ul[2]/li[3]/text()')).strip(" ['']") 43 | try: 44 | return re.findall('\d+',result1)[0] 45 | except: 46 | return '' 47 | 48 | 49 | def getLabel(a): 50 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 51 | result1 = str(html.xpath('//*[@id="avodDetails"]/div/div[3]/div[2]/div/ul[1]/li[5]/a/span/text()')).strip(" ['']") 52 | return result1 53 | 54 | 55 | def getNum(a): 56 | html = etree.fromstring(a, etree.HTMLParser()) 57 | result1 = str(html.xpath('//*[@id="hinban"]/text()')).strip(" ['']") 58 | return result1 59 | 60 | 61 | def getYear(getRelease): 62 | try: 63 | result = str(re.search('\d{4}', getRelease).group()) 64 | return result 65 | except: 66 | return getRelease 67 | 68 | 69 | def getRelease(a): 70 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 71 | result1 = str(html.xpath('//*[@id="avodDetails"]/div/div[3]/div[2]/div/ul[2]/li[4]/text()')).strip(" ['']") 72 | try: 73 | return re.findall('\d{4}/\d{2}/\d{2}', result1)[0] 74 | except: 75 | return '' 76 | 77 | 78 | def getTag(a): 79 | result2=[] 80 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 81 | result1 = html.xpath('//*[@id="avodDetails"]/div/div[3]/div[2]/div/ul[1]/li[6]/a/text()') 82 | for i in result1: 83 | i=i.replace(u'\n','') 84 | i=i.replace(u'\t','') 85 | result2.append(i) 86 | return result2 87 | 88 | 89 | def getCover_small(a, index=0): 90 | # same issue mentioned below, 91 | # javdb sometime returns multiple results 92 | # DO NOT just get the firt one, get the one with correct index number 93 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 94 | result = html.xpath("//div[@class='item-image fix-scale-cover']/img/@src")[index] 95 | if not 'https' in result: 96 | result = 'https:' + result 97 | return result 98 | 99 | 100 | def getCover(htmlcode): 101 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 102 | result = str(html.xpath('//*[@id="avodDetails"]/div/div[3]/div[1]/p/a/@href')).strip(" ['']") 103 | return 'https:'+result 104 | 105 | 106 | def getDirector(a): 107 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 108 | result1 = str(html.xpath('//*[@id="program_detail_director"]/text()')).strip(" ['']").replace(u'\\n','').replace(u'\\t','') 109 | return result1 110 | 111 | 112 | def getOutline(htmlcode): 113 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 114 | result = str(html.xpath('//*[@id="avodDetails"]/div/div[3]/div[2]/div/ul[2]/li[5]/p/text()')).strip(" ['']") 115 | try: 116 | return re.sub('\\\\\w*\d+','',result) 117 | except: 118 | return result 119 | 120 | 121 | def main(number): 122 | try: 123 | number = number.upper() 124 | query_result = get_html( 125 | 'https://xcity.jp/result_published/?genre=%2Fresult_published%2F&q=' + number.replace('-', 126 | '') + '&sg=main&num=30') 127 | html = etree.fromstring(query_result, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 128 | urls = html.xpath("//table[contains(@class, 'resultList')]/tr[2]/td[1]/a/@href")[0] 129 | detail_page = get_html('https://xcity.jp' + urls) 130 | dic = { 131 | 'actor': getActor(detail_page), 132 | 'title': getTitle(detail_page), 133 | 'studio': getStudio(detail_page), 134 | 'outline': getOutline(detail_page), 135 | 'runtime': getRuntime(detail_page), 136 | 'director': getDirector(detail_page), 137 | 'release': getRelease(detail_page), 138 | 'number': getNum(detail_page), 139 | 'cover': getCover(detail_page), 140 | 'cover_small': '', 141 | 'imagecut': 1, 142 | 'tag': getTag(detail_page), 143 | 'label': getLabel(detail_page), 144 | 'year': getYear(getRelease(detail_page)), # str(re.search('\d{4}',getRelease(a)).group()), 145 | 'actor_photo': getActorPhoto(getActor(detail_page)), 146 | 'website': 'https://javdb.com' + urls, 147 | 'source': 'xcity.py', 148 | } 149 | except Exception as e: 150 | # print(e) 151 | dic = {"title": ""} 152 | 153 | js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'), ) # .encode('UTF-8') 154 | return js 155 | 156 | if __name__ == '__main__': 157 | print(main('VNDS-2624')) 158 | --------------------------------------------------------------------------------