Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
153b4699fe | ||
|
|
4bf915d916 |
+98
-65
@@ -6,14 +6,38 @@ import os
|
|||||||
import time
|
import time
|
||||||
import re
|
import re
|
||||||
from ADC_function import *
|
from ADC_function import *
|
||||||
from core import *
|
|
||||||
import json
|
import json
|
||||||
import shutil
|
import shutil
|
||||||
import fnmatch
|
import fnmatch
|
||||||
from configparser import ConfigParser
|
from configparser import ConfigParser
|
||||||
|
os.chdir(os.getcwd())
|
||||||
|
|
||||||
|
# ============global var===========
|
||||||
|
|
||||||
def UpdateCheck(version):
|
version='2.1'
|
||||||
|
|
||||||
|
config = ConfigParser()
|
||||||
|
config.read(config_file, encoding='UTF-8')
|
||||||
|
|
||||||
|
Platform = sys.platform
|
||||||
|
|
||||||
|
# ==========global var end=========
|
||||||
|
|
||||||
|
def moveMovies():
|
||||||
|
movieFiles = []
|
||||||
|
fromPath = config['movie_location']['path']
|
||||||
|
if Platform == 'win32':
|
||||||
|
movieFormat = ["avi", "rmvb", "wmv", "mov", "mp4", "mkv", "flv", "ts"]
|
||||||
|
else:
|
||||||
|
movieFormat = ["AVI", "RMVB", "WMV", "MOV", "MP4", "MKV", "FLV", "TS","avi", "rmvb", "wmv", "mov", "mp4", "mkv", "flv", "ts"]
|
||||||
|
for fm in movieFormat:
|
||||||
|
movieFiles = movieFiles + [os.path.join(dirpath, f)
|
||||||
|
for dirpath, dirnames, files in os.walk(fromPath)
|
||||||
|
for f in fnmatch.filter(files, '*.' + fm)]
|
||||||
|
for movie in movieFiles:
|
||||||
|
print("Move file " + movie)
|
||||||
|
shutil.move(movie, os.path.curdir)
|
||||||
|
def UpdateCheck():
|
||||||
if UpdateCheckSwitch() == '1':
|
if UpdateCheckSwitch() == '1':
|
||||||
html2 = get_html('https://raw.githubusercontent.com/yoshiko2/AV_Data_Capture/master/update_check.json')
|
html2 = get_html('https://raw.githubusercontent.com/yoshiko2/AV_Data_Capture/master/update_check.json')
|
||||||
html = json.loads(str(html2))
|
html = json.loads(str(html2))
|
||||||
@@ -25,38 +49,27 @@ def UpdateCheck(version):
|
|||||||
print('[*]======================================================')
|
print('[*]======================================================')
|
||||||
else:
|
else:
|
||||||
print('[+]Update Check disabled!')
|
print('[+]Update Check disabled!')
|
||||||
|
def movie_lists():
|
||||||
|
global exclude_directory_1
|
||||||
def movie_lists(escape_folder):
|
global exclude_directory_2
|
||||||
escape_folder = re.split('[,,]', escape_folder)
|
total=[]
|
||||||
total = []
|
file_type = ['mp4','avi','rmvb','wmv','mov','mkv','flv','ts']
|
||||||
file_type = ['.mp4', '.avi', '.rmvb', '.wmv', '.mov', '.mkv', '.flv', '.ts', '.MP4', '.AVI', '.RMVB', '.WMV','.MOV', '.MKV', '.FLV', '.TS', ]
|
exclude_directory_1 = config['common']['failed_output_folder']
|
||||||
file_root = os.getcwd()
|
exclude_directory_2 = config['common']['success_output_folder']
|
||||||
for root, dirs, files in os.walk(file_root):
|
for a in file_type:
|
||||||
flag_escape = 0
|
total += glob.glob(r"./*." + a)
|
||||||
for folder in escape_folder:
|
|
||||||
if folder in root:
|
|
||||||
flag_escape = 1
|
|
||||||
break
|
|
||||||
if flag_escape == 1:
|
|
||||||
continue
|
|
||||||
for f in files:
|
|
||||||
if os.path.splitext(f)[1] in file_type:
|
|
||||||
path = os.path.join(root, f)
|
|
||||||
path = path.replace(file_root, '.')
|
|
||||||
total.append(path)
|
|
||||||
return total
|
return total
|
||||||
|
def CreatFailedFolder():
|
||||||
|
if not os.path.exists('failed/'): # 新建failed文件夹
|
||||||
def CreatFailedFolder(failed_folder):
|
|
||||||
if not os.path.exists(failed_folder + '/'): # 新建failed文件夹
|
|
||||||
try:
|
try:
|
||||||
os.makedirs(failed_folder + '/')
|
os.makedirs('failed/')
|
||||||
except:
|
except:
|
||||||
print("[-]failed!can not be make folder 'failed'\n[-](Please run as Administrator)")
|
print("[-]failed!can not be make folder 'failed'\n[-](Please run as Administrator)")
|
||||||
os._exit(0)
|
os._exit(0)
|
||||||
|
def lists_from_test(custom_nuber): #电影列表
|
||||||
|
a=[]
|
||||||
|
a.append(custom_nuber)
|
||||||
|
return a
|
||||||
def CEF(path):
|
def CEF(path):
|
||||||
try:
|
try:
|
||||||
files = os.listdir(path) # 获取路径下的子文件(夹)列表
|
files = os.listdir(path) # 获取路径下的子文件(夹)列表
|
||||||
@@ -64,68 +77,88 @@ def CEF(path):
|
|||||||
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):
|
||||||
|
#从右开始替换文件名中内容,源字符串,将被替换的子字符串, 新字符串,用于替换old子字符串,可选字符串, 替换不超过 max 次
|
||||||
|
count = len(self)
|
||||||
|
if max and str(max[0]).isdigit():
|
||||||
|
count = max[0]
|
||||||
|
return new.join(self.rsplit(old, count))
|
||||||
def getNumber(filepath):
|
def getNumber(filepath):
|
||||||
filepath = filepath.replace('.\\', '')
|
filepath = filepath.replace('.\\','')
|
||||||
if '-' in filepath or '_' in filepath: # 普通提取番号 主要处理包含减号-和_的番号
|
try: # 普通提取番号 主要处理包含减号-的番号
|
||||||
filepath = filepath.replace("_", "-")
|
filepath = filepath.replace("_", "-")
|
||||||
filepath.strip('22-sht.me').strip('-HD').strip('-hd')
|
filepath.strip('22-sht.me').strip('-HD').strip('-hd')
|
||||||
filename = str(re.sub("\[\d{4}-\d{1,2}-\d{1,2}\] - ", "", filepath)) # 去除文件名中时间
|
filename = str(re.sub("\[\d{4}-\d{1,2}-\d{1,2}\] - ", "", filepath)) # 去除文件名中时间
|
||||||
if 'FC2' or 'fc2' in filename:
|
if 'FC2' or 'fc2' in filename:
|
||||||
filename = filename.replace('-PPV', '').replace('PPV-', '').replace('FC2PPV-','FC2-').replace('FC2PPV_','FC2-')
|
filename=filename.replace('-PPV','').replace('PPV-','')
|
||||||
file_number = re.search('\w+-\w+', filename).group()
|
|
||||||
return file_number
|
|
||||||
else: # 提取不含减号-的番号,FANZA CID
|
|
||||||
try:
|
try:
|
||||||
return str(
|
file_number = re.search('\w+-\d+', filename).group()
|
||||||
re.findall(r'(.+?)\.', str(re.search('([^<>/\\\\|:""\\*\\?]+)\\.\\w+$', filepath).group()))).strip("['']").replace('_', '-')
|
except: # 提取类似mkbd-s120番号
|
||||||
except:
|
file_number = re.search('\w+-\w+\d+', filename).group()
|
||||||
return re.search(r'(.+?)\.', filepath)[0]
|
return file_number
|
||||||
|
except: # 提取不含减号-的番号
|
||||||
|
try:
|
||||||
|
filename = str(re.sub("ts6\d", "", filepath)).strip('Tokyo-hot').strip('tokyo-hot')
|
||||||
|
filename = str(re.sub(".*?\.com-\d+", "", filename)).replace('_', '')
|
||||||
|
file_number = str(re.search('\w+\d{4}', filename).group(0))
|
||||||
|
return file_number
|
||||||
|
except: # 提取无减号番号
|
||||||
|
filename = str(re.sub("ts6\d", "", filepath)) # 去除ts64/265
|
||||||
|
filename = str(re.sub(".*?\.com-\d+", "", filename))
|
||||||
|
file_number = str(re.match('\w+', filename).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
|
||||||
|
|
||||||
|
def RunCore():
|
||||||
|
if Platform == 'win32':
|
||||||
|
if os.path.exists('core.py'):
|
||||||
|
os.system('python core.py' + ' "' + i + '" --number "' + getNumber(i) + '"') # 从py文件启动(用于源码py)
|
||||||
|
elif os.path.exists('core.exe'):
|
||||||
|
os.system('core.exe' + ' "' + i + '" --number "' + getNumber(i) + '"') # 从exe启动(用于EXE版程序)
|
||||||
|
elif os.path.exists('core.py') and os.path.exists('core.exe'):
|
||||||
|
os.system('python core.py' + ' "' + i + '" --number "' + getNumber(i) + '"') # 从py文件启动(用于源码py)
|
||||||
|
else:
|
||||||
|
if os.path.exists('core.py'):
|
||||||
|
os.system('python3 core.py' + ' "' + i + '" --number "' + getNumber(i) + '"') # 从py文件启动(用于源码py)
|
||||||
|
elif os.path.exists('core.exe'):
|
||||||
|
os.system('core.exe' + ' "' + i + '" --number "' + getNumber(i) + '"') # 从exe启动(用于EXE版程序)
|
||||||
|
elif os.path.exists('core.py') and os.path.exists('core.exe'):
|
||||||
|
os.system('python3 core.py' + ' "' + i + '" --number "' + getNumber(i) + '"') # 从py文件启动(用于源码py)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ =='__main__':
|
||||||
version = '2.4'
|
|
||||||
config_file = 'config.ini'
|
|
||||||
config = ConfigParser()
|
|
||||||
config.read(config_file, encoding='UTF-8')
|
|
||||||
success_folder = config['common']['success_output_folder']
|
|
||||||
failed_folder = config['common']['failed_output_folder'] # 失败输出目录
|
|
||||||
escape_folder = config['escape']['folders'] # 多级目录刮削需要排除的目录
|
|
||||||
print('[*]================== AV Data Capture ===================')
|
print('[*]================== AV Data Capture ===================')
|
||||||
print('[*] Version ' + version)
|
print('[*] Version '+version)
|
||||||
print('[*]======================================================')
|
print('[*]======================================================')
|
||||||
|
CreatFailedFolder()
|
||||||
UpdateCheck(version)
|
UpdateCheck()
|
||||||
CreatFailedFolder(failed_folder)
|
moveMovies()
|
||||||
os.chdir(os.getcwd())
|
os.chdir(os.getcwd())
|
||||||
movie_list = movie_lists(escape_folder)
|
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
count_all = str(len(movie_list))
|
count_all = str(len(movie_lists()))
|
||||||
print('[+]Find', count_all, 'movies')
|
print('[+]Find',str(len(movie_lists())),'movies')
|
||||||
if config['common']['soft_link'] == '1':
|
if config['common']['soft_link'] == '1':
|
||||||
print('[!] --- Soft link mode is ENABLE! ----')
|
print('[!] --- Soft link mode is ENABLE! ----')
|
||||||
for i in movie_list: # 遍历电影列表 交给core处理
|
for i in movie_lists(): #遍历电影列表 交给core处理
|
||||||
count = count + 1
|
count = count + 1
|
||||||
percentage = str(count / int(count_all) * 100)[:4] + '%'
|
percentage = str(count/int(count_all)*100)[:4]+'%'
|
||||||
print('[!] - ' + percentage + ' [' + str(count) + '/' + count_all + '] -')
|
print('[!] - '+percentage+' ['+str(count)+'/'+count_all+'] -')
|
||||||
try:
|
try:
|
||||||
print("[!]Making Data for [" + i + "], the number is [" + getNumber(i) + "]")
|
print("[!]Making Data for [" + i + "], the number is [" + getNumber(i) + "]")
|
||||||
core_main(i, getNumber(i))
|
RunCore()
|
||||||
print("[*]======================================================")
|
print("[*]======================================================")
|
||||||
except: # 番号提取异常
|
except: # 番号提取异常
|
||||||
print('[-]' + i + ' Cannot catch the number :')
|
print('[-]' + i + ' Cannot catch the number :')
|
||||||
if config['common']['soft_link'] == '1':
|
if config['common']['soft_link'] == '1':
|
||||||
print('[-]Link', i, 'to failed folder')
|
print('[-]Link',i,'to failed folder')
|
||||||
os.symlink(i, str(os.getcwd()) + '/' + 'failed/')
|
os.symlink(i,str(os.getcwd()) + '/' + 'failed/')
|
||||||
else:
|
else:
|
||||||
print('[-]Move ' + i + ' to failed folder')
|
print('[-]Move ' + i + ' to failed folder')
|
||||||
shutil.move(i, str(os.getcwd()) + '/' + 'failed/')
|
shutil.move(i, str(os.getcwd()) + '/' + 'failed/')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
CEF(success_folder)
|
CEF(exclude_directory_1)
|
||||||
CEF(failed_folder)
|
CEF(exclude_directory_2)
|
||||||
print("[+]All finished!!!")
|
print("[+]All finished!!!")
|
||||||
input("[+][+]Press enter key exit, you can check the error messge before you exit.")
|
input("[+][+]Press enter key exit, you can check the error messge before you exit.")
|
||||||
@@ -38,6 +38,7 @@
|
|||||||
* 用户使用该软件时,若产生一切违法行为由用户承担<br>
|
* 用户使用该软件时,若产生一切违法行为由用户承担<br>
|
||||||
* 严禁用户使用于商业和个人其他意图<br>
|
* 严禁用户使用于商业和个人其他意图<br>
|
||||||
* 本软件作者保留最终决定权和最终解释权<br>
|
* 本软件作者保留最终决定权和最终解释权<br>
|
||||||
|
* 本软件受国际版权法保护
|
||||||
|
|
||||||
**若用户不同意上述条款任意一条,请勿使用该软件**<br>
|
**若用户不同意上述条款任意一条,请勿使用该软件**<br>
|
||||||
|
|
||||||
@@ -159,12 +160,18 @@ pip install pillow
|
|||||||
如果是PLEX,请安装插件:```XBMCnfoMoviesImporter```
|
如果是PLEX,请安装插件:```XBMCnfoMoviesImporter```
|
||||||
|
|
||||||
---
|
---
|
||||||
### 排除指定字符和目录
|
### 抓取目录
|
||||||
>[escape]
|
>[escape]
|
||||||
>literals=\
|
>literals=\
|
||||||
>folders=failed,JAV_output
|
|
||||||
```literals=``` 标题指定字符删除,例如```iterals=\()```,删除标题中```\()```字符
|
```literals=``` 标题指定字符删除,例如```iterals=\()```,删除标题中```\()```字符
|
||||||
```folders=``` 排指定目录,例如```folders=failed,JAV_output```,多目录刮削时跳过failed,JAV_output
|
|
||||||
|
---
|
||||||
|
### 抓取目录选择
|
||||||
|
>[movie_location]<br>
|
||||||
|
>path=<br>
|
||||||
|
|
||||||
|
如果directory后面为空,则抓取和程序同一目录下的影片
|
||||||
|
|
||||||
---
|
---
|
||||||
### 调试模式
|
### 调试模式
|
||||||
|
|||||||
+3
-4
@@ -5,7 +5,7 @@ success_output_folder=JAV_output
|
|||||||
soft_link=0
|
soft_link=0
|
||||||
|
|
||||||
[proxy]
|
[proxy]
|
||||||
proxy=127.0.0.1:1081
|
proxy=
|
||||||
timeout=10
|
timeout=10
|
||||||
retry=3
|
retry=3
|
||||||
|
|
||||||
@@ -22,7 +22,6 @@ media_warehouse=emby
|
|||||||
|
|
||||||
[escape]
|
[escape]
|
||||||
literals=\()
|
literals=\()
|
||||||
folders=failed,JAV_output
|
|
||||||
|
|
||||||
[debug_mode]
|
[movie_location]
|
||||||
switch=0
|
path=
|
||||||
|
|||||||
@@ -16,36 +16,103 @@ import siro
|
|||||||
import avsox
|
import avsox
|
||||||
import javbus
|
import javbus
|
||||||
import javdb
|
import javdb
|
||||||
import fanza
|
# =========website========
|
||||||
import requests
|
|
||||||
|
|
||||||
|
# 初始化全局变量
|
||||||
|
Config = ConfigParser()
|
||||||
|
Config.read(config_file, encoding='UTF-8')
|
||||||
|
try:
|
||||||
|
option = ReadMediaWarehouse()
|
||||||
|
except:
|
||||||
|
print('[-]Config media_warehouse read failed!')
|
||||||
|
title = '' #标题
|
||||||
|
studio = '' #片商
|
||||||
|
year = '' #年份
|
||||||
|
outline = '' #简介
|
||||||
|
runtime = '' #运行时间
|
||||||
|
director = '' #导演
|
||||||
|
actor_list = [] #演员列表
|
||||||
|
actor = '' #演员
|
||||||
|
release = '' #上市时间
|
||||||
|
number = '' #番号
|
||||||
|
cover = '' #封面URL
|
||||||
|
imagecut = '' #封面裁剪指数
|
||||||
|
tag = [] #标签
|
||||||
|
cn_sub = '' #中文字幕
|
||||||
|
c_word = '' #中文字幕后缀
|
||||||
|
multi_part = 0 #多集
|
||||||
|
part = '' #多集
|
||||||
|
path = '' #路径
|
||||||
|
houzhui = '' #后缀
|
||||||
|
website = '' #网站
|
||||||
|
json_data = {} #元数据集合
|
||||||
|
actor_photo = {} #演员图片URL
|
||||||
|
cover_small = '' #小封面链接
|
||||||
|
naming_rule = '' #元数据内标题命名规则
|
||||||
|
location_rule = ''#位置规则
|
||||||
|
program_mode = Config['common']['main_mode'] #运行模式
|
||||||
|
failed_folder = Config['common']['failed_output_folder'] #失败输出目录
|
||||||
|
success_folder = Config['common']['success_output_folder'] #成功输出目录
|
||||||
|
|
||||||
|
|
||||||
# =====================本地文件处理===========================
|
# =====================本地文件处理===========================
|
||||||
|
|
||||||
def escapePath(path, Config): # Remove escape literals
|
def escapePath(path): # Remove escape literals
|
||||||
escapeLiterals = Config['escape']['literals']
|
escapeLiterals = Config['escape']['literals']
|
||||||
backslash = '\\'
|
backslash = '\\'
|
||||||
for literal in escapeLiterals:
|
for literal in escapeLiterals:
|
||||||
path = path.replace(backslash + literal, '')
|
path = path.replace(backslash+literal,'')
|
||||||
return path
|
return path
|
||||||
|
|
||||||
|
def moveFailedFolder():
|
||||||
def moveFailedFolder(filepath, failed_folder):
|
global filepath
|
||||||
print('[-]Move to Failed output folder')
|
print('[-]Move to Failed output folder')
|
||||||
shutil.move(filepath, str(os.getcwd()) + '/' + failed_folder + '/')
|
shutil.move(filepath, str(os.getcwd()) + '/' + failed_folder + '/')
|
||||||
return
|
os._exit(0)
|
||||||
|
|
||||||
|
|
||||||
def CreatFailedFolder(failed_folder):
|
def argparse_get_file():
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("--number", help="Enter Number on here", default='')
|
||||||
|
parser.add_argument("file", help="Write the file path on here")
|
||||||
|
args = parser.parse_args()
|
||||||
|
return (args.file, args.number)
|
||||||
|
|
||||||
|
|
||||||
|
def CreatFailedFolder():
|
||||||
if not os.path.exists(failed_folder + '/'): # 新建failed文件夹
|
if not os.path.exists(failed_folder + '/'): # 新建failed文件夹
|
||||||
try:
|
try:
|
||||||
os.makedirs(failed_folder + '/')
|
os.makedirs(failed_folder + '/')
|
||||||
except:
|
except:
|
||||||
print("[-]failed!can not be make Failed output folder\n[-](Please run as Administrator)")
|
print("[-]failed!can not be make Failed output folder\n[-](Please run as Administrator)")
|
||||||
return
|
os._exit(0)
|
||||||
|
|
||||||
|
|
||||||
def getDataFromJSON(file_number, filepath, failed_folder): # 从JSON返回元数据
|
def getDataFromJSON(file_number): # 从JSON返回元数据
|
||||||
|
global title
|
||||||
|
global studio
|
||||||
|
global year
|
||||||
|
global outline
|
||||||
|
global runtime
|
||||||
|
global director
|
||||||
|
global actor_list
|
||||||
|
global actor
|
||||||
|
global release
|
||||||
|
global number
|
||||||
|
global cover
|
||||||
|
global imagecut
|
||||||
|
global tag
|
||||||
|
global image_main
|
||||||
|
global cn_sub
|
||||||
|
global website
|
||||||
|
global actor_photo
|
||||||
|
global cover_small
|
||||||
|
global json_data
|
||||||
|
|
||||||
|
global naming_rule
|
||||||
|
global location_rule
|
||||||
|
|
||||||
# ================================================网站规则添加开始================================================
|
# ================================================网站规则添加开始================================================
|
||||||
|
|
||||||
if re.match('^\d{5,}', file_number):
|
if re.match('^\d{5,}', file_number):
|
||||||
@@ -61,18 +128,15 @@ def getDataFromJSON(file_number, filepath, failed_folder): # 从JSON返回元
|
|||||||
json_data = json.loads(javdb.main(file_number))
|
json_data = json.loads(javdb.main(file_number))
|
||||||
# ==
|
# ==
|
||||||
elif 'fc2' in file_number or 'FC2' in file_number:
|
elif 'fc2' in file_number or 'FC2' in file_number:
|
||||||
json_data = json.loads(fc2fans_club.main(
|
json_data = json.loads(fc2fans_club.main(file_number.replace('fc2-','').replace('fc2_','').replace('FC2-','').replace('fc2_','')))
|
||||||
file_number.replace('fc2-', '').replace('fc2_', '').replace('FC2-', '').replace('fc2_', '')))
|
|
||||||
# ==
|
# ==
|
||||||
elif 'HEYZO' in file_number or 'heyzo' in file_number or 'Heyzo' in file_number:
|
elif 'HEYZO' in number or 'heyzo' in number or 'Heyzo' in number:
|
||||||
json_data = json.loads(avsox.main(file_number))
|
json_data = json.loads(avsox.main(file_number))
|
||||||
# ==
|
# ==
|
||||||
elif 'siro' in file_number or 'SIRO' in file_number or 'Siro' in 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))
|
json_data = json.loads(siro.main(file_number))
|
||||||
# ==
|
# ==
|
||||||
else:
|
else:
|
||||||
json_data = json.loads(fanza.main(file_number))
|
|
||||||
if getDataState(json_data) == 0: # 如果元数据获取失败,请求番号至其他网站抓取
|
|
||||||
json_data = json.loads(javbus.main(file_number))
|
json_data = json.loads(javbus.main(file_number))
|
||||||
if getDataState(json_data) == 0: # 如果元数据获取失败,请求番号至其他网站抓取
|
if getDataState(json_data) == 0: # 如果元数据获取失败,请求番号至其他网站抓取
|
||||||
json_data = json.loads(avsox.main(file_number))
|
json_data = json.loads(avsox.main(file_number))
|
||||||
@@ -81,10 +145,16 @@ def getDataFromJSON(file_number, filepath, failed_folder): # 从JSON返回元
|
|||||||
|
|
||||||
# ================================================网站规则添加结束================================================
|
# ================================================网站规则添加结束================================================
|
||||||
|
|
||||||
title = json_data['title']
|
title = str(json_data['title']).replace(' ', '')
|
||||||
|
studio = json_data['studio']
|
||||||
|
year = json_data['year']
|
||||||
|
outline = json_data['outline']
|
||||||
|
runtime = json_data['runtime']
|
||||||
|
director = json_data['director']
|
||||||
actor_list = str(json_data['actor']).strip("[ ]").replace("'", '').split(',') # 字符串转列表
|
actor_list = str(json_data['actor']).strip("[ ]").replace("'", '').split(',') # 字符串转列表
|
||||||
release = json_data['release']
|
release = json_data['release']
|
||||||
number = json_data['number']
|
number = json_data['number']
|
||||||
|
cover = json_data['cover']
|
||||||
try:
|
try:
|
||||||
cover_small = json_data['cover_small']
|
cover_small = json_data['cover_small']
|
||||||
except:
|
except:
|
||||||
@@ -92,13 +162,16 @@ def getDataFromJSON(file_number, filepath, failed_folder): # 从JSON返回元
|
|||||||
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']
|
||||||
|
website = json_data['website']
|
||||||
|
source = json_data['source']
|
||||||
|
|
||||||
if title == '' or number == '':
|
if title == '' or number == '':
|
||||||
print('[-]Movie Data not found!')
|
print('[-]Movie Data not found!')
|
||||||
moveFailedFolder(filepath, failed_folder)
|
moveFailedFolder()
|
||||||
|
|
||||||
# if imagecut == '3':
|
if imagecut == '3':
|
||||||
# DownloadFileWithFilename()
|
DownloadFileWithFilename()
|
||||||
|
|
||||||
# ====================处理异常字符====================== #\/:*?"<>|
|
# ====================处理异常字符====================== #\/:*?"<>|
|
||||||
title = title.replace('\\', '')
|
title = title.replace('\\', '')
|
||||||
@@ -119,36 +192,11 @@ def getDataFromJSON(file_number, filepath, failed_folder): # 从JSON返回元
|
|||||||
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'])
|
||||||
|
|
||||||
# 返回处理后的json_data
|
|
||||||
json_data['title'] = title
|
|
||||||
json_data['actor'] = actor
|
|
||||||
json_data['release'] = release
|
|
||||||
json_data['cover_small'] = cover_small
|
|
||||||
json_data['tag'] = tag
|
|
||||||
json_data['naming_rule'] = naming_rule
|
|
||||||
json_data['location_rule'] = location_rule
|
|
||||||
return json_data
|
|
||||||
|
|
||||||
|
def smallCoverCheck():
|
||||||
def get_info(json_data): # 返回json里的数据
|
|
||||||
title = json_data['title']
|
|
||||||
studio = json_data['studio']
|
|
||||||
year = json_data['year']
|
|
||||||
outline = json_data['outline']
|
|
||||||
runtime = json_data['runtime']
|
|
||||||
director = json_data['director']
|
|
||||||
actor_photo = json_data['actor_photo']
|
|
||||||
release = json_data['release']
|
|
||||||
number = json_data['number']
|
|
||||||
cover = json_data['cover']
|
|
||||||
website = json_data['website']
|
|
||||||
return title, studio, year, outline, runtime, director, actor_photo, release, number, cover, website
|
|
||||||
|
|
||||||
|
|
||||||
def smallCoverCheck(path, number, imagecut, cover_small, c_word, option, Config, filepath, failed_folder):
|
|
||||||
if imagecut == 3:
|
if imagecut == 3:
|
||||||
if option == 'emby':
|
if option == 'emby':
|
||||||
DownloadFileWithFilename(cover_small, '1.jpg', path, Config, filepath, failed_folder)
|
DownloadFileWithFilename(cover_small, '1.jpg', path)
|
||||||
try:
|
try:
|
||||||
img = Image.open(path + '/1.jpg')
|
img = Image.open(path + '/1.jpg')
|
||||||
except Exception:
|
except Exception:
|
||||||
@@ -159,18 +207,18 @@ def smallCoverCheck(path, number, imagecut, cover_small, c_word, option, Config,
|
|||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
os.remove(path + '/1.jpg')
|
os.remove(path + '/1.jpg')
|
||||||
if option == 'kodi':
|
if option == 'kodi':
|
||||||
DownloadFileWithFilename(cover_small, '1.jpg', path, Config, filepath, failed_folder)
|
DownloadFileWithFilename(cover_small, '1.jpg', path)
|
||||||
try:
|
try:
|
||||||
img = Image.open(path + '/1.jpg')
|
img = Image.open(path + '/1.jpg')
|
||||||
except Exception:
|
except Exception:
|
||||||
img = Image.open('1.jpg')
|
img = Image.open('1.jpg')
|
||||||
w = img.width
|
w = img.width
|
||||||
h = img.height
|
h = img.height
|
||||||
img.save(path + '/' + number + c_word + '-poster.jpg')
|
img.save(path + '/' + number + c_word +'-poster.jpg')
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
os.remove(path + '/1.jpg')
|
os.remove(path + '/1.jpg')
|
||||||
if option == 'plex':
|
if option == 'plex':
|
||||||
DownloadFileWithFilename(cover_small, '1.jpg', path, Config, filepath, failed_folder)
|
DownloadFileWithFilename(cover_small, '1.jpg', path)
|
||||||
try:
|
try:
|
||||||
img = Image.open(path + '/1.jpg')
|
img = Image.open(path + '/1.jpg')
|
||||||
except Exception:
|
except Exception:
|
||||||
@@ -181,31 +229,26 @@ def smallCoverCheck(path, number, imagecut, cover_small, c_word, option, Config,
|
|||||||
os.remove(path + '/1.jpg')
|
os.remove(path + '/1.jpg')
|
||||||
|
|
||||||
|
|
||||||
def creatFolder(success_folder, location_rule, json_data, Config): # 创建文件夹
|
def creatFolder(): # 创建文件夹
|
||||||
title, studio, year, outline, runtime, director, actor_photo, release, number, cover, website = get_info(json_data)
|
global actor
|
||||||
if len(location_rule) > 240: # 新建成功输出文件夹
|
global path
|
||||||
path = success_folder + '/' + location_rule.replace("'actor'", "'manypeople'", 3).replace("actor",
|
if len(os.getcwd() + path) > 240: # 新建成功输出文件夹
|
||||||
"'manypeople'",
|
path = success_folder+'/'+location_rule.replace("'actor'","'manypeople'",3).replace("actor","'manypeople'",3) #path为影片+元数据所在目录
|
||||||
3) # path为影片+元数据所在目录
|
|
||||||
else:
|
else:
|
||||||
path = success_folder + '/' + location_rule
|
path = success_folder + '/' + location_rule
|
||||||
# print(path)
|
# print(path)
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
path = escapePath(path, Config)
|
path = escapePath(path)
|
||||||
try:
|
try:
|
||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
except:
|
except:
|
||||||
path = success_folder + '/' + location_rule.replace('/[' + number + ']-' + title, "/number")
|
path = success_folder + '/' + location_rule.replace('/[' + number + ']-' + title, "/number")
|
||||||
path = escapePath(path, Config)
|
path = escapePath(path)
|
||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
return path
|
|
||||||
|
|
||||||
|
|
||||||
# =====================资源下载部分===========================
|
# =====================资源下载部分===========================
|
||||||
def DownloadFileWithFilename(url, filename, path, Config, filepath, failed_folder): # path = examle:photo , video.in the Project Folder!
|
def DownloadFileWithFilename(url, filename, path): # path = examle:photo , video.in the Project Folder!
|
||||||
retry_count = 0
|
|
||||||
proxy = ''
|
|
||||||
timeout = 0
|
|
||||||
try:
|
try:
|
||||||
proxy = Config['proxy']['proxy']
|
proxy = Config['proxy']['proxy']
|
||||||
timeout = int(Config['proxy']['timeout'])
|
timeout = int(Config['proxy']['timeout'])
|
||||||
@@ -225,7 +268,7 @@ def DownloadFileWithFilename(url, filename, path, Config, filepath, failed_folde
|
|||||||
proxies={"http": "http://" + str(proxy), "https": "https://" + str(proxy)})
|
proxies={"http": "http://" + str(proxy), "https": "https://" + str(proxy)})
|
||||||
if r == '':
|
if r == '':
|
||||||
print('[-]Movie Data not found!')
|
print('[-]Movie Data not found!')
|
||||||
return
|
os._exit(0)
|
||||||
with open(str(path) + "/" + filename, "wb") as code:
|
with open(str(path) + "/" + filename, "wb") as code:
|
||||||
code.write(r.content)
|
code.write(r.content)
|
||||||
return
|
return
|
||||||
@@ -237,7 +280,7 @@ def DownloadFileWithFilename(url, filename, path, Config, filepath, failed_folde
|
|||||||
r = requests.get(url, timeout=timeout, headers=headers)
|
r = requests.get(url, timeout=timeout, headers=headers)
|
||||||
if r == '':
|
if r == '':
|
||||||
print('[-]Movie Data not found!')
|
print('[-]Movie Data not found!')
|
||||||
return
|
os._exit(0)
|
||||||
with open(str(path) + "/" + filename, "wb") as code:
|
with open(str(path) + "/" + filename, "wb") as code:
|
||||||
code.write(r.content)
|
code.write(r.content)
|
||||||
return
|
return
|
||||||
@@ -254,26 +297,14 @@ def DownloadFileWithFilename(url, filename, path, Config, filepath, failed_folde
|
|||||||
i += 1
|
i += 1
|
||||||
print('[-]Image Download : Connect retry ' + str(i) + '/' + str(retry_count))
|
print('[-]Image Download : Connect retry ' + str(i) + '/' + str(retry_count))
|
||||||
print('[-]Connect Failed! Please check your Proxy or Network!')
|
print('[-]Connect Failed! Please check your Proxy or Network!')
|
||||||
moveFailedFolder(filepath, failed_folder)
|
moveFailedFolder()
|
||||||
|
|
||||||
|
|
||||||
def imageDownload(option, cover, number, c_word, path, multi_part, Config, filepath, failed_folder): # 封面是否下载成功,否则移动到failed
|
def imageDownload(): # 封面是否下载成功,否则移动到failed
|
||||||
if option == 'emby':
|
if option == 'emby':
|
||||||
if DownloadFileWithFilename(cover, number + c_word + '.jpg', path, Config, filepath, failed_folder) == 'failed':
|
if DownloadFileWithFilename(cover, number + c_word + '.jpg', path) == 'failed':
|
||||||
moveFailedFolder(filepath, failed_folder)
|
moveFailedFolder()
|
||||||
DownloadFileWithFilename(cover, number + c_word + '.jpg', path, Config, filepath, failed_folder)
|
DownloadFileWithFilename(cover, number + c_word + '.jpg', path)
|
||||||
if not os.path.getsize(path + '/' + number + c_word + '.jpg') == 0:
|
|
||||||
print('[+]Image Downloaded!', path + '/' + number + c_word + '.jpg')
|
|
||||||
return
|
|
||||||
i = 1
|
|
||||||
while i <= int(config['proxy']['retry']):
|
|
||||||
if os.path.getsize(path + '/' + number + c_word + '.jpg') == 0:
|
|
||||||
print('[!]Image Download Failed! Trying again. [' + config['proxy']['retry'] + '/3]')
|
|
||||||
DownloadFileWithFilename(cover, number + c_word + '.jpg', path, Config, filepath, failed_folder)
|
|
||||||
i = i + 1
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
break
|
|
||||||
if multi_part == 1:
|
if multi_part == 1:
|
||||||
old_name = os.path.join(path, number + c_word + '.jpg')
|
old_name = os.path.join(path, number + c_word + '.jpg')
|
||||||
new_name = os.path.join(path, number + c_word + '.jpg')
|
new_name = os.path.join(path, number + c_word + '.jpg')
|
||||||
@@ -282,52 +313,23 @@ def imageDownload(option, cover, number, c_word, path, multi_part, Config, filep
|
|||||||
else:
|
else:
|
||||||
print('[+]Image Downloaded!', path + '/' + number + c_word + '.jpg')
|
print('[+]Image Downloaded!', path + '/' + number + c_word + '.jpg')
|
||||||
elif option == 'plex':
|
elif option == 'plex':
|
||||||
if DownloadFileWithFilename(cover, 'fanart.jpg', path, Config, filepath, failed_folder) == 'failed':
|
if DownloadFileWithFilename(cover, 'fanart.jpg', path) == 'failed':
|
||||||
moveFailedFolder(filepath, failed_folder)
|
moveFailedFolder()
|
||||||
DownloadFileWithFilename(cover, 'fanart.jpg', path, Config, filepath, failed_folder)
|
DownloadFileWithFilename(cover, 'fanart.jpg', path)
|
||||||
if not os.path.getsize(path + '/fanart.jpg') == 0:
|
|
||||||
print('[+]Image Downloaded!', path + '/fanart.jpg')
|
|
||||||
return
|
|
||||||
i = 1
|
|
||||||
while i <= int(config['proxy']['retry']):
|
|
||||||
if os.path.getsize(path + '/fanart.jpg') == 0:
|
|
||||||
print('[!]Image Download Failed! Trying again. [' + config['proxy']['retry'] + '/3]')
|
|
||||||
DownloadFileWithFilename(cover, 'fanart.jpg', path, Config, filepath, failed_folder)
|
|
||||||
i = i + 1
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
break
|
|
||||||
if not os.path.getsize(path + '/' + number + c_word + '.jpg') == 0:
|
|
||||||
print('[!]Image Download Failed! Trying again.')
|
|
||||||
DownloadFileWithFilename(cover, number + c_word + '.jpg', path, Config, filepath, failed_folder)
|
|
||||||
print('[+]Image Downloaded!', path + '/fanart.jpg')
|
print('[+]Image Downloaded!', path + '/fanart.jpg')
|
||||||
elif option == 'kodi':
|
elif option == 'kodi':
|
||||||
if DownloadFileWithFilename(cover, number + c_word + '-fanart.jpg', path, Config, filepath, failed_folder) == 'failed':
|
if DownloadFileWithFilename(cover, number + c_word + '-fanart.jpg', path) == 'failed':
|
||||||
moveFailedFolder(filepath, failed_folder)
|
moveFailedFolder()
|
||||||
DownloadFileWithFilename(cover, number + c_word + '-fanart.jpg', path, Config, filepath, failed_folder)
|
DownloadFileWithFilename(cover, number + c_word + '-fanart.jpg', path)
|
||||||
if not os.path.getsize(path + '/' + number + c_word + '-fanart.jpg') == 0:
|
|
||||||
print('[+]Image Downloaded!', path + '/' + number + c_word + '-fanart.jpg')
|
|
||||||
return
|
|
||||||
i = 1
|
|
||||||
while i <= int(config['proxy']['retry']):
|
|
||||||
if os.path.getsize(path + '/' + number + c_word + '-fanart.jpg') == 0:
|
|
||||||
print('[!]Image Download Failed! Trying again. [' + config['proxy']['retry'] + '/3]')
|
|
||||||
DownloadFileWithFilename(cover, number + c_word + '-fanart.jpg', path, Config, filepath, failed_folder)
|
|
||||||
i = i + 1
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
break
|
|
||||||
print('[+]Image Downloaded!', path + '/' + number + c_word + '-fanart.jpg')
|
print('[+]Image Downloaded!', path + '/' + number + c_word + '-fanart.jpg')
|
||||||
|
|
||||||
|
|
||||||
def PrintFiles(option, path, c_word, naming_rule, part, cn_sub, json_data, filepath, failed_folder, tag):
|
def PrintFiles():
|
||||||
title, studio, year, outline, runtime, director, actor_photo, release, number, cover, website = get_info(json_data)
|
|
||||||
try:
|
try:
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
if option == 'plex':
|
if option == 'plex':
|
||||||
with open(path + "/" + number + c_word + ".nfo", "wt", encoding='UTF-8') as code:
|
with open(path + "/" + number + c_word + ".nfo", "wt", encoding='UTF-8') as code:
|
||||||
print('<?xml version="1.0" encoding="UTF-8" ?>', file=code)
|
|
||||||
print("<movie>", file=code)
|
print("<movie>", file=code)
|
||||||
print(" <title>" + naming_rule + part + "</title>", file=code)
|
print(" <title>" + naming_rule + part + "</title>", file=code)
|
||||||
print(" <set>", file=code)
|
print(" <set>", file=code)
|
||||||
@@ -375,7 +377,6 @@ def PrintFiles(option, path, c_word, naming_rule, part, cn_sub, json_data, filep
|
|||||||
print("[+]Writeed! " + path + "/" + number + ".nfo")
|
print("[+]Writeed! " + path + "/" + number + ".nfo")
|
||||||
elif option == 'emby':
|
elif option == 'emby':
|
||||||
with open(path + "/" + number + c_word + ".nfo", "wt", encoding='UTF-8') as code:
|
with open(path + "/" + number + c_word + ".nfo", "wt", encoding='UTF-8') as code:
|
||||||
print('<?xml version="1.0" encoding="UTF-8" ?>', file=code)
|
|
||||||
print("<movie>", file=code)
|
print("<movie>", file=code)
|
||||||
print(" <title>" + naming_rule + part + "</title>", file=code)
|
print(" <title>" + naming_rule + part + "</title>", file=code)
|
||||||
print(" <set>", file=code)
|
print(" <set>", file=code)
|
||||||
@@ -423,7 +424,6 @@ def PrintFiles(option, path, c_word, naming_rule, part, cn_sub, json_data, filep
|
|||||||
print("[+]Writeed! " + path + "/" + number + c_word + ".nfo")
|
print("[+]Writeed! " + path + "/" + number + c_word + ".nfo")
|
||||||
elif option == 'kodi':
|
elif option == 'kodi':
|
||||||
with open(path + "/" + number + c_word + ".nfo", "wt", encoding='UTF-8') as code:
|
with open(path + "/" + number + c_word + ".nfo", "wt", encoding='UTF-8') as code:
|
||||||
print('<?xml version="1.0" encoding="UTF-8" ?>', file=code)
|
|
||||||
print("<movie>", file=code)
|
print("<movie>", file=code)
|
||||||
print(" <title>" + naming_rule + part + "</title>", file=code)
|
print(" <title>" + naming_rule + part + "</title>", file=code)
|
||||||
print(" <set>", file=code)
|
print(" <set>", file=code)
|
||||||
@@ -471,14 +471,14 @@ def PrintFiles(option, path, c_word, naming_rule, part, cn_sub, json_data, filep
|
|||||||
except IOError as e:
|
except IOError as e:
|
||||||
print("[-]Write Failed!")
|
print("[-]Write Failed!")
|
||||||
print(e)
|
print(e)
|
||||||
moveFailedFolder(filepath, failed_folder)
|
moveFailedFolder()
|
||||||
except Exception as e1:
|
except Exception as e1:
|
||||||
print(e1)
|
print(e1)
|
||||||
print("[-]Write Failed!")
|
print("[-]Write Failed!")
|
||||||
moveFailedFolder(filepath, failed_folder)
|
moveFailedFolder()
|
||||||
|
|
||||||
|
|
||||||
def cutImage(option, imagecut, path, number, c_word):
|
def cutImage():
|
||||||
if option == 'plex':
|
if option == 'plex':
|
||||||
if imagecut == 1:
|
if imagecut == 1:
|
||||||
try:
|
try:
|
||||||
@@ -534,60 +534,64 @@ def cutImage(option, imagecut, path, number, c_word):
|
|||||||
img.save(path + '/' + number + c_word + '-poster.jpg')
|
img.save(path + '/' + number + c_word + '-poster.jpg')
|
||||||
|
|
||||||
|
|
||||||
def pasteFileToFolder(filepath, path, number, c_word): # 文件路径,番号,后缀,要移动至的位置
|
def pasteFileToFolder(filepath, path): # 文件路径,番号,后缀,要移动至的位置
|
||||||
|
global houzhui
|
||||||
houzhui = str(re.search('[.](AVI|RMVB|WMV|MOV|MP4|MKV|FLV|TS|avi|rmvb|wmv|mov|mp4|mkv|flv|ts)$', filepath).group())
|
houzhui = str(re.search('[.](AVI|RMVB|WMV|MOV|MP4|MKV|FLV|TS|avi|rmvb|wmv|mov|mp4|mkv|flv|ts)$', filepath).group())
|
||||||
try:
|
try:
|
||||||
if config['common']['soft_link'] == '1': # 如果soft_link=1 使用软链接
|
if config['common']['soft_link'] == '1': #如果soft_link=1 使用软链接
|
||||||
os.symlink(filepath, path + '/' + number + c_word + houzhui)
|
os.symlink(filepath, path + '/' + number + c_word + houzhui)
|
||||||
else:
|
else:
|
||||||
os.rename(filepath, path + '/' + number + c_word + houzhui)
|
os.rename(filepath, path + '/' + number + c_word + houzhui)
|
||||||
if os.path.exists(os.getcwd() + '/' + number + c_word + '.srt'): # 字幕移动
|
if os.path.exists(os.getcwd()+'/'+number + c_word + '.srt'): #字幕移动
|
||||||
os.rename(os.getcwd() + '/' + number + c_word + '.srt', path + '/' + number + c_word + '.srt')
|
os.rename(os.getcwd()+'/'+number + c_word + '.srt', path + '/' + number + c_word + '.srt')
|
||||||
print('[+]Sub moved!')
|
print('[+]Sub moved!')
|
||||||
elif os.path.exists(os.getcwd() + '/' + number + c_word + '.ssa'):
|
elif os.path.exists(os.getcwd()+'/'+number + c_word + '.ssa'):
|
||||||
os.rename(os.getcwd() + '/' + number + c_word + '.ssa', path + '/' + number + c_word + '.ssa')
|
os.rename(os.getcwd()+'/'+number + c_word + '.ssa', path + '/' + number + c_word + '.ssa')
|
||||||
print('[+]Sub moved!')
|
print('[+]Sub moved!')
|
||||||
elif os.path.exists(os.getcwd() + '/' + number + c_word + '.sub'):
|
elif os.path.exists(os.getcwd()+'/'+number + c_word + '.sub'):
|
||||||
os.rename(os.getcwd() + '/' + number + c_word + '.sub', path + '/' + number + c_word + '.sub')
|
os.rename(os.getcwd()+'/'+number + c_word + '.sub', path + '/' + number + c_word + '.sub')
|
||||||
print('[+]Sub moved!')
|
print('[+]Sub moved!')
|
||||||
except FileExistsError:
|
except FileExistsError:
|
||||||
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.')
|
||||||
return
|
os._exit(0)
|
||||||
except PermissionError:
|
except PermissionError:
|
||||||
print('[-]Error! Please run as administrator!')
|
print('[-]Error! Please run as administrator!')
|
||||||
return
|
os._exit(0)
|
||||||
|
|
||||||
|
|
||||||
def pasteFileToFolder_mode2(filepath, path, multi_part, number, part, c_word): # 文件路径,番号,后缀,要移动至的位置
|
def pasteFileToFolder_mode2(filepath, path): # 文件路径,番号,后缀,要移动至的位置
|
||||||
|
global houzhui
|
||||||
|
global number
|
||||||
if multi_part == 1:
|
if multi_part == 1:
|
||||||
number += part # 这时number会被附加上CD1后缀
|
number += part # 这时number会被附加上CD1后缀
|
||||||
houzhui = str(re.search('[.](AVI|RMVB|WMV|MOV|MP4|MKV|FLV|TS|avi|rmvb|wmv|mov|mp4|mkv|flv|ts)$', filepath).group())
|
houzhui = str(re.search('[.](AVI|RMVB|WMV|MOV|MP4|MKV|FLV|TS|avi|rmvb|wmv|mov|mp4|mkv|flv|ts)$', filepath).group())
|
||||||
|
path = success_folder + '/' + location_rule
|
||||||
try:
|
try:
|
||||||
if config['common']['soft_link'] == '1':
|
if config['common']['soft_link'] == '1':
|
||||||
os.symlink(filepath, path + '/' + number + part + c_word + houzhui)
|
os.symlink(filepath, path + '/' + number + part + c_word + houzhui)
|
||||||
else:
|
else:
|
||||||
os.rename(filepath, path + '/' + number + part + c_word + houzhui)
|
os.rename(filepath, path + '/' + number + part + c_word + houzhui)
|
||||||
if os.path.exists(number + '.srt'): # 字幕移动
|
if os.path.exists(number+'.srt'): #字幕移动
|
||||||
os.rename(number + part + c_word + '.srt', path + '/' + number + part + c_word + '.srt')
|
os.rename(number + part + c_word + '.srt', path + '/' + number + part + c_word + '.srt')
|
||||||
print('[+]Sub moved!')
|
print('[+]Sub moved!')
|
||||||
elif os.path.exists(number + part + c_word + '.ass'):
|
elif os.path.exists(number + part + c_word+'.ass'):
|
||||||
os.rename(number + part + c_word + '.ass', path + '/' + number + part + c_word + '.ass')
|
os.rename(number + part + c_word + '.ass', path + '/' + number + part + c_word + '.ass')
|
||||||
print('[+]Sub moved!')
|
print('[+]Sub moved!')
|
||||||
elif os.path.exists(number + part + c_word + '.sub'):
|
elif os.path.exists(number + part + c_word+'.sub'):
|
||||||
os.rename(number + part + c_word + '.sub', path + '/' + number + part + c_word + '.sub')
|
os.rename(number + part + c_word + '.sub', path + '/' + number + part + c_word + '.sub')
|
||||||
print('[+]Sub moved!')
|
print('[+]Sub moved!')
|
||||||
print('[!]Success')
|
print('[!]Success')
|
||||||
except FileExistsError:
|
except FileExistsError:
|
||||||
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.')
|
||||||
return
|
os._exit(0)
|
||||||
except PermissionError:
|
except PermissionError:
|
||||||
print('[-]Error! Please run as administrator!')
|
print('[-]Error! Please run as administrator!')
|
||||||
return
|
os._exit(0)
|
||||||
|
|
||||||
|
|
||||||
def copyRenameJpgToBackdrop(option, path, number, c_word):
|
def copyRenameJpgToBackdrop():
|
||||||
if option == 'plex':
|
if option == 'plex':
|
||||||
shutil.copy(path + '/fanart.jpg', path + '/Backdrop.jpg')
|
shutil.copy(path + '/fanart.jpg', path + '/Backdrop.jpg')
|
||||||
shutil.copy(path + '/poster.png', path + '/thumb.png')
|
shutil.copy(path + '/poster.png', path + '/thumb.png')
|
||||||
@@ -597,7 +601,7 @@ def copyRenameJpgToBackdrop(option, path, number, c_word):
|
|||||||
shutil.copy(path + '/' + number + c_word + '-fanart.jpg', path + '/Backdrop.jpg')
|
shutil.copy(path + '/' + number + c_word + '-fanart.jpg', path + '/Backdrop.jpg')
|
||||||
|
|
||||||
|
|
||||||
def get_part(filepath, failed_folder):
|
def get_part(filepath):
|
||||||
try:
|
try:
|
||||||
if re.search('-CD\d+', filepath):
|
if re.search('-CD\d+', filepath):
|
||||||
return re.findall('-CD\d+', filepath)[0]
|
return re.findall('-CD\d+', filepath)[0]
|
||||||
@@ -605,68 +609,57 @@ def get_part(filepath, failed_folder):
|
|||||||
return re.findall('-cd\d+', filepath)[0]
|
return re.findall('-cd\d+', filepath)[0]
|
||||||
except:
|
except:
|
||||||
print("[-]failed!Please rename the filename again!")
|
print("[-]failed!Please rename the filename again!")
|
||||||
moveFailedFolder(filepath, failed_folder)
|
moveFailedFolder()
|
||||||
|
|
||||||
|
|
||||||
def debug_mode(json_data):
|
def debug_mode():
|
||||||
try:
|
try:
|
||||||
if config['debug_mode']['switch'] == '1':
|
if config['debug_mode']['switch'] == '1':
|
||||||
print('[+] ---Debug info---')
|
print('[+] ---Debug info---')
|
||||||
for i, v in json_data.items():
|
for i, v in json_data.items():
|
||||||
if i == 'outline':
|
if i == 'outline':
|
||||||
print('[+] -', i, ' :', len(v), 'characters')
|
print('[+] -', i, ':', len(v), 'characters')
|
||||||
continue
|
continue
|
||||||
if i == 'actor_photo' or i == 'year':
|
if i == 'actor_photo' or i == 'year':
|
||||||
continue
|
continue
|
||||||
print('[+] -', "%-11s" % i, ':', v)
|
print('[+] -', i+str(9-len(i)*'-'), ':', v)
|
||||||
print('[+] ---Debug info---')
|
print('[+] ---Debug info---')
|
||||||
except:
|
except:
|
||||||
aaa = ''
|
aaa = ''
|
||||||
|
|
||||||
|
|
||||||
def core_main(file_path, number_th):
|
if __name__ == '__main__':
|
||||||
# =======================================================================初始化所需变量
|
filepath = argparse_get_file()[0] # 影片的路径
|
||||||
multi_part = 0
|
|
||||||
part = ''
|
|
||||||
c_word = ''
|
|
||||||
option = ''
|
|
||||||
cn_sub = ''
|
|
||||||
config_file = 'config.ini'
|
|
||||||
Config = ConfigParser()
|
|
||||||
Config.read(config_file, encoding='UTF-8')
|
|
||||||
try:
|
|
||||||
option = ReadMediaWarehouse()
|
|
||||||
except:
|
|
||||||
print('[-]Config media_warehouse read failed!')
|
|
||||||
program_mode = Config['common']['main_mode'] # 运行模式
|
|
||||||
failed_folder = Config['common']['failed_output_folder'] # 失败输出目录
|
|
||||||
success_folder = Config['common']['success_output_folder'] # 成功输出目录
|
|
||||||
filepath = file_path # 影片的路径
|
|
||||||
number = number_th
|
|
||||||
json_data = getDataFromJSON(number, filepath, failed_folder) # 定义番号
|
|
||||||
imagecut = json_data['imagecut']
|
|
||||||
tag = json_data['tag']
|
|
||||||
# =======================================================================判断-C,-CD后缀
|
|
||||||
if '-CD' in filepath or '-cd' in filepath:
|
if '-CD' in filepath or '-cd' in filepath:
|
||||||
multi_part = 1
|
multi_part = 1
|
||||||
part = get_part(filepath, failed_folder)
|
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'
|
||||||
c_word = '-C' # 中文字幕影片后缀
|
c_word = '-C' #中文字幕影片后缀
|
||||||
|
|
||||||
CreatFailedFolder(failed_folder) # 创建输出失败目录
|
if argparse_get_file()[1] == '': # 如果第二个运行参数为空,获取从第一个参数影片路径的番号
|
||||||
debug_mode(json_data) # 调试模式检测
|
try:
|
||||||
path = creatFolder(success_folder, json_data['location_rule'], json_data, Config) # 创建文件夹
|
number = str(re.findall(r'(.+?)\.', str(re.search('([^<>/\\\\|:""\\*\\?]+)\\.\\w+$', filepath).group()))).strip("['']").replace('_', '-')
|
||||||
# =======================================================================刮削模式
|
print("[!]Making Data for [" + number + "]")
|
||||||
|
except:
|
||||||
|
print("[-]failed!Please rename the filename again!")
|
||||||
|
moveFailedFolder()
|
||||||
|
else:
|
||||||
|
number = argparse_get_file()[1]
|
||||||
|
CreatFailedFolder() # 创建输出失败目录
|
||||||
|
getDataFromJSON(number) # 定义番号
|
||||||
|
debug_mode() # 调试模式检测
|
||||||
|
creatFolder() # 创建文件夹
|
||||||
if program_mode == '1':
|
if program_mode == '1':
|
||||||
if multi_part == 1:
|
if multi_part == 1:
|
||||||
number += part # 这时number会被附加上CD1后缀
|
number += part # 这时number会被附加上CD1后缀
|
||||||
smallCoverCheck(path, number, imagecut, json_data['cover_small'], c_word, option, Config, filepath, failed_folder) # 检查小封面
|
smallCoverCheck() # 检查小封面
|
||||||
imageDownload(option, json_data['cover'], number, c_word, path, multi_part, Config, filepath, failed_folder) # creatFoder会返回番号路径
|
imageDownload() # creatFoder会返回番号路径
|
||||||
cutImage(option, imagecut, path, number, c_word) # 裁剪图
|
cutImage() # 裁剪图
|
||||||
copyRenameJpgToBackdrop(option, path, number, c_word)
|
copyRenameJpgToBackdrop()
|
||||||
PrintFiles(option, path, c_word, json_data['naming_rule'], part, cn_sub, json_data, filepath, failed_folder, tag) # 打印文件
|
PrintFiles() # 打印文件
|
||||||
pasteFileToFolder(filepath, path, number, c_word) # 移动文件
|
# renameBackdropToJpg_copy()
|
||||||
# =======================================================================整理模式
|
pasteFileToFolder(filepath, path) # 移动文件
|
||||||
elif program_mode == '2':
|
elif program_mode == '2':
|
||||||
pasteFileToFolder_mode2(filepath, path, multi_part, number, part, c_word) # 移动文件
|
pasteFileToFolder_mode2(filepath, path) # 移动文件
|
||||||
|
|||||||
@@ -1,678 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
import re
|
|
||||||
import os
|
|
||||||
import os.path
|
|
||||||
import shutil
|
|
||||||
from PIL import Image
|
|
||||||
import time
|
|
||||||
import json
|
|
||||||
from ADC_function import *
|
|
||||||
from configparser import ConfigParser
|
|
||||||
import argparse
|
|
||||||
# =========website========
|
|
||||||
import fc2fans_club
|
|
||||||
import siro
|
|
||||||
import avsox
|
|
||||||
import javbus
|
|
||||||
import javdb
|
|
||||||
import fanza
|
|
||||||
import requests
|
|
||||||
|
|
||||||
|
|
||||||
# =====================本地文件处理===========================
|
|
||||||
|
|
||||||
def escapePath(path, Config): # Remove escape literals
|
|
||||||
escapeLiterals = Config['escape']['literals']
|
|
||||||
backslash = '\\'
|
|
||||||
for literal in escapeLiterals:
|
|
||||||
path = path.replace(backslash + literal, '')
|
|
||||||
return path
|
|
||||||
|
|
||||||
|
|
||||||
def moveFailedFolder(filepath, failed_folder):
|
|
||||||
print('[-]Move to Failed output folder')
|
|
||||||
shutil.move(filepath, str(os.getcwd()) + '/' + failed_folder + '/')
|
|
||||||
os._exit(0)
|
|
||||||
|
|
||||||
|
|
||||||
def CreatFailedFolder(failed_folder):
|
|
||||||
if not os.path.exists(failed_folder + '/'): # 新建failed文件夹
|
|
||||||
try:
|
|
||||||
os.makedirs(failed_folder + '/')
|
|
||||||
except:
|
|
||||||
print("[-]failed!can not be make Failed output folder\n[-](Please run as Administrator)")
|
|
||||||
os._exit(0)
|
|
||||||
|
|
||||||
|
|
||||||
def getDataFromJSON(file_number, filepath, failed_folder): # 从JSON返回元数据
|
|
||||||
# ================================================网站规则添加开始================================================
|
|
||||||
|
|
||||||
if re.match('^\d{5,}', file_number):
|
|
||||||
json_data = json.loads(avsox.main(file_number))
|
|
||||||
if getDataState(json_data) == 0: # 如果元数据获取失败,请求番号至其他网站抓取
|
|
||||||
json_data = json.loads(javdb.main(file_number))
|
|
||||||
# ==
|
|
||||||
elif re.match('\d+\D+', file_number):
|
|
||||||
json_data = json.loads(siro.main(file_number))
|
|
||||||
if getDataState(json_data) == 0: # 如果元数据获取失败,请求番号至其他网站抓取
|
|
||||||
json_data = json.loads(javbus.main(file_number))
|
|
||||||
if 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.replace('fc2-', '').replace('fc2_', '').replace('FC2-', '').replace('fc2_', '')))
|
|
||||||
# ==
|
|
||||||
elif 'HEYZO' in file_number or 'heyzo' in file_number or 'Heyzo' in file_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))
|
|
||||||
elif not '-' in file_number or '_' in file_number:
|
|
||||||
json_data = json.loads(fanza.main(file_number))
|
|
||||||
if getDataState(json_data) == 0: # 如果元数据获取失败,请求番号至其他网站抓取
|
|
||||||
json_data = json.loads(javbus.main(file_number))
|
|
||||||
if getDataState(json_data) == 0: # 如果元数据获取失败,请求番号至其他网站抓取
|
|
||||||
json_data = json.loads(avsox.main(file_number))
|
|
||||||
if getDataState(json_data) == 0: # 如果元数据获取失败,请求番号至其他网站抓取
|
|
||||||
json_data = json.loads(javdb.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))
|
|
||||||
if getDataState(json_data) == 0: # 如果元数据获取失败,请求番号至其他网站抓取
|
|
||||||
json_data = json.loads(javdb.main(file_number))
|
|
||||||
|
|
||||||
# ================================================网站规则添加结束================================================
|
|
||||||
|
|
||||||
title = json_data['title']
|
|
||||||
actor_list = str(json_data['actor']).strip("[ ]").replace("'", '').split(',') # 字符串转列表
|
|
||||||
release = json_data['release']
|
|
||||||
number = json_data['number']
|
|
||||||
try:
|
|
||||||
cover_small = json_data['cover_small']
|
|
||||||
except:
|
|
||||||
cover_small = ''
|
|
||||||
imagecut = json_data['imagecut']
|
|
||||||
tag = str(json_data['tag']).strip("[ ]").replace("'", '').replace(" ", '').split(',') # 字符串转列表 @
|
|
||||||
actor = str(actor_list).strip("[ ]").replace("'", '').replace(" ", '')
|
|
||||||
|
|
||||||
if title == '' or number == '':
|
|
||||||
print('[-]Movie Data not found!')
|
|
||||||
moveFailedFolder(filepath, failed_folder)
|
|
||||||
|
|
||||||
# if imagecut == '3':
|
|
||||||
# DownloadFileWithFilename()
|
|
||||||
|
|
||||||
# ====================处理异常字符====================== #\/:*?"<>|
|
|
||||||
title = title.replace('\\', '')
|
|
||||||
title = title.replace('/', '')
|
|
||||||
title = title.replace(':', '')
|
|
||||||
title = title.replace('*', '')
|
|
||||||
title = title.replace('?', '')
|
|
||||||
title = title.replace('"', '')
|
|
||||||
title = title.replace('<', '')
|
|
||||||
title = title.replace('>', '')
|
|
||||||
title = title.replace('|', '')
|
|
||||||
release = release.replace('/', '-')
|
|
||||||
tmpArr = cover_small.split(',')
|
|
||||||
if len(tmpArr) > 0:
|
|
||||||
cover_small = tmpArr[0].strip('\"').strip('\'')
|
|
||||||
# ====================处理异常字符 END================== #\/:*?"<>|
|
|
||||||
|
|
||||||
naming_rule = eval(config['Name_Rule']['naming_rule'])
|
|
||||||
location_rule = eval(config['Name_Rule']['location_rule'])
|
|
||||||
|
|
||||||
# 返回处理后的json_data
|
|
||||||
json_data['title'] = title
|
|
||||||
json_data['actor'] = actor
|
|
||||||
json_data['release'] = release
|
|
||||||
json_data['cover_small'] = cover_small
|
|
||||||
json_data['tag'] = tag
|
|
||||||
json_data['naming_rule'] = naming_rule
|
|
||||||
json_data['location_rule'] = location_rule
|
|
||||||
return json_data
|
|
||||||
|
|
||||||
|
|
||||||
def get_info(json_data): # 返回json里的数据
|
|
||||||
title = json_data['title']
|
|
||||||
studio = json_data['studio']
|
|
||||||
year = json_data['year']
|
|
||||||
outline = json_data['outline']
|
|
||||||
runtime = json_data['runtime']
|
|
||||||
director = json_data['director']
|
|
||||||
actor_photo = json_data['actor_photo']
|
|
||||||
release = json_data['release']
|
|
||||||
number = json_data['number']
|
|
||||||
cover = json_data['cover']
|
|
||||||
website = json_data['website']
|
|
||||||
return title, studio, year, outline, runtime, director, actor_photo, release, number, cover, website
|
|
||||||
|
|
||||||
|
|
||||||
def smallCoverCheck(path, number, imagecut, cover_small, c_word, option, Config, filepath, failed_folder):
|
|
||||||
if imagecut == 3:
|
|
||||||
if option == 'emby':
|
|
||||||
DownloadFileWithFilename(cover_small, '1.jpg', path, Config, filepath, failed_folder)
|
|
||||||
try:
|
|
||||||
img = Image.open(path + '/1.jpg')
|
|
||||||
except Exception:
|
|
||||||
img = Image.open('1.jpg')
|
|
||||||
w = img.width
|
|
||||||
h = img.height
|
|
||||||
img.save(path + '/' + number + c_word + '.png')
|
|
||||||
time.sleep(1)
|
|
||||||
os.remove(path + '/1.jpg')
|
|
||||||
if option == 'kodi':
|
|
||||||
DownloadFileWithFilename(cover_small, '1.jpg', path, Config, filepath, failed_folder)
|
|
||||||
try:
|
|
||||||
img = Image.open(path + '/1.jpg')
|
|
||||||
except Exception:
|
|
||||||
img = Image.open('1.jpg')
|
|
||||||
w = img.width
|
|
||||||
h = img.height
|
|
||||||
img.save(path + '/' + number + c_word + '-poster.jpg')
|
|
||||||
time.sleep(1)
|
|
||||||
os.remove(path + '/1.jpg')
|
|
||||||
if option == 'plex':
|
|
||||||
DownloadFileWithFilename(cover_small, '1.jpg', path, Config, filepath, failed_folder)
|
|
||||||
try:
|
|
||||||
img = Image.open(path + '/1.jpg')
|
|
||||||
except Exception:
|
|
||||||
img = Image.open('1.jpg')
|
|
||||||
w = img.width
|
|
||||||
h = img.height
|
|
||||||
img.save(path + '/poster.png')
|
|
||||||
os.remove(path + '/1.jpg')
|
|
||||||
|
|
||||||
|
|
||||||
def creatFolder(success_folder, location_rule, json_data, Config): # 创建文件夹
|
|
||||||
title, studio, year, outline, runtime, director, actor_photo, release, number, cover, website = get_info(json_data)
|
|
||||||
if len(location_rule) > 240: # 新建成功输出文件夹
|
|
||||||
path = success_folder + '/' + location_rule.replace("'actor'", "'manypeople'", 3).replace("actor","'manypeople'",3) # path为影片+元数据所在目录
|
|
||||||
else:
|
|
||||||
path = success_folder + '/' + location_rule
|
|
||||||
# print(path)
|
|
||||||
if not os.path.exists(path):
|
|
||||||
path = escapePath(path, Config)
|
|
||||||
try:
|
|
||||||
os.makedirs(path)
|
|
||||||
except:
|
|
||||||
path = success_folder + '/' + location_rule.replace('/[' + number + ']-' + title, "/number")
|
|
||||||
path = escapePath(path, Config)
|
|
||||||
os.makedirs(path)
|
|
||||||
return path
|
|
||||||
|
|
||||||
|
|
||||||
# =====================资源下载部分===========================
|
|
||||||
def DownloadFileWithFilename(url, filename, path, Config, filepath, failed_folder): # path = examle:photo , video.in the Project Folder!
|
|
||||||
retry_count = 0
|
|
||||||
proxy = ''
|
|
||||||
timeout = 0
|
|
||||||
try:
|
|
||||||
proxy = Config['proxy']['proxy']
|
|
||||||
timeout = int(Config['proxy']['timeout'])
|
|
||||||
retry_count = int(Config['proxy']['retry'])
|
|
||||||
except:
|
|
||||||
print('[-]Proxy config error! Please check the config.')
|
|
||||||
i = 0
|
|
||||||
|
|
||||||
while i < retry_count:
|
|
||||||
try:
|
|
||||||
if not proxy == '':
|
|
||||||
if not os.path.exists(path):
|
|
||||||
os.makedirs(path)
|
|
||||||
headers = {
|
|
||||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36'}
|
|
||||||
r = requests.get(url, headers=headers, timeout=timeout,
|
|
||||||
proxies={"http": "http://" + str(proxy), "https": "https://" + str(proxy)})
|
|
||||||
if r == '':
|
|
||||||
print('[-]Movie Data not found!')
|
|
||||||
os._exit(0)
|
|
||||||
with open(str(path) + "/" + filename, "wb") as code:
|
|
||||||
code.write(r.content)
|
|
||||||
return
|
|
||||||
else:
|
|
||||||
if not os.path.exists(path):
|
|
||||||
os.makedirs(path)
|
|
||||||
headers = {
|
|
||||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36'}
|
|
||||||
r = requests.get(url, timeout=timeout, headers=headers)
|
|
||||||
if r == '':
|
|
||||||
print('[-]Movie Data not found!')
|
|
||||||
os._exit(0)
|
|
||||||
with open(str(path) + "/" + filename, "wb") as code:
|
|
||||||
code.write(r.content)
|
|
||||||
return
|
|
||||||
except requests.exceptions.RequestException:
|
|
||||||
i += 1
|
|
||||||
print('[-]Image Download : Connect retry ' + str(i) + '/' + str(retry_count))
|
|
||||||
except requests.exceptions.ConnectionError:
|
|
||||||
i += 1
|
|
||||||
print('[-]Image Download : Connect retry ' + str(i) + '/' + str(retry_count))
|
|
||||||
except requests.exceptions.ProxyError:
|
|
||||||
i += 1
|
|
||||||
print('[-]Image Download : Connect retry ' + str(i) + '/' + str(retry_count))
|
|
||||||
except requests.exceptions.ConnectTimeout:
|
|
||||||
i += 1
|
|
||||||
print('[-]Image Download : Connect retry ' + str(i) + '/' + str(retry_count))
|
|
||||||
print('[-]Connect Failed! Please check your Proxy or Network!')
|
|
||||||
moveFailedFolder(filepath, failed_folder)
|
|
||||||
|
|
||||||
|
|
||||||
def imageDownload(option, cover, number, c_word, path, multi_part, Config, filepath, failed_folder): # 封面是否下载成功,否则移动到failed
|
|
||||||
if option == 'emby':
|
|
||||||
if DownloadFileWithFilename(cover, number + c_word + '.jpg', path, Config, filepath, failed_folder) == 'failed':
|
|
||||||
moveFailedFolder(filepath, failed_folder)
|
|
||||||
DownloadFileWithFilename(cover, number + c_word + '.jpg', path, Config, filepath, failed_folder)
|
|
||||||
if not os.path.getsize(path + '/' + number + c_word + '.jpg') == 0:
|
|
||||||
print('[+]Image Downloaded!', path + '/' + number + c_word + '.jpg')
|
|
||||||
return
|
|
||||||
i = 1
|
|
||||||
while i <= int(config['proxy']['retry']):
|
|
||||||
if os.path.getsize(path + '/' + number + c_word + '.jpg') == 0:
|
|
||||||
print('[!]Image Download Failed! Trying again. [' + config['proxy']['retry'] + '/3]')
|
|
||||||
DownloadFileWithFilename(cover, number + c_word + '.jpg', path, Config, filepath, failed_folder)
|
|
||||||
i = i + 1
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
break
|
|
||||||
if multi_part == 1:
|
|
||||||
old_name = os.path.join(path, number + c_word + '.jpg')
|
|
||||||
new_name = os.path.join(path, number + c_word + '.jpg')
|
|
||||||
os.rename(old_name, new_name)
|
|
||||||
print('[+]Image Downloaded!', path + '/' + number + c_word + '.jpg')
|
|
||||||
else:
|
|
||||||
print('[+]Image Downloaded!', path + '/' + number + c_word + '.jpg')
|
|
||||||
elif option == 'plex':
|
|
||||||
if DownloadFileWithFilename(cover, 'fanart.jpg', path, Config, filepath, failed_folder) == 'failed':
|
|
||||||
moveFailedFolder(filepath, failed_folder)
|
|
||||||
DownloadFileWithFilename(cover, 'fanart.jpg', path, Config, filepath, failed_folder)
|
|
||||||
if not os.path.getsize(path + '/fanart.jpg') == 0:
|
|
||||||
print('[+]Image Downloaded!', path + '/fanart.jpg')
|
|
||||||
return
|
|
||||||
i = 1
|
|
||||||
while i <= int(config['proxy']['retry']):
|
|
||||||
if os.path.getsize(path + '/fanart.jpg') == 0:
|
|
||||||
print('[!]Image Download Failed! Trying again. [' + config['proxy']['retry'] + '/3]')
|
|
||||||
DownloadFileWithFilename(cover, 'fanart.jpg', path, Config, filepath, failed_folder)
|
|
||||||
i = i + 1
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
break
|
|
||||||
if not os.path.getsize(path + '/' + number + c_word + '.jpg') == 0:
|
|
||||||
print('[!]Image Download Failed! Trying again.')
|
|
||||||
DownloadFileWithFilename(cover, number + c_word + '.jpg', path, Config, filepath, failed_folder)
|
|
||||||
print('[+]Image Downloaded!', path + '/fanart.jpg')
|
|
||||||
elif option == 'kodi':
|
|
||||||
if DownloadFileWithFilename(cover, number + c_word + '-fanart.jpg', path, Config, filepath, failed_folder) == 'failed':
|
|
||||||
moveFailedFolder(filepath, failed_folder)
|
|
||||||
DownloadFileWithFilename(cover, number + c_word + '-fanart.jpg', path, Config, filepath, failed_folder)
|
|
||||||
if not os.path.getsize(path + '/' + number + c_word + '-fanart.jpg') == 0:
|
|
||||||
print('[+]Image Downloaded!', path + '/' + number + c_word + '-fanart.jpg')
|
|
||||||
return
|
|
||||||
i = 1
|
|
||||||
while i <= int(config['proxy']['retry']):
|
|
||||||
if os.path.getsize(path + '/' + number + c_word + '-fanart.jpg') == 0:
|
|
||||||
print('[!]Image Download Failed! Trying again. [' + config['proxy']['retry'] + '/3]')
|
|
||||||
DownloadFileWithFilename(cover, number + c_word + '-fanart.jpg', path, Config, filepath, failed_folder)
|
|
||||||
i = i + 1
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
break
|
|
||||||
print('[+]Image Downloaded!', path + '/' + number + c_word + '-fanart.jpg')
|
|
||||||
|
|
||||||
|
|
||||||
def PrintFiles(option, path, c_word, naming_rule, part, cn_sub, json_data, filepath, failed_folder, tag):
|
|
||||||
title, studio, year, outline, runtime, director, actor_photo, release, number, cover, website = get_info(json_data)
|
|
||||||
try:
|
|
||||||
if not os.path.exists(path):
|
|
||||||
os.makedirs(path)
|
|
||||||
if option == 'plex':
|
|
||||||
with open(path + "/" + number + c_word + ".nfo", "wt", encoding='UTF-8') as code:
|
|
||||||
print('<?xml version="1.0" encoding="UTF-8" ?>', file=code)
|
|
||||||
print("<movie>", file=code)
|
|
||||||
print(" <title>" + naming_rule + part + "</title>", file=code)
|
|
||||||
print(" <set>", file=code)
|
|
||||||
print(" </set>", file=code)
|
|
||||||
print(" <studio>" + studio + "+</studio>", file=code)
|
|
||||||
print(" <year>" + year + "</year>", file=code)
|
|
||||||
print(" <outline>" + outline + "</outline>", file=code)
|
|
||||||
print(" <plot>" + outline + "</plot>", file=code)
|
|
||||||
print(" <runtime>" + str(runtime).replace(" ", "") + "</runtime>", file=code)
|
|
||||||
print(" <director>" + director + "</director>", file=code)
|
|
||||||
print(" <poster>poster.png</poster>", file=code)
|
|
||||||
print(" <thumb>thumb.png</thumb>", file=code)
|
|
||||||
print(" <fanart>fanart.jpg</fanart>", file=code)
|
|
||||||
try:
|
|
||||||
for key, value in actor_photo.items():
|
|
||||||
print(" <actor>", file=code)
|
|
||||||
print(" <name>" + key + "</name>", file=code)
|
|
||||||
if not value == '': # or actor_photo == []:
|
|
||||||
print(" <thumb>" + value + "</thumb>", file=code)
|
|
||||||
print(" </actor>", file=code)
|
|
||||||
except:
|
|
||||||
aaaa = ''
|
|
||||||
print(" <maker>" + studio + "</maker>", file=code)
|
|
||||||
print(" <label>", file=code)
|
|
||||||
print(" </label>", file=code)
|
|
||||||
if cn_sub == '1':
|
|
||||||
print(" <tag>中文字幕</tag>", file=code)
|
|
||||||
try:
|
|
||||||
for i in str(json_data['tag']).strip("[ ]").replace("'", '').replace(" ", '').split(','):
|
|
||||||
print(" <tag>" + i + "</tag>", file=code)
|
|
||||||
except:
|
|
||||||
aaaaa = ''
|
|
||||||
try:
|
|
||||||
for i in str(json_data['tag']).strip("[ ]").replace("'", '').replace(" ", '').split(','):
|
|
||||||
print(" <genre>" + i + "</genre>", file=code)
|
|
||||||
except:
|
|
||||||
aaaaaaaa = ''
|
|
||||||
if cn_sub == '1':
|
|
||||||
print(" <genre>中文字幕</genre>", file=code)
|
|
||||||
print(" <num>" + number + "</num>", file=code)
|
|
||||||
print(" <release>" + release + "</release>", file=code)
|
|
||||||
print(" <cover>" + cover + "</cover>", file=code)
|
|
||||||
print(" <website>" + website + "</website>", file=code)
|
|
||||||
print("</movie>", file=code)
|
|
||||||
print("[+]Writeed! " + path + "/" + number + ".nfo")
|
|
||||||
elif option == 'emby':
|
|
||||||
with open(path + "/" + number + c_word + ".nfo", "wt", encoding='UTF-8') as code:
|
|
||||||
print('<?xml version="1.0" encoding="UTF-8" ?>', file=code)
|
|
||||||
print("<movie>", file=code)
|
|
||||||
print(" <title>" + naming_rule + part + "</title>", file=code)
|
|
||||||
print(" <set>", file=code)
|
|
||||||
print(" </set>", file=code)
|
|
||||||
print(" <studio>" + studio + "+</studio>", file=code)
|
|
||||||
print(" <year>" + year + "</year>", file=code)
|
|
||||||
print(" <outline>" + outline + "</outline>", file=code)
|
|
||||||
print(" <plot>" + outline + "</plot>", file=code)
|
|
||||||
print(" <runtime>" + str(runtime).replace(" ", "") + "</runtime>", file=code)
|
|
||||||
print(" <director>" + director + "</director>", file=code)
|
|
||||||
print(" <poster>" + number + c_word + ".png</poster>", file=code)
|
|
||||||
print(" <thumb>" + number + c_word + ".png</thumb>", file=code)
|
|
||||||
print(" <fanart>" + number + c_word + '.jpg' + "</fanart>", file=code)
|
|
||||||
try:
|
|
||||||
for key, value in actor_photo.items():
|
|
||||||
print(" <actor>", file=code)
|
|
||||||
print(" <name>" + key + "</name>", file=code)
|
|
||||||
if not value == '': # or actor_photo == []:
|
|
||||||
print(" <thumb>" + value + "</thumb>", file=code)
|
|
||||||
print(" </actor>", file=code)
|
|
||||||
except:
|
|
||||||
aaaa = ''
|
|
||||||
print(" <maker>" + studio + "</maker>", file=code)
|
|
||||||
print(" <label>", file=code)
|
|
||||||
print(" </label>", file=code)
|
|
||||||
if cn_sub == '1':
|
|
||||||
print(" <tag>中文字幕</tag>", file=code)
|
|
||||||
try:
|
|
||||||
for i in tag:
|
|
||||||
print(" <tag>" + i + "</tag>", file=code)
|
|
||||||
except:
|
|
||||||
aaaaa = ''
|
|
||||||
try:
|
|
||||||
for i in tag:
|
|
||||||
print(" <genre>" + i + "</genre>", file=code)
|
|
||||||
except:
|
|
||||||
aaaaaaaa = ''
|
|
||||||
if cn_sub == '1':
|
|
||||||
print(" <genre>中文字幕</genre>", file=code)
|
|
||||||
print(" <num>" + number + "</num>", file=code)
|
|
||||||
print(" <premiered>" + release + "</premiered>", file=code)
|
|
||||||
print(" <cover>" + cover + "</cover>", file=code)
|
|
||||||
print(" <website>" + "https://www.javbus.com/" + number + "</website>", file=code)
|
|
||||||
print("</movie>", file=code)
|
|
||||||
print("[+]Writeed! " + path + "/" + number + c_word + ".nfo")
|
|
||||||
elif option == 'kodi':
|
|
||||||
with open(path + "/" + number + c_word + ".nfo", "wt", encoding='UTF-8') as code:
|
|
||||||
print('<?xml version="1.0" encoding="UTF-8" ?>', file=code)
|
|
||||||
print("<movie>", file=code)
|
|
||||||
print(" <title>" + naming_rule + part + "</title>", file=code)
|
|
||||||
print(" <set>", file=code)
|
|
||||||
print(" </set>", file=code)
|
|
||||||
print(" <studio>" + studio + "+</studio>", file=code)
|
|
||||||
print(" <year>" + year + "</year>", file=code)
|
|
||||||
print(" <outline>" + outline + "</outline>", file=code)
|
|
||||||
print(" <plot>" + outline + "</plot>", file=code)
|
|
||||||
print(" <runtime>" + str(runtime).replace(" ", "") + "</runtime>", file=code)
|
|
||||||
print(" <director>" + director + "</director>", file=code)
|
|
||||||
print(" <poster>" + number + c_word + "-poster.jpg</poster>", file=code)
|
|
||||||
print(" <fanart>" + number + c_word + '-fanart.jpg' + "</fanart>", file=code)
|
|
||||||
try:
|
|
||||||
for key, value in actor_photo.items():
|
|
||||||
print(" <actor>", file=code)
|
|
||||||
print(" <name>" + key + "</name>", file=code)
|
|
||||||
if not value == '': # or actor_photo == []:
|
|
||||||
print(" <thumb>" + value + "</thumb>", file=code)
|
|
||||||
print(" </actor>", file=code)
|
|
||||||
except:
|
|
||||||
aaaa = ''
|
|
||||||
print(" <maker>" + studio + "</maker>", file=code)
|
|
||||||
print(" <label>", file=code)
|
|
||||||
print(" </label>", file=code)
|
|
||||||
if cn_sub == '1':
|
|
||||||
print(" <tag>中文字幕</tag>", file=code)
|
|
||||||
try:
|
|
||||||
for i in tag:
|
|
||||||
print(" <tag>" + i + "</tag>", file=code)
|
|
||||||
except:
|
|
||||||
aaaaa = ''
|
|
||||||
try:
|
|
||||||
for i in tag:
|
|
||||||
print(" <genre>" + i + "</genre>", file=code)
|
|
||||||
except:
|
|
||||||
aaaaaaaa = ''
|
|
||||||
if cn_sub == '1':
|
|
||||||
print(" <genre>中文字幕</genre>", file=code)
|
|
||||||
print(" <num>" + number + "</num>", file=code)
|
|
||||||
print(" <release>" + release + "</release>", file=code)
|
|
||||||
print(" <cover>" + cover + "</cover>", file=code)
|
|
||||||
print(" <website>" + "https://www.javbus.com/" + number + "</website>", file=code)
|
|
||||||
print("</movie>", file=code)
|
|
||||||
print("[+]Writeed! " + path + "/" + number + c_word + ".nfo")
|
|
||||||
except IOError as e:
|
|
||||||
print("[-]Write Failed!")
|
|
||||||
print(e)
|
|
||||||
moveFailedFolder(filepath, failed_folder)
|
|
||||||
except Exception as e1:
|
|
||||||
print(e1)
|
|
||||||
print("[-]Write Failed!")
|
|
||||||
moveFailedFolder(filepath, failed_folder)
|
|
||||||
|
|
||||||
|
|
||||||
def cutImage(option, imagecut, path, number, c_word):
|
|
||||||
if option == 'plex':
|
|
||||||
if imagecut == 1:
|
|
||||||
try:
|
|
||||||
img = Image.open(path + '/fanart.jpg')
|
|
||||||
imgSize = img.size
|
|
||||||
w = img.width
|
|
||||||
h = img.height
|
|
||||||
img2 = img.crop((w / 1.9, 0, w, h))
|
|
||||||
img2.save(path + '/poster.png')
|
|
||||||
except:
|
|
||||||
print('[-]Cover cut failed!')
|
|
||||||
elif imagecut == 0:
|
|
||||||
img = Image.open(path + '/fanart.jpg')
|
|
||||||
w = img.width
|
|
||||||
h = img.height
|
|
||||||
img.save(path + '/poster.png')
|
|
||||||
elif option == 'emby':
|
|
||||||
if imagecut == 1:
|
|
||||||
try:
|
|
||||||
img = Image.open(path + '/' + number + c_word + '.jpg')
|
|
||||||
imgSize = img.size
|
|
||||||
w = img.width
|
|
||||||
h = img.height
|
|
||||||
img2 = img.crop((w / 1.9, 0, w, h))
|
|
||||||
img2.save(path + '/' + number + c_word + '.png')
|
|
||||||
except:
|
|
||||||
print('[-]Cover cut failed!')
|
|
||||||
elif imagecut == 0:
|
|
||||||
img = Image.open(path + '/' + number + c_word + '.jpg')
|
|
||||||
w = img.width
|
|
||||||
h = img.height
|
|
||||||
img.save(path + '/' + number + c_word + '.png')
|
|
||||||
elif option == 'kodi':
|
|
||||||
if imagecut == 1:
|
|
||||||
try:
|
|
||||||
img = Image.open(path + '/' + number + c_word + '-fanart.jpg')
|
|
||||||
imgSize = img.size
|
|
||||||
w = img.width
|
|
||||||
h = img.height
|
|
||||||
img2 = img.crop((w / 1.9, 0, w, h))
|
|
||||||
img2.save(path + '/' + number + c_word + '-poster.jpg')
|
|
||||||
except:
|
|
||||||
print('[-]Cover cut failed!')
|
|
||||||
elif imagecut == 0:
|
|
||||||
img = Image.open(path + '/' + number + c_word + '-fanart.jpg')
|
|
||||||
w = img.width
|
|
||||||
h = img.height
|
|
||||||
try:
|
|
||||||
img = img.convert('RGB')
|
|
||||||
img.save(path + '/' + number + c_word + '-poster.jpg')
|
|
||||||
except:
|
|
||||||
img = img.convert('RGB')
|
|
||||||
img.save(path + '/' + number + c_word + '-poster.jpg')
|
|
||||||
|
|
||||||
|
|
||||||
def pasteFileToFolder(filepath, path, number, c_word): # 文件路径,番号,后缀,要移动至的位置
|
|
||||||
houzhui = str(re.search('[.](AVI|RMVB|WMV|MOV|MP4|MKV|FLV|TS|avi|rmvb|wmv|mov|mp4|mkv|flv|ts)$', filepath).group())
|
|
||||||
try:
|
|
||||||
if config['common']['soft_link'] == '1': # 如果soft_link=1 使用软链接
|
|
||||||
os.symlink(filepath, path + '/' + number + c_word + houzhui)
|
|
||||||
else:
|
|
||||||
os.rename(filepath, path + '/' + number + c_word + houzhui)
|
|
||||||
if os.path.exists(os.getcwd() + '/' + number + c_word + '.srt'): # 字幕移动
|
|
||||||
os.rename(os.getcwd() + '/' + number + c_word + '.srt', path + '/' + number + c_word + '.srt')
|
|
||||||
print('[+]Sub moved!')
|
|
||||||
elif os.path.exists(os.getcwd() + '/' + number + c_word + '.ssa'):
|
|
||||||
os.rename(os.getcwd() + '/' + number + c_word + '.ssa', path + '/' + number + c_word + '.ssa')
|
|
||||||
print('[+]Sub moved!')
|
|
||||||
elif os.path.exists(os.getcwd() + '/' + number + c_word + '.sub'):
|
|
||||||
os.rename(os.getcwd() + '/' + number + c_word + '.sub', path + '/' + number + c_word + '.sub')
|
|
||||||
print('[+]Sub moved!')
|
|
||||||
except FileExistsError:
|
|
||||||
print('[-]File Exists! Please check your movie!')
|
|
||||||
print('[-]move to the root folder of the program.')
|
|
||||||
os._exit(0)
|
|
||||||
except PermissionError:
|
|
||||||
print('[-]Error! Please run as administrator!')
|
|
||||||
os._exit(0)
|
|
||||||
|
|
||||||
|
|
||||||
def pasteFileToFolder_mode2(filepath, path, multi_part, number, part, c_word): # 文件路径,番号,后缀,要移动至的位置
|
|
||||||
if multi_part == 1:
|
|
||||||
number += part # 这时number会被附加上CD1后缀
|
|
||||||
houzhui = str(re.search('[.](AVI|RMVB|WMV|MOV|MP4|MKV|FLV|TS|avi|rmvb|wmv|mov|mp4|mkv|flv|ts)$', filepath).group())
|
|
||||||
try:
|
|
||||||
if config['common']['soft_link'] == '1':
|
|
||||||
os.symlink(filepath, path + '/' + number + part + c_word + houzhui)
|
|
||||||
else:
|
|
||||||
os.rename(filepath, path + '/' + number + part + c_word + houzhui)
|
|
||||||
if os.path.exists(number + '.srt'): # 字幕移动
|
|
||||||
os.rename(number + part + c_word + '.srt', path + '/' + number + part + c_word + '.srt')
|
|
||||||
print('[+]Sub moved!')
|
|
||||||
elif os.path.exists(number + part + c_word + '.ass'):
|
|
||||||
os.rename(number + part + c_word + '.ass', path + '/' + number + part + c_word + '.ass')
|
|
||||||
print('[+]Sub moved!')
|
|
||||||
elif os.path.exists(number + part + c_word + '.sub'):
|
|
||||||
os.rename(number + part + c_word + '.sub', path + '/' + number + part + c_word + '.sub')
|
|
||||||
print('[+]Sub moved!')
|
|
||||||
print('[!]Success')
|
|
||||||
except FileExistsError:
|
|
||||||
print('[-]File Exists! Please check your movie!')
|
|
||||||
print('[-]move to the root folder of the program.')
|
|
||||||
os._exit(0)
|
|
||||||
except PermissionError:
|
|
||||||
print('[-]Error! Please run as administrator!')
|
|
||||||
os._exit(0)
|
|
||||||
|
|
||||||
|
|
||||||
def copyRenameJpgToBackdrop(option, path, number, c_word):
|
|
||||||
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 + '/' + number + c_word + '.jpg', path + '/Backdrop.jpg')
|
|
||||||
if option == 'kodi':
|
|
||||||
shutil.copy(path + '/' + number + c_word + '-fanart.jpg', path + '/Backdrop.jpg')
|
|
||||||
|
|
||||||
|
|
||||||
def get_part(filepath, failed_folder):
|
|
||||||
try:
|
|
||||||
if re.search('-CD\d+', filepath):
|
|
||||||
return re.findall('-CD\d+', filepath)[0]
|
|
||||||
if re.search('-cd\d+', filepath):
|
|
||||||
return re.findall('-cd\d+', filepath)[0]
|
|
||||||
except:
|
|
||||||
print("[-]failed!Please rename the filename again!")
|
|
||||||
moveFailedFolder(filepath, failed_folder)
|
|
||||||
|
|
||||||
|
|
||||||
def debug_mode(json_data):
|
|
||||||
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('[+] -', "%-11s" % i, ':', v)
|
|
||||||
print('[+] ---Debug info---')
|
|
||||||
except:
|
|
||||||
aaa = ''
|
|
||||||
|
|
||||||
|
|
||||||
def core_main(file_path, number_th):
|
|
||||||
# =======================================================================初始化所需变量
|
|
||||||
multi_part = 0
|
|
||||||
part = ''
|
|
||||||
c_word = ''
|
|
||||||
option = ''
|
|
||||||
cn_sub = ''
|
|
||||||
path = ''
|
|
||||||
config_file = 'config.ini'
|
|
||||||
Config = ConfigParser()
|
|
||||||
Config.read(config_file, encoding='UTF-8')
|
|
||||||
try:
|
|
||||||
option = ReadMediaWarehouse()
|
|
||||||
except:
|
|
||||||
print('[-]Config media_warehouse read failed!')
|
|
||||||
program_mode = Config['common']['main_mode'] # 运行模式
|
|
||||||
failed_folder = Config['common']['failed_output_folder'] # 失败输出目录
|
|
||||||
success_folder = Config['common']['success_output_folder'] # 成功输出目录
|
|
||||||
filepath = file_path # 影片的路径
|
|
||||||
number = number_th
|
|
||||||
json_data = getDataFromJSON(number, filepath, failed_folder) # 定义番号
|
|
||||||
imagecut = json_data['imagecut']
|
|
||||||
tag = json_data['tag']
|
|
||||||
# =======================================================================判断-C,-CD后缀
|
|
||||||
if '-CD' in filepath or '-cd' in filepath:
|
|
||||||
multi_part = 1
|
|
||||||
part = get_part(filepath, failed_folder)
|
|
||||||
if '-c.' in filepath or '-C.' in filepath or '中文' in filepath or '字幕' in filepath:
|
|
||||||
cn_sub = '1'
|
|
||||||
c_word = '-C' # 中文字幕影片后缀
|
|
||||||
|
|
||||||
CreatFailedFolder(failed_folder) # 创建输出失败目录
|
|
||||||
debug_mode(json_data) # 调试模式检测
|
|
||||||
path = creatFolder(success_folder, json_data['location_rule'], json_data, Config) # 创建文件夹
|
|
||||||
print(path)
|
|
||||||
# =======================================================================刮削模式
|
|
||||||
if program_mode == '1':
|
|
||||||
if multi_part == 1:
|
|
||||||
number += part # 这时number会被附加上CD1后缀
|
|
||||||
smallCoverCheck(path, number, imagecut, json_data['cover_small'], c_word, option, Config, filepath, failed_folder) # 检查小封面
|
|
||||||
imageDownload(option, json_data['cover'], number, c_word, path, multi_part, Config, filepath, failed_folder) # creatFoder会返回番号路径
|
|
||||||
cutImage(option, imagecut, path, number, c_word) # 裁剪图
|
|
||||||
copyRenameJpgToBackdrop(option, path, number, c_word)
|
|
||||||
PrintFiles(option, path, c_word, json_data['naming_rule'], part, cn_sub, json_data, filepath, failed_folder, tag) # 打印文件
|
|
||||||
pasteFileToFolder(filepath, path, number, c_word) # 移动文件
|
|
||||||
# =======================================================================整理模式
|
|
||||||
elif program_mode == '2':
|
|
||||||
pasteFileToFolder_mode2(filepath, path, multi_part, number, part, c_word) # 移动文件
|
|
||||||
@@ -1,113 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import re
|
|
||||||
from lxml import etree
|
|
||||||
import json
|
|
||||||
from ADC_function import *
|
|
||||||
# import sys
|
|
||||||
# import io
|
|
||||||
# sys.stdout = io.TextIOWrapper(sys.stdout.buffer, errors = 'replace', line_buffering = True)
|
|
||||||
|
|
||||||
def getTitle(a):
|
|
||||||
html = etree.fromstring(a, etree.HTMLParser())
|
|
||||||
result = html.xpath('//*[@id="title"]/text()')[0]
|
|
||||||
return result
|
|
||||||
def getActor(a): #//*[@id="center_column"]/div[2]/div[1]/div/table/tbody/tr[1]/td/text()
|
|
||||||
html = etree.fromstring(a, etree.HTMLParser())
|
|
||||||
result = str(html.xpath("//td[contains(text(),'出演者')]/following-sibling::td/span/a/text()")).strip(" ['']").replace("', '",',')
|
|
||||||
return result
|
|
||||||
def getStudio(a):
|
|
||||||
html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text()
|
|
||||||
try:
|
|
||||||
result1 = html.xpath("//td[contains(text(),'メーカー')]/following-sibling::td/a/text()")[0]
|
|
||||||
except:
|
|
||||||
result1 = html.xpath("//td[contains(text(),'メーカー')]/following-sibling::td/text()")[0]
|
|
||||||
return result1
|
|
||||||
def getRuntime(a):
|
|
||||||
html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text()
|
|
||||||
result1 = html.xpath("//td[contains(text(),'収録時間')]/following-sibling::td/text()")[0]
|
|
||||||
return re.search('\d+', str(result1)).group()
|
|
||||||
def getLabel(a):
|
|
||||||
html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text()
|
|
||||||
try:
|
|
||||||
result1 = html.xpath("//td[contains(text(),'シリーズ:')]/following-sibling::td/a/text()")[0]
|
|
||||||
except:
|
|
||||||
result1 = html.xpath("//td[contains(text(),'シリーズ:')]/following-sibling::td/text()")[0]
|
|
||||||
return result1
|
|
||||||
def getNum(a):
|
|
||||||
html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text()
|
|
||||||
try:
|
|
||||||
result1 = html.xpath("//td[contains(text(),'品番:')]/following-sibling::td/a/text()")[0]
|
|
||||||
except:
|
|
||||||
result1 = html.xpath("//td[contains(text(),'品番:')]/following-sibling::td/text()")[0]
|
|
||||||
return result1
|
|
||||||
def getYear(getRelease):
|
|
||||||
try:
|
|
||||||
result = str(re.search('\d{4}',getRelease).group())
|
|
||||||
return result
|
|
||||||
except:
|
|
||||||
return getRelease
|
|
||||||
def getRelease(a):
|
|
||||||
html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text()
|
|
||||||
try:
|
|
||||||
result1 = html.xpath("//td[contains(text(),'発売日:')]/following-sibling::td/a/text()")[0].lstrip('\n')
|
|
||||||
except:
|
|
||||||
result1 = html.xpath("//td[contains(text(),'発売日:')]/following-sibling::td/text()")[0].lstrip('\n')
|
|
||||||
return result1
|
|
||||||
def getTag(a):
|
|
||||||
html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text()
|
|
||||||
try:
|
|
||||||
result1 = str(html.xpath("//td[contains(text(),'ジャンル:')]/following-sibling::td/a/text()")).strip(" ['']")
|
|
||||||
except:
|
|
||||||
result1 = str(html.xpath("//td[contains(text(),'ジャンル:')]/following-sibling::td/text()")).strip(" ['']")
|
|
||||||
return result1.replace("', '",",")
|
|
||||||
def getCover(htmlcode,number):
|
|
||||||
html = etree.fromstring(htmlcode, etree.HTMLParser())
|
|
||||||
result = html.xpath('//*[@id="'+number+'"]/@href')[0]
|
|
||||||
return result
|
|
||||||
def getDirector(a):
|
|
||||||
html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text()
|
|
||||||
try:
|
|
||||||
result1 = html.xpath("//td[contains(text(),'監督:')]/following-sibling::td/a/text()")[0]
|
|
||||||
except:
|
|
||||||
result1 = html.xpath("//td[contains(text(),'監督:')]/following-sibling::td/text()")[0]
|
|
||||||
return result1
|
|
||||||
def getOutline(htmlcode):
|
|
||||||
html = etree.fromstring(htmlcode, etree.HTMLParser())
|
|
||||||
result = str(html.xpath("//div[@class='mg-b20 lh4']/text()")[0]).replace('\n','')
|
|
||||||
return result
|
|
||||||
def main(number):
|
|
||||||
htmlcode=get_html('https://www.dmm.co.jp/digital/videoa/-/detail/=/cid='+number)
|
|
||||||
url = 'https://www.dmm.co.jp/digital/videoa/-/detail/=/cid='+number
|
|
||||||
if '404 Not Found' in htmlcode:
|
|
||||||
htmlcode=get_html('https://www.dmm.co.jp/mono/dvd/-/detail/=/cid='+number)
|
|
||||||
url = 'https://www.dmm.co.jp/mono/dvd/-/detail/=/cid='+number
|
|
||||||
try:
|
|
||||||
dic = {
|
|
||||||
'title': getTitle(htmlcode).strip(getActor(htmlcode)),
|
|
||||||
'studio': getStudio(htmlcode),
|
|
||||||
'outline': getOutline(htmlcode),
|
|
||||||
'runtime': getRuntime(htmlcode),
|
|
||||||
'director': getDirector(htmlcode),
|
|
||||||
'actor': getActor(htmlcode),
|
|
||||||
'release': getRelease(htmlcode),
|
|
||||||
'number': getNum(htmlcode),
|
|
||||||
'cover': getCover(htmlcode,number),
|
|
||||||
'imagecut': 1,
|
|
||||||
'tag': getTag(htmlcode),
|
|
||||||
'label':getLabel(htmlcode),
|
|
||||||
'year': getYear(getRelease(htmlcode)), # str(re.search('\d{4}',getRelease(a)).group()),
|
|
||||||
'actor_photo': '',
|
|
||||||
'website': url,
|
|
||||||
'source': 'siro.py',
|
|
||||||
}
|
|
||||||
except :
|
|
||||||
dic = {
|
|
||||||
'title': '',
|
|
||||||
}
|
|
||||||
js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':')) # .encode('UTF-8')
|
|
||||||
return js
|
|
||||||
|
|
||||||
# main('DV-1562')
|
|
||||||
# input("[+][+]Press enter key exit, you can check the error messge before you exit.\n[+][+]按回车键结束,你可以在结束之前查看和错误信息。")
|
|
||||||
#print(main('n0635'))
|
|
||||||
@@ -3,9 +3,6 @@ from lxml import etree
|
|||||||
import json
|
import json
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from ADC_function import *
|
from ADC_function import *
|
||||||
# import sys
|
|
||||||
# import io
|
|
||||||
# sys.stdout = io.TextIOWrapper(sys.stdout.buffer, errors = 'replace', line_buffering = True)
|
|
||||||
|
|
||||||
def getTitle(a):
|
def getTitle(a):
|
||||||
try:
|
try:
|
||||||
@@ -64,13 +61,13 @@ def getTag(a):
|
|||||||
return str(result1 + result2).strip('+').replace(",\\xa0", "").replace("'", "").replace(' ', '').replace(',,', '').lstrip(',')
|
return str(result1 + result2).strip('+').replace(",\\xa0", "").replace("'", "").replace(' ', '').replace(',,', '').lstrip(',')
|
||||||
def getCover_small(a):
|
def getCover_small(a):
|
||||||
html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text()
|
html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text()
|
||||||
result = html.xpath("//div[@class='item-image fix-scale-cover']/img/@src")[0]
|
result = 'http:' + html.xpath(
|
||||||
if not 'https' in result:
|
'//div[@id=\'videos\']/div[@class=\'grid columns\']/div[@class=\'grid-item column\'][1]/a['
|
||||||
result = 'https:' + result
|
'@class=\'box\']/div[@class=\'item-image fix-scale-cover\']/img/@src')[0]
|
||||||
return result
|
return result
|
||||||
def getCover(htmlcode):
|
def getCover(htmlcode):
|
||||||
html = etree.fromstring(htmlcode, etree.HTMLParser())
|
html = etree.fromstring(htmlcode, etree.HTMLParser())
|
||||||
result = str(html.xpath("//div[@class='column column-video-cover']/a/img/@src")).strip(" ['']")
|
result = str(html.xpath('/html/body/section/div/div[@class=\'columns item-content\']/div[@class=\'column column-video-cover\']/a/img/@src')).strip(" ['']")
|
||||||
return result
|
return result
|
||||||
def getDirector(a):
|
def getDirector(a):
|
||||||
html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text()
|
html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text()
|
||||||
@@ -139,7 +136,7 @@ def main(number):
|
|||||||
'label': getLabel(b),
|
'label': getLabel(b),
|
||||||
'year': getYear(getRelease(b)), # str(re.search('\d{4}',getRelease(a)).group()),
|
'year': getYear(getRelease(b)), # str(re.search('\d{4}',getRelease(a)).group()),
|
||||||
'actor_photo': getActorPhoto(getActor(b)),
|
'actor_photo': getActorPhoto(getActor(b)),
|
||||||
'website': 'https://javdb3.com' + result1,
|
'website': 'https://javdb.com' + result1,
|
||||||
'source': 'javdb.py',
|
'source': 'javdb.py',
|
||||||
}
|
}
|
||||||
if getNum(b) != number: # 与搜索到的番号不匹配
|
if getNum(b) != number: # 与搜索到的番号不匹配
|
||||||
@@ -150,4 +147,4 @@ def main(number):
|
|||||||
|
|
||||||
# main('DV-1562')
|
# main('DV-1562')
|
||||||
# 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[+][+]按回车键结束,你可以在结束之前查看和错误信息。")
|
||||||
# print(main('YMDD-178'))
|
# print(get_html('https://javdb1.com/v/WwZ0Q'))
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "2.3",
|
"version": "2.1",
|
||||||
"version_show":"2.3",
|
"version_show":"2.1",
|
||||||
"download": "https://github.com/yoshiko2/AV_Data_Capture/releases"
|
"download": "https://github.com/yoshiko2/AV_Data_Capture/releases"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user