Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f99def64bb | ||
|
|
94c4838b42 | ||
|
|
73c0126fb8 | ||
|
|
ae99c652f5 | ||
|
|
2b9ce63601 | ||
|
|
6928df8c3f | ||
|
|
8ccdf7dc5a | ||
|
|
b438312c97 | ||
|
|
fd05706636 | ||
|
|
1e407ef962 |
@@ -1,3 +1,4 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
@@ -18,18 +19,13 @@ if os.path.exists(config_file):
|
|||||||
else:
|
else:
|
||||||
print('[+]config.ini: not found, creating...')
|
print('[+]config.ini: not found, creating...')
|
||||||
with open("config.ini", "wt", encoding='UTF-8') as code:
|
with open("config.ini", "wt", encoding='UTF-8') as code:
|
||||||
print("[common]", file=code)
|
|
||||||
print("main_mode=1", file=code)
|
|
||||||
print("failed_output_folder=failed", file=code)
|
|
||||||
print("success_output_folder=JAV_output", file=code)
|
|
||||||
print("", file=code)
|
|
||||||
print("[proxy]",file=code)
|
print("[proxy]",file=code)
|
||||||
print("proxy=127.0.0.1:1080",file=code)
|
print("proxy=127.0.0.1:1080",file=code)
|
||||||
print("timeout=10", file=code)
|
print("timeout=10", file=code)
|
||||||
print("retry=3", file=code)
|
print("retry=3", file=code)
|
||||||
print("", file=code)
|
print("", file=code)
|
||||||
print("[Name_Rule]", file=code)
|
print("[Name_Rule]", file=code)
|
||||||
print("location_rule=actor+'/'+number",file=code)
|
print("location_rule='JAV_output/'+actor+'/'+number",file=code)
|
||||||
print("naming_rule=number+'-'+title",file=code)
|
print("naming_rule=number+'-'+title",file=code)
|
||||||
print("", file=code)
|
print("", file=code)
|
||||||
print("[update]",file=code)
|
print("[update]",file=code)
|
||||||
@@ -41,8 +37,10 @@ else:
|
|||||||
print("#plex only test!", file=code)
|
print("#plex only test!", file=code)
|
||||||
print("", file=code)
|
print("", file=code)
|
||||||
print("[directory_capture]", file=code)
|
print("[directory_capture]", file=code)
|
||||||
|
print("switch=0", file=code)
|
||||||
print("directory=", file=code)
|
print("directory=", file=code)
|
||||||
print("", file=code)
|
print("", file=code)
|
||||||
|
print("everyone switch:1=on, 0=off", file=code)
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
print('[+]config.ini: created!')
|
print('[+]config.ini: created!')
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ os.chdir(os.getcwd())
|
|||||||
|
|
||||||
# ============global var===========
|
# ============global var===========
|
||||||
|
|
||||||
version='1.1'
|
version='1.3'
|
||||||
|
|
||||||
config = ConfigParser()
|
config = ConfigParser()
|
||||||
config.read(config_file, encoding='UTF-8')
|
config.read(config_file, encoding='UTF-8')
|
||||||
@@ -36,36 +36,26 @@ def UpdateCheck():
|
|||||||
else:
|
else:
|
||||||
print('[+]Update Check disabled!')
|
print('[+]Update Check disabled!')
|
||||||
def movie_lists():
|
def movie_lists():
|
||||||
|
global exclude_directory_1
|
||||||
|
global exclude_directory_2
|
||||||
directory = config['directory_capture']['directory']
|
directory = config['directory_capture']['directory']
|
||||||
mp4=[]
|
total=[]
|
||||||
avi=[]
|
file_type = ['mp4','avi','rmvb','wmv','mov','mkv','flv','ts']
|
||||||
rmvb=[]
|
exclude_directory_1 = config['common']['failed_output_folder']
|
||||||
wmv=[]
|
exclude_directory_2 = config['common']['success_output_folder']
|
||||||
mov=[]
|
|
||||||
mkv=[]
|
|
||||||
flv=[]
|
|
||||||
ts=[]
|
|
||||||
if directory=='*':
|
if directory=='*':
|
||||||
|
remove_total = []
|
||||||
|
for o in file_type:
|
||||||
|
remove_total += glob.glob(r"./" + exclude_directory_1 + "/*." + o)
|
||||||
|
remove_total += glob.glob(r"./" + exclude_directory_2 + "/*." + o)
|
||||||
for i in os.listdir(os.getcwd()):
|
for i in os.listdir(os.getcwd()):
|
||||||
mp4 += glob.glob(r"./" + i + "/*.mp4")
|
for a in file_type:
|
||||||
avi += glob.glob(r"./" + i + "/*.avi")
|
total += glob.glob(r"./" + i + "/*." + a)
|
||||||
rmvb += glob.glob(r"./" + i + "/*.rmvb")
|
for b in remove_total:
|
||||||
wmv += glob.glob(r"./" + i + "/*.wmv")
|
total.remove(b)
|
||||||
mov += glob.glob(r"./" + i + "/*.mov")
|
|
||||||
mkv += glob.glob(r"./" + i + "/*.mkv")
|
|
||||||
flv += glob.glob(r"./" + i + "/*.flv")
|
|
||||||
ts += glob.glob(r"./" + i + "/*.ts")
|
|
||||||
total = mp4 + avi + rmvb + wmv + mov + mkv + flv + ts
|
|
||||||
return total
|
return total
|
||||||
mp4 = glob.glob(r"./" + directory + "/*.mp4")
|
for a in file_type:
|
||||||
avi = glob.glob(r"./" + directory + "/*.avi")
|
total += glob.glob(r"./" + directory + "/*." + a)
|
||||||
rmvb = glob.glob(r"./" + directory + "/*.rmvb")
|
|
||||||
wmv = glob.glob(r"./" + directory + "/*.wmv")
|
|
||||||
mov = glob.glob(r"./" + directory + "/*.mov")
|
|
||||||
mkv = glob.glob(r"./" + directory + "/*.mkv")
|
|
||||||
flv = glob.glob(r"./" + directory + "/*.flv")
|
|
||||||
ts = glob.glob(r"./" + directory + "/*.ts")
|
|
||||||
total = mp4 + avi + rmvb + wmv + mov + mkv + flv + ts
|
|
||||||
return total
|
return total
|
||||||
def CreatFailedFolder():
|
def CreatFailedFolder():
|
||||||
if not os.path.exists('failed/'): # 新建failed文件夹
|
if not os.path.exists('failed/'): # 新建failed文件夹
|
||||||
@@ -79,13 +69,13 @@ def lists_from_test(custom_nuber): #电影列表
|
|||||||
a.append(custom_nuber)
|
a.append(custom_nuber)
|
||||||
return a
|
return a
|
||||||
def CEF(path):
|
def CEF(path):
|
||||||
files = os.listdir(path) # 获取路径下的子文件(夹)列表
|
try:
|
||||||
for file in files:
|
files = os.listdir(path) # 获取路径下的子文件(夹)列表
|
||||||
try: #试图删除空目录,非空目录删除会报错
|
for file in files:
|
||||||
os.removedirs(path + '/' + file) # 删除这个空文件夹
|
os.removedirs(path + '/' + file) # 删除这个空文件夹
|
||||||
print('[+]Deleting empty folder',path + '/' + file)
|
print('[+]Deleting empty folder', path + '/' + file)
|
||||||
except:
|
except:
|
||||||
a=''
|
a=''
|
||||||
def rreplace(self, old, new, *max):
|
def rreplace(self, old, new, *max):
|
||||||
#从右开始替换文件名中内容,源字符串,将被替换的子字符串, 新字符串,用于替换old子字符串,可选字符串, 替换不超过 max 次
|
#从右开始替换文件名中内容,源字符串,将被替换的子字符串, 新字符串,用于替换old子字符串,可选字符串, 替换不超过 max 次
|
||||||
count = len(self)
|
count = len(self)
|
||||||
@@ -93,30 +83,27 @@ def rreplace(self, old, new, *max):
|
|||||||
count = max[0]
|
count = max[0]
|
||||||
return new.join(self.rsplit(old, count))
|
return new.join(self.rsplit(old, count))
|
||||||
def getNumber(filepath):
|
def getNumber(filepath):
|
||||||
|
filepath = filepath.replace('.\\','')
|
||||||
try: # 普通提取番号 主要处理包含减号-的番号
|
try: # 普通提取番号 主要处理包含减号-的番号
|
||||||
|
filepath = filepath.replace("_", "-")
|
||||||
|
filepath.strip('22-sht.me').strip('-HD').strip('-hd')
|
||||||
|
filename = str(re.sub("\[\d{4}-\d{1,2}-\d{1,2}\] - ", "", filepath)) # 去除文件名中时间
|
||||||
try:
|
try:
|
||||||
filepath1 = filepath.replace("_", "-")
|
|
||||||
filepath1.strip('22-sht.me').strip('-HD').strip('-hd')
|
|
||||||
filename = str(re.sub("\[\d{4}-\d{1,2}-\d{1,2}\] - ", "", filepath1)) # 去除文件名中时间
|
|
||||||
file_number = re.search('\w+-\d+', filename).group()
|
file_number = re.search('\w+-\d+', filename).group()
|
||||||
return file_number
|
except: # 提取类似mkbd-s120番号
|
||||||
except:
|
file_number = re.search('\w+-\w+\d+', filename).group()
|
||||||
filepath1 = filepath.replace("_", "-")
|
return file_number
|
||||||
filepath1.strip('22-sht.me').strip('-HD').strip('-hd')
|
|
||||||
filename = str(re.sub("\[\d{4}-\d{1,2}-\d{1,2}\] - ", "", filepath1)) # 去除文件名中时间
|
|
||||||
file_number = re.search('\w+-\w+', filename).group()
|
|
||||||
return file_number
|
|
||||||
except: # 提取不含减号-的番号
|
except: # 提取不含减号-的番号
|
||||||
try:
|
try:
|
||||||
filename1 = str(re.sub("ts6\d", "", filepath)).strip('Tokyo-hot').strip('tokyo-hot')
|
filename = str(re.sub("ts6\d", "", filepath)).strip('Tokyo-hot').strip('tokyo-hot')
|
||||||
filename0 = str(re.sub(".*?\.com-\d+", "", filename1)).strip('_')
|
filename = str(re.sub(".*?\.com-\d+", "", filename)).replace('_', '')
|
||||||
file_number = str(re.search('\w+\d{4}', filename0).group(0))
|
file_number = str(re.search('\w+\d{4}', filename).group(0))
|
||||||
return file_number
|
return file_number
|
||||||
except: # 提取无减号番号
|
except: # 提取无减号番号
|
||||||
filename1 = str(re.sub("ts6\d", "", filepath)) # 去除ts64/265
|
filename = str(re.sub("ts6\d", "", filepath)) # 去除ts64/265
|
||||||
filename0 = str(re.sub(".*?\.com-\d+", "", filename1))
|
filename = str(re.sub(".*?\.com-\d+", "", filename))
|
||||||
file_number2 = str(re.match('\w+', filename0).group())
|
file_number = str(re.match('\w+', filename).group())
|
||||||
file_number = str(file_number2.replace(re.match("^[A-Za-z]+", file_number2).group(),re.match("^[A-Za-z]+", file_number2).group() + '-'))
|
file_number = str(file_number.replace(re.match("^[A-Za-z]+", file_number).group(),re.match("^[A-Za-z]+", file_number).group() + '-'))
|
||||||
return file_number
|
return file_number
|
||||||
|
|
||||||
def RunCore():
|
def RunCore():
|
||||||
@@ -160,7 +147,7 @@ if __name__ =='__main__':
|
|||||||
shutil.move(i, str(os.getcwd()) + '/' + 'failed/')
|
shutil.move(i, str(os.getcwd()) + '/' + 'failed/')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
CEF(exclude_directory_1)
|
||||||
CEF('JAV_output')
|
CEF(exclude_directory_2)
|
||||||
print("[+]All finished!!!")
|
print("[+]All finished!!!")
|
||||||
input("[+][+]Press enter key exit, you can check the error messge before you exit.\n[+][+]按回车键结束,你可以在结束之前查看和错误信息。")
|
input("[+][+]Press enter key exit, you can check the error messge before you exit.\n[+][+]按回车键结束,你可以在结束之前查看和错误信息。")
|
||||||
19
README.md
19
README.md
@@ -30,10 +30,11 @@
|
|||||||
* [写在后面](#9写在后面)
|
* [写在后面](#9写在后面)
|
||||||
|
|
||||||
# 免责声明
|
# 免责声明
|
||||||
1.本软件仅供**技术交流,学术交流**使用,本项目旨在学习 Python3<br>
|
* 本软件仅供**技术交流,学术交流**使用,本项目旨在学习 Python3<br>
|
||||||
2.本软件禁止用于任何非法用途<br>
|
* 本软件禁止用于任何非法用途<br>
|
||||||
3.使用者使用该软件产生的一切法律后果由使用者承担<br>
|
* 使用者使用该软件产生的一切法律后果由使用者承担<br>
|
||||||
4.不可使用于商业和个人其他意图<br>
|
* 不可使用于商业和个人其他意图<br>
|
||||||
|
* 使用该软件前,请自觉遵守当地法律法规
|
||||||
|
|
||||||
# 注意
|
# 注意
|
||||||
**推荐用法: 使用该软件后,对于不能正常获取元数据的电影可以用 Everaver 来补救**<br>
|
**推荐用法: 使用该软件后,对于不能正常获取元数据的电影可以用 Everaver 来补救**<br>
|
||||||
@@ -163,12 +164,18 @@ config.ini
|
|||||||
可选择emby, plex<br>
|
可选择emby, plex<br>
|
||||||
如果是PLEX,请安装插件:```XBMCnfoMoviesImporter```
|
如果是PLEX,请安装插件:```XBMCnfoMoviesImporter```
|
||||||
|
|
||||||
|
---
|
||||||
|
#### 调试模式
|
||||||
|
>[debug_mode]<br>switch=1<br>
|
||||||
|
|
||||||
|
如要开启调试模式,请手动输入以上代码到```config.ini```中,开启后可在抓取中显示影片元数据
|
||||||
|
|
||||||
---
|
---
|
||||||
#### 抓取目录选择
|
#### 抓取目录选择
|
||||||
>[directory_capture]<br>
|
>[directory_capture]<br>
|
||||||
>directory=<br>
|
>directory=<br>
|
||||||
如果directory后面为空,则抓取和程序同一目录下的影片,设置为``` * ```可抓取软件所在目录下的所有子目录中的影片
|
如果directory后面为空,则抓取和程序同一目录下的影片,设置为``` * ```可抓取软件所在目录下的所有子目录中的影片
|
||||||
## 3.(可选)设置自定义目录和影片重命名规则
|
### 3.(可选)设置自定义目录和影片重命名规则
|
||||||
>[Name_Rule]<br>
|
>[Name_Rule]<br>
|
||||||
>location_rule=actor+'/'+number<br>
|
>location_rule=actor+'/'+number<br>
|
||||||
>naming_rule=number+'-'+title<br>
|
>naming_rule=number+'-'+title<br>
|
||||||
@@ -196,10 +203,10 @@ config.ini
|
|||||||
目录结构规则:默认 ```location_rule=actor+'/'+number```<br> **不推荐修改时在这里添加title**,有时title过长,因为Windows API问题,抓取数据时新建文件夹容易出错。<br>
|
目录结构规则:默认 ```location_rule=actor+'/'+number```<br> **不推荐修改时在这里添加title**,有时title过长,因为Windows API问题,抓取数据时新建文件夹容易出错。<br>
|
||||||
影片命名规则:默认 ```naming_rule=number+'-'+title```<br> **在EMBY,KODI等本地媒体库显示的标题,不影响目录结构下影片文件的命名**,依旧是 番号+后缀。
|
影片命名规则:默认 ```naming_rule=number+'-'+title```<br> **在EMBY,KODI等本地媒体库显示的标题,不影响目录结构下影片文件的命名**,依旧是 番号+后缀。
|
||||||
|
|
||||||
---
|
|
||||||
### 更新开关
|
### 更新开关
|
||||||
>[update]<br>update_check=1<br>
|
>[update]<br>update_check=1<br>
|
||||||
1为开,0为关
|
1为开,0为关
|
||||||
|
|
||||||
## 4.建议把软件拷贝和电影的统一目录下
|
## 4.建议把软件拷贝和电影的统一目录下
|
||||||
如果```config.ini```中```directory=```后面为空的情况下
|
如果```config.ini```中```directory=```后面为空的情况下
|
||||||
## 5.运行 ```AV_Data_capture.py/.exe```
|
## 5.运行 ```AV_Data_capture.py/.exe```
|
||||||
|
|||||||
179
core.py
179
core.py
@@ -18,14 +18,13 @@ import javbus
|
|||||||
import javdb
|
import javdb
|
||||||
#=========website========
|
#=========website========
|
||||||
|
|
||||||
|
#初始化全局变量
|
||||||
Config = ConfigParser()
|
Config = ConfigParser()
|
||||||
Config.read(config_file, encoding='UTF-8')
|
Config.read(config_file, encoding='UTF-8')
|
||||||
try:
|
try:
|
||||||
option = ReadMediaWarehouse()
|
option = ReadMediaWarehouse()
|
||||||
except:
|
except:
|
||||||
print('[-]Config media_warehouse read failed!')
|
print('[-]Config media_warehouse read failed!')
|
||||||
|
|
||||||
#初始化全局变量
|
|
||||||
title=''
|
title=''
|
||||||
studio=''
|
studio=''
|
||||||
year=''
|
year=''
|
||||||
@@ -40,6 +39,8 @@ cover=''
|
|||||||
imagecut=''
|
imagecut=''
|
||||||
tag=[]
|
tag=[]
|
||||||
cn_sub=''
|
cn_sub=''
|
||||||
|
multi_part=0
|
||||||
|
part=''
|
||||||
path=''
|
path=''
|
||||||
houzhui=''
|
houzhui=''
|
||||||
website=''
|
website=''
|
||||||
@@ -48,10 +49,11 @@ actor_photo={}
|
|||||||
cover_small=''
|
cover_small=''
|
||||||
naming_rule =''#eval(config['Name_Rule']['naming_rule'])
|
naming_rule =''#eval(config['Name_Rule']['naming_rule'])
|
||||||
location_rule=''#eval(config['Name_Rule']['location_rule'])
|
location_rule=''#eval(config['Name_Rule']['location_rule'])
|
||||||
program_mode = Config['common']['main_mode']
|
program_mode = Config['common']['main_mode']
|
||||||
failed_folder= Config['common']['failed_output_folder']
|
failed_folder = Config['common']['failed_output_folder']
|
||||||
success_folder=Config['common']['success_output_folder']
|
success_folder = Config['common']['success_output_folder']
|
||||||
#=====================本地文件处理===========================
|
#=====================本地文件处理===========================
|
||||||
|
|
||||||
def moveFailedFolder():
|
def moveFailedFolder():
|
||||||
global filepath
|
global filepath
|
||||||
print('[-]Move to Failed output folder')
|
print('[-]Move to Failed output folder')
|
||||||
@@ -94,41 +96,40 @@ def getDataFromJSON(file_number): #从JSON返回元数据
|
|||||||
global website
|
global website
|
||||||
global actor_photo
|
global actor_photo
|
||||||
global cover_small
|
global cover_small
|
||||||
|
global json_data
|
||||||
|
|
||||||
global naming_rule
|
global naming_rule
|
||||||
global location_rule
|
global location_rule
|
||||||
|
|
||||||
|
|
||||||
# ================================================网站规则添加开始================================================
|
# ================================================网站规则添加开始================================================
|
||||||
|
|
||||||
try: # 添加 需要 正则表达式的规则
|
if re.match('^\d{5,}', file_number):
|
||||||
if re.search('^\d{5,}', file_number).group() in file_number:
|
json_data = json.loads(avsox.main(file_number))
|
||||||
json_data = json.loads(avsox.main(file_number))
|
if getDataState(json_data) == 0: # 如果元数据获取失败,请求番号至其他网站抓取
|
||||||
if getDataState(json_data) == 0: #如果元数据获取失败,请求番号至其他网站抓取
|
json_data = json.loads(javdb.main(file_number))
|
||||||
json_data = json.loads(javdb.main(file_number))
|
#==
|
||||||
|
elif re.match('\d+\D+', file_number):
|
||||||
elif re.search('\d+\D+', file_number).group() in file_number:
|
json_data = json.loads(siro.main(file_number))
|
||||||
json_data = json.loads(siro.main(file_number))
|
if getDataState(json_data) == 0: # 如果元数据获取失败,请求番号至其他网站抓取
|
||||||
if getDataState(json_data) == 0: #如果元数据获取失败,请求番号至其他网站抓取
|
|
||||||
json_data = json.loads(javbus.main(file_number))
|
|
||||||
elif getDataState(json_data) == 0: #如果元数据获取失败,请求番号至其他网站抓取
|
|
||||||
json_data = json.loads(javdb.main(file_number))
|
|
||||||
|
|
||||||
except: # 添加 无需 正则表达式的规则
|
|
||||||
if 'fc2' in file_number:
|
|
||||||
json_data = json.loads(fc2fans_club.main(file_number.strip('fc2_').strip('fc2-').strip('ppv-').strip('PPV-').strip('FC2_').strip('FC2-').strip('ppv-').strip('PPV-')))
|
|
||||||
elif 'FC2' in file_number:
|
|
||||||
json_data = json.loads(fc2fans_club.main(file_number.strip('FC2_').strip('FC2-').strip('ppv-').strip('PPV-').strip('fc2_').strip('fc2-').strip('ppv-').strip('PPV-')))
|
|
||||||
elif 'HEYZO' in number or 'heyzo' in number or 'Heyzo' in number:
|
|
||||||
json_data = json.loads(avsox.main(file_number))
|
|
||||||
elif 'siro' in file_number or 'SIRO' in file_number or 'Siro' in file_number:
|
|
||||||
json_data = json.loads(siro.main(file_number))
|
|
||||||
else:
|
|
||||||
json_data = json.loads(javbus.main(file_number))
|
json_data = json.loads(javbus.main(file_number))
|
||||||
if getDataState(json_data) == 0: #如果元数据获取失败,请求番号至其他网站抓取
|
elif getDataState(json_data) == 0: # 如果元数据获取失败,请求番号至其他网站抓取
|
||||||
json_data = json.loads(avsox.main(file_number))
|
json_data = json.loads(javdb.main(file_number))
|
||||||
elif getDataState(json_data) == 0: #如果元数据获取失败,请求番号至其他网站抓取
|
# ==
|
||||||
json_data = json.loads(javdb.main(file_number))
|
elif 'fc2' in file_number or 'FC2' in file_number:
|
||||||
|
json_data = json.loads(fc2fans_club.main(file_number))
|
||||||
|
# ==
|
||||||
|
elif 'HEYZO' in number or 'heyzo' in number or 'Heyzo' in number:
|
||||||
|
json_data = json.loads(avsox.main(file_number))
|
||||||
|
# ==
|
||||||
|
elif 'siro' in file_number or 'SIRO' in file_number or 'Siro' in file_number:
|
||||||
|
json_data = json.loads(siro.main(file_number))
|
||||||
|
# ==
|
||||||
|
else:
|
||||||
|
json_data = json.loads(javbus.main(file_number))
|
||||||
|
if getDataState(json_data) == 0: # 如果元数据获取失败,请求番号至其他网站抓取
|
||||||
|
json_data = json.loads(avsox.main(file_number))
|
||||||
|
elif getDataState(json_data) == 0: # 如果元数据获取失败,请求番号至其他网站抓取
|
||||||
|
json_data = json.loads(javdb.main(file_number))
|
||||||
|
|
||||||
# ================================================网站规则添加结束================================================
|
# ================================================网站规则添加结束================================================
|
||||||
|
|
||||||
@@ -145,9 +146,9 @@ def getDataFromJSON(file_number): #从JSON返回元数据
|
|||||||
try:
|
try:
|
||||||
cover_small = json_data['cover_small']
|
cover_small = json_data['cover_small']
|
||||||
except:
|
except:
|
||||||
aaaaaaa=''
|
cover_small=''
|
||||||
imagecut = json_data['imagecut']
|
imagecut = json_data['imagecut']
|
||||||
tag = str(json_data['tag']).strip("[ ]").replace("'", '').replace(" ", '').split(',') # 字符串转列表
|
tag = str(json_data['tag']).strip("[ ]").replace("'", '').replace(" ", '').split(',') # 字符串转列表 @
|
||||||
actor = str(actor_list).strip("[ ]").replace("'", '').replace(" ", '')
|
actor = str(actor_list).strip("[ ]").replace("'", '').replace(" ", '')
|
||||||
actor_photo = json_data['actor_photo']
|
actor_photo = json_data['actor_photo']
|
||||||
website = json_data['website']
|
website = json_data['website']
|
||||||
@@ -162,24 +163,15 @@ def getDataFromJSON(file_number): #从JSON返回元数据
|
|||||||
|
|
||||||
|
|
||||||
# ====================处理异常字符====================== #\/:*?"<>|
|
# ====================处理异常字符====================== #\/:*?"<>|
|
||||||
if '\\' in title:
|
title = title.replace('\\', '')
|
||||||
title=title.replace('\\', ' ')
|
title = title.replace('/', '')
|
||||||
elif r'/' in title:
|
title = title.replace(':', '')
|
||||||
title=title.replace(r'/', '')
|
title = title.replace('*', '')
|
||||||
elif ':' in title:
|
title = title.replace('?', '')
|
||||||
title=title.replace(':', '')
|
title = title.replace('"', '')
|
||||||
elif '*' in title:
|
title = title.replace('<', '')
|
||||||
title=title.replace('*', '')
|
title = title.replace('>', '')
|
||||||
elif '?' in title:
|
title = title.replace('|', '')
|
||||||
title=title.replace('?', '')
|
|
||||||
elif '"' in title:
|
|
||||||
title=title.replace('"', '')
|
|
||||||
elif '<' in title:
|
|
||||||
title=title.replace('<', '')
|
|
||||||
elif '>' in title:
|
|
||||||
title=title.replace('>', '')
|
|
||||||
elif '|' in title:
|
|
||||||
title=title.replace('|', '')
|
|
||||||
# ====================处理异常字符 END================== #\/:*?"<>|
|
# ====================处理异常字符 END================== #\/:*?"<>|
|
||||||
|
|
||||||
naming_rule = eval(config['Name_Rule']['naming_rule'])
|
naming_rule = eval(config['Name_Rule']['naming_rule'])
|
||||||
@@ -204,9 +196,8 @@ def smallCoverCheck():
|
|||||||
def creatFolder(): #创建文件夹
|
def creatFolder(): #创建文件夹
|
||||||
global actor
|
global actor
|
||||||
global path
|
global path
|
||||||
if len(actor) > 240: #新建成功输出文件夹
|
if len(os.getcwd()+path) > 240: #新建成功输出文件夹
|
||||||
path = success_folder+'/'+location_rule.replace("'actor'","'超多人'",3).replace("actor","'超多人'",3) #path为影片+元数据所在目录
|
path = success_folder+'/'+location_rule.replace("'actor'","'超多人'",3).replace("actor","'超多人'",3) #path为影片+元数据所在目录
|
||||||
#print(path)
|
|
||||||
else:
|
else:
|
||||||
path = success_folder+'/'+location_rule
|
path = success_folder+'/'+location_rule
|
||||||
#print(path)
|
#print(path)
|
||||||
@@ -272,17 +263,19 @@ def imageDownload(filepath): #封面是否下载成功,否则移动到failed
|
|||||||
if DownloadFileWithFilename(cover, number + '.jpg', path) == 'failed':
|
if DownloadFileWithFilename(cover, number + '.jpg', path) == 'failed':
|
||||||
moveFailedFolder()
|
moveFailedFolder()
|
||||||
DownloadFileWithFilename(cover, number + '.jpg', path)
|
DownloadFileWithFilename(cover, number + '.jpg', path)
|
||||||
print('[+]Image Downloaded!', path + '/' + number + '.jpg')
|
if multi_part == 1:
|
||||||
|
old_name = os.path.join(path, number + '.jpg')
|
||||||
|
new_name = os.path.join(path, number + part + '.jpg')
|
||||||
|
os.rename(old_name, new_name)
|
||||||
|
print('[+]Image Downloaded!', path + '/' + number + part + '.jpg')
|
||||||
|
else:
|
||||||
|
print('[+]Image Downloaded!', path + '/' + number + '.jpg')
|
||||||
elif option == 'plex':
|
elif option == 'plex':
|
||||||
if DownloadFileWithFilename(cover, 'fanart.jpg', path) == 'failed':
|
if DownloadFileWithFilename(cover, 'fanart.jpg', path) == 'failed':
|
||||||
moveFailedFolder()
|
moveFailedFolder()
|
||||||
DownloadFileWithFilename(cover, 'fanart.jpg', path)
|
DownloadFileWithFilename(cover, 'fanart.jpg', path)
|
||||||
print('[+]Image Downloaded!', path + '/fanart.jpg')
|
print('[+]Image Downloaded!', path + '/fanart.jpg')
|
||||||
def PrintFiles(filepath):
|
def PrintFiles(filepath):
|
||||||
#global path
|
|
||||||
global title
|
|
||||||
global cn_sub
|
|
||||||
global actor_photo
|
|
||||||
try:
|
try:
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
@@ -316,12 +309,12 @@ def PrintFiles(filepath):
|
|||||||
if cn_sub == '1':
|
if cn_sub == '1':
|
||||||
print(" <tag>中文字幕</tag>", file=code)
|
print(" <tag>中文字幕</tag>", file=code)
|
||||||
try:
|
try:
|
||||||
for i in tag:
|
for i in str(json_data['tag']).strip("[ ]").replace("'", '').replace(" ", '').split(','):
|
||||||
print(" <tag>" + i + "</tag>", file=code)
|
print(" <tag>" + i + "</tag>", file=code)
|
||||||
except:
|
except:
|
||||||
aaaaa = ''
|
aaaaa = ''
|
||||||
try:
|
try:
|
||||||
for i in tag:
|
for i in str(json_data['tag']).strip("[ ]").replace("'", '').replace(" ", '').split(','):
|
||||||
print(" <genre>" + i + "</genre>", file=code)
|
print(" <genre>" + i + "</genre>", file=code)
|
||||||
except:
|
except:
|
||||||
aaaaaaaa = ''
|
aaaaaaaa = ''
|
||||||
@@ -430,15 +423,8 @@ def pasteFileToFolder(filepath, path): #文件路径,番号,后缀,要移
|
|||||||
print('[-]File Exists! Please check your movie!')
|
print('[-]File Exists! Please check your movie!')
|
||||||
print('[-]move to the root folder of the program.')
|
print('[-]move to the root folder of the program.')
|
||||||
os._exit(0)
|
os._exit(0)
|
||||||
def pasteFileToFolder_mode2(filepath, path): #文件路径,番号,后缀,要移动至的位置
|
except PermissionError:
|
||||||
global houzhui
|
print('[-]Error! Please run as administrator!')
|
||||||
houzhui = str(re.search('[.](AVI|RMVB|WMV|MOV|MP4|MKV|FLV|TS|avi|rmvb|wmv|mov|mp4|mkv|flv|ts)$', filepath).group())
|
|
||||||
try:
|
|
||||||
os.rename(filepath, path + houzhui)
|
|
||||||
print('[+]Movie ' + number + ' move to target folder Finished!')
|
|
||||||
except:
|
|
||||||
print('[-]File Exists! Please check your movie!')
|
|
||||||
print('[-]move to the root folder of the program.')
|
|
||||||
os._exit(0)
|
os._exit(0)
|
||||||
def renameJpgToBackdrop_copy():
|
def renameJpgToBackdrop_copy():
|
||||||
if option == 'plex':
|
if option == 'plex':
|
||||||
@@ -446,10 +432,40 @@ def renameJpgToBackdrop_copy():
|
|||||||
shutil.copy(path + '/poster.png', path + '/thumb.png')
|
shutil.copy(path + '/poster.png', path + '/thumb.png')
|
||||||
if option == 'emby':
|
if option == 'emby':
|
||||||
shutil.copy(path + '/' + number + '.jpg', path + '/Backdrop.jpg')
|
shutil.copy(path + '/' + number + '.jpg', path + '/Backdrop.jpg')
|
||||||
|
def renameBackdropToJpg_copy():
|
||||||
|
if option == 'plex':
|
||||||
|
shutil.copy(path + '/fanart.jpg', path + '/Backdrop.jpg')
|
||||||
|
shutil.copy(path + '/poster.png', path + '/thumb.png')
|
||||||
|
if option == 'emby':
|
||||||
|
shutil.copy(path + '/Backdrop.jpg', path + '/' + number + '.jpg')
|
||||||
|
print('[+]Image Downloaded!', path + '/' + number + '.jpg')
|
||||||
|
def get_part(filepath):
|
||||||
|
try:
|
||||||
|
if re.search('-CD\d+', filepath):
|
||||||
|
return re.findall('-CD\d+', filepath)[0]
|
||||||
|
except:
|
||||||
|
print("[-]failed!Please rename the filename again!")
|
||||||
|
moveFailedFolder()
|
||||||
|
def debug_mode():
|
||||||
|
try:
|
||||||
|
if config['debug_mode']['switch'] == '1':
|
||||||
|
print('[+] ---Debug info---')
|
||||||
|
for i, v in json_data.items():
|
||||||
|
if i == 'outline':
|
||||||
|
print('[+] -', i, ':', len(v), 'characters')
|
||||||
|
continue
|
||||||
|
if i == 'actor_photo' or i == 'year':
|
||||||
|
continue
|
||||||
|
print('[+] -', i, ':', v)
|
||||||
|
print('[+] ---Debug info---')
|
||||||
|
except:
|
||||||
|
aaa=''
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
filepath=argparse_get_file()[0] #影片的路径
|
filepath=argparse_get_file()[0] #影片的路径
|
||||||
|
|
||||||
|
if '-CD' in filepath or '-cd' in filepath:
|
||||||
|
multi_part = 1
|
||||||
|
part = get_part(filepath)
|
||||||
if '-c.' in filepath or '-C.' in filepath or '中文' in filepath or '字幕' in filepath:
|
if '-c.' in filepath or '-C.' in filepath or '中文' in filepath or '字幕' in filepath:
|
||||||
cn_sub='1'
|
cn_sub='1'
|
||||||
|
|
||||||
@@ -464,13 +480,20 @@ if __name__ == '__main__':
|
|||||||
number = argparse_get_file()[1]
|
number = argparse_get_file()[1]
|
||||||
CreatFailedFolder()
|
CreatFailedFolder()
|
||||||
getDataFromJSON(number) # 定义番号
|
getDataFromJSON(number) # 定义番号
|
||||||
|
debug_mode()
|
||||||
creatFolder() # 创建文件夹
|
creatFolder() # 创建文件夹
|
||||||
if program_mode == '1':
|
if program_mode == '1':
|
||||||
imageDownload(filepath) # creatFoder会返回番号路径
|
if part == '-CD1' or multi_part == 0:
|
||||||
PrintFiles(filepath) # 打印文件
|
smallCoverCheck()
|
||||||
smallCoverCheck()
|
imageDownload(filepath) # creatFoder会返回番号路径
|
||||||
cutImage() # 裁剪图
|
if multi_part == 1:
|
||||||
|
number += part
|
||||||
|
PrintFiles(filepath) # 打印文件
|
||||||
|
cutImage() # 裁剪图
|
||||||
|
renameJpgToBackdrop_copy()
|
||||||
|
else:
|
||||||
|
number += part
|
||||||
|
renameBackdropToJpg_copy()
|
||||||
pasteFileToFolder(filepath, path) # 移动文件
|
pasteFileToFolder(filepath, path) # 移动文件
|
||||||
renameJpgToBackdrop_copy()
|
|
||||||
elif program_mode == '2':
|
elif program_mode == '2':
|
||||||
pasteFileToFolder_mode2(filepath, path) # 移动文件
|
pasteFileToFolder(filepath, path) # 移动文件
|
||||||
|
|||||||
@@ -4,51 +4,43 @@ import json
|
|||||||
import ADC_function
|
import ADC_function
|
||||||
|
|
||||||
def getTitle(htmlcode): #获取厂商
|
def getTitle(htmlcode): #获取厂商
|
||||||
#print(htmlcode)
|
|
||||||
html = etree.fromstring(htmlcode,etree.HTMLParser())
|
html = etree.fromstring(htmlcode,etree.HTMLParser())
|
||||||
result = str(html.xpath('/html/body/div[2]/div/div[1]/h3/text()')).strip(" ['']")
|
result = str(html.xpath('//*[@id="container"]/div[1]/div/article/section[1]/h2/text()')).strip(" ['']")
|
||||||
result2 = str(re.sub('\D{2}2-\d+','',result)).replace(' ','',1)
|
return result
|
||||||
#print(result2)
|
|
||||||
return result2
|
|
||||||
def getActor(htmlcode):
|
def getActor(htmlcode):
|
||||||
try:
|
try:
|
||||||
html = etree.fromstring(htmlcode, etree.HTMLParser())
|
html = etree.fromstring(htmlcode, etree.HTMLParser())
|
||||||
result = str(html.xpath('/html/body/div[2]/div/div[1]/h5[5]/a/text()')).strip(" ['']")
|
result = str(html.xpath('//*[@id="container"]/div[1]/div/article/section[1]/div/div[2]/dl/dd[5]/a/text()')).strip(" ['']")
|
||||||
return result
|
return result
|
||||||
except:
|
except:
|
||||||
return ''
|
return ''
|
||||||
def getStudio(htmlcode): #获取厂商
|
def getStudio(htmlcode): #获取厂商
|
||||||
html = etree.fromstring(htmlcode,etree.HTMLParser())
|
try:
|
||||||
result = str(html.xpath('/html/body/div[2]/div/div[1]/h5[3]/a[1]/text()')).strip(" ['']")
|
html = etree.fromstring(htmlcode, etree.HTMLParser())
|
||||||
return result
|
result = str(html.xpath('//*[@id="container"]/div[1]/div/article/section[1]/div/div[2]/dl/dd[5]/a/text()')).strip(" ['']")
|
||||||
|
return result
|
||||||
|
except:
|
||||||
|
return ''
|
||||||
def getNum(htmlcode): #获取番号
|
def getNum(htmlcode): #获取番号
|
||||||
html = etree.fromstring(htmlcode, etree.HTMLParser())
|
html = etree.fromstring(htmlcode, etree.HTMLParser())
|
||||||
result = str(html.xpath('/html/body/div[5]/div[1]/div[2]/p[1]/span[2]/text()')).strip(" ['']")
|
result = str(html.xpath('/html/body/div[5]/div[1]/div[2]/p[1]/span[2]/text()')).strip(" ['']")
|
||||||
#print(result)
|
|
||||||
return result
|
return result
|
||||||
def getRelease(htmlcode2): #
|
def getRelease(htmlcode2): #
|
||||||
#a=ADC_function.get_html('http://adult.contents.fc2.com/article_search.php?id='+str(number).lstrip("FC2-").lstrip("fc2-").lstrip("fc2_").lstrip("fc2-")+'&utm_source=aff_php&utm_medium=source_code&utm_campaign=from_aff_php')
|
|
||||||
html=etree.fromstring(htmlcode2,etree.HTMLParser())
|
html=etree.fromstring(htmlcode2,etree.HTMLParser())
|
||||||
result = str(html.xpath('//*[@id="container"]/div[1]/div/article/section[1]/div/div[2]/dl/dd[4]/text()')).strip(" ['']")
|
result = str(html.xpath('//*[@id="container"]/div[1]/div/article/section[1]/div/div[2]/dl/dd[4]/text()')).strip(" ['']")
|
||||||
return result
|
return result
|
||||||
def getCover(htmlcode,number,htmlcode2): #获取厂商 #
|
def getCover(htmlcode2): #获取厂商 #
|
||||||
#a = ADC_function.get_html('http://adult.contents.fc2.com/article_search.php?id=' + str(number).lstrip("FC2-").lstrip("fc2-").lstrip("fc2_").lstrip("fc2-") + '&utm_source=aff_php&utm_medium=source_code&utm_campaign=from_aff_php')
|
|
||||||
html = etree.fromstring(htmlcode2, etree.HTMLParser())
|
html = etree.fromstring(htmlcode2, etree.HTMLParser())
|
||||||
result = str(html.xpath('//*[@id="container"]/div[1]/div/article/section[1]/div/div[1]/a/img/@src')).strip(" ['']")
|
result = str(html.xpath('//*[@id="container"]/div[1]/div/article/section[1]/div/div[1]/a/img/@src')).strip(" ['']")
|
||||||
if result == '':
|
|
||||||
html = etree.fromstring(htmlcode, etree.HTMLParser())
|
|
||||||
result2 = str(html.xpath('//*[@id="slider"]/ul[1]/li[1]/img/@src')).strip(" ['']")
|
|
||||||
return 'http://fc2fans.club' + result2
|
|
||||||
return 'http:' + result
|
return 'http:' + result
|
||||||
def getOutline(htmlcode2,number): #获取番号 #
|
def getOutline(htmlcode2): #获取番号 #
|
||||||
#a = ADC_function.get_html('http://adult.contents.fc2.com/article_search.php?id=' + str(number).lstrip("FC2-").lstrip("fc2-").lstrip("fc2_").lstrip("fc2-") + '&utm_source=aff_php&utm_medium=source_code&utm_campaign=from_aff_php')
|
|
||||||
html = etree.fromstring(htmlcode2, etree.HTMLParser())
|
html = etree.fromstring(htmlcode2, etree.HTMLParser())
|
||||||
result = str(html.xpath('//*[@id="container"]/div[1]/div/article/section[4]/p/text()')).replace("\\n",'',10000).strip(" ['']").replace("'",'',10000)
|
result = str(html.xpath('//*[@id="container"]/div[1]/div/article/section[4]/p/text()')).strip(" ['']").replace("\\n",'',10000).replace("'",'',10000).replace(', ,','').strip(' ').replace('。,',',')
|
||||||
return result
|
return result
|
||||||
def getTag(htmlcode): #获取番号
|
def getTag(htmlcode): #获取番号
|
||||||
html = etree.fromstring(htmlcode, etree.HTMLParser())
|
html = etree.fromstring(htmlcode, etree.HTMLParser())
|
||||||
result = str(html.xpath('/html/body/div[2]/div/div[1]/h5[4]/a/text()'))
|
result = html.xpath('//*[@id="container"]/div[1]/div/article/section[6]/ul/li/a/text()')
|
||||||
return result.strip(" ['']").replace("'",'').replace(' ','')
|
return result
|
||||||
def getYear(release):
|
def getYear(release):
|
||||||
try:
|
try:
|
||||||
result = re.search('\d{4}',release).group()
|
result = re.search('\d{4}',release).group()
|
||||||
@@ -56,30 +48,28 @@ def getYear(release):
|
|||||||
except:
|
except:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
def main(number2):
|
def main(number):
|
||||||
number=number2.replace('PPV','').replace('ppv','')
|
number=number.replace('PPV','').replace('ppv','').strip('fc2_').strip('fc2-').strip('ppv-').strip('PPV-').strip('FC2_').strip('FC2-').strip('ppv-').strip('PPV-').replace('fc2ppv-','').replace('FC2PPV-','')
|
||||||
htmlcode2 = ADC_function.get_html('http://adult.contents.fc2.com/article_search.php?id='+str(number).lstrip("FC2-").lstrip("fc2-").lstrip("fc2_").lstrip("fc2-")+'&utm_source=aff_php&utm_medium=source_code&utm_campaign=from_aff_php')
|
htmlcode2 = ADC_function.get_html('http://adult.contents.fc2.com/article_search.php?id='+str(number).lstrip("FC2-").lstrip("fc2-").lstrip("fc2_").lstrip("fc2-")+'')
|
||||||
htmlcode = ADC_function.get_html('http://fc2fans.club/html/FC2-' + number + '.html')
|
#htmlcode = ADC_function.get_html('http://fc2fans.club/html/FC2-' + number + '.html')
|
||||||
dic = {
|
dic = {
|
||||||
'title': getTitle(htmlcode),
|
'title': getTitle(htmlcode2),
|
||||||
'studio': getStudio(htmlcode),
|
'studio': getStudio(htmlcode2),
|
||||||
'year': '',#str(re.search('\d{4}',getRelease(number)).group()),
|
'year': getYear(getRelease(htmlcode2)),
|
||||||
'outline': getOutline(htmlcode,number),
|
'outline': getOutline(htmlcode2),
|
||||||
'runtime': getYear(getRelease(htmlcode)),
|
'runtime': getYear(getRelease(htmlcode2)),
|
||||||
'director': getStudio(htmlcode),
|
'director': getStudio(htmlcode2),
|
||||||
'actor': getActor(htmlcode),
|
'actor': getStudio(htmlcode2),
|
||||||
'release': getRelease(number),
|
'release': getRelease(htmlcode2),
|
||||||
'number': 'FC2-'+number,
|
'number': 'FC2-'+number,
|
||||||
'cover': getCover(htmlcode,number,htmlcode2),
|
'cover': getCover(htmlcode2),
|
||||||
'imagecut': 0,
|
'imagecut': 0,
|
||||||
'tag': getTag(htmlcode),
|
'tag': getTag(htmlcode2),
|
||||||
'actor_photo':'',
|
'actor_photo':'',
|
||||||
'website': 'http://fc2fans.club/html/FC2-' + number + '.html',
|
'website': 'http://adult.contents.fc2.com/article_search.php?id=' + number,
|
||||||
'source': 'fc2fans_club.py',
|
'source': 'fc2fans_club.py',
|
||||||
}
|
}
|
||||||
#print(getTitle(htmlcode))
|
|
||||||
#print(getNum(htmlcode))
|
|
||||||
js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'),)#.encode('UTF-8')
|
js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'),)#.encode('UTF-8')
|
||||||
return js
|
return js
|
||||||
|
|
||||||
#print(main('1051725'))
|
#print(main('1145465'))
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "1.1",
|
"version": "1.3",
|
||||||
"version_show":"Beta 1.1",
|
"version_show":"1.3",
|
||||||
"download": "https://github.com/wenead99/AV_Data_Capture/releases"
|
"download": "https://github.com/wenead99/AV_Data_Capture/releases"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user