212 |
213 |
214 | ## 3.多目录影片处理
215 | 可以遍历**程序所在目录及子目录**(除指定的**排除目录**),对遍历到的所有视频进行刮削,成功则同**元数据、封面图**一起输出到**JAV_output**目录,失败移入**failed**目录。
216 |
217 | ## 4.多集影片处理
218 | 可以把多集电影按照集数后缀命名为类似**ssni-xxx-cd1.mp4,ssni-xxx-cd2.mp4,abp-xxx-CD1.mp4**的规则,只要含有```-CDn./-cdn.```类似命名规则,即可使用分集功能
219 |
220 | ## 5.异常处理(重要)
221 | ### 请确保软件是完整地!确保ini文件内容是和下载提供ini文件内容的一致的!
222 |
223 | ---
224 | ### 5.1.关于软件打开就闪退
225 | 可以打开cmd命令提示符,把 ```AVDC_Main.py/AVDC.exe```拖进cmd窗口回车运行,查看错误,出现的错误信息**依据以下条目解决**
226 |
227 | ---
228 | ### 5.2.报```Connect Failed! Please check your Proxy or Network!```错误
229 | 可以把文件的**proxy=后面的地址和端口删除**,并开启代理软件全局模式,或者重启电脑,代理软件,网卡
230 |
231 | ---
232 | ### 5.3.关于 ```Updata_check``` 和 ```JSON``` 相关的错误
233 | 跳转 [网络设置](#27网络设置)
234 |
235 | ---
236 | ### 5.4.关于字幕文件移动功能
237 | 字幕文件前缀必须与影片文件前缀一致,才可以使用该功能
238 |
239 | ---
240 | ### 5.5.关于```FileNotFoundError: [WinError 3] 系统找不到指定的路径。: 'JAV_output''```
241 | 在软件所在文件夹下新建 JAV_output 文件夹,可能是你没有把软件拉到和电影的同一目录
242 |
243 | ---
244 | ### 5.6.关于连接拒绝的错误
245 | 请设置好[代理](#27网络设置)
246 |
247 | ---
248 | ### 5.7、关于Nonetype,xpath报错
249 | 同上
250 |
251 | ---
252 | ### 5.8.关于番号提取失败或者异常
253 | 目前可以提取元素的影片:**JAVBUS、JAVDB、AVSOX、FANZA、FC2CLUB**上有元数据的电影,请确保视频名能在这些网站找到
254 | 使用**工具页里的单个视频刮削**,选择**刮削网站**,进行刮削。
255 |
256 | ---
257 | ### 5.9.关于PIL/image.py
258 | 暂时无解,可能是网络问题或者pillow模块打包问题,你可以用源码运行(要安装好第一步的模块)
259 |
260 |
261 | ## 6.软件会自动把元数据获取成功的电影移动到JAV_output文件夹中,根据演员分类,失败的电影移动到failed文件夹中。
262 | ## 7.导入媒体库
263 | 把JAV_output文件夹导入到EMBY,KODI,PLEX中,等待元数据刷新,完成
264 | ## 8.关于群晖NAS
265 | 开启SMB在Windows上挂载为网络磁盘即可使用本软件,也适用于其他NAS
266 | ## 9.写在后面
267 | 怎么样,看着自己的日本电影被这样完美地管理,是不是感觉成就感爆棚呢?
268 |
269 |
270 |
271 |
--------------------------------------------------------------------------------
/javdb.py:
--------------------------------------------------------------------------------
1 | import re
2 | from lxml import etree
3 | import json
4 | from ADC_function import *
5 |
6 |
7 | # import sys
8 | # import io
9 | # sys.stdout = io.TextIOWrapper(sys.stdout.buffer, errors = 'replace', line_buffering = True)
10 | def getTitle(a):
11 | try:
12 | html = etree.fromstring(a, etree.HTMLParser())
13 | result = str(html.xpath('/html/body/section/div/h2/strong/text()')).strip(" ['']")
14 | return re.sub('.*\] ', '', result.replace('/', ',').replace('\\xa0', '').replace(' : ', ''))
15 | except:
16 | return re.sub('.*\] ', '', result.replace('/', ',').replace('\\xa0', ''))
17 |
18 |
19 | def getActor(a): # //*[@id="center_column"]/div[2]/div[1]/div/table/tbody/tr[1]/td/text()
20 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text()
21 | result1 = html.xpath('//strong[contains(text(),"演員")]/../following-sibling::span/text()')
22 | result2 = html.xpath('//strong[contains(text(),"演員")]/../following-sibling::span/a/text()')
23 | return result1 + result2
24 |
25 |
26 | def getActorPhoto(actor): # //*[@id="star_qdt"]/li/a/img
27 | d = {}
28 | for i in actor:
29 | if ',' not in i or ')' in i:
30 | p = {i: ''}
31 | d.update(p)
32 | return d
33 |
34 |
35 | def getStudio(a):
36 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text()
37 | result1 = str(html.xpath('//strong[contains(text(),"片商")]/../following-sibling::span/text()')).strip(" ['']")
38 | result2 = str(html.xpath('//strong[contains(text(),"片商")]/../following-sibling::span/a/text()')).strip(" ['']")
39 | return str(result1 + result2).strip('+').replace("', '", '').replace('"', '')
40 |
41 |
42 | def getRuntime(a):
43 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text()
44 | result1 = str(html.xpath('//strong[contains(text(),"時長")]/../following-sibling::span/text()')).strip(" ['']")
45 | result2 = str(html.xpath('//strong[contains(text(),"時長")]/../following-sibling::span/a/text()')).strip(" ['']")
46 | return str(result1 + result2).strip('+').rstrip('mi')
47 |
48 |
49 | def getLabel(a):
50 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text()
51 | result1 = str(html.xpath('//strong[contains(text(),"系列")]/../following-sibling::span/text()')).strip(" ['']")
52 | result2 = str(html.xpath('//strong[contains(text(),"系列")]/../following-sibling::span/a/text()')).strip(" ['']")
53 | return str(result1 + result2).strip('+').replace("', '", '').replace('"', '')
54 |
55 |
56 | def getNum(a):
57 | html = etree.fromstring(a, etree.HTMLParser())
58 | result1 = str(html.xpath('//strong[contains(text(),"番號")]/../following-sibling::span/text()')).strip(
59 | " ['']").replace('_', '-')
60 | result2 = str(html.xpath('//strong[contains(text(),"番號")]/../following-sibling::span/a/text()')).strip(
61 | " ['']").replace('_', '-')
62 | return str(result2 + result1).strip('+')
63 |
64 |
65 | def getYear(getRelease):
66 | try:
67 | result = str(re.search('\d{4}', getRelease).group())
68 | return result
69 | except:
70 | return getRelease
71 |
72 |
73 | def getRelease(a):
74 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text()
75 | result1 = str(html.xpath('//strong[contains(text(),"時間")]/../following-sibling::span/text()')).strip(" ['']")
76 | result2 = str(html.xpath('//strong[contains(text(),"時間")]/../following-sibling::span/a/text()')).strip(" ['']")
77 | return str(result1 + result2).strip('+')
78 |
79 |
80 | def getTag(a):
81 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text()
82 | result1 = str(html.xpath('//strong[contains(text(),"类别")]/../following-sibling::span/text()')).strip(" ['']")
83 | result2 = str(html.xpath('//strong[contains(text(),"类别")]/../following-sibling::span/a/text()')).strip(" ['']")
84 | return str(result1 + result2).strip('+').replace(",\\xa0", "").replace("'", "").replace(' ', '').replace(',,',
85 | '').lstrip(
86 | ',')
87 |
88 |
89 | def getCover_small(a, count):
90 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text()
91 | result = html.xpath("//div[@class='item-image fix-scale-cover']/img/@src")[count]
92 | if not 'https' in result:
93 | result = 'https:' + result
94 | return result
95 |
96 |
97 | def getCover(htmlcode):
98 | html = etree.fromstring(htmlcode, etree.HTMLParser())
99 | result = str(html.xpath("//div[@class='column column-video-cover']/a/img/@src")).strip(" ['']")
100 | return result
101 |
102 |
103 | def getDirector(a):
104 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text()
105 | result1 = str(html.xpath('//strong[contains(text(),"導演")]/../following-sibling::span/text()')).strip(" ['']")
106 | result2 = str(html.xpath('//strong[contains(text(),"導演")]/../following-sibling::span/a/text()')).strip(" ['']")
107 | return str(result1 + result2).strip('+').replace("', '", '').replace('"', '')
108 |
109 |
110 | def getOutline(htmlcode):
111 | html = etree.fromstring(htmlcode, etree.HTMLParser())
112 | result = str(html.xpath('//*[@id="introduction"]/dd/p[1]/text()')).strip(" ['']")
113 | return result
114 |
115 |
116 | def main(number):
117 | try:
118 | a = get_html('https://javdb.com/search?q=' + number + '&f=all').replace(u'\xa0', u' ')
119 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text()
120 | counts = len(html.xpath(
121 | '//div[@id=\'videos\']/div[@class=\'grid columns\']/div[@class=\'grid-item column\']'))
122 | if counts == 0:
123 | dic = {
124 | 'title': '',
125 | 'actor': '',
126 | 'website': '',
127 | }
128 | js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4,
129 | separators=(',', ':'), ) # .encode('UTF-8')
130 | return js
131 | count = 1
132 | number_get = ''
133 | movie_found = 0
134 | for count in range(1, counts + 1): # 遍历搜索结果,找到需要的番号
135 | number_get = html.xpath(
136 | '//div[@id=\'videos\']/div[@class=\'grid columns\']/div[@class=\'grid-item column\'][' + str(
137 | count) + ']/a[@class=\'box\']/div[@class=\'uid\']/text()')[0]
138 | number_get = number_get.replace('_', '-')
139 | if number_get == number.upper() or number_get == number.lower():
140 | movie_found = 1
141 | break
142 | result1 = html.xpath('//*[@id="videos"]/div/div/a/@href')[count - 1]
143 | b = get_html('https://javdb.com' + result1).replace(u'\xa0', u' ')
144 | actor = getActor(b)
145 | if len(actor) == 0 and 'FC2-' in number_get:
146 | actor.append('FC2-NoActor')
147 | if movie_found == 1:
148 | dic = {
149 | 'actor': str(actor).strip(" [',']").replace('\'', ''),
150 | 'title': getTitle(b).replace('中文字幕', '').replace("\\n", '').replace('_', '-').replace(number_get,
151 | '').strip().replace(
152 | ' ', '-').replace('--', '-'),
153 | 'studio': getStudio(b),
154 | 'outline': getOutline(b).replace('\n', ''),
155 | 'runtime': getRuntime(b),
156 | 'director': getDirector(b),
157 | 'release': getRelease(b),
158 | 'number': number_get,
159 | 'cover': getCover(b),
160 | 'cover_small': getCover_small(a, count - 1),
161 | 'imagecut': 3,
162 | 'tag': getTag(b),
163 | 'label': getLabel(b),
164 | 'year': getYear(getRelease(b)), # str(re.search('\d{4}',getRelease(a)).group()),
165 | 'actor_photo': getActorPhoto(actor),
166 | 'website': 'https://javdb.com' + result1,
167 | 'source': 'javdb.py',
168 | }
169 | else: # 未找到番号
170 | dic = {
171 | 'title': '',
172 | 'actor': str(actor).strip(" [',']").replace('\'', ''),
173 | 'website': '',
174 | }
175 | except:
176 | if a == 'ProxyError':
177 | dic = {
178 | 'title': '',
179 | 'actor': '',
180 | 'website': 'timeout',
181 | }
182 | else:
183 | dic = {
184 | 'title': '',
185 | 'actor': '',
186 | 'website': '',
187 | }
188 | js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'), ) # .encode('UTF-8')
189 | return js
190 |
191 |
192 | # print(main('LUXU-1217'))
193 | # input("[+][+]Press enter key exit, you can check the error messge before you exit.\n[+][+]按回车键结束,你可以在结束之前查看和错误信息。")
194 | # print(main('abs-141'))
195 | # print(main('040409-562'))
196 | # print(main('n1403'))
197 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/AVDC_Main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | import threading
4 | from PyQt5 import QtCore, QtGui, QtWidgets
5 | from PyQt5.QtWidgets import QApplication, QMainWindow
6 | from PyQt5.QtGui import QPixmap
7 | from PyQt5.QtGui import QTextCursor, QCursor
8 | from PyQt5.QtWidgets import *
9 | from PyQt5.QtCore import pyqtSignal, QThread, Qt
10 | from AVDC import *
11 | import sys
12 | import time
13 | import os.path
14 | import json
15 | from configparser import ConfigParser
16 | from AV_Data_Capture import *
17 | from core import *
18 | from fanza import *
19 | import requests
20 | import shutil
21 | import base64
22 | import re
23 | from aip import AipBodyAnalysis
24 | from PIL import Image
25 | import os
26 |
27 |
28 | class MyMAinWindow(QMainWindow, Ui_AVDV):
29 | progressBarValue = pyqtSignal(int) # 进度条信号量
30 |
31 | def __init__(self, parent=None):
32 | super(MyMAinWindow, self).__init__(parent)
33 | self.Ui = Ui_AVDV() # 实例化 Ui
34 | self.Ui.setupUi(self) # 初始化Ui
35 | self.Init_Ui()
36 | # 初始化需要的变量
37 | self.version = '3.61'
38 | self.m_drag = False
39 | self.m_DragPosition = 0
40 | self.item_succ = self.Ui.treeWidget_number.topLevelItem(0)
41 | self.item_fail = self.Ui.treeWidget_number.topLevelItem(1)
42 | self.json_array = {}
43 | self.Init()
44 | self.Load_Config()
45 | self.show_version()
46 |
47 | def Init_Ui(self):
48 | pix = QPixmap('AVDC-ico.png')
49 | self.Ui.label_ico.setScaledContents(True)
50 | self.Ui.label_ico.setPixmap(pix) # 添加图标
51 | self.Ui.progressBar_avdc.setValue(0) # 进度条清0
52 | self.progressBarValue.connect(self.set_processbar)
53 | self.Ui.progressBar_avdc.setTextVisible(False) # 不显示进度条文字
54 | self.setWindowFlag(QtCore.Qt.FramelessWindowHint) # 隐藏边框
55 | # self.setWindowOpacity(0.9) # 设置窗口透明度
56 | self.setAttribute(QtCore.Qt.WA_TranslucentBackground) # 设置窗口背景透明
57 | self.Ui.treeWidget_number.expandAll()
58 | self.Ui.checkBox_cover.setChecked(True)
59 | # 控件美化
60 | self.Ui.widget_setting.setStyleSheet(
61 | '''
62 | QWidget#widget_setting{
63 | background:#F0F8FF;
64 | border-radius:20px;
65 | padding:2px 4px;
66 | }
67 | QPushButton{
68 | font-size:15px;
69 | background:gray;
70 | border:9px solid gray;
71 | border-radius:15px;
72 | padding:2px 4px;
73 | }
74 |
75 | ''')
76 | self.Ui.centralwidget.setStyleSheet(
77 | '''
78 | QWidget#centralwidget{
79 | background:gray;
80 | border:1px solid gray;
81 | width:300px;
82 | border-radius:20px;
83 | padding:2px 4px;
84 | }
85 | QTextBrowser{
86 | border:1px solid gray;
87 | background:white;
88 | width:300px;
89 | border-radius:10px;
90 | padding:2px 4px;
91 | }
92 | QLineEdit{
93 | background:white;
94 | border:1px solid white;
95 | width:300px;
96 | border-radius:10px;
97 | padding:2px 4px;
98 | }
99 | QTextBrowser#textBrowser_about{
100 | background:white;
101 | border:1px solid white;
102 | width:300px;
103 | border-radius:10px;
104 | padding:2px 4px;
105 | }
106 | QTextBrowser#textBrowser_warning{
107 | background:gray;
108 | border:1px solid gray;
109 | width:300px;
110 | border-radius:10px;
111 | padding:2px 4px;
112 | }
113 | QPushButton#pushButton_start_cap,#pushButton_move_mp4,#pushButton_select_file,#pushButton_select_fanart{
114 | font-size:20px;
115 | background:#F0F8FF;
116 | border:2px solid white;
117 | width:300px;
118 | border-radius:20px;
119 | padding:2px 4px;
120 | }
121 | QPushButton#pushButton_add_actor_pic{
122 | font-size:20px;
123 | background:#F0F8FF;
124 | border:2px solid white;
125 | width:300px;
126 | border-radius:20px;
127 | padding:2px 4px;
128 | }
129 | QPushButton#pushButton_save_config,#pushButton_show_pic_actor{
130 | font-size:20px;
131 | background:#F0F8FF;
132 | border:2px solid white;
133 | width:300px;
134 | border-radius:13px;
135 | padding:2px 4px;
136 | }
137 | QProgressBar::chunk{
138 | background-color: #2196F3;
139 | width: 5px; /*区块宽度*/
140 | margin: 0.5px;
141 | }
142 | ''')
143 |
144 | # ========================================================================按钮点击事件
145 | def Init(self):
146 | self.Ui.stackedWidget.setCurrentIndex(0)
147 | self.Ui.treeWidget_number.clicked.connect(self.treeWidget_number_clicked)
148 | self.Ui.pushButton_close.clicked.connect(self.close_win)
149 | self.Ui.pushButton_min.clicked.connect(self.min_win)
150 | self.Ui.pushButton_main.clicked.connect(self.pushButton_main_clicked)
151 | self.Ui.pushButton_tool.clicked.connect(self.pushButton_tool_clicked)
152 | self.Ui.pushButton_setting.clicked.connect(self.pushButton_setting_clicked)
153 | self.Ui.pushButton_select_file.clicked.connect(self.pushButton_select_file_clicked)
154 | self.Ui.pushButton_about.clicked.connect(self.pushButton_about_clicked)
155 | self.Ui.pushButton_start_cap.clicked.connect(self.pushButton_start_cap_clicked)
156 | self.Ui.pushButton_save_config.clicked.connect(self.pushButton_save_config_clicked)
157 | self.Ui.pushButton_move_mp4.clicked.connect(self.move_file)
158 | self.Ui.pushButton_add_actor_pic.clicked.connect(self.pushButton_add_actor_pic_clicked)
159 | self.Ui.pushButton_show_pic_actor.clicked.connect(self.pushButton_show_pic_actor_clicked)
160 | self.Ui.pushButton_select_fanart.clicked.connect(self.pushButton_select_fanart_clicked)
161 | self.Ui.pushButton_log.clicked.connect(self.pushButton_show_log_clicked)
162 | self.Ui.checkBox_cover.stateChanged.connect(self.cover_change)
163 |
164 | # ========================================================================加载config
165 | def Load_Config(self):
166 | config_file = 'config.ini'
167 | config = ConfigParser()
168 | config.read(config_file, encoding='UTF-8')
169 | if int(config['common']['main_mode']) == 1:
170 | self.Ui.radioButton_common.setChecked(True)
171 | elif int(config['common']['main_mode']) == 2:
172 | self.Ui.radioButton_sort.setChecked(True)
173 | if int(config['common']['soft_link']) == 1:
174 | self.Ui.radioButton_soft_on.setChecked(True)
175 | elif int(config['common']['soft_link']) == 0:
176 | self.Ui.radioButton_soft_off.setChecked(True)
177 | if int(config['update']['update_check']) == 1:
178 | self.Ui.radioButton_update_on.setChecked(True)
179 | elif int(config['update']['update_check']) == 0:
180 | self.Ui.radioButton_update_off.setChecked(True)
181 | if int(config['debug_mode']['switch']) == 1:
182 | self.Ui.radioButton_debug_on.setChecked(True)
183 | elif int(config['debug_mode']['switch']) == 0:
184 | self.Ui.radioButton_debug_off.setChecked(True)
185 | if config['media']['media_warehouse'] == 'emby' or config['media']['media_warehouse'] == 'jellyfin':
186 | self.Ui.radioButton_emby.setChecked(True)
187 | elif config['media']['media_warehouse'] == 'plex':
188 | self.Ui.radioButton_plex.setChecked(True)
189 | elif config['media']['media_warehouse'] == 'kodi':
190 | self.Ui.radioButton_kodi.setChecked(True)
191 | if config['common']['website'] == 'all':
192 | self.Ui.radioButton_all.setChecked(True)
193 | elif config['common']['website'] == 'javdb':
194 | self.Ui.radioButton_javdb.setChecked(True)
195 | self.Ui.lineEdit_success.setText(config['common']['success_output_folder'])
196 | self.Ui.lineEdit_fail.setText(config['common']['failed_output_folder'])
197 | self.Ui.lineEdit_escape_dir.setText(config['escape']['folders'])
198 | self.Ui.lineEdit_escape_char.setText(config['escape']['literals'])
199 | self.Ui.lineEdit_proxy.setText(config['proxy']['proxy'])
200 | self.Ui.lineEdit_timeout.setText(config['proxy']['timeout'])
201 | self.Ui.lineEdit_retry.setText(config['proxy']['retry'])
202 | self.Ui.lineEdit_dir_name.setText(config['Name_Rule']['location_rule'])
203 | self.Ui.lineEdit_media_name.setText(config['Name_Rule']['naming_rule'])
204 | self.Ui.lineEdit_escape_dir_move.setText(config['escape']['folders'])
205 | self.Ui.lineEdit_emby_url.setText(config['emby']['emby_url'])
206 | self.Ui.lineEdit_api_key.setText(config['emby']['api_key'])
207 |
208 | # ========================================================================显示版本号
209 | def show_version(self):
210 | self.add_text_main('[*]======================== AVDC ========================')
211 | self.add_text_main('[*] Version ' + self.version)
212 | self.add_text_main('[*]======================================================')
213 |
214 | # ========================================================================鼠标拖动窗口
215 | def mousePressEvent(self, e):
216 | if e.button() == Qt.LeftButton:
217 | self.m_drag = True
218 | self.m_DragPosition = e.globalPos() - self.pos()
219 | self.setCursor(QCursor(Qt.OpenHandCursor))
220 |
221 | def mouseReleaseEvent(self, e):
222 | if e.button() == Qt.LeftButton:
223 | self.m_drag = False
224 | self.setCursor(QCursor(Qt.ArrowCursor))
225 |
226 | def mouseMoveEvent(self, e):
227 | if Qt.LeftButton and self.m_drag:
228 | self.move(e.globalPos() - self.m_DragPosition)
229 | e.accept()
230 |
231 | # ========================================================================左侧按钮点击事件响应函数
232 | def close_win(self):
233 | os._exit(0)
234 |
235 | def min_win(self):
236 | self.setWindowState(Qt.WindowMinimized)
237 |
238 | def pushButton_main_clicked(self):
239 | self.Ui.stackedWidget.setCurrentIndex(0)
240 |
241 | def pushButton_tool_clicked(self):
242 | self.Ui.stackedWidget.setCurrentIndex(1)
243 |
244 | def pushButton_setting_clicked(self):
245 | self.Ui.stackedWidget.setCurrentIndex(2)
246 |
247 | def pushButton_about_clicked(self):
248 | self.Ui.stackedWidget.setCurrentIndex(3)
249 |
250 | def pushButton_show_log_clicked(self):
251 | self.Ui.stackedWidget.setCurrentIndex(4)
252 |
253 | def cover_change(self):
254 | if not self.Ui.checkBox_cover.isChecked():
255 | self.Ui.label_poster.setText("封面图")
256 | self.Ui.label_fanart.setText("缩略图")
257 |
258 | def treeWidget_number_clicked(self, qmodeLindex):
259 | item = self.Ui.treeWidget_number.currentItem()
260 | if item.text(0) != '成功' and item.text(0) != '失败':
261 | try:
262 | index_json = str(item.text(0)).split('.')[0]
263 | self.add_label_info(self.json_array[str(index_json)])
264 | except:
265 | print('Error in treeWidget_number_clicked!')
266 |
267 | def pushButton_start_cap_clicked(self):
268 | self.Ui.pushButton_start_cap.setEnabled(False)
269 | try:
270 | t = threading.Thread(target=self.AVDC_Main)
271 | t.start() # 启动线程,即让线程开始执行
272 | except Exception as error_info:
273 | self.add_text_main('[-]Error in pushButton_start_cap_clicked: ' + str(error_info))
274 |
275 | def pushButton_save_config_clicked(self):
276 | try:
277 | t = threading.Thread(target=self.save_config_clicked)
278 | t.start() # 启动线程,即让线程开始执行
279 | except Exception as error_info:
280 | self.add_text_main('[-]Error in pushButton_save_config_clicked: ' + str(error_info))
281 |
282 | # ========================================================================读取设置页设置,保存在config.ini
283 | def save_config_clicked(self):
284 | main_mode = 1
285 | soft_link = 0
286 | switch_debug = 0
287 | update_check = 0
288 | media_warehouse = ''
289 | website = ''
290 | if self.Ui.radioButton_common.isChecked(): # 普通模式
291 | main_mode = 1
292 | elif self.Ui.radioButton_sort.isChecked(): # 整理模式
293 | main_mode = 2
294 | if self.Ui.radioButton_soft_on.isChecked(): # 软链接开
295 | soft_link = 1
296 | elif self.Ui.radioButton_soft_off.isChecked(): # 软链接关
297 | soft_link = 0
298 | if self.Ui.radioButton_debug_on.isChecked(): # 调试模式开
299 | switch_debug = 1
300 | elif self.Ui.radioButton_debug_off.isChecked(): # 调试模式关
301 | switch_debug = 0
302 | if self.Ui.radioButton_update_on.isChecked(): # 检查更新
303 | update_check = 1
304 | elif self.Ui.radioButton_update_off.isChecked(): # 不检查更新
305 | update_check = 0
306 | if self.Ui.radioButton_emby.isChecked(): # emby/jellyfin
307 | media_warehouse = 'emby'
308 | elif self.Ui.radioButton_plex.isChecked(): # plex
309 | media_warehouse = 'plex'
310 | elif self.Ui.radioButton_kodi.isChecked(): # kodi
311 | media_warehouse = 'kodi'
312 | if self.Ui.radioButton_all.isChecked(): # all
313 | website = 'all'
314 | elif self.Ui.radioButton_javdb.isChecked(): # javdb
315 | website = 'javdb'
316 | json_config = {
317 | 'main_mode': main_mode,
318 | 'soft_link': soft_link,
319 | 'switch_debug': switch_debug,
320 | 'update_check': update_check,
321 | 'media_warehouse': media_warehouse,
322 | 'website': website,
323 | 'failed_output_folder': self.Ui.lineEdit_fail.text(),
324 | 'success_output_folder': self.Ui.lineEdit_success.text(),
325 | 'proxy': self.Ui.lineEdit_proxy.text(),
326 | 'timeout': self.Ui.lineEdit_timeout.text(),
327 | 'retry': self.Ui.lineEdit_retry.text(),
328 | 'location_rule': self.Ui.lineEdit_dir_name.text(),
329 | 'naming_rule': self.Ui.lineEdit_media_name.text(),
330 | 'literals': self.Ui.lineEdit_escape_char.text(),
331 | 'folders': self.Ui.lineEdit_escape_dir.text(),
332 | 'emby_url': self.Ui.lineEdit_emby_url.text(),
333 | 'api_key': self.Ui.lineEdit_api_key.text(),
334 | }
335 | save_config(json_config)
336 |
337 | # ========================================================================小工具-单视频刮削
338 | def pushButton_select_file_clicked(self):
339 | filePath, fileType = QtWidgets.QFileDialog.getOpenFileName(self, "选取文件", os.getcwd(),
340 | "Movie Files(*.mp4 *.avi *.rmvb "
341 | "*.wmv *.mov *.mkv *.flv *.ts *.MP4 *.AVI *.RMVB "
342 | "*.WMV *.MOV *.MKV *.FLV *.TS);;All Files(*)")
343 | if filePath != '':
344 | self.Ui.stackedWidget.setCurrentIndex(0)
345 | try:
346 | t = threading.Thread(target=self.select_file_thread, args=(filePath,))
347 | t.start() # 启动线程,即让线程开始执行
348 | except Exception as error_info:
349 | self.add_text_main('[-]Error in pushButton_select_file_clicked: ' + str(error_info))
350 |
351 | def select_file_thread(self, file_name):
352 | file_root = os.getcwd().replace("\\\\", "/").replace("\\", "/")
353 | file_path = file_name.replace(file_root, '.').replace("\\\\", "/").replace("\\", "/")
354 | file_name = os.path.splitext(file_name.split('/')[-1])[0]
355 | mode = 0
356 | if self.Ui.comboBox_website.currentText() == 'All websites':
357 | mode = 1
358 | elif self.Ui.comboBox_website.currentText() == 'javdb':
359 | mode = 2
360 | elif self.Ui.comboBox_website.currentText() == 'javbus':
361 | mode = 3
362 | elif self.Ui.comboBox_website.currentText() == 'avsox':
363 | mode = 4
364 | elif self.Ui.comboBox_website.currentText() == 'fc2club':
365 | mode = 5
366 | elif self.Ui.comboBox_website.currentText() == 'fanza':
367 | mode = 6
368 | elif self.Ui.comboBox_website.currentText() == 'siro':
369 | mode = 7
370 | try:
371 | if '-CD' in file_name or '-cd' in file_name:
372 | part = ''
373 | if re.search('-CD\d+', file_name):
374 | part = re.findall('-CD\d+', file_name)[0]
375 | elif re.search('-cd\d+', file_name):
376 | part = re.findall('-cd\d+', file_name)[0]
377 | file_name = file_name.replace(part, '')
378 | if '-c.' in file_path or '-C.' in file_path:
379 | file_name = file_name[0:-2]
380 | self.add_text_main("[!]Making Data for [" + file_path + "], the number is [" + file_name + "]")
381 | self.Core_Main(file_path, file_name, mode, 0)
382 | except Exception as error_info:
383 | self.add_text_main('[-]Error in select_file_thread: ' + str(error_info))
384 | self.add_text_main("[*]======================================================")
385 |
386 | # ========================================================================小工具-裁剪封面图
387 | def pushButton_select_fanart_clicked(self):
388 | filePath, fileType = QtWidgets.QFileDialog.getOpenFileName(self, "选取文件", os.getcwd(),
389 | "Picture Files(*.jpg);;All Files(*)")
390 | if filePath != '':
391 | self.Ui.stackedWidget.setCurrentIndex(0)
392 | try:
393 | t = threading.Thread(target=self.select_fanart_thread, args=(filePath,))
394 | t.start() # 启动线程,即让线程开始执行
395 | except Exception as error_info:
396 | self.add_text_main('[-]Error in pushButton_select_fanart_clicked: ' + str(error_info))
397 |
398 | def select_fanart_thread(self, file_path):
399 | file_name = file_path.split('/')[-1]
400 | file_path = file_path.replace('/' + file_name, '')
401 | self.image_cut(file_path, file_name)
402 | self.add_text_main("[*]======================================================")
403 |
404 | def image_cut(self, path, file_name):
405 | file_path = os.path.join(path, file_name)
406 | png_name = ''
407 | if self.Ui.radioButton_emby.isChecked(): # emby/jellyfin
408 | png_name = os.path.splitext(file_name)[0] + '.png'
409 | elif self.Ui.radioButton_plex.isChecked(): # plex
410 | png_name = 'poster.png'
411 | elif self.Ui.radioButton_kodi.isChecked(): # kodi
412 | png_name = file_name.replace('-fanart.jpg', '-poster.png')
413 | try:
414 | if os.path.exists(os.path.join(path, png_name)):
415 | os.remove(os.path.join(path, png_name))
416 | except Exception as error_info:
417 | self.add_text_main('[-]Error in image_cut: ' + str(error_info))
418 | return
419 |
420 | """ 你的 APPID AK SK """
421 | APP_ID = '17013175'
422 | API_KEY = 'IQs1mkG4FerdtmNh6qKDI4fW'
423 | SECRET_KEY = 'dLr9GTqqutqP9nWKKRaEinVDhxYlPbnD'
424 |
425 | client = AipBodyAnalysis(APP_ID, API_KEY, SECRET_KEY)
426 |
427 | """ 获取图片分辨率 """
428 | im = Image.open(file_path) # 返回一个Image对象
429 | width, height = im.size
430 |
431 | """ 读取图片 """
432 | with open(file_path, 'rb') as fp:
433 | image = fp.read()
434 |
435 | """ 调用人体检测与属性识别 """
436 | result = client.bodyAnalysis(image)
437 | ewidth = int(0.661538 * height)
438 | ex = int(result["person_info"][0]['body_parts']['nose']['x'])
439 | if width - ex < ewidth / 2:
440 | ex = width - ewidth
441 | else:
442 | ex -= int(ewidth / 2)
443 | ey = 0
444 | ew = ewidth
445 | eh = height
446 | fp = open(file_path, 'rb')
447 | img = Image.open(fp)
448 | img_new_png = img.crop((ex, ey, ew + ex, eh + ey))
449 | fp.close()
450 | img_new_png.save(path + '/' + png_name)
451 | self.add_text_main('[+]Poster Cut ' + png_name + ' from ' + file_name + '!')
452 | pix = QPixmap(file_path)
453 | self.Ui.label_fanart.setScaledContents(True)
454 | self.Ui.label_fanart.setPixmap(pix) # 添加图标
455 | pix = QPixmap(path + '/' + png_name)
456 | self.Ui.label_poster.setScaledContents(True)
457 | self.Ui.label_poster.setPixmap(pix) # 添加图标
458 |
459 | # ========================================================================小工具-视频移动
460 | def move_file(self):
461 | self.Ui.stackedWidget.setCurrentIndex(4)
462 | try:
463 | t = threading.Thread(target=self.move_file_thread)
464 | t.start() # 启动线程,即让线程开始执行
465 | except Exception as error_info:
466 | self.add_text_main('[-]Error in move_file: ' + str(error_info))
467 |
468 | def move_file_thread(self):
469 | escape_dir = self.Ui.lineEdit_escape_dir_move.text()
470 | movie_list = movie_lists(escape_dir)
471 | self.add_text_main('[+]Move Movies Start!')
472 | for movie in movie_list:
473 | sour = movie
474 | lenth = len(sour.split('/'))
475 | des = os.getcwd() + '/' + sour.split('/')[lenth - 1]
476 | try:
477 | if len(sour.split('/')) > 2:
478 | shutil.move(sour, des)
479 | self.add_text_main(' [+]Move ' + sour.split('/')[lenth - 1] + ' Success!')
480 | except Exception as error_info:
481 | self.add_text_main('[-]Error in move_file_thread: ' + str(error_info))
482 | self.add_text_main("[+]Move Movies All Finished!!!")
483 | self.add_text_main("[*]======================================================")
484 |
485 | # ========================================================================小工具-emby女优头像
486 | def pushButton_add_actor_pic_clicked(self): # 添加头像按钮响应
487 | self.Ui.stackedWidget.setCurrentIndex(0)
488 | emby_url = self.Ui.lineEdit_emby_url.text()
489 | api_key = self.Ui.lineEdit_api_key.text()
490 | if emby_url == '':
491 | self.add_text_main('[-]The emby_url is empty!')
492 | self.add_text_main("[*]======================================================")
493 | return
494 | elif api_key == '':
495 | self.add_text_main('[-]The api_key is empty!')
496 | self.add_text_main("[*]======================================================")
497 | return
498 | try:
499 | t = threading.Thread(target=self.found_profile_picture, args=(1,))
500 | t.start() # 启动线程,即让线程开始执行
501 | except Exception as error_info:
502 | self.add_text_main('[-]Error in pushButton_add_actor_pic_clicked: ' + str(error_info))
503 |
504 | def pushButton_show_pic_actor_clicked(self): # 查看按钮响应
505 | self.Ui.stackedWidget.setCurrentIndex(0)
506 | emby_url = self.Ui.lineEdit_emby_url.text()
507 | api_key = self.Ui.lineEdit_api_key.text()
508 | if emby_url == '':
509 | self.add_text_main('[-]The emby_url is empty!')
510 | self.add_text_main("[*]======================================================")
511 | return
512 | elif api_key == '':
513 | self.add_text_main('[-]The api_key is empty!')
514 | self.add_text_main("[*]======================================================")
515 | return
516 | if self.Ui.comboBox_pic_actor.currentIndex() == 0: # 可添加头像的女优
517 | try:
518 | t = threading.Thread(target=self.found_profile_picture, args=(2,))
519 | t.start() # 启动线程,即让线程开始执行
520 | except Exception as error_info:
521 | self.add_text_main('[-]Error in pushButton_show_pic_actor_clicked: ' + str(error_info))
522 | else:
523 | try:
524 | t = threading.Thread(target=self.show_actor, args=(self.Ui.comboBox_pic_actor.currentIndex(),))
525 | t.start() # 启动线程,即让线程开始执行
526 | except Exception as error_info:
527 | self.add_text_main('[-]Error in pushButton_show_pic_actor_clicked: ' + str(error_info))
528 |
529 | def show_actor(self, mode): # 按模式显示相应列表
530 | if mode == 1: # 没有头像的女优
531 | self.add_text_main('[+]没有头像的女优!')
532 | elif mode == 2: # 有头像的女优
533 | self.add_text_main('[+]有头像的女优!')
534 | elif mode == 3: # 所有女优
535 | self.add_text_main('[+]所有女优!')
536 | actor_list = self.get_emby_actor_list()
537 | if actor_list['TotalRecordCount'] == 0:
538 | self.add_text_main("[*]======================================================")
539 | return
540 | count = 1
541 | actor_list_temp = ''
542 | for actor in actor_list['Items']:
543 | if mode == 3: # 所有女优
544 | actor_list_temp += str(count) + '.' + actor['Name'] + ','
545 | count += 1
546 | elif mode == 2 and actor['ImageTags'] != {}: # 有头像的女优
547 | actor_list_temp += str(count) + '.' + actor['Name'] + ','
548 | count += 1
549 | elif mode == 1 and actor['ImageTags'] == {}: # 没有头像的女优
550 | actor_list_temp += str(count) + '.' + actor['Name'] + ','
551 | count += 1
552 | if (count - 1) % 5 == 0 and actor_list_temp != '':
553 | self.add_text_main('[+]' + actor_list_temp)
554 | actor_list_temp = ''
555 | self.add_text_main("[*]======================================================")
556 |
557 | def get_emby_actor_list(self): # 获取emby的演员列表
558 | emby_url = self.Ui.lineEdit_emby_url.text()
559 | api_key = self.Ui.lineEdit_api_key.text()
560 | emby_url = emby_url.replace(':', ':')
561 | url = 'http://' + emby_url + '/emby/Persons?api_key=' + api_key
562 | headers = {
563 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
564 | 'Chrome/60.0.3100.0 Safari/537.36'}
565 | getweb = requests.get(str(url), headers=headers, timeout=10)
566 | getweb.encoding = 'utf-8'
567 | actor_list = {}
568 | try:
569 | actor_list = json.loads(getweb.text)
570 | except:
571 | self.add_text_main('[-]Error! Check your emby_url or api_key!')
572 | actor_list['TotalRecordCount'] = 0
573 | return actor_list
574 |
575 | def found_profile_picture(self, mode): # mode=1,上传头像,mode=2,显示可添加头像的女优
576 | if mode == 1:
577 | self.add_text_main('[+]Start upload profile pictures!')
578 | elif mode == 2:
579 | self.add_text_main('[+]可添加头像的女优!')
580 | path = 'Actor'
581 | if not os.path.exists(path):
582 | self.add_text_main('[+]Actor folder not exist!')
583 | self.add_text_main("[*]======================================================")
584 | return
585 | path_success = 'Actor/Success'
586 | if not os.path.exists(path_success):
587 | os.makedirs(path_success)
588 | profile_pictures = os.listdir(path)
589 | actor_list = self.get_emby_actor_list()
590 | if actor_list['TotalRecordCount'] == 0:
591 | self.add_text_main("[*]======================================================")
592 | return
593 | count = 1
594 | for actor in actor_list['Items']:
595 | flag = 0
596 | pic_name = ''
597 | if actor['Name'] + '.jpg' in profile_pictures:
598 | flag = 1
599 | pic_name = actor['Name'] + '.jpg'
600 | elif actor['Name'] + '.png' in profile_pictures:
601 | flag = 1
602 | pic_name = actor['Name'] + '.png'
603 | if flag == 0:
604 | byname_list = re.split('[,()]', actor['Name'])
605 | for byname in byname_list:
606 | if byname + '.jpg' in profile_pictures:
607 | pic_name = byname + '.jpg'
608 | flag = 1
609 | break
610 | elif byname + '.png' in profile_pictures:
611 | pic_name = byname + '.png'
612 | flag = 1
613 | break
614 | if flag == 1 and (actor['ImageTags'] == {} or not os.path.exists(path_success + '/' + pic_name)):
615 | if mode == 1:
616 | try:
617 | self.upload_profile_picture(count, actor, path + '/' + pic_name)
618 | shutil.copy(path + '/' + pic_name, path_success + '/' + pic_name)
619 | except Exception as error_info:
620 | self.add_text_main('[-]Error in found_profile_picture! ' + str(error_info))
621 | else:
622 | self.add_text_main('[+]' + "%4s" % str(count) + '.Actor name: ' + actor['Name'] + ' Pic name: '
623 | + pic_name)
624 | count += 1
625 | if count == 1:
626 | self.add_text_main('[-]NO profile picture can be uploaded!')
627 | self.add_text_main("[*]======================================================")
628 |
629 | def upload_profile_picture(self, count, actor, pic_path): # 上传头像
630 | emby_url = self.Ui.lineEdit_emby_url.text()
631 | api_key = self.Ui.lineEdit_api_key.text()
632 | emby_url = emby_url.replace(':', ':')
633 | try:
634 | f = open(pic_path, 'rb') # 二进制方式打开图文件
635 | b6_pic = base64.b64encode(f.read()) # 读取文件内容,转换为base64编码
636 | f.close()
637 | url = 'http://' + emby_url + '/emby/Items/' + actor['Id'] + '/Images/Primary?api_key=' + api_key
638 | if pic_path.endswith('jpg'):
639 | header = {"Content-Type": 'image/png', }
640 | else:
641 | header = {"Content-Type": 'image/jpeg', }
642 | respones = requests.post(url=url, data=b6_pic, headers=header)
643 | self.add_text_main(
644 | '[+]' + "%4s" % str(count) + '.Success upload profile picture for ' + actor['Name'] + '!')
645 | except Exception as error_info:
646 | self.add_text_main('[-]Error in upload_profile_picture! ' + str(error_info))
647 |
648 | # ========================================================================core.py
649 | def add_text_main(self, text):
650 | time.sleep(0.1)
651 | self.Ui.textBrowser_log_main.append(text)
652 | self.Ui.textBrowser_log_main.moveCursor(QTextCursor.End)
653 |
654 | def moveFailedFolder(self, filepath, failed_folder):
655 | self.add_text_main('[-]Move to Failed output folder')
656 | shutil.move(filepath, str(os.getcwd()) + '/' + failed_folder + '/')
657 |
658 | # =====================资源下载部分===========================
659 | def DownloadFileWithFilename(self, url, filename, path, Config, filepath,
660 | failed_folder): # path = examle:photo , video.in the Project Folder!
661 | retry_count = 0
662 | proxy = ''
663 | timeout = 0
664 | try:
665 | proxy = Config['proxy']['proxy']
666 | timeout = int(Config['proxy']['timeout'])
667 | retry_count = int(Config['proxy']['retry'])
668 | except:
669 | self.add_text_main('[-]Proxy config error! Please check the config.')
670 | i = 0
671 |
672 | while i < retry_count:
673 | try:
674 | if not proxy == '':
675 | if not os.path.exists(path):
676 | os.makedirs(path)
677 | headers = {
678 | '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'}
679 | r = requests.get(url, headers=headers, timeout=timeout,
680 | proxies={"http": "http://" + str(proxy), "https": "https://" + str(proxy)})
681 | if r == '':
682 | self.add_text_main('[-]Movie Data not found!')
683 | # os._exit(0)
684 | with open(str(path) + "/" + filename, "wb") as code:
685 | code.write(r.content)
686 | return
687 | else:
688 | if not os.path.exists(path):
689 | os.makedirs(path)
690 | headers = {
691 | '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'}
692 | r = requests.get(url, timeout=timeout, headers=headers)
693 | if r == '':
694 | self.add_text_main('[-]Movie Data not found!')
695 | # os._exit(0)
696 | with open(str(path) + "/" + filename, "wb") as code:
697 | code.write(r.content)
698 | return
699 | except requests.exceptions.RequestException:
700 | i += 1
701 | print('[-]Image Download : Connect retry ' + str(i) + '/' + str(retry_count))
702 | except requests.exceptions.ConnectionError:
703 | i += 1
704 | print('[-]Image Download : Connect retry ' + str(i) + '/' + str(retry_count))
705 | except requests.exceptions.ProxyError:
706 | i += 1
707 | print('[-]Image Download : Connect retry ' + str(i) + '/' + str(retry_count))
708 | except requests.exceptions.ConnectTimeout:
709 | i += 1
710 | print('[-]Image Download : Connect retry ' + str(i) + '/' + str(retry_count))
711 | self.add_text_main('[-]Connect Failed! Please check your Proxy or Network!')
712 | self.moveFailedFolder(filepath, failed_folder)
713 |
714 | def fanartDownload(self, option, cover, number, c_word, path, multi_part, Config, filepath,
715 | failed_folder): # 封面是否下载成功,否则移动到failed
716 | if option == 'emby':
717 | if self.DownloadFileWithFilename(cover, number + c_word + '.jpg', path, Config, filepath,
718 | failed_folder) == 'failed':
719 | self.moveFailedFolder(filepath, failed_folder)
720 | self.DownloadFileWithFilename(cover, number + c_word + '.jpg', path, Config, filepath, failed_folder)
721 | if not os.path.getsize(path + '/' + number + c_word + '.jpg') == 0:
722 | self.add_text_main('[+]Fanart Downloaded! ' + number + c_word + '.jpg')
723 | return
724 | i = 1
725 | while i <= int(Config['proxy']['retry']):
726 | if os.path.getsize(path + '/' + number + c_word + '.jpg') == 0:
727 | print('[!]Image Download Failed! Trying again. ' + str(i) + '/' + Config['proxy']['retry'])
728 | self.DownloadFileWithFilename(cover, number + c_word + '.jpg', path, Config, filepath,
729 | failed_folder)
730 | i = i + 1
731 | else:
732 | break
733 | if multi_part == 1:
734 | old_name = os.path.join(path, number + c_word + '.jpg')
735 | new_name = os.path.join(path, number + c_word + '.jpg')
736 | os.rename(old_name, new_name)
737 | self.add_text_main('[+]Fanart Downloaded! ' + number + c_word + '.jpg')
738 | else:
739 | self.add_text_main('[+]Fanart Downloaded! ' + number + c_word + '.jpg')
740 | elif option == 'plex':
741 | if self.DownloadFileWithFilename(cover, 'fanart.jpg', path, Config, filepath, failed_folder) == 'failed':
742 | self.moveFailedFolder(filepath, failed_folder)
743 | self.DownloadFileWithFilename(cover, 'fanart.jpg', path, Config, filepath, failed_folder)
744 | if not os.path.getsize(path + '/fanart.jpg') == 0:
745 | self.add_text_main('[+]Fanart Downloaded! fanart.jpg')
746 | return
747 | i = 1
748 | while i <= int(Config['proxy']['retry']):
749 | if os.path.getsize(path + '/fanart.jpg') == 0:
750 | print('[!]Image Download Failed! Trying again. ' + str(i) + '/' + Config['proxy']['retry'])
751 | self.DownloadFileWithFilename(cover, 'fanart.jpg', path, Config, filepath, failed_folder)
752 | i = i + 1
753 | continue
754 | else:
755 | break
756 | if not os.path.getsize(path + '/' + number + c_word + '.jpg') == 0:
757 | print('[!]Image Download Failed! Trying again.')
758 | self.DownloadFileWithFilename(cover, number + c_word + '.jpg', path, Config, filepath, failed_folder)
759 | self.add_text_main('[+]Fanart Downloaded! fanart.jpg')
760 | elif option == 'kodi':
761 | if self.DownloadFileWithFilename(cover, number + c_word + '-fanart.jpg', path, Config, filepath,
762 | failed_folder) == 'failed':
763 | self.moveFailedFolder(filepath, failed_folder)
764 | self.DownloadFileWithFilename(cover, number + c_word + '-fanart.jpg', path, Config, filepath, failed_folder)
765 | if not os.path.getsize(path + '/' + number + c_word + '-fanart.jpg') == 0:
766 | self.add_text_main('[+]Fanart Downloaded! ' + number + c_word + '-fanart.jpg')
767 | return
768 | i = 1
769 | while i <= int(Config['proxy']['retry']):
770 | if os.path.getsize(path + '/' + number + c_word + '-fanart.jpg') == 0:
771 | print('[!]Image Download Failed! Trying again. ' + str(i) + '/' + Config['proxy']['retry'])
772 | self.DownloadFileWithFilename(cover, number + c_word + '-fanart.jpg', path, Config, filepath,
773 | failed_folder)
774 | i = i + 1
775 | continue
776 | else:
777 | break
778 | self.add_text_main('[+]Fanart Downloaded! ' + number + c_word + '-fanart.jpg')
779 |
780 | def smallCoverDownload(self, path, number, imagecut, cover_small, c_word, option, Config, filepath, failed_folder):
781 | if imagecut == 3:
782 | self.DownloadFileWithFilename(cover_small, 'cover_small.jpg', path, Config, filepath, failed_folder)
783 | try:
784 | fp = open(path + '/cover_small.jpg', 'rb')
785 | img = Image.open(fp)
786 | w = img.width
787 | h = img.height
788 | if int(w) >= int(h):
789 | self.add_text_main('[-]The size of cover_small.jpg is error, Try to cut fanart!')
790 | os.remove(path + '/cover_small.jpg')
791 | return 'small_cover_error'
792 | if option == 'emby':
793 | img.save(path + '/' + number + c_word + '.png')
794 | self.add_text_main('[+]Poster Downloaded! ' + number + c_word + '.png')
795 | elif option == 'kodi':
796 | img.save(path + '/' + number + c_word + '-poster.jpg')
797 | self.add_text_main('[+]Poster Downloaded! ' + number + c_word + '-poster.jpg')
798 | elif option == 'plex':
799 | img.save(path + '/poster.png')
800 | self.add_text_main('[+]Poster Downloaded! poster.png')
801 | time.sleep(1)
802 | fp.close()
803 | os.remove(path + '/cover_small.jpg')
804 | except Exception as error_info:
805 | self.add_text_main('[-]Error in smallCoverDownload: ' + str(error_info))
806 | fp.close()
807 | os.remove(path + '/cover_small.jpg')
808 | self.add_text_main('[+]Try to cut fanart!')
809 | return 'small_cover_error'
810 |
811 | # ========================================================================打印NFO
812 | def PrintFiles(self, option, path, c_word, naming_rule, part, cn_sub, json_data, filepath, failed_folder):
813 | title, studio, year, outline, runtime, director, actor_photo, actor, release, tag, number, cover, website, label = get_info(
814 | json_data)
815 | name_title = naming_rule.replace('title', title).replace('studio', studio).replace('year', year).replace(
816 | 'runtime',
817 | runtime).replace(
818 | 'director', director).replace('actor', actor).replace('release', release).replace('number', number).replace(
819 | 'label', label)
820 | try:
821 | if not os.path.exists(path):
822 | os.makedirs(path)
823 | with open(path + "/" + number + part + c_word + ".nfo", "wt", encoding='UTF-8') as code:
824 | print('', file=code)
825 | print("", file=code)
826 | print(" " + name_title + part + "", file=code)
827 | print(" ", file=code)
828 | print(" ", file=code)
829 | print(" " + studio + "+", file=code)
830 | print(" " + year + "", file=code)
831 | print(" " + outline + "", file=code)
832 | print(" " + outline + "", file=code)
833 | print(" " + str(runtime).replace(" ", "") + "", file=code)
834 | print(" " + director + "", file=code)
835 | if option == 'emby':
836 | print(" " + number + part + c_word + ".png", file=code)
837 | print(" " + number + part + c_word + ".png", file=code)
838 | print(" " + number + part + c_word + '.jpg' + "", file=code)
839 | elif option == 'kodi':
840 | print(" " + number + part + c_word + "-poster.jpg", file=code)
841 | print(" " + number + part + c_word + '-fanart.jpg' + "", file=code)
842 | elif option == 'plex':
843 | print(" poster.png", file=code)
844 | print(" thumb.png", file=code)
845 | print(" fanart.jpg", file=code)
846 | try:
847 | for key, value in actor_photo.items():
848 | print(" ", file=code)
849 | print(" " + key + "", file=code)
850 | if not value == '': # or actor_photo == []:
851 | print(" " + value + "", file=code)
852 | print(" ", file=code)
853 | except Exception as error_info:
854 | self.add_text_main('[-]Error in actor_photo: ' + str(error_info))
855 | print(" " + studio + "", file=code)
856 | print(" ", file=code)
858 | print(" " + label + "", file=code)
859 | if cn_sub == '1':
860 | print(" 中文字幕", file=code)
861 | try:
862 | for i in tag:
863 | if i != '':
864 | print(" " + i + "", file=code)
865 | except Exception as error_info:
866 | self.add_text_main('[-]Error in tag: ' + str(error_info))
867 | try:
868 | for i in tag:
869 | if i != '':
870 | print(" " + i + "", file=code)
871 | except Exception as error_info:
872 | self.add_text_main('[-]Error in genre: ' + str(error_info))
873 | print(" " + label + "", file=code)
874 | if cn_sub == '1':
875 | print(" 中文字幕", file=code)
876 | print(" " + number + "", file=code)
877 | if option == 'emby':
878 | print(" " + release + "", file=code)
879 | elif option == 'kodi' or option == 'plex':
880 | print(" " + release + "", file=code)
881 | print(" " + cover + "", file=code)
882 | print(" " + website + "", file=code)
883 | print("", file=code)
884 | self.add_text_main("[+]Nfo Writed! " + number + part + c_word + ".nfo")
885 | except IOError as e:
886 | self.add_text_main("[-]Write Failed!")
887 | self.add_text_main('[-]Error in PrintFiles: ' + str(e))
888 | self.moveFailedFolder(filepath, failed_folder)
889 | except Exception as error_info:
890 | self.add_text_main("[-]Write Failed!")
891 | self.add_text_main('[-]Error in PrintFiles: ' + str(error_info))
892 | self.moveFailedFolder(filepath, failed_folder)
893 |
894 | def cutImage(self, option, imagecut, path, number, c_word):
895 | if option == 'plex':
896 | if imagecut == 1:
897 | try:
898 | img = Image.open(path + '/fanart.jpg')
899 | imgSize = img.size
900 | w = img.width
901 | h = img.height
902 | img2 = img.crop((w / 1.9, 0, w, h))
903 | img2.save(path + '/poster.png')
904 | self.add_text_main('[+]Poster Cut! ' + 'poster.png')
905 | except:
906 | self.add_text_main('[-]Cover cut failed!')
907 | elif imagecut == 0:
908 | self.image_cut(path, 'fanart.jpg')
909 | elif option == 'emby':
910 | if imagecut == 1:
911 | try:
912 | img = Image.open(path + '/' + number + c_word + '.jpg')
913 | imgSize = img.size
914 | w = img.width
915 | h = img.height
916 | img2 = img.crop((w / 1.9, 0, w, h))
917 | img2.save(path + '/' + number + c_word + '.png')
918 | self.add_text_main('[+]Poster Cut! ' + number + c_word + '.png')
919 | except:
920 | self.add_text_main('[-]Cover cut failed!')
921 | elif imagecut == 0:
922 | self.image_cut(path, number + c_word + '.jpg')
923 | elif option == 'kodi':
924 | if imagecut == 1:
925 | try:
926 | img = Image.open(path + '/' + number + c_word + '-fanart.jpg')
927 | imgSize = img.size
928 | w = img.width
929 | h = img.height
930 | img2 = img.crop((w / 1.9, 0, w, h))
931 | img2.save(path + '/' + number + c_word + '-poster.jpg')
932 | self.add_text_main('[+]Poster Cut! ' + number + c_word + '-poster.jpg')
933 | except:
934 | self.add_text_main('[-]Cover cut failed!')
935 | elif imagecut == 0:
936 | self.image_cut(path, number + c_word + '-fanart.jpg')
937 |
938 | def copyRenameJpgToBackdrop(self, option, path, number, c_word):
939 | if option == 'plex':
940 | shutil.copy(path + '/fanart.jpg', path + '/Backdrop.jpg')
941 | shutil.copy(path + '/poster.png', path + '/thumb.png')
942 | if option == 'emby':
943 | shutil.copy(path + '/' + number + c_word + '.jpg', path + '/Backdrop.jpg')
944 | if option == 'kodi':
945 | shutil.copy(path + '/' + number + c_word + '-fanart.jpg', path + '/Backdrop.jpg')
946 |
947 | def pasteFileToFolder(self, filepath, path, number, c_word, config): # 文件路径,番号,后缀,要移动至的位置
948 | houzhui = str(
949 | re.search('[.](AVI|RMVB|WMV|MOV|MP4|MKV|FLV|TS|avi|rmvb|wmv|mov|mp4|mkv|flv|ts)$', filepath).group())
950 | try:
951 | if config['common']['soft_link'] == '1': # 如果soft_link=1 使用软链接
952 | os.symlink(filepath, path + '/' + number + c_word + houzhui)
953 | self.add_text_main('[+]Movie Linked! ' + number + c_word + houzhui)
954 | else:
955 | os.rename(filepath, path + '/' + number + c_word + houzhui)
956 | self.add_text_main('[+]Movie Moved! ' + number + c_word + houzhui)
957 | if os.path.exists(os.getcwd() + '/' + number + c_word + '.srt'): # 字幕移动
958 | os.rename(os.getcwd() + '/' + number + c_word + '.srt', path + '/' + number + c_word + '.srt')
959 | self.add_text_main('[+]Sub moved!')
960 | elif os.path.exists(os.getcwd() + '/' + number + c_word + '.ssa'):
961 | os.rename(os.getcwd() + '/' + number + c_word + '.ssa', path + '/' + number + c_word + '.ssa')
962 | self.add_text_main('[+]Sub moved!')
963 | elif os.path.exists(os.getcwd() + '/' + number + c_word + '.sub'):
964 | os.rename(os.getcwd() + '/' + number + c_word + '.sub', path + '/' + number + c_word + '.sub')
965 | self.add_text_main('[+]Sub moved!')
966 | except FileExistsError:
967 | self.add_text_main('[-]Error in pasteFileToFolder_mode2! File Exists! Please check your movie!')
968 | except PermissionError:
969 | self.add_text_main('[-]Error in pasteFileToFolder_mode2! Please run as administrator!')
970 |
971 | def pasteFileToFolder_mode2(self, filepath, path, number, part, c_word, config): # 文件路径,番号,后缀,要移动至的位置
972 | houzhui = str(
973 | re.search('[.](AVI|RMVB|WMV|MOV|MP4|MKV|FLV|TS|avi|rmvb|wmv|mov|mp4|mkv|flv|ts)$', filepath).group())
974 | try:
975 | if config['common']['soft_link'] == '1':
976 | os.symlink(filepath, path + '/' + number + c_word + houzhui)
977 | self.add_text_main('[+]Movie Linked! ' + number + c_word + houzhui)
978 | else:
979 | os.rename(filepath, path + '/' + number + c_word + houzhui)
980 | self.add_text_main('[+]Movie Moved! ' + number + c_word + houzhui)
981 | if os.path.exists(number + '.srt'): # 字幕移动
982 | os.rename(number + part + c_word + '.srt', path + '/' + number + c_word + '.srt')
983 | self.add_text_main('[+]Sub moved!')
984 | elif os.path.exists(number + part + c_word + '.ass'):
985 | os.rename(number + part + c_word + '.ass', path + '/' + number + c_word + '.ass')
986 | self.add_text_main('[+]Sub moved!')
987 | elif os.path.exists(number + part + c_word + '.sub'):
988 | os.rename(number + part + c_word + '.sub', path + '/' + number + c_word + '.sub')
989 | self.add_text_main('[+]Sub moved!')
990 | self.add_text_main('[!]Success')
991 | except FileExistsError:
992 | self.add_text_main('[-]Error in pasteFileToFolder_mode2! File Exists! Please check your movie!')
993 | except PermissionError:
994 | self.add_text_main('[-]Error in pasteFileToFolder_mode2! Please run as administrator!')
995 |
996 | def get_part(self, filepath, failed_folder):
997 | try:
998 | if re.search('-CD\d+', filepath):
999 | return re.findall('-CD\d+', filepath)[0]
1000 | if re.search('-cd\d+', filepath):
1001 | return re.findall('-cd\d+', filepath)[0]
1002 | except Exception as error_info:
1003 | self.add_text_main('[-]Error in get_part: ' + str(error_info))
1004 | self.moveFailedFolder(filepath, failed_folder)
1005 |
1006 | # ========================================================================更新进度条
1007 | def set_processbar(self, value):
1008 | self.Ui.progressBar_avdc.setProperty("value", value)
1009 | self.Ui.label_percent.setText(str(value) + '%')
1010 |
1011 | # ========================================================================输出调试信息
1012 | def debug_mode(self, json_data, config):
1013 | try:
1014 | self.add_text_main('[+] ---Debug info---')
1015 | for key, value in json_data.items():
1016 | if key == 'title' and value == '':
1017 | self.add_text_main(' [+]Title is None, Not Find Info!')
1018 | break
1019 | if value == '' or key == 'actor_photo':
1020 | continue
1021 | if key == 'tag':
1022 | value = str(json_data['tag']).strip(" ['']").replace('\'', '')
1023 | self.add_text_main(' [+]-' + "%-13s" % key + ': ' + str(value))
1024 | self.add_text_main('[+] ---Debug info---')
1025 | except Exception as error_info:
1026 | self.add_text_main('[-]Error in debug_mode: ' + str(error_info))
1027 |
1028 | # ========================================================================创建输出文件夹
1029 | def creatFolder(self, success_folder, json_data, config):
1030 | title, studio, year, outline, runtime, director, actor_photo, actor, release, tag, number, cover, website, label = get_info(
1031 | json_data)
1032 | if len(actor.split(',')) >= 15:
1033 | actor = actor.split(',')[0] + ',' + actor.split(',')[1] + ',' + actor.split(',')[2] + '等演员'
1034 | location_rule = json_data['location_rule']
1035 | path = location_rule.replace('title', title).replace('studio', studio).replace('year', year).replace('runtime',
1036 | runtime).replace(
1037 | 'director', director).replace('actor', actor).replace('release', release).replace('number', number).replace(
1038 | 'label', label)
1039 | path = path.replace('//', '/')
1040 | if len(path) > 200:
1041 | self.add_text_main('[-]Error in Length of Path! Repleaced with actor/number')
1042 | path = actor + '/' + json_data['number']
1043 | path = success_folder + '/' + path
1044 | if not os.path.exists(path):
1045 | path = escapePath(path, config)
1046 | try:
1047 | os.makedirs(path)
1048 | except Exception as error_info:
1049 | self.add_text_main('[-]Error in creatFolder: ' + str(error_info))
1050 | return 'error'
1051 | return path
1052 |
1053 | # ========================================================================从指定网站获取json_data
1054 | def get_json_data(self, mode, number, config):
1055 | if (mode == 0 and self.Ui.radioButton_all.isChecked()) or mode == 1:
1056 | json_data = getDataFromJSON(number, config, 1) # 所有网站
1057 | elif (mode == 0 and self.Ui.radioButton_javdb.isChecked()) or mode == 2:
1058 | self.add_text_main('[!]Please Wait Three Seconds!')
1059 | time.sleep(3)
1060 | json_data = getDataFromJSON(number, config, 2) # 仅javdb
1061 | else:
1062 | json_data = getDataFromJSON(number, config, mode) # 仅javbus或仅avsox或仅fc2club或仅fanza或仅siro
1063 | return json_data
1064 |
1065 | # ========================================================================json_data添加到主界面
1066 | def add_label_info(self, json_data):
1067 | self.Ui.label_number.setText(json_data['number'])
1068 | self.Ui.label_release.setText(json_data['release'])
1069 | self.Ui.label_director.setText(json_data['director'])
1070 | self.Ui.label_runtime.setText(json_data['runtime'])
1071 | self.Ui.label_studio.setText(json_data['studio'])
1072 | self.Ui.label_label.setText(json_data['label'])
1073 | self.Ui.label_title.setText(json_data['title'])
1074 | self.Ui.label_actor.setText(json_data['actor'])
1075 | self.Ui.label_outline.setText(json_data['outline'])
1076 | self.Ui.label_tag.setText(str(json_data['tag']).strip(" [',']").replace('\'', ''))
1077 | if self.Ui.checkBox_cover.isChecked():
1078 | fanart_path = json_data['fanart_path']
1079 | poster_path = json_data['poster_path']
1080 | if os.path.exists(fanart_path):
1081 | pix = QPixmap(fanart_path)
1082 | self.Ui.label_fanart.setScaledContents(True)
1083 | self.Ui.label_fanart.setPixmap(pix) # 添加缩略图
1084 | if os.path.exists(poster_path):
1085 | pix = QPixmap(poster_path)
1086 | self.Ui.label_poster.setScaledContents(True)
1087 | self.Ui.label_poster.setPixmap(pix) # 添加封面图
1088 |
1089 |
1090 | def Core_Main(self, file_path, number_th, mode, count):
1091 | # =======================================================================初始化所需变量
1092 | multi_part = 0
1093 | part = ''
1094 | c_word = ''
1095 | option = ''
1096 | cn_sub = ''
1097 | filepath = file_path # 影片的路径
1098 | number = number_th.replace('_', '-')
1099 | config_file = 'config.ini'
1100 | Config = ConfigParser()
1101 | Config.read(config_file, encoding='UTF-8')
1102 | try:
1103 | option = ReadMediaWarehouse(Config)
1104 | except Exception as error_info:
1105 | self.add_text_main('[-]Error in Core_Main: ' + str(error_info))
1106 | program_mode = Config['common']['main_mode'] # 运行模式
1107 | failed_folder = Config['common']['failed_output_folder'] # 失败输出目录
1108 | success_folder = Config['common']['success_output_folder'] # 成功输出目录
1109 | # =======================================================================获取json_data
1110 | json_data = self.get_json_data(mode, number, Config)
1111 | # =======================================================================是否找到影片信息
1112 | if json_data['website'] == 'timeout':
1113 | self.add_text_main('[-]Connect Failed! Please check your Proxy or Network!')
1114 | return ''
1115 | elif self.Ui.radioButton_javdb.isChecked() and json_data['actor'] == 'N/A':
1116 | self.add_text_main('[-]Your IP Has Been Blocked By JAVDB!')
1117 | return ''
1118 | elif json_data['title'] == '':
1119 | self.add_text_main('[-]Movie Data not found!')
1120 | node = QTreeWidgetItem(self.item_fail)
1121 | node.setText(0, str(count) + '.' + os.path.splitext(filepath.split('/')[-1])[0])
1122 | self.item_fail.addChild(node)
1123 | self.moveFailedFolder(filepath, failed_folder)
1124 | return 'not found'
1125 | # =======================================================================调试模式
1126 | if self.Ui.radioButton_debug_on.isChecked():
1127 | self.debug_mode(json_data, Config)
1128 | # =======================================================================判断-C,-CD后缀
1129 | if '-CD' in filepath or '-cd' in filepath:
1130 | multi_part = 1
1131 | part = self.get_part(filepath, failed_folder)
1132 | if '-c.' in filepath or '-C.' in filepath or '中文' in filepath or '字幕' in filepath:
1133 | cn_sub = '1'
1134 | c_word = '-C' # 中文字幕影片后缀
1135 | # =======================================================================创建输出文件夹
1136 | self.CreatFailedFolder(failed_folder) # 创建输出失败目录
1137 | path = self.creatFolder(success_folder, json_data, Config) # 创建文件夹
1138 | if path == 'error':
1139 | node = QTreeWidgetItem(self.item_fail)
1140 | node.setText(0, str(count) + '.' + os.path.splitext(filepath.split('/')[-1])[0])
1141 | self.item_fail.addChild(node)
1142 | self.moveFailedFolder(filepath, failed_folder)
1143 | return
1144 | self.add_text_main('[+]Folder : ' + path)
1145 | self.add_text_main('[+]From : ' + json_data['website'])
1146 | # =======================================================================刮削模式
1147 | number = json_data['number']
1148 | if multi_part == 1:
1149 | number += part # 这时number会被附加上-CDx后缀
1150 | if program_mode == '1':
1151 | # imagecut 1 裁剪右半面,0 裁剪缩略图为封面,3 下载小封面
1152 | self.fanartDownload(option, json_data['cover'], number, c_word, path, multi_part, Config, filepath,
1153 | failed_folder)
1154 | if self.smallCoverDownload(path, number, json_data['imagecut'], json_data['cover_small'], c_word, option,
1155 | Config, filepath, failed_folder) == 'small_cover_error': # 检查小封面
1156 | json_data['imagecut'] = 0
1157 | self.cutImage(option, json_data['imagecut'], path, number, c_word) # 裁剪图
1158 | self.copyRenameJpgToBackdrop(option, path, number, c_word)
1159 | self.PrintFiles(option, path, c_word, json_data['naming_rule'], part, cn_sub, json_data, filepath,
1160 | failed_folder) # 打印文件
1161 | self.pasteFileToFolder(filepath, path, number, c_word, Config) # 移动文件
1162 | # =======================================================================整理模式
1163 | elif program_mode == '2':
1164 | self.pasteFileToFolder_mode2(filepath, path, number, part, c_word, Config) # 移动文件
1165 | # =======================================================================json添加封面项
1166 | fanart_path = ''
1167 | poster_path = ''
1168 | if self.Ui.radioButton_emby.isChecked(): # emby/jellyfin
1169 | fanart_path = path + '/' + number + c_word + '.jpg'
1170 | poster_path = path + '/' + number + c_word + '.png'
1171 | elif self.Ui.radioButton_plex.isChecked(): # plex
1172 | fanart_path = path + '/fanart.jpg'
1173 | poster_path = path + '/poster.png'
1174 | elif self.Ui.radioButton_kodi.isChecked(): # kodi
1175 | fanart_path = path + '/' + number + c_word + '-fanart.jpg'
1176 | poster_path = path + '/' + number + c_word + '-poster.jpg'
1177 | json_data['fanart_path'] = fanart_path
1178 | json_data['poster_path'] = poster_path
1179 | json_data['number'] = number
1180 | self.add_label_info(json_data)
1181 | self.json_array[str(count)] = json_data
1182 |
1183 | # ========================================================================AVDC刮削主功能
1184 | def UpdateCheck(self):
1185 | if self.Ui.radioButton_update_on.isChecked():
1186 | check = 1
1187 | self.add_text_main('[!]Update Checking!')
1188 | else:
1189 | check = 0
1190 | if UpdateCheckSwitch(check) == '1':
1191 | html2 = get_html('https://raw.githubusercontent.com/moyy996/AVDC/master/update_check.json')
1192 | if html2 == 'ProxyError':
1193 | return 'ProxyError'
1194 | html = json.loads(str(html2))
1195 | if float(self.version) < float(html['version']):
1196 | self.add_text_main('[*] * New update ' + html['version'] + ' *')
1197 | self.add_text_main('[*] ↓ Download ↓')
1198 | self.add_text_main('[*] ' + html['download'])
1199 | else:
1200 | self.add_text_main('[!]No Newer Version Available!')
1201 | return 'True'
1202 |
1203 | def CreatFailedFolder(self, failed_folder):
1204 | if not os.path.exists(failed_folder + '/'): # 新建failed文件夹
1205 | try:
1206 | os.makedirs(failed_folder + '/')
1207 | except Exception as error_info:
1208 | self.add_text_main('[-]Error in CreatFailedFolder: ' + str(error_info))
1209 |
1210 | def CEF(self, path):
1211 | dirs = os.listdir(path) # 获取路径下的子文件(夹)列表
1212 | for dir in dirs:
1213 | try:
1214 | os.removedirs(path + '/' + dir) # 删除这个空文件夹
1215 | self.add_text_main('[+]Deleting empty folder' + path + '/' + dir)
1216 | except:
1217 | print('[+]Deleting empty folder error!')
1218 |
1219 | def AVDC_Main(self):
1220 | # =======================================================================初始化所需变量
1221 | config_file = 'config.ini'
1222 | config = ConfigParser()
1223 | config.read(config_file, encoding='UTF-8')
1224 | success_folder = config['common']['success_output_folder']
1225 | failed_folder = config['common']['failed_output_folder'] # 失败输出目录
1226 | escape_folder = config['escape']['folders'] # 多级目录刮削需要排除的目录
1227 | # =======================================================================检测更新,判断网络情况,新建failed目录,获取影片列表
1228 | os.chdir(os.getcwd())
1229 | if self.UpdateCheck() == 'ProxyError':
1230 | self.add_text_main('[-]Connect Failed! Please check your Proxy or Network!')
1231 | self.Ui.pushButton_start_cap.setEnabled(True)
1232 | self.add_text_main("[*]======================================================")
1233 | return
1234 | self.CreatFailedFolder(failed_folder) # 新建failed文件夹
1235 | movie_list = movie_lists(escape_folder) # 获取所有需要刮削的影片列表
1236 | count = 0
1237 | count_all = str(len(movie_list))
1238 | self.add_text_main("[*]======================================================")
1239 | self.add_text_main('[+]Find ' + count_all + ' movies')
1240 | if config['common']['soft_link'] == '1':
1241 | self.add_text_main('[!] --- Soft link mode is ENABLE! ----')
1242 | # =======================================================================遍历电影列表 交给core处理
1243 | for movie in movie_list: # 遍历电影列表 交给core处理
1244 | count += 1
1245 | self.Ui.label_progress.setText(str(count) + '/' + str(count_all))
1246 | percentage = str(count / int(count_all) * 100)[:4] + '%'
1247 | value = int(count / int(count_all) * 100)
1248 | self.progressBarValue.emit(int(value))
1249 | self.add_text_main('[!] - ' + percentage + ' [' + str(count) + '/' + count_all + '] -')
1250 | try:
1251 | self.add_text_main("[!]Making Data for [" + movie + "], the number is [" + getNumber(movie) + "]")
1252 | if self.Core_Main(movie, getNumber(movie), 0, count) != 'not found':
1253 | node = QTreeWidgetItem(self.item_succ)
1254 | node.setText(0, str(count) + '.' + os.path.splitext(movie.split('/')[-1])[0])
1255 | self.item_succ.addChild(node)
1256 | self.add_text_main("[*]======================================================")
1257 | except Exception as error_info:
1258 | node = QTreeWidgetItem(self.item_fail)
1259 | node.setText(0, str(count) + '.' + os.path.splitext(movie.split('/')[-1])[0])
1260 | self.item_fail.addChild(node)
1261 | self.add_text_main('[-]Error in AVDC_Main: ' + str(error_info))
1262 | curr_path = str(os.getcwd()).replace('\\', '/')
1263 | if config['common']['soft_link'] == '1':
1264 | self.add_text_main('[-]Link ' + movie + ' to failed folder')
1265 | try:
1266 | os.symlink(movie, curr_path + '/' + 'failed/')
1267 | except Exception as error_info:
1268 | self.add_text_main('[-]Error in AVDC_Main: ' + str(error_info))
1269 | else:
1270 | try:
1271 | shutil.move(movie, curr_path + '/' + 'failed/')
1272 | self.add_text_main('[-]Move ' + movie + ' to failed folder')
1273 | except shutil.Error as error_info:
1274 | self.add_text_main('[-]Error in AVDC_Main: ' + str(error_info))
1275 | self.add_text_main("[*]======================================================")
1276 | continue
1277 | self.Ui.pushButton_start_cap.setEnabled(True)
1278 | self.CEF(success_folder)
1279 | self.add_text_main("[+]All finished!!!")
1280 |
1281 |
1282 | if __name__ == '__main__':
1283 | '''
1284 | 主函数
1285 | '''
1286 | app = QApplication(sys.argv)
1287 | ui = MyMAinWindow()
1288 | ui.show()
1289 | sys.exit(app.exec_())
1290 |
--------------------------------------------------------------------------------