├── .gitignore
├── ADC_function.py
├── LICENSE
├── OOF_Rename.py
├── OOF_core.py
├── ReadMe.md
├── actor.py
├── avsox.py
├── config.ini
├── fanza.py
├── fc2fans_club.py
├── jav321.py
├── javbus.py
├── javdb.py
├── linux_make.py
├── mgstage.py
├── py_to_exe.bat
├── readme
├── 1.png
├── 2.png
├── This is readms.md's images folder
└── single.gif
└── ruquirments.txt
/.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 | pip-wheel-metadata/
24 | share/python-wheels/
25 | *.egg-info/
26 | .installed.cfg
27 | *.egg
28 | MANIFEST
29 |
30 | # PyInstaller
31 | # Usually these files are written by a python script from a template
32 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
33 | *.manifest
34 | *.spec
35 |
36 | # Installer logs
37 | pip-log.txt
38 | pip-delete-this-directory.txt
39 |
40 | # Unit test / coverage reports
41 | htmlcov/
42 | .tox/
43 | .nox/
44 | .coverage
45 | .coverage.*
46 | .cache
47 | nosetests.xml
48 | coverage.xml
49 | *.cover
50 | *.py,cover
51 | .hypothesis/
52 | .pytest_cache/
53 |
54 | # Translations
55 | *.mo
56 | *.pot
57 |
58 | # Django stuff:
59 | *.log
60 | local_settings.py
61 | db.sqlite3
62 | db.sqlite3-journal
63 |
64 | # Flask stuff:
65 | instance/
66 | .webassets-cache
67 |
68 | # Scrapy stuff:
69 | .scrapy
70 |
71 | # Sphinx documentation
72 | docs/_build/
73 |
74 | # PyBuilder
75 | target/
76 |
77 | # Jupyter Notebook
78 | .ipynb_checkpoints
79 |
80 | # IPython
81 | profile_default/
82 | ipython_config.py
83 |
84 | # pyenv
85 | .python-version
86 |
87 | # pipenv
88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not
91 | # install all needed dependencies.
92 | #Pipfile.lock
93 |
94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow
95 | __pypackages__/
96 |
97 | # Celery stuff
98 | celerybeat-schedule
99 | celerybeat.pid
100 |
101 | # SageMath parsed files
102 | *.sage.py
103 |
104 | # Environments
105 | .env
106 | .venv
107 | env/
108 | venv/
109 | ENV/
110 | env.bak/
111 | venv.bak/
112 |
113 | # Spyder project settings
114 | .spyderproject
115 | .spyproject
116 |
117 | # Rope project settings
118 | .ropeproject
119 |
120 | # mkdocs documentation
121 | /site
122 |
123 | # mypy
124 | .mypy_cache/
125 | .dmypy.json
126 | dmypy.json
127 |
128 | # Pyre type checker
129 | .pyre/
130 |
--------------------------------------------------------------------------------
/ADC_function.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 |
4 | import requests
5 | from configparser import ConfigParser
6 | import os
7 | import re
8 | import time
9 | import sys
10 | from lxml import etree
11 | import sys
12 | import io
13 | # sys.stdout = io.TextIOWrapper(sys.stdout.buffer, errors = 'replace', line_buffering = True)
14 | # sys.setdefaultencoding('utf-8')
15 |
16 | config_file='config.ini'
17 | config = ConfigParser()
18 |
19 | if os.path.exists(config_file):
20 | try:
21 | config.read(config_file, encoding='UTF-8')
22 | except:
23 | print('[-]Config.ini read failed! Please use the offical file!')
24 | else:
25 | print('[+]config.ini: not found, creating...',end='')
26 | with open("config.ini", "wt", encoding='UTF-8') as code:
27 | file_text = """[common]
28 | main_mode=1
29 | failed_output_folder=failed
30 | success_output_folder=JAV_output
31 | soft_link=0
32 |
33 | [proxy]
34 | proxy=192.168.2.2:1080
35 | timeout=10
36 | retry=3
37 |
38 | [Name_Rule]
39 | location_rule=actor+'/'+number
40 | naming_rule=number+'-'+title
41 |
42 | [update]
43 | update_check=1
44 |
45 | [media]
46 | media_warehouse=emby
47 | #emby or plex or kodi ,emby=jellyfin
48 |
49 | [escape]
50 | literals=\()/
51 | folders=failed,JAV_output
52 |
53 | [debug_mode]
54 | switch=0
55 |
56 | """
57 | print(file_text, file=code)
58 | time.sleep(2)
59 | print('.')
60 | print('[+]config.ini: created!')
61 | print('[+]Please restart the program!')
62 | time.sleep(4)
63 | os._exit(0)
64 | try:
65 | config.read(config_file, encoding='UTF-8')
66 | except:
67 | print('[-]Config.ini read failed! Please use the offical file!')
68 |
69 | def get_network_settings():
70 | try:
71 | proxy = config["proxy"]["proxy"]
72 | timeout = int(config["proxy"]["timeout"])
73 | retry_count = int(config["proxy"]["retry"])
74 | assert timeout > 0
75 | assert retry_count > 0
76 | except:
77 | raise ValueError("[-]Proxy config error! Please check the config.")
78 | return proxy, timeout, retry_count
79 |
80 |
81 | def get_data_state(data: dict) -> bool: # 元数据获取失败检测
82 | if data["title"] is None or data["title"] == "" or data["title"] == "null":
83 | return False
84 |
85 | if data["number"] is None or data["number"] == "" or data["number"] == "null":
86 | return False
87 |
88 | return True
89 |
90 | def ReadMediaWarehouse():
91 | return config['media']['media_warehouse']
92 |
93 | def UpdateCheckSwitch():
94 | check=str(config['update']['update_check'])
95 | if check == '1':
96 | return '1'
97 | elif check == '0':
98 | return '0'
99 | elif check == '':
100 | return '0'
101 |
102 | def getXpathSingle(htmlcode,xpath):
103 | html = etree.fromstring(htmlcode, etree.HTMLParser())
104 | result1 = str(html.xpath(xpath)).strip(" ['']")
105 | return result1
106 |
107 | def get_html(url,cookies = None):#网页请求核心
108 | proxy, timeout, retry_count = get_network_settings()
109 | i = 0
110 | while i < retry_count:
111 | try:
112 | if not proxy == '':
113 | #proxies = {"http": "http://" + proxy,"https": "https://" + proxy}
114 | proxies={"http": str(proxy), "https": str(proxy)}
115 | 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'}
116 | getweb = requests.get(str(url), headers=headers, timeout=timeout,proxies=proxies, cookies=cookies)
117 | getweb.encoding = 'utf-8'
118 | return getweb.text
119 | else:
120 | headers = {'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'}
121 | getweb = requests.get(str(url), headers=headers, timeout=timeout, cookies=cookies)
122 | getweb.encoding = 'utf-8'
123 | return getweb.text
124 | except:
125 | i += 1
126 | print('[-]Connect retry '+str(i)+'/'+str(retry_count))
127 | print('[-]Connect Failed! Please check your Proxy or Network!')
128 |
129 |
130 | def post_html(url: str, query: dict) -> requests.Response:
131 | proxy, timeout, retry_count = get_network_settings()
132 |
133 | if proxy:
134 | #proxies = {"http": "http://" + proxy, "https": "https://" + proxy}
135 | proxies={"http": str(proxy), "https": str(proxy)}
136 | else:
137 | proxies = {}
138 |
139 | for i in range(retry_count):
140 | try:
141 | result = requests.post(url, data=query, proxies=proxies)
142 | return result
143 | except requests.exceptions.ProxyError:
144 | print("[-]Connect retry {}/{}".format(i+1, retry_count))
145 | print("[-]Connect Failed! Please check your Proxy or Network!")
146 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/OOF_Rename.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 |
4 | import glob
5 | import os
6 | import time
7 | import re
8 | import codecs
9 | from ADC_function import *
10 | from OOF_core import *
11 | import json
12 | import shutil
13 | from configparser import ConfigParser
14 |
15 | def delExistFile(path): #重命名已存在的文件,加上时间戳
16 | if os.path.exists(path):
17 | time_stamp = int(time.time()) #时间戳
18 | file_timestamp = time.strftime("%Y%m%d%H%M%S", time.localtime(time_stamp))#YYYYMMDDhh24miss
19 | filename=os.path.splitext(path)[0] #文件名
20 | filetype=os.path.splitext(path)[1]
21 | Newpath=os.path.join(filename+"_"+file_timestamp+filetype)
22 | try:
23 | os.rename(path,Newpath)
24 | print("[!]"+path+" 已存在! 已重命名为"+Newpath)
25 | except:
26 | print("[-]failed!can not rename file 'failed'\n[-](Please run as Administrator)")
27 | os._exit(0)
28 |
29 |
30 | def getNumber(filepath,absolute_path = False): #从路径中得到番号
31 | if absolute_path == True:
32 | filepath=filepath.replace('\\','/')
33 | file_number = str(re.findall(r'(.+?)\.', str(re.search('([^<>/\\\\|:""\\*\\?]+)\\.\\w+$', filepath).group()))).strip("['']").replace('_', '-')
34 | return file_number
35 | if '-' in filepath or '_' in filepath: # 普通提取番号 主要处理包含减号-和_的番号
36 | filepath = filepath.replace("_", "-")
37 | filepath.strip('22-sht.me').strip('-HD').strip('-hd')
38 | filename = str(re.sub("\[\d{4}-\d{1,2}-\d{1,2}\] - ", "", filepath)) # 去除文件名中时间
39 | if 'FC2' or 'fc2' in filename:
40 | filename = filename.replace('-PPV', '').replace('PPV-', '').replace('FC2PPV-', 'FC2-').replace('FC2PPV_', 'FC2-')
41 | filename = filename.replace('-ppv', '').replace('ppv-', '').replace('fc2ppv-', 'FC2-').replace('fc2ppv_', 'FC2-')
42 | file_number = re.search(r'\w+-\w+', filename, re.A).group()
43 | return file_number
44 | else: # 提取不含减号-的番号,FANZA CID
45 | try:
46 | return str(re.findall(r'(.+?)\.', str(re.search('([^<>/\\\\|:""\\*\\?]+)\\.\\w+$', filepath).group()))).strip("['']").replace('_', '-')
47 | except:
48 | return re.search(r'(.+?)\.', filepath)[0]
49 |
50 |
51 | if __name__ == '__main__':
52 | config_file = 'config.ini'
53 | config = ConfigParser()
54 | config.read(config_file, encoding='UTF-8')
55 | input_file = config['common']['input_file'] # 输入文件
56 | success_folder = config['common']['success_output_folder'] # 成功输出目录
57 | failed_file = config['common']['failed_output_file'] # 失败输出
58 | print('[*]================== 开始重命名,请联网 ===================')
59 |
60 | #备份旧文件和文件夹
61 | delExistFile(success_folder)
62 | delExistFile(failed_file)
63 |
64 | for l in open(input_file,'r', encoding='UTF-8'): #遍历txt文件,交给core
65 | link=l.split('|')
66 | filename=link[0]
67 | try:
68 | print("[!]Making Data for [" + filename + "], the number is [" + getNumber(filename) + "]")
69 | core_main(l, getNumber(filename))
70 | print("[*]======================================================")
71 | except Exception as e: # 番号提取异常
72 | print('[-]' + filename + ' ERRPR :')
73 | print('[-]',e)
74 | try:
75 | print('[-]Move ' + filename + ' to failed file')
76 | #输出链接到失败文件
77 | open_failed= codecs.open(failed_file,'a+', encoding='utf-8')
78 | open_failed.write(l)
79 | open_failed.close()
80 | except Exception as e2:
81 | print('[!]', e2)
82 | continue
83 |
84 | print("[+]All finished!!!")
85 | input("[+][+]Press enter key exit, you can check the error messge before you exit.")
86 |
--------------------------------------------------------------------------------
/OOF_core.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import re
4 | import os
5 | import os.path
6 | import shutil
7 | from PIL import Image
8 | import time
9 | import json
10 | from ADC_function import *
11 | from configparser import ConfigParser
12 | import argparse
13 | import codecs
14 | # =========website========
15 | import fc2fans_club
16 | import mgstage
17 | import avsox
18 | import javbus
19 | import javdb
20 | import fanza
21 | import jav321
22 | import requests
23 | import random
24 |
25 |
26 | # =====================本地文件处理===========================
27 |
28 | def escapePath(path, Config): # Remove escape literals
29 | escapeLiterals = Config['escape']['literals']
30 | backslash = '\\'
31 | for literal in escapeLiterals:
32 | path = path.replace(backslash + literal, '')
33 | return path
34 |
35 | def moveToFailedFile(full_link, failed_file):
36 | print('[-]Move to Failed file')
37 | open_failed= codecs.open(failed_file,'a+', encoding='utf-8')
38 | open_failed.write(full_link)
39 | open_failed.close()
40 | return
41 | '''
42 | def moveFailedFolder(filepath, failed_folder): #移动文件到失败文件夹
43 | print('[-]Move to Failed output folder')
44 | shutil.move(filepath, str(os.getcwd()) + '/' + failed_folder + '/')
45 | return
46 |
47 |
48 | def CreatFailedFolder(failed_folder):
49 | if not os.path.exists(failed_folder + '/'): # 新建failed文件夹
50 | try:
51 | os.makedirs(failed_folder + '/')
52 | except:
53 | print("[-]failed!can not be make Failed output folder\n[-](Please run as Administrator)")
54 | return
55 | '''
56 | def getDataFromJSON(file_number, filepath, failed_folder): # 从JSON返回元数据
57 | """
58 | iterate through all services and fetch the data
59 | """
60 |
61 | func_mapping = {
62 | "avsox": avsox.main,
63 | "fc2": fc2fans_club.main,
64 | "fanza": fanza.main,
65 | "javdb": javdb.main,
66 | "javbus": javbus.main,
67 | "mgstage": mgstage.main,
68 | "jav321": jav321.main,
69 | }
70 |
71 | # default fetch order list, from the begining to the end
72 | sources = ["javbus", "javdb", "fanza", "mgstage", "fc2", "avsox", "jav321"]
73 |
74 | # if the input file name matches centain rules,
75 | # move some web service to the begining of the list
76 | if re.match(r"^\d{5,}", file_number) or (
77 | "HEYZO" in file_number or "heyzo" in file_number or "Heyzo" in file_number
78 | ):
79 | sources.insert(0, sources.pop(sources.index("avsox")))
80 | elif re.match(r"\d+\D+", file_number) or (
81 | "siro" in file_number or "SIRO" in file_number or "Siro" in file_number
82 | ):
83 | sources.insert(0, sources.pop(sources.index("fanza")))
84 | elif "fc2" in file_number or "FC2" in file_number:
85 | sources.insert(0, sources.pop(sources.index("fc2")))
86 |
87 | for source in sources:
88 | json_data = json.loads(func_mapping[source](file_number))
89 | # if any service return a valid return, break
90 | if get_data_state(json_data):
91 | break
92 |
93 | # ================================================网站规则添加结束================================================
94 |
95 | title = json_data['title']
96 | actor_list = str(json_data['actor']).strip("[ ]").replace("'", '').split(',') # 字符串转列表
97 | release = json_data['release']
98 | number = json_data['number']
99 | studio = json_data['studio']
100 | source = json_data['source']
101 | runtime = json_data['runtime']
102 | outline = json_data['outline']
103 | label = json_data['label']
104 | year = json_data['year']
105 | try:
106 | cover_small = json_data['cover_small']
107 | except:
108 | cover_small = ''
109 | imagecut = json_data['imagecut']
110 | tag = str(json_data['tag']).strip("[ ]").replace("'", '').replace(" ", '').split(',') # 字符串转列表 @
111 | actor = str(actor_list).strip("[ ]").replace("'", '').replace(" ", '')
112 |
113 |
114 | if title == '' or number == '':
115 | print('[-]Movie Data not found!')
116 | '''
117 | moveFailedFolder(filepath, failed_folder)
118 | '''
119 | moveToFailedFile(filepath, failed_folder)
120 | return
121 |
122 | # if imagecut == '3':
123 | # DownloadFileWithFilename()
124 |
125 | # ====================处理异常字符====================== #\/:*?"<>|
126 | title = title.replace('\\', '')
127 | title = title.replace('/', '')
128 | title = title.replace(':', '')
129 | title = title.replace('*', '')
130 | title = title.replace('?', '')
131 | title = title.replace('"', '')
132 | title = title.replace('<', '')
133 | title = title.replace('>', '')
134 | title = title.replace('|', '')
135 | title = title.replace('&', '')
136 | release = release.replace('/', '-')
137 | tmpArr = cover_small.split(',')
138 | if len(tmpArr) > 0:
139 | cover_small = tmpArr[0].strip('\"').strip('\'')
140 | # ====================处理异常字符 END================== #\/:*?"<>|
141 |
142 | naming_rule = eval(config['Name_Rule']['naming_rule'])
143 | location_rule = eval(config['Name_Rule']['location_rule'])
144 | if 'actor' in config['Name_Rule']['location_rule'] and len(actor) > 100:
145 | print(config['Name_Rule']['location_rule'])
146 | location_rule = eval(config['Name_Rule']['location_rule'].replace("actor","'多人作品'"))
147 | if 'title' in config['Name_Rule']['location_rule'] and len(title) > 100:
148 | location_rule = eval(config['Name_Rule']['location_rule'].replace("title",'number'))
149 |
150 | # 返回处理后的json_data
151 | json_data['title'] = title
152 | json_data['actor'] = actor
153 | json_data['release'] = release
154 | json_data['cover_small'] = cover_small
155 | json_data['tag'] = tag
156 | json_data['naming_rule'] = naming_rule
157 | json_data['location_rule'] = location_rule
158 | json_data['year'] = year
159 | json_data['actor_list'] = actor_list
160 | return json_data
161 |
162 |
163 | def get_info(json_data): # 返回json里的数据
164 | title = json_data['title']
165 | studio = json_data['studio']
166 | year = json_data['year']
167 | outline = json_data['outline']
168 | runtime = json_data['runtime']
169 | director = json_data['director']
170 | actor_photo = json_data['actor_photo']
171 | release = json_data['release']
172 | number = json_data['number']
173 | cover = json_data['cover']
174 | website = json_data['website']
175 | return title, studio, year, outline, runtime, director, actor_photo, release, number, cover, website
176 |
177 |
178 | def smallCoverCheck(path, number, imagecut, cover_small, c_word, Config, filepath, failed_folder):
179 | if imagecut == 3:
180 | DownloadFileWithFilename(cover_small, path + '/' + number + c_word + '-poster.jpg', path, Config, filepath, failed_folder)
181 | print('[+]Image Downloaded! '+ path + '/' + number + c_word + '-poster.jpg')
182 |
183 |
184 | def creatFolder(success_folder, location_rule, json_data, Config): # 创建文件夹
185 | title, studio, year, outline, runtime, director, actor_photo, release, number, cover, website= get_info(json_data)
186 | if len(location_rule) > 240: # 新建成功输出文件夹
187 | path = success_folder + '/' + location_rule.replace("'actor'", "'manypeople'", 3).replace("actor","'manypeople'",3) # path为影片+元数据所在目录
188 | else:
189 | path = success_folder + '/' + location_rule
190 | if not os.path.exists(path):
191 | path = escapePath(path, Config)
192 | try:
193 | os.makedirs(path)
194 | except:
195 | path = success_folder + '/' + location_rule.replace('/[' + number + ']-' + title, "/number")
196 | path = escapePath(path, Config)
197 |
198 | os.makedirs(path)
199 | return path
200 |
201 |
202 | # =====================资源下载部分===========================
203 | def DownloadFileWithFilename(url, filename, path, Config, filepath, failed_folder): # path = examle:photo , video.in the Project Folder!
204 | proxy, timeout, retry_count = get_network_settings()
205 | i = 0
206 |
207 | while i < retry_count:
208 | try:
209 | if not proxy == '':
210 | if not os.path.exists(path):
211 | os.makedirs(path)
212 | headers = {
213 | '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'}
214 | r = requests.get(url, headers=headers, timeout=timeout,
215 | #proxies={"http": "http://" + str(proxy), "https": "https://" + str(proxy)})
216 | proxies={"http": str(proxy), "https": str(proxy)})
217 | if r == '':
218 | print('[-]Movie Data not found!')
219 | return
220 | with open(str(path) + "/" + filename, "wb") as code:
221 | code.write(r.content)
222 | return
223 | else:
224 | if not os.path.exists(path):
225 | os.makedirs(path)
226 | headers = {
227 | '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'}
228 | r = requests.get(url, timeout=timeout, headers=headers)
229 | if r == '':
230 | print('[-]Movie Data not found!')
231 | return
232 | with open(str(path) + "/" + filename, "wb") as code:
233 | code.write(r.content)
234 | return
235 | except requests.exceptions.RequestException:
236 | i += 1
237 | print('[-]Image Download : Connect retry ' + str(i) + '/' + str(retry_count))
238 | except requests.exceptions.ConnectionError:
239 | i += 1
240 | print('[-]Image Download : Connect retry ' + str(i) + '/' + str(retry_count))
241 | except requests.exceptions.ProxyError:
242 | i += 1
243 | print('[-]Image Download : Connect retry ' + str(i) + '/' + str(retry_count))
244 | except requests.exceptions.ConnectTimeout:
245 | i += 1
246 | print('[-]Image Download : Connect retry ' + str(i) + '/' + str(retry_count))
247 | print('[-]Connect Failed! Please check your Proxy or Network!')
248 | '''
249 | moveFailedFolder(filepath, failed_folder)
250 | '''
251 | moveToFailedFile(filepath, failed_folder)
252 | return
253 |
254 |
255 | def imageDownload(cover, number, c_word, path, multi_part, Config, filepath, failed_folder): # 封面是否下载成功,否则移动到failed
256 | if DownloadFileWithFilename(cover, number + c_word + '-fanart.jpg', path, Config, filepath,failed_folder) == 'failed':
257 | '''
258 | moveFailedFolder(filepath, failed_folder)
259 | '''
260 | moveToFailedFile(filepath, failed_folder)
261 | return
262 | i = 1
263 | while i <= int(config['proxy']['retry']):
264 | if os.path.getsize(path + '/' + number + c_word + '-fanart.jpg') == 0:
265 | print('[!]Image Download Failed! Trying again. [' + config['proxy']['retry'] + '/3]')
266 | DownloadFileWithFilename(cover, number + c_word + '-fanart.jpg', path, Config, filepath, failed_folder)
267 | i = i + 1
268 | continue
269 | else:
270 | break
271 | if os.path.getsize(path + '/' + number + c_word + '-fanart.jpg') == 0:
272 | return
273 | print('[+]Image Downloaded!', path + '/' + number + c_word + '-fanart.jpg')
274 | shutil.copyfile(path + '/' + number + c_word + '-fanart.jpg',path + '/' + number + c_word + '-thumb.jpg')
275 |
276 |
277 | def PrintFiles(path, c_word, naming_rule, part, cn_sub, json_data, filepath, failed_folder, tag, actor_list, liuchu):
278 | title, studio, year, outline, runtime, director, actor_photo, release, number, cover, website = get_info(json_data)
279 | try:
280 | if not os.path.exists(path):
281 | os.makedirs(path)
282 | with open(path + "/" + number + c_word + ".nfo", "wt", encoding='UTF-8') as code:
283 | print('', file=code)
284 | print("", file=code)
285 | print(" " + naming_rule + part + "", file=code)
286 | print(" ", file=code)
287 | print(" ", file=code)
288 | print(" " + studio + "+", file=code)
289 | print(" " + year + "", file=code)
290 | print(" " + outline + "", file=code)
291 | print(" " + outline + "", file=code)
292 | print(" " + str(runtime).replace(" ", "") + "", file=code)
293 | print(" " + director + "", file=code)
294 | print(" " + number + c_word + "-poster.jpg", file=code)
295 | print(" " + number + c_word + "-thumb.jpg", file=code)
296 | print(" " + number + c_word + '-fanart.jpg' + "", file=code)
297 | try:
298 | for key in actor_list:
299 | print(" ", file=code)
300 | print(" " + key + "", file=code)
301 | print(" ", file=code)
302 | except:
303 | aaaa = ''
304 | print(" " + studio + "", file=code)
305 | print(" ", file=code)
307 | if cn_sub == '1':
308 | print(" 中文字幕", file=code)
309 | if liuchu == '流出':
310 | print(" 流出", file=code)
311 | try:
312 | for i in tag:
313 | print(" " + i + "", file=code)
314 | except:
315 | aaaaa = ''
316 | try:
317 | for i in tag:
318 | print(" " + i + "", file=code)
319 | except:
320 | aaaaaaaa = ''
321 | if cn_sub == '1':
322 | print(" 中文字幕", file=code)
323 | print(" " + number + "", file=code)
324 | print(" " + release + "", file=code)
325 | print(" " + cover + "", file=code)
326 | print(" " + website + "", file=code)
327 | print("", file=code)
328 | print("[+]Writeed! " + path + "/" + number + c_word + ".nfo")
329 | except IOError as e:
330 | print("[-]Write Failed!")
331 | print(e)
332 | '''
333 | moveFailedFolder(filepath, failed_folder)
334 | '''
335 | moveToFailedFile(filepath, failed_folder)
336 | return
337 | except Exception as e1:
338 | print(e1)
339 | print("[-]Write Failed!")
340 | '''
341 | moveFailedFolder(filepath, failed_folder)
342 | '''
343 | moveToFailedFile(filepath, failed_folder)
344 | return
345 |
346 |
347 | def cutImage(imagecut, path, number, c_word):
348 | if imagecut == 1:
349 | try:
350 | img = Image.open(path + '/' + number + c_word + '-fanart.jpg')
351 | imgSize = img.size
352 | w = img.width
353 | h = img.height
354 | img2 = img.crop((w / 1.9, 0, w, h))
355 | img2.save(path + '/' + number + c_word + '-poster.jpg')
356 | print('[+]Image Cutted! ' + path + '/' + number + c_word + '-poster.jpg')
357 | except:
358 | print('[-]Cover cut failed!')
359 | elif imagecut == 0:
360 | shutil.copyfile(path + '/' + number + c_word + '-fanart.jpg',path + '/' + number + c_word + '-poster.jpg')
361 | print('[+]Image Copyed! ' + path + '/' + number + c_word + '-poster.jpg')
362 |
363 |
364 | def pasteFileToFolder(filepath, path, number, c_word): # 文件路径,番号,后缀,要移动至的位置
365 | houzhui = str(re.search('[.](AVI|RMVB|WMV|MOV|MP4|MKV|FLV|TS|WEBM|avi|rmvb|wmv|mov|mp4|mkv|flv|ts|webm)$', filepath).group())
366 | try:
367 | if config['common']['soft_link'] == '1': # 如果soft_link=1 使用软链接
368 | os.symlink(filepath, path + '/' + number + c_word + houzhui)
369 | else:
370 | os.rename(filepath, path + '/' + number + c_word + houzhui)
371 | if os.path.exists(os.getcwd() + '/' + number + c_word + '.srt'): # 字幕移动
372 | os.rename(os.getcwd() + '/' + number + c_word + '.srt', path + '/' + number + c_word + '.srt')
373 | print('[+]Sub moved!')
374 | elif os.path.exists(os.getcwd() + '/' + number + c_word + '.ssa'):
375 | os.rename(os.getcwd() + '/' + number + c_word + '.ssa', path + '/' + number + c_word + '.ssa')
376 | print('[+]Sub moved!')
377 | elif os.path.exists(os.getcwd() + '/' + number + c_word + '.sub'):
378 | os.rename(os.getcwd() + '/' + number + c_word + '.sub', path + '/' + number + c_word + '.sub')
379 | print('[+]Sub moved!')
380 | except FileExistsError:
381 | print('[-]File Exists! Please check your movie!')
382 | print('[-]move to the root folder of the program.')
383 | return
384 | except PermissionError:
385 | print('[-]Error! Please run as administrator!')
386 | return
387 |
388 | '''
389 | def pasteFileToFolder_mode2(filepath, path, multi_part, number, part, c_word): # 文件路径,番号,后缀,要移动至的位置
390 | if multi_part == 1:
391 | number += part # 这时number会被附加上CD1后缀
392 | houzhui = str(re.search('[.](AVI|RMVB|WMV|MOV|MP4|MKV|FLV|TS|WEBM|avi|rmvb|wmv|mov|mp4|mkv|flv|ts|webm)$', filepath).group())
393 | try:
394 | if config['common']['soft_link'] == '1':
395 | os.symlink(filepath, path + '/' + number + part + c_word + houzhui)
396 | else:
397 | os.rename(filepath, path + '/' + number + part + c_word + houzhui)
398 | if os.path.exists(number + '.srt'): # 字幕移动
399 | os.rename(number + part + c_word + '.srt', path + '/' + number + part + c_word + '.srt')
400 | print('[+]Sub moved!')
401 | elif os.path.exists(number + part + c_word + '.ass'):
402 | os.rename(number + part + c_word + '.ass', path + '/' + number + part + c_word + '.ass')
403 | print('[+]Sub moved!')
404 | elif os.path.exists(number + part + c_word + '.sub'):
405 | os.rename(number + part + c_word + '.sub', path + '/' + number + part + c_word + '.sub')
406 | print('[+]Sub moved!')
407 | print('[!]Success')
408 | except FileExistsError:
409 | print('[-]File Exists! Please check your movie!')
410 | print('[-]move to the root folder of the program.')
411 | return
412 | except PermissionError:
413 | print('[-]Error! Please run as administrator!')
414 | return
415 | '''
416 | def get_part(filepath, failed_folder):
417 | try:
418 | if re.search('-CD\d+', filepath):
419 | return re.findall('-CD\d+', filepath)[0]
420 | if re.search('-cd\d+', filepath):
421 | return re.findall('-cd\d+', filepath)[0]
422 | except:
423 | print("[-]failed!Please rename the filename again!")
424 | '''
425 | moveFailedFolder(filepath, failed_folder)
426 | '''
427 | moveToFailedFile(full_link, failed_file)
428 | return
429 |
430 | def debug_mode(json_data):
431 | try:
432 | if config['debug_mode']['switch'] == '1':
433 | print('[+] ---Debug info---')
434 | for i, v in json_data.items():
435 | if i == 'outline':
436 | print('[+] -', i, ' :', len(v), 'characters')
437 | continue
438 | if i == 'actor_photo' or i == 'year':
439 | continue
440 | print('[+] -', "%-11s" % i, ':', v)
441 | print('[+] ---Debug info---')
442 | except:
443 | aaa = ''
444 |
445 |
446 | def getNewFileName(json_data, Config, number, part, c_word, liuchu): #目的是把后缀添加到番号后
447 | title = json_data['title']
448 | actor = json_data['actor']
449 | studio = json_data['studio']
450 | director = json_data['director']
451 | release = json_data['release']
452 | year = json_data['year']
453 | number = number+part+c_word+liuchu
454 | cover = json_data['cover']
455 | tag = json_data['tag']
456 | outline = json_data['outline']
457 | runtime = json_data['runtime']
458 | return eval(Config['Name_Rule']['naming_rule'])
459 |
460 | def moveToTxt(new_name, full_link, folder, success_file):
461 | link = full_link.split('|')
462 | filename = link[0] # 原名
463 | filesize = link[1]
464 | fileid = link[2]
465 | preid = link[3].strip() #去除了换行符\n
466 | houzhui = str(re.search('[.](AVI|RMVB|WMV|MOV|MP4|MKV|FLV|TS|WEBM|avi|rmvb|wmv|mov|mp4|mkv|flv|ts|webm)$', filename).group())
467 | try:
468 | #path = folder + '/' + success_file
469 | #open_file = codecs.open((folder + '/' + success_file),'a+', encoding='utf-8')
470 | if not os.path.exists(folder):
471 | os.mkdir(folder)
472 | open_file = codecs.open((folder + '/' + success_file),'a+', encoding='utf-8')
473 | open_file.write(new_name + houzhui +'|'+ filesize +'|'+ fileid +'|'+ preid +'\n')
474 | open_file.close()
475 | print( "[+] " + filename + " 保存到 " + folder + '/' +success_file)
476 | except PermissionError:
477 | print('[-]Error! Please run as administrator!')
478 | return
479 |
480 |
481 | def core_main(full_link, number_th):
482 | # =======================================================================初始化所需变量
483 | multi_part = 0 #是否是CD1 CD2
484 | part = ''
485 | c_word = '' # 中文字幕影片后缀
486 | cn_sub = ''
487 | liuchu = ''
488 | config_file = 'config.ini'
489 | Config = ConfigParser()
490 | Config.read(config_file, encoding='UTF-8')
491 | program_mode = Config['common']['main_mode'] # 运行模式
492 | file_mode = re.findall(r'\d', program_mode)
493 | '''
494 | #函数中这两个参数,只是给了传给moveFailedFolder,所以filepath和full_link可替代
495 | failed_folder = Config['common']['failed_output_folder'] # 失败输出目录
496 | filepath = full_link # 影片的路径filepath
497 | '''
498 | success_folder = Config['common']['success_output_folder'] # 成功输出目录
499 | success_file = "RenameSu.txt" # 成功输出
500 | failed_file = Config['common']['failed_output_file'] # 失败输出
501 | number = number_th
502 | #分割链接
503 | link = full_link.split('|')
504 | filename = link[0] # 原名
505 |
506 | json_data = getDataFromJSON(number, full_link, failed_file) # 爬虫获取元数据, 失败时传给 moveToFailedFile(full_link, failed_file)
507 | if json_data["number"] != number:
508 | # fix issue #119
509 | # the root cause is we normalize the search id
510 | # PrintFiles() will use the normalized id from website,
511 | # but pasteFileToFolder() still use the input raw search id
512 | # so the solution is: use the normalized search id
513 | number = json_data["number"]
514 | imagecut = json_data['imagecut']
515 | tag = json_data['tag']
516 | # =======================================================================判断-C,-CD后缀
517 | if '-CD' in filename or '-cd' in filename:
518 | multi_part = 1
519 | '''
520 | part = get_part(filename, failed_folder)
521 | '''
522 | part = get_part(filename, failed_file)
523 | if '-c.' in filename or '-C.' in filename or '中文' in filename or '字幕' in filename:
524 | cn_sub = '1'
525 | c_word = '-C' # 中文字幕影片后缀
526 | if '流出' in filename:
527 | liuchu = '流出'
528 | '''
529 | CreatFailedFolder(failed_folder) # 创建输出失败目录
530 | '''
531 | debug_mode(json_data) # 调试模式检测
532 |
533 | new_name = getNewFileName(json_data, Config, number, part, c_word, liuchu) #文件全名,在番号后加了后缀,!不带扩展名!
534 | if file_mode[0] == '1': #全部输出到成功目录
535 | path = success_folder
536 | if file_mode[1] == '1': #只存链接文件
537 | moveToTxt(new_name, full_link, path, success_file)
538 | elif file_mode[1] == '2': #存链接文件和封面图
539 | moveToTxt(new_name, full_link, path, success_file)
540 | imageDownload(json_data['cover'], number, c_word, path, multi_part, Config, full_link, failed_file)
541 | elif file_mode[1] == '3': #存所有文件
542 | moveToTxt(new_name, full_link, path, success_file)
543 | smallCoverCheck(path, number, imagecut, json_data['cover_small'], c_word, Config, full_link, failed_file) # 检查小封面
544 | imageDownload(json_data['cover'], number, c_word, path, multi_part, Config, full_link, failed_file)
545 | cutImage(imagecut, path, number, c_word) # 裁剪图
546 | PrintFiles(path, c_word, json_data['naming_rule'], part, cn_sub, json_data, full_link, failed_file, tag, json_data['actor_list'],liuchu) # 打印nfo文件
547 | elif file_mode[0] == '2': #按location_rule分类输出到文件夹
548 | path = creatFolder(success_folder, json_data['location_rule'], json_data, Config) # 输出的文件夹
549 | if file_mode[1] == '1':
550 | moveToTxt(new_name, full_link, path, success_file)
551 | elif file_mode[1] == '2':
552 | moveToTxt(new_name, full_link, path, success_file)
553 | imageDownload(json_data['cover'], number, c_word, path, multi_part, Config, full_link, failed_file)
554 | elif file_mode[1] == '3':
555 | moveToTxt(new_name, full_link, path, success_file)
556 | smallCoverCheck(path, number, imagecut, json_data['cover_small'], c_word, Config, full_link, failed_file) # 检查小封面
557 | imageDownload(json_data['cover'], number, c_word, path, multi_part, Config, full_link, failed_file)
558 | cutImage(imagecut, path, number, c_word) # 裁剪图
559 | PrintFiles(path, c_word, json_data['naming_rule'], part, cn_sub, json_data, full_link, failed_file, tag, json_data['actor_list'],liuchu) # 打印nfo文件
560 |
561 | '''
562 | full_link, failed_file 替换 filepath, failed_folder
563 | 原始代码
564 | # =======================================================================刮削模式
565 | if program_mode == '1':
566 | if multi_part == 1:
567 | number += part # 这时number会被附加上CD1后缀
568 | smallCoverCheck(path, number, imagecut, json_data['cover_small'], c_word, Config, filepath, failed_folder) # 检查小封面
569 | imageDownload(json_data['cover'], number, c_word, path, multi_part, Config, filepath, failed_folder) # creatFoder会返回番号路径
570 | cutImage(imagecut, path, number, c_word) # 裁剪图
571 | PrintFiles(path, c_word, json_data['naming_rule'], part, cn_sub, json_data, filepath, failed_folder, tag, json_data['actor_list'],liuchu) # 打印文件
572 | pasteFileToFolder(filepath, path, number, c_word) # 移动文件
573 | # =======================================================================整理模式
574 | elif program_mode == '2':
575 | pasteFileToFolder_mode2(filepath, path, multi_part, number, part, c_word) # 移动文件
576 | '''
--------------------------------------------------------------------------------
/ReadMe.md:
--------------------------------------------------------------------------------
1 | # 115_Code_Rename
2 | 修改自项目 AV Data Capture (CLI)
3 |
4 | 工具的初衷是:为Fake115Upload生成的**日本电影115转存码批量自动重命名。**
5 |
6 | 处理115转存码,识别番号,按规则重命名。重命名后的码转存到网盘后,文件名是完整的,**间接为网盘文件重命名**。
7 | 也可以对转存码**分类、抓取影片封面图、元数据**。
8 |
9 | # 下载
10 |
11 | [Windows版](https://github.com/LSD08KM/115_Code_Rename/releases)
12 |
13 | 其他系统请clone源码包运行,并手动安装Python3环境
14 |
15 | # 如何使用
16 |
17 | ## 注意事项,必读!
18 |
19 | 工具要处理的文本文档如下图所示:
20 |
21 | 
22 |
23 | 文件内每行一条转存码,转存码的开头是文件名。
24 |
25 | 旧文件名必须满足 AV Data Capture (CLI) 的条件:文件名中间要有下划线或者减号"_","-",没有多余的内容只有番号为最佳。
26 |
27 | 默认将重命名失败的码保存在`115failed.txt` ,
28 | 成功的码保存在AV_output文件夹内的`RenameSu.txt`。
29 |
30 | 重命名后的文档如下:
31 |
32 | 
33 |
34 | ## 简要教程:
35 |
36 | 1. 把软件和写有115转存码的文本文档放到同一目录
37 | 2. 修改config.ini参数,把input_file=后的文件名改成要处理的文件
38 | 3. 设置 config.ini 文件的代理(路由器拥有自动代理功能的可以把 proxy= 后面内容去掉)
39 | 4. 运行软件等待完成
40 |
41 | **详细请看以下完整文档**
42 |
43 | # 完整使用文档
44 |
45 | ## 模块安装
46 | 如果运行**源码**版,运行前请安装**Python环境**和安装以下**模块**
47 |
48 | 在终端 cmd/Powershell/Terminal 中输入以下代码来安装模块
49 |
50 | ```python
51 | pip install requests pyquery lxml Beautifulsoup4 pillow
52 | ```
53 |
54 | ## 配置文件config.ini
55 | ### 配置文件的参数
56 | ```
57 | [common]
58 | 运行模式:
59 | main_mode=21
60 | 输入文档(要处理的文档):
61 | input_file=115s.txt
62 | 保存重命名失败的转存码的文档:
63 | failed_output_file=115failed.txt
64 | 保存重命名成功的转存码的文件夹
65 | success_output_folder=AV_output
66 | 没用,不要修改:
67 | soft_link=0
68 |
69 | 网络设置:
70 | [proxy]
71 | 代理设置:
72 | proxy=socks5://127.0.0.1:10808
73 | 连接超时重试:
74 | timeout=5
75 | 连接重试次数:
76 | retry=2
77 |
78 | 重命名规则:
79 | [Name_Rule]
80 | 自定义目录:
81 | location_rule= year+'/'+studio
82 | 命名规则:
83 | naming_rule=number+' '+actor+' '+title
84 |
85 | 没用,不要修改:
86 | [update]
87 | update_check=0
88 |
89 | 没用,不要修改:
90 | [escape]
91 | literals=\()/
92 | folders=AV_output
93 |
94 | 调试模式:
95 | [debug_mode]
96 | switch=0
97 | ```
98 |
99 | ### 运行模式
100 |
101 | ```
102 | [common]
103 | main_mode=11
104 | ```
105 | 11 转存码存到输出目录下的单一文档
106 | 12 转存码存到输出目录下的单一文档,并下载封面图
107 | 13 转存码存到输出目录下的单一文档,并下载全部图片及元数据文件
108 | 21 转存码按目录结构规则分类
109 | 22 转存码按目录结构规则分类,并下载封面图
110 | 23 转存码按目录结构规则分类,并下载全部图片及元数据文件
111 |
112 | ---
113 | ### 设置输入文档、失败输出文档和成功输出目录
114 |
115 | ```
116 | input_file=115s.txt
117 | failed_output_file=115failed.txt
118 | success_output_folder=AV_output
119 | ```
120 | ---
121 | ### 网络设置
122 | ```
123 | [proxy]
124 | proxy=127.0.0.1:1081
125 | timeout=10
126 | retry=3
127 | ```
128 | #### 针对某些地区的代理设置
129 | ```
130 | proxy=127.0.0.1:1081
131 | ```
132 |
133 | 打开```config.ini```,在```[proxy]```下的```proxy```行设置本地代理地址和端口,支持Shadowxxxx/X,V2XXX本地代理端口
134 | 素人系列抓取建议使用日本代理
135 | **路由器拥有自动代理功能的可以把proxy=后面内容去掉**
136 | **本地代理软件开全局模式的用户同上**
137 | **如果遇到tineout错误,可以把文件的proxy=后面的地址和端口删除,并开启代理软件全局模式,或者重启电脑,代理软件,网卡**
138 |
139 | ---
140 | #### 连接超时重试设置
141 | ```
142 | timeout=10
143 | ```
144 | 10为超时重试时间 单位:秒
145 |
146 | ---
147 | #### 连接重试次数设置
148 | ```
149 | retry=3
150 | ```
151 | 3即为重试次数
152 |
153 | ---
154 | ### 设置目录结构规则和影片重命名规则
155 |
156 | 默认配置:
157 |
158 | ```
159 | [Name_Rule]
160 | location_rule= year+'/'+studio
161 | naming_rule=number+' '+actor+' '+title
162 | ```
163 | #### 命名参数
164 | ```
165 | title = 片名
166 | actor = 演员
167 | studio = 公司
168 | director = 导演
169 | release = 发售日
170 | year = 发行年份
171 | number = 番号
172 | cover = 封面链接
173 | tag = 类型
174 | outline = 简介
175 | runtime = 时长
176 | ```
177 |
178 | 上面的参数以下都称之为**变量**
179 |
180 | #### 例子:
181 | 自定义规则方法:有两种元素,变量和字符,无论是任何一种元素之间连接必须要用加号 **+** ,比如:```'naming_rule=['+number+']-'+title```,其中冒号 ' ' 内的文字是字符,没有冒号包含的文字是变量,元素之间连接必须要用加号 **+**
182 |
183 | **目录结构规则:**通过文件夹结构实现分类。默认 ```location_rule= year+'/'+studio ```。
184 | **不推荐修改时在这里添加 title**,有时 title 过长,因为 Windows API 问题,抓取数据时新建文件夹容易出错。
185 |
186 | **影片命名规则:**默认 ```naming_rule=number+'-'+title```
187 |
188 | ---
189 | ### 调试模式
190 | ```
191 | [debug_mode]
192 | switch=1
193 | ```
194 |
195 | 如要开启调试模式,请手动输入以上代码到```config.ini```中,开启后可在抓取中显示影片元数据
196 |
197 | ---
198 |
199 | ## 多集影片处理
200 |
201 | 可以把多集电影按照集数后缀命名为类似`ssni-xxx-cd1.mp4m,ssni-xxx-cd2.mp4,abp-xxx-CD1.mp4`的规则,只要含有`-CDn./-cdn.`类似命名规则,即可使用分集功能
202 |
203 | ## 中文字幕处理
204 |
205 | 当文件名包含: 中文,字幕,-c., -C., 会在番号后添加-C后缀。
206 |
207 | 处理元数据时会加上**中文字幕**标签。
208 |
209 | ## 旧文件处理
210 |
211 | 当该目录存在以前的输出文档或文件夹,例如`115failed.txt`或`AV_output`文件夹。会将旧文件重命名,例如`AV_output_20200411170755`,以防文件混乱。
212 |
213 |
--------------------------------------------------------------------------------
/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=11
3 | input_file=115s.txt
4 | failed_output_file=115failed.txt
5 | success_output_folder=AV_output
6 | soft_link=0
7 |
8 | [proxy]
9 | proxy=socks5://127.0.0.1:10808
10 | timeout=5
11 | retry=2
12 |
13 | [Name_Rule]
14 | location_rule= year+'/'+studio
15 | naming_rule=number+' '+actor+' '+title
16 |
17 | [update]
18 | update_check=0
19 |
20 | [escape]
21 | literals=\()/
22 | folders=AV_output
23 |
24 | [debug_mode]
25 | switch=0
26 |
--------------------------------------------------------------------------------
/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 | return result
100 |
101 |
102 | def getTag(text):
103 | html = etree.fromstring(text, etree.HTMLParser()) # //table/tr[1]/td[1]/text()
104 | try:
105 | result = html.xpath(
106 | "//td[contains(text(),'ジャンル:')]/following-sibling::td/a/text()"
107 | )
108 | except:
109 | result = html.xpath(
110 | "//td[contains(text(),'ジャンル:')]/following-sibling::td/text()"
111 | )
112 | return result
113 |
114 |
115 | def getCover(text, number):
116 | html = etree.fromstring(text, etree.HTMLParser())
117 | cover_number = number
118 | try:
119 | result = html.xpath('//*[@id="' + cover_number + '"]/@href')[0]
120 | except:
121 | # sometimes fanza modify _ to \u0005f for image id
122 | if "_" in cover_number:
123 | cover_number = cover_number.replace("_", r"\u005f")
124 | try:
125 | result = html.xpath('//*[@id="' + cover_number + '"]/@href')[0]
126 | except:
127 | # (TODO) handle more edge case
128 | # print(html)
129 | # raise exception here, same behavior as before
130 | # people's major requirement is fetching the picture
131 | raise ValueError("can not find image")
132 | return result
133 |
134 |
135 | def getDirector(text):
136 | html = etree.fromstring(text, etree.HTMLParser()) # //table/tr[1]/td[1]/text()
137 | try:
138 | result = html.xpath(
139 | "//td[contains(text(),'監督:')]/following-sibling::td/a/text()"
140 | )[0]
141 | except:
142 | result = html.xpath(
143 | "//td[contains(text(),'監督:')]/following-sibling::td/text()"
144 | )[0]
145 | return result
146 |
147 |
148 | def getOutline(text):
149 | html = etree.fromstring(text, etree.HTMLParser())
150 | try:
151 | result = str(html.xpath("//div[@class='mg-b20 lh4']/text()")[0]).replace(
152 | "\n", ""
153 | )
154 | if result == "":
155 | result = str(html.xpath("//div[@class='mg-b20 lh4']//p/text()")[0]).replace(
156 | "\n", ""
157 | )
158 | except:
159 | # (TODO) handle more edge case
160 | # print(html)
161 | return ""
162 | return result
163 |
164 |
165 | def main(number):
166 | # fanza allow letter + number + underscore, normalize the input here
167 | # @note: I only find the usage of underscore as h_test123456789
168 | fanza_search_number = number
169 | # AV_Data_Capture.py.getNumber() over format the input, restore the h_ prefix
170 | if fanza_search_number.startswith("h-"):
171 | fanza_search_number = fanza_search_number.replace("h-", "h_")
172 |
173 | fanza_search_number = re.sub(r"[^0-9a-zA-Z_]", "", fanza_search_number).lower()
174 |
175 | fanza_urls = [
176 | "https://www.dmm.co.jp/digital/videoa/-/detail/=/cid=",
177 | "https://www.dmm.co.jp/mono/dvd/-/detail/=/cid=",
178 | "https://www.dmm.co.jp/digital/anime/-/detail/=/cid=",
179 | "https://www.dmm.co.jp/mono/anime/-/detail/=/cid=",
180 | "https://www.dmm.co.jp/digital/videoc/-/detail/=/cid=",
181 | "https://www.dmm.co.jp/digital/nikkatsu/-/detail/=/cid=",
182 | ]
183 | chosen_url = ""
184 | for url in fanza_urls:
185 | chosen_url = url + fanza_search_number
186 | htmlcode = get_html(chosen_url)
187 | if "404 Not Found" not in htmlcode:
188 | break
189 | if "404 Not Found" in htmlcode:
190 | return json.dumps({"title": "",})
191 | try:
192 | # for some old page, the input number does not match the page
193 | # for example, the url will be cid=test012
194 | # but the hinban on the page is test00012
195 | # so get the hinban first, and then pass it to following functions
196 | fanza_hinban = getNum(htmlcode)
197 | data = {
198 | "title": getTitle(htmlcode).strip(getActor(htmlcode)),
199 | "studio": getStudio(htmlcode),
200 | "outline": getOutline(htmlcode),
201 | "runtime": getRuntime(htmlcode),
202 | "director": getDirector(htmlcode) if "anime" not in chosen_url else "",
203 | "actor": getActor(htmlcode) if "anime" not in chosen_url else "",
204 | "release": getRelease(htmlcode),
205 | "number": fanza_hinban,
206 | "cover": getCover(htmlcode, fanza_hinban),
207 | "imagecut": 1,
208 | "tag": getTag(htmlcode),
209 | "label": getLabel(htmlcode),
210 | "year": getYear(
211 | getRelease(htmlcode)
212 | ), # str(re.search('\d{4}',getRelease(a)).group()),
213 | "actor_photo": "",
214 | "website": chosen_url,
215 | "source": "fanza.py",
216 | }
217 | except:
218 | data = {
219 | "title": "",
220 | }
221 | js = json.dumps(
222 | data, ensure_ascii=False, sort_keys=True, indent=4, separators=(",", ":")
223 | ) # .encode('UTF-8')
224 | return js
225 |
226 |
227 | if __name__ == "__main__":
228 | # print(main("DV-1562"))
229 | # input("[+][+]Press enter key exit, you can check the error messge before you exit.\n[+][+]按回车键结束,你可以在结束之前查看和错误信息。")
230 | # print(main("ipx292"))
231 | pass
232 |
--------------------------------------------------------------------------------
/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 |
8 | def getActorPhoto(htmlcode): #//*[@id="star_qdt"]/li/a/img
9 | soup = BeautifulSoup(htmlcode, 'lxml')
10 | a = soup.find_all(attrs={'class': 'star-name'})
11 | d={}
12 | for i in a:
13 | l=i.a['href']
14 | t=i.get_text()
15 | html = etree.fromstring(get_html(l), etree.HTMLParser())
16 | p=str(html.xpath('//*[@id="waterfall"]/div[1]/div/div[1]/img/@src')).strip(" ['']")
17 | p2={t:p}
18 | d.update(p2)
19 | return d
20 | def getTitle(htmlcode): #获取标题
21 | doc = pq(htmlcode)
22 | title=str(doc('div.container h3').text()).replace(' ','-')
23 | try:
24 | title2 = re.sub('n\d+-','',title)
25 | return title2
26 | except:
27 | return title
28 | def getStudio(htmlcode): #获取厂商
29 | html = etree.fromstring(htmlcode,etree.HTMLParser())
30 | result = str(html.xpath('/html/body/div[5]/div[1]/div[2]/p[5]/a/text()')).strip(" ['']")
31 | return result
32 | def getYear(htmlcode): #获取年份
33 | html = etree.fromstring(htmlcode,etree.HTMLParser())
34 | result = str(html.xpath('/html/body/div[5]/div[1]/div[2]/p[2]/text()')).strip(" ['']")
35 | return result
36 | def getCover(htmlcode): #获取封面链接
37 | doc = pq(htmlcode)
38 | image = doc('a.bigImage')
39 | return image.attr('href')
40 | def getRelease(htmlcode): #获取出版日期
41 | html = etree.fromstring(htmlcode, etree.HTMLParser())
42 | result = str(html.xpath('/html/body/div[5]/div[1]/div[2]/p[2]/text()')).strip(" ['']")
43 | return result
44 | def getRuntime(htmlcode): #获取分钟
45 | soup = BeautifulSoup(htmlcode, 'lxml')
46 | a = soup.find(text=re.compile('分鐘'))
47 | return a
48 | def getActor(htmlcode): #获取女优
49 | b=[]
50 | soup=BeautifulSoup(htmlcode,'lxml')
51 | a=soup.find_all(attrs={'class':'star-name'})
52 | for i in a:
53 | b.append(i.get_text())
54 | return b
55 | def getNum(htmlcode): #获取番号
56 | html = etree.fromstring(htmlcode, etree.HTMLParser())
57 | result = str(html.xpath('/html/body/div[5]/div[1]/div[2]/p[1]/span[2]/text()')).strip(" ['']")
58 | return result
59 | def getDirector(htmlcode): #获取导演
60 | html = etree.fromstring(htmlcode, etree.HTMLParser())
61 | result = str(html.xpath('/html/body/div[5]/div[1]/div[2]/p[4]/a/text()')).strip(" ['']")
62 | return result
63 | def getOutline(htmlcode): #获取演员
64 | doc = pq(htmlcode)
65 | result = str(doc('tr td div.mg-b20.lh4 p.mg-b20').text())
66 | return result
67 | def getSerise(htmlcode):
68 | html = etree.fromstring(htmlcode, etree.HTMLParser())
69 | result = str(html.xpath('/html/body/div[5]/div[1]/div[2]/p[7]/a/text()')).strip(" ['']")
70 | return result
71 | def getTag(htmlcode): # 获取演员
72 | tag = []
73 | soup = BeautifulSoup(htmlcode, 'lxml')
74 | a = soup.find_all(attrs={'class': 'genre'})
75 | for i in a:
76 | if 'onmouseout' in str(i):
77 | continue
78 | tag.append(i.get_text())
79 | return tag
80 |
81 |
82 | def main(number):
83 | try:
84 | htmlcode = get_html('https://www.javbus.com/' + number)
85 | try:
86 | dww_htmlcode = get_html("https://www.dmm.co.jp/mono/dvd/-/detail/=/cid=" + number.replace("-", ''))
87 | except:
88 | dww_htmlcode = ''
89 | dic = {
90 | 'title': str(re.sub('\w+-\d+-', '', getTitle(htmlcode))),
91 | 'studio': getStudio(htmlcode),
92 | 'year': str(re.search('\d{4}', getYear(htmlcode)).group()),
93 | 'outline': getOutline(dww_htmlcode),
94 | 'runtime': getRuntime(htmlcode),
95 | 'director': getDirector(htmlcode),
96 | 'actor': getActor(htmlcode),
97 | 'release': getRelease(htmlcode),
98 | 'number': getNum(htmlcode),
99 | 'cover': getCover(htmlcode),
100 | 'imagecut': 1,
101 | 'tag': getTag(htmlcode),
102 | 'label': getSerise(htmlcode),
103 | 'actor_photo': getActorPhoto(htmlcode),
104 | 'website': 'https://www.javbus.com/' + number,
105 | 'source' : 'javbus.py',
106 | }
107 | js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'), ) # .encode('UTF-8')
108 | return js
109 | except:
110 | return main_uncensored(number)
111 |
112 | def main_uncensored(number):
113 | htmlcode = get_html('https://www.javbus.com/' + number)
114 | dww_htmlcode = get_html("https://www.dmm.co.jp/mono/dvd/-/detail/=/cid=" + number.replace("-", ''))
115 | if getTitle(htmlcode) == '':
116 | htmlcode = get_html('https://www.javbus.com/' + number.replace('-','_'))
117 | dww_htmlcode = get_html("https://www.dmm.co.jp/mono/dvd/-/detail/=/cid=" + number.replace("-", ''))
118 | dic = {
119 | 'title': str(re.sub('\w+-\d+-','',getTitle(htmlcode))).replace(getNum(htmlcode)+'-',''),
120 | 'studio': getStudio(htmlcode),
121 | 'year': getYear(htmlcode),
122 | 'outline': getOutline(dww_htmlcode),
123 | 'runtime': getRuntime(htmlcode),
124 | 'director': getDirector(htmlcode),
125 | 'actor': getActor(htmlcode),
126 | 'release': getRelease(htmlcode),
127 | 'number': getNum(htmlcode),
128 | 'cover': getCover(htmlcode),
129 | 'tag': getTag(htmlcode),
130 | 'label': getSerise(htmlcode),
131 | 'imagecut': 0,
132 | 'actor_photo': '',
133 | 'website': 'https://www.javbus.com/' + number,
134 | 'source': 'javbus.py',
135 | }
136 | js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'), ) # .encode('UTF-8')
137 | return js
138 |
139 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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(" ['']")
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 | #print(main('SIRO-3607'))
112 |
--------------------------------------------------------------------------------
/py_to_exe.bat:
--------------------------------------------------------------------------------
1 | pyinstaller --onefile OOF_Rename.py --hidden-import ADC_function.py --hidden-import OOF_core.py
2 | rmdir /s/q build
3 | rmdir /s/q __pycache__
4 | pause
--------------------------------------------------------------------------------
/readme/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LSD08KM/115_Code_Rename/221dd8199200719c55495b7da5956df131bfee6e/readme/1.png
--------------------------------------------------------------------------------
/readme/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LSD08KM/115_Code_Rename/221dd8199200719c55495b7da5956df131bfee6e/readme/2.png
--------------------------------------------------------------------------------
/readme/This is readms.md's images folder:
--------------------------------------------------------------------------------
1 | 1
2 |
--------------------------------------------------------------------------------
/readme/single.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LSD08KM/115_Code_Rename/221dd8199200719c55495b7da5956df131bfee6e/readme/single.gif
--------------------------------------------------------------------------------
/ruquirments.txt:
--------------------------------------------------------------------------------
1 | lxml
2 | bs4
3 | pillow
4 | pyquery
--------------------------------------------------------------------------------