commit
						03a4669e48
					
				@ -6,24 +6,14 @@ 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===========
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
version='2.3'
 | 
					def UpdateCheck(version):
 | 
				
			||||||
 | 
					 | 
				
			||||||
config = ConfigParser()
 | 
					 | 
				
			||||||
config.read(config_file, encoding='UTF-8')
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Platform = sys.platform
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# ==========global var end=========
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
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))
 | 
				
			||||||
@ -35,33 +25,39 @@ def UpdateCheck():
 | 
				
			|||||||
            print('[*]======================================================')
 | 
					            print('[*]======================================================')
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        print('[+]Update Check disabled!')
 | 
					        print('[+]Update Check disabled!')
 | 
				
			||||||
def movie_lists():
 | 
					
 | 
				
			||||||
    global exclude_directory_1
 | 
					
 | 
				
			||||||
    global exclude_directory_2
 | 
					def movie_lists(escape_folder):
 | 
				
			||||||
    total=[]
 | 
					    escape_folder = re.split('[,,]', escape_folder)
 | 
				
			||||||
    file_type = ['.mp4','.avi','.rmvb','.wmv','.mov','.mkv','.flv','.ts','.MP4', '.AVI', '.RMVB', '.WMV', '.MOV', '.MKV', '.FLV', '.TS',]
 | 
					    total = []
 | 
				
			||||||
    exclude_directory_1 = config['common']['failed_output_folder']
 | 
					    file_type = ['.mp4', '.avi', '.rmvb', '.wmv', '.mov', '.mkv', '.flv', '.ts', '.MP4', '.AVI', '.RMVB', '.WMV',
 | 
				
			||||||
    exclude_directory_2 = config['common']['success_output_folder']
 | 
					                 '.MOV', '.MKV', '.FLV', '.TS', ]
 | 
				
			||||||
    file_root=os.getcwd()
 | 
					    file_root = os.getcwd()
 | 
				
			||||||
    for root,dirs,files in os.walk(file_root):
 | 
					    for root, dirs, files in os.walk(file_root):
 | 
				
			||||||
        if exclude_directory_1 not in root and exclude_directory_2 not in root:
 | 
					        flag_escape = 0
 | 
				
			||||||
 | 
					        for folder in escape_folder:
 | 
				
			||||||
 | 
					            if folder in root:
 | 
				
			||||||
 | 
					                flag_escape = 1
 | 
				
			||||||
 | 
					                break
 | 
				
			||||||
 | 
					        if flag_escape == 1:
 | 
				
			||||||
 | 
					            continue
 | 
				
			||||||
        for f in files:
 | 
					        for f in files:
 | 
				
			||||||
            if os.path.splitext(f)[1] in file_type:
 | 
					            if os.path.splitext(f)[1] in file_type:
 | 
				
			||||||
                    path = os.path.join(root,f)
 | 
					                path = os.path.join(root, f)
 | 
				
			||||||
                    path = path.replace(file_root,'.')
 | 
					                path = path.replace(file_root, '.')
 | 
				
			||||||
                total.append(path)
 | 
					                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/')
 | 
					            os.makedirs(failed_folder + '/')
 | 
				
			||||||
        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)  # 获取路径下的子文件(夹)列表
 | 
				
			||||||
@ -69,21 +65,17 @@ 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:  # 普通提取番号 主要处理包含减号-和_的番号
 | 
					    if '-' in filepath or '_' in filepath:  # 普通提取番号 主要处理包含减号-和_的番号
 | 
				
			||||||
        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-','')
 | 
					            filename = filename.replace('-PPV', '').replace('PPV-', '')
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            file_number = re.search('\w+-\d+', filename).group()
 | 
					            file_number = re.search('\w+-\d+', filename).group()
 | 
				
			||||||
        except:  # 提取类似mkbd-s120番号
 | 
					        except:  # 提取类似mkbd-s120番号
 | 
				
			||||||
@ -91,63 +83,54 @@ def getNumber(filepath):
 | 
				
			|||||||
        return file_number
 | 
					        return file_number
 | 
				
			||||||
    else:  # 提取不含减号-的番号,FANZA CID
 | 
					    else:  # 提取不含减号-的番号,FANZA CID
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            return str(re.findall(r'(.+?)\.', str(re.search('([^<>/\\\\|:""\\*\\?]+)\\.\\w+$', filepath).group()))).strip("['']").replace('_', '-')
 | 
					            return str(
 | 
				
			||||||
 | 
					                re.findall(r'(.+?)\.', str(re.search('([^<>/\\\\|:""\\*\\?]+)\\.\\w+$', filepath).group()))).strip(
 | 
				
			||||||
 | 
					                "['']").replace('_', '-')
 | 
				
			||||||
        except:
 | 
					        except:
 | 
				
			||||||
            return re.search(r'(.+?)\.',filepath)[0]
 | 
					            return re.search(r'(.+?)\.', filepath)[0]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
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'):
 | 
					 | 
				
			||||||
            try:
 | 
					 | 
				
			||||||
                os.system('python3 core.py' + '   "' + i + '" --number "' + getNumber(i) + '"')  # 从py文件启动(用于源码py)
 | 
					 | 
				
			||||||
            except:
 | 
					 | 
				
			||||||
                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('python3 core.py' + '   "' + i + '" --number "' + getNumber(i) + '"')  # 从py文件启动(用于源码py)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
if __name__ =='__main__':
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    version = '2.3'
 | 
				
			||||||
 | 
					    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)
 | 
				
			||||||
    os.chdir(os.getcwd())
 | 
					    os.chdir(os.getcwd())
 | 
				
			||||||
    movie_list=movie_lists()
 | 
					    movie_list = movie_lists(escape_folder)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    count = 0
 | 
					    count = 0
 | 
				
			||||||
    count_all = str(len(movie_list))
 | 
					    count_all = str(len(movie_list))
 | 
				
			||||||
    print('[+]Find',count_all,'movies')
 | 
					    print('[+]Find', count_all, '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_list:  # 遍历电影列表 交给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) + "]")
 | 
				
			||||||
            RunCore()
 | 
					            core_main(i, getNumber(i))
 | 
				
			||||||
            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(exclude_directory_1)
 | 
					    CEF(success_folder)
 | 
				
			||||||
    CEF(exclude_directory_2)
 | 
					    CEF(failed_folder)
 | 
				
			||||||
    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.")
 | 
				
			||||||
							
								
								
									
										12
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								README.md
									
									
									
									
									
								
							@ -159,18 +159,12 @@ 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后面为空,则抓取和程序同一目录下的影片
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
---
 | 
					---
 | 
				
			||||||
### 调试模式
 | 
					### 调试模式
 | 
				
			||||||
 | 
				
			|||||||
@ -22,6 +22,7 @@ media_warehouse=emby
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
[escape]
 | 
					[escape]
 | 
				
			||||||
literals=\()
 | 
					literals=\()
 | 
				
			||||||
 | 
					folders=failed,JAV_output
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[debug_mode]
 | 
					[debug_mode]
 | 
				
			||||||
switch=0
 | 
					switch=0
 | 
				
			||||||
							
								
								
									
										298
									
								
								core.py
									
									
									
									
									
								
							
							
						
						
									
										298
									
								
								core.py
									
									
									
									
									
								
							@ -17,71 +17,26 @@ import avsox
 | 
				
			|||||||
import javbus
 | 
					import javbus
 | 
				
			||||||
import javdb
 | 
					import javdb
 | 
				
			||||||
import fanza
 | 
					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): # Remove escape literals
 | 
					def escapePath(path, Config):  # 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():
 | 
					
 | 
				
			||||||
    global filepath
 | 
					def moveFailedFolder(filepath, failed_folder):
 | 
				
			||||||
    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 + '/')
 | 
				
			||||||
    os._exit(0)
 | 
					    os._exit(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def argparse_get_file():
 | 
					def CreatFailedFolder(failed_folder):
 | 
				
			||||||
    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 + '/')
 | 
				
			||||||
@ -90,30 +45,7 @@ def CreatFailedFolder():
 | 
				
			|||||||
            os._exit(0)
 | 
					            os._exit(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def getDataFromJSON(file_number):  # 从JSON返回元数据
 | 
					def getDataFromJSON(file_number, filepath, failed_folder):  # 从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):
 | 
				
			||||||
@ -129,9 +61,10 @@ def getDataFromJSON(file_number):  # 从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(file_number.replace('fc2-','').replace('fc2_','').replace('FC2-','').replace('fc2_','')))
 | 
					        json_data = json.loads(fc2fans_club.main(
 | 
				
			||||||
 | 
					            file_number.replace('fc2-', '').replace('fc2_', '').replace('FC2-', '').replace('fc2_', '')))
 | 
				
			||||||
    # ==
 | 
					    # ==
 | 
				
			||||||
    elif 'HEYZO' in number or 'heyzo' in number or 'Heyzo' in number:
 | 
					    elif 'HEYZO' in file_number or 'heyzo' in file_number or 'Heyzo' in file_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:
 | 
				
			||||||
@ -155,15 +88,9 @@ def getDataFromJSON(file_number):  # 从JSON返回元数据
 | 
				
			|||||||
    # ================================================网站规则添加结束================================================
 | 
					    # ================================================网站规则添加结束================================================
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    title = json_data['title']
 | 
					    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_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:
 | 
				
			||||||
@ -171,16 +98,13 @@ def getDataFromJSON(file_number):  # 从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()
 | 
					        moveFailedFolder(filepath, failed_folder)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if imagecut == '3':
 | 
					    # if imagecut == '3':
 | 
				
			||||||
        DownloadFileWithFilename()
 | 
					    #     DownloadFileWithFilename()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # ====================处理异常字符====================== #\/:*?"<>|
 | 
					    # ====================处理异常字符====================== #\/:*?"<>|
 | 
				
			||||||
    title = title.replace('\\', '')
 | 
					    title = title.replace('\\', '')
 | 
				
			||||||
@ -201,11 +125,36 @@ def getDataFromJSON(file_number):  # 从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)
 | 
					            DownloadFileWithFilename(cover_small, '1.jpg', path, Config, filepath, failed_folder)
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                img = Image.open(path + '/1.jpg')
 | 
					                img = Image.open(path + '/1.jpg')
 | 
				
			||||||
            except Exception:
 | 
					            except Exception:
 | 
				
			||||||
@ -216,18 +165,18 @@ def smallCoverCheck():
 | 
				
			|||||||
            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)
 | 
					            DownloadFileWithFilename(cover_small, '1.jpg', path, Config, filepath, failed_folder)
 | 
				
			||||||
            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)
 | 
					            DownloadFileWithFilename(cover_small, '1.jpg', path, Config, filepath, failed_folder)
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                img = Image.open(path + '/1.jpg')
 | 
					                img = Image.open(path + '/1.jpg')
 | 
				
			||||||
            except Exception:
 | 
					            except Exception:
 | 
				
			||||||
@ -238,26 +187,31 @@ def smallCoverCheck():
 | 
				
			|||||||
            os.remove(path + '/1.jpg')
 | 
					            os.remove(path + '/1.jpg')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def creatFolder():  # 创建文件夹
 | 
					def creatFolder(success_folder, location_rule, json_data, Config):  # 创建文件夹
 | 
				
			||||||
    global actor
 | 
					    title, studio, year, outline, runtime, director, actor_photo, release, number, cover, website = get_info(json_data)
 | 
				
			||||||
    global path
 | 
					    if len(location_rule) > 240:  # 新建成功输出文件夹
 | 
				
			||||||
    if len(os.getcwd() + path) > 240:  # 新建成功输出文件夹
 | 
					        path = success_folder + '/' + location_rule.replace("'actor'", "'manypeople'", 3).replace("actor",
 | 
				
			||||||
        path = success_folder+'/'+location_rule.replace("'actor'","'manypeople'",3).replace("actor","'manypeople'",3) #path为影片+元数据所在目录
 | 
					                                                                                                  "'manypeople'",
 | 
				
			||||||
 | 
					                                                                                                  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)
 | 
					        path = escapePath(path, Config)
 | 
				
			||||||
        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)
 | 
					            path = escapePath(path, Config)
 | 
				
			||||||
            os.makedirs(path)
 | 
					            os.makedirs(path)
 | 
				
			||||||
 | 
					    return path
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# =====================资源下载部分===========================
 | 
					# =====================资源下载部分===========================
 | 
				
			||||||
def DownloadFileWithFilename(url, filename, path):  # path = examle:photo , video.in the Project Folder!
 | 
					def DownloadFileWithFilename(url, filename, path, Config, filepath, failed_folder):  # 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'])
 | 
				
			||||||
@ -306,14 +260,14 @@ def DownloadFileWithFilename(url, filename, path):  # path = examle:photo , vide
 | 
				
			|||||||
            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()
 | 
					    moveFailedFolder(filepath, failed_folder)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def imageDownload():  # 封面是否下载成功,否则移动到failed
 | 
					def imageDownload(option, cover, number, c_word, path, multi_part, Config, filepath, failed_folder):  # 封面是否下载成功,否则移动到failed
 | 
				
			||||||
    if option == 'emby':
 | 
					    if option == 'emby':
 | 
				
			||||||
        if DownloadFileWithFilename(cover, number + c_word + '.jpg', path) == 'failed':
 | 
					        if DownloadFileWithFilename(cover, number + c_word + '.jpg', path, Config, filepath, failed_folder) == 'failed':
 | 
				
			||||||
            moveFailedFolder()
 | 
					            moveFailedFolder(filepath, failed_folder)
 | 
				
			||||||
        DownloadFileWithFilename(cover, number + c_word + '.jpg', path)
 | 
					        DownloadFileWithFilename(cover, number + c_word + '.jpg', path, Config, filepath, failed_folder)
 | 
				
			||||||
        if not os.path.getsize(path + '/' + number + c_word + '.jpg') == 0:
 | 
					        if not os.path.getsize(path + '/' + number + c_word + '.jpg') == 0:
 | 
				
			||||||
            print('[+]Image Downloaded!', path + '/' + number + c_word + '.jpg')
 | 
					            print('[+]Image Downloaded!', path + '/' + number + c_word + '.jpg')
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
@ -321,7 +275,7 @@ def imageDownload():  # 封面是否下载成功,否则移动到failed
 | 
				
			|||||||
        while i <= int(config['proxy']['retry']):
 | 
					        while i <= int(config['proxy']['retry']):
 | 
				
			||||||
            if os.path.getsize(path + '/' + number + c_word + '.jpg') == 0:
 | 
					            if os.path.getsize(path + '/' + number + c_word + '.jpg') == 0:
 | 
				
			||||||
                print('[!]Image Download Failed! Trying again. [' + config['proxy']['retry'] + '/3]')
 | 
					                print('[!]Image Download Failed! Trying again. [' + config['proxy']['retry'] + '/3]')
 | 
				
			||||||
                DownloadFileWithFilename(cover, number + c_word + '.jpg', path)
 | 
					                DownloadFileWithFilename(cover, number + c_word + '.jpg', path, Config, filepath, failed_folder)
 | 
				
			||||||
                i = i + 1
 | 
					                i = i + 1
 | 
				
			||||||
                continue
 | 
					                continue
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
@ -334,9 +288,9 @@ def imageDownload():  # 封面是否下载成功,否则移动到failed
 | 
				
			|||||||
        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) == 'failed':
 | 
					        if DownloadFileWithFilename(cover, 'fanart.jpg', path, Config, filepath, failed_folder) == 'failed':
 | 
				
			||||||
            moveFailedFolder()
 | 
					            moveFailedFolder(filepath, failed_folder)
 | 
				
			||||||
        DownloadFileWithFilename(cover, 'fanart.jpg', path)
 | 
					        DownloadFileWithFilename(cover, 'fanart.jpg', path, Config, filepath, failed_folder)
 | 
				
			||||||
        if not os.path.getsize(path + '/fanart.jpg') == 0:
 | 
					        if not os.path.getsize(path + '/fanart.jpg') == 0:
 | 
				
			||||||
            print('[+]Image Downloaded!', path + '/fanart.jpg')
 | 
					            print('[+]Image Downloaded!', path + '/fanart.jpg')
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
@ -344,19 +298,19 @@ def imageDownload():  # 封面是否下载成功,否则移动到failed
 | 
				
			|||||||
        while i <= int(config['proxy']['retry']):
 | 
					        while i <= int(config['proxy']['retry']):
 | 
				
			||||||
            if os.path.getsize(path + '/fanart.jpg') == 0:
 | 
					            if os.path.getsize(path + '/fanart.jpg') == 0:
 | 
				
			||||||
                print('[!]Image Download Failed! Trying again. [' + config['proxy']['retry'] + '/3]')
 | 
					                print('[!]Image Download Failed! Trying again. [' + config['proxy']['retry'] + '/3]')
 | 
				
			||||||
                DownloadFileWithFilename(cover, 'fanart.jpg', path)
 | 
					                DownloadFileWithFilename(cover, 'fanart.jpg', path, Config, filepath, failed_folder)
 | 
				
			||||||
                i = i + 1
 | 
					                i = i + 1
 | 
				
			||||||
                continue
 | 
					                continue
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                break
 | 
					                break
 | 
				
			||||||
        if not os.path.getsize(path + '/' + number + c_word + '.jpg') == 0:
 | 
					        if not os.path.getsize(path + '/' + number + c_word + '.jpg') == 0:
 | 
				
			||||||
            print('[!]Image Download Failed! Trying again.')
 | 
					            print('[!]Image Download Failed! Trying again.')
 | 
				
			||||||
            DownloadFileWithFilename(cover, number + c_word + '.jpg', path)
 | 
					            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) == 'failed':
 | 
					        if DownloadFileWithFilename(cover, number + c_word + '-fanart.jpg', path, Config, filepath, failed_folder) == 'failed':
 | 
				
			||||||
            moveFailedFolder()
 | 
					            moveFailedFolder(filepath, failed_folder)
 | 
				
			||||||
        DownloadFileWithFilename(cover, number + c_word + '-fanart.jpg', path)
 | 
					        DownloadFileWithFilename(cover, number + c_word + '-fanart.jpg', path, Config, filepath, failed_folder)
 | 
				
			||||||
        if not os.path.getsize(path + '/' + number + c_word + '-fanart.jpg') == 0:
 | 
					        if not os.path.getsize(path + '/' + number + c_word + '-fanart.jpg') == 0:
 | 
				
			||||||
            print('[+]Image Downloaded!', path + '/' + number + c_word + '-fanart.jpg')
 | 
					            print('[+]Image Downloaded!', path + '/' + number + c_word + '-fanart.jpg')
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
@ -364,7 +318,7 @@ def imageDownload():  # 封面是否下载成功,否则移动到failed
 | 
				
			|||||||
        while i <= int(config['proxy']['retry']):
 | 
					        while i <= int(config['proxy']['retry']):
 | 
				
			||||||
            if os.path.getsize(path + '/' + number + c_word + '-fanart.jpg') == 0:
 | 
					            if os.path.getsize(path + '/' + number + c_word + '-fanart.jpg') == 0:
 | 
				
			||||||
                print('[!]Image Download Failed! Trying again. [' + config['proxy']['retry'] + '/3]')
 | 
					                print('[!]Image Download Failed! Trying again. [' + config['proxy']['retry'] + '/3]')
 | 
				
			||||||
                DownloadFileWithFilename(cover, number + c_word + '-fanart.jpg', path)
 | 
					                DownloadFileWithFilename(cover, number + c_word + '-fanart.jpg', path, Config, filepath, failed_folder)
 | 
				
			||||||
                i = i + 1
 | 
					                i = i + 1
 | 
				
			||||||
                continue
 | 
					                continue
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
@ -372,7 +326,8 @@ def imageDownload():  # 封面是否下载成功,否则移动到failed
 | 
				
			|||||||
        print('[+]Image Downloaded!', path + '/' + number + c_word + '-fanart.jpg')
 | 
					        print('[+]Image Downloaded!', path + '/' + number + c_word + '-fanart.jpg')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def PrintFiles():
 | 
					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:
 | 
					    try:
 | 
				
			||||||
        if not os.path.exists(path):
 | 
					        if not os.path.exists(path):
 | 
				
			||||||
            os.makedirs(path)
 | 
					            os.makedirs(path)
 | 
				
			||||||
@ -522,14 +477,14 @@ def PrintFiles():
 | 
				
			|||||||
    except IOError as e:
 | 
					    except IOError as e:
 | 
				
			||||||
        print("[-]Write Failed!")
 | 
					        print("[-]Write Failed!")
 | 
				
			||||||
        print(e)
 | 
					        print(e)
 | 
				
			||||||
        moveFailedFolder()
 | 
					        moveFailedFolder(filepath, failed_folder)
 | 
				
			||||||
    except Exception as e1:
 | 
					    except Exception as e1:
 | 
				
			||||||
        print(e1)
 | 
					        print(e1)
 | 
				
			||||||
        print("[-]Write Failed!")
 | 
					        print("[-]Write Failed!")
 | 
				
			||||||
        moveFailedFolder()
 | 
					        moveFailedFolder(filepath, failed_folder)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def cutImage():
 | 
					def cutImage(option, imagecut, path, number, c_word):
 | 
				
			||||||
    if option == 'plex':
 | 
					    if option == 'plex':
 | 
				
			||||||
        if imagecut == 1:
 | 
					        if imagecut == 1:
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
@ -585,22 +540,21 @@ def cutImage():
 | 
				
			|||||||
                img.save(path + '/' + number + c_word + '-poster.jpg')
 | 
					                img.save(path + '/' + number + c_word + '-poster.jpg')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def pasteFileToFolder(filepath, path):  # 文件路径,番号,后缀,要移动至的位置
 | 
					def pasteFileToFolder(filepath, path, number, c_word):  # 文件路径,番号,后缀,要移动至的位置
 | 
				
			||||||
    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!')
 | 
				
			||||||
@ -611,25 +565,22 @@ def pasteFileToFolder(filepath, path):  # 文件路径,番号,后缀,要
 | 
				
			|||||||
        os._exit(0)
 | 
					        os._exit(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def pasteFileToFolder_mode2(filepath, path):  # 文件路径,番号,后缀,要移动至的位置
 | 
					def pasteFileToFolder_mode2(filepath, path, multi_part, number, part, c_word):  # 文件路径,番号,后缀,要移动至的位置
 | 
				
			||||||
    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')
 | 
				
			||||||
@ -642,7 +593,7 @@ def pasteFileToFolder_mode2(filepath, path):  # 文件路径,番号,后缀
 | 
				
			|||||||
        os._exit(0)
 | 
					        os._exit(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def copyRenameJpgToBackdrop():
 | 
					def copyRenameJpgToBackdrop(option, path, number, c_word):
 | 
				
			||||||
    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')
 | 
				
			||||||
@ -652,7 +603,7 @@ def copyRenameJpgToBackdrop():
 | 
				
			|||||||
        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):
 | 
					def get_part(filepath, failed_folder):
 | 
				
			||||||
    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]
 | 
				
			||||||
@ -660,10 +611,10 @@ def get_part(filepath):
 | 
				
			|||||||
            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()
 | 
					        moveFailedFolder(filepath, failed_folder)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def debug_mode():
 | 
					def debug_mode(json_data):
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        if config['debug_mode']['switch'] == '1':
 | 
					        if config['debug_mode']['switch'] == '1':
 | 
				
			||||||
            print('[+] ---Debug info---')
 | 
					            print('[+] ---Debug info---')
 | 
				
			||||||
@ -673,44 +624,55 @@ def debug_mode():
 | 
				
			|||||||
                    continue
 | 
					                    continue
 | 
				
			||||||
                if i == 'actor_photo' or i == 'year':
 | 
					                if i == 'actor_photo' or i == 'year':
 | 
				
			||||||
                    continue
 | 
					                    continue
 | 
				
			||||||
                print('[+]  -',"%-11s" % i, ':', v)
 | 
					                print('[+]  -', "%-11s" % i, ':', v)
 | 
				
			||||||
            print('[+] ---Debug info---')
 | 
					            print('[+] ---Debug info---')
 | 
				
			||||||
    except:
 | 
					    except:
 | 
				
			||||||
        aaa = ''
 | 
					        aaa = ''
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if __name__ == '__main__':
 | 
					def core_main(file_path, number_th):
 | 
				
			||||||
    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)
 | 
					        part = get_part(filepath, failed_folder)
 | 
				
			||||||
    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'  # 中文字幕影片后缀
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if argparse_get_file()[1] == '':  # 如果第二个运行参数为空,获取从第一个参数影片路径的番号
 | 
					    CreatFailedFolder(failed_folder)  # 创建输出失败目录
 | 
				
			||||||
        try:
 | 
					    debug_mode(json_data)  # 调试模式检测
 | 
				
			||||||
            number = str(re.findall(r'(.+?)\.', str(re.search('([^<>/\\\\|:""\\*\\?]+)\\.\\w+$', filepath).group()))).strip("['']").replace('_', '-')
 | 
					    path = creatFolder(success_folder, json_data['location_rule'], json_data, Config)  # 创建文件夹
 | 
				
			||||||
            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() # 检查小封面
 | 
					        smallCoverCheck(path, number, imagecut, json_data['cover_small'], c_word, option, Config, filepath, failed_folder)  # 检查小封面
 | 
				
			||||||
        imageDownload()  # creatFoder会返回番号路径
 | 
					        imageDownload(option, json_data['cover'], number, c_word, path, multi_part, Config, filepath, failed_folder)  # creatFoder会返回番号路径
 | 
				
			||||||
        cutImage()  # 裁剪图
 | 
					        cutImage(option, imagecut, path, number, c_word)  # 裁剪图
 | 
				
			||||||
        copyRenameJpgToBackdrop()
 | 
					        copyRenameJpgToBackdrop(option, path, number, c_word)
 | 
				
			||||||
        PrintFiles()  # 打印文件
 | 
					        PrintFiles(option, path, c_word, json_data['naming_rule'], part, cn_sub, json_data, filepath, failed_folder, tag)  # 打印文件
 | 
				
			||||||
        # renameBackdropToJpg_copy()
 | 
					        pasteFileToFolder(filepath, path, number, c_word)  # 移动文件
 | 
				
			||||||
        pasteFileToFolder(filepath, path)  # 移动文件
 | 
					        # =======================================================================整理模式
 | 
				
			||||||
    elif program_mode == '2':
 | 
					    elif program_mode == '2':
 | 
				
			||||||
        pasteFileToFolder_mode2(filepath, path)  # 移动文件
 | 
					        pasteFileToFolder_mode2(filepath, path, multi_part, number, part, c_word)  # 移动文件
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										5
									
								
								fanza.py
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								fanza.py
									
									
									
									
									
								
							@ -82,6 +82,7 @@ def main(number):
 | 
				
			|||||||
    if '404 Not Found' in htmlcode:
 | 
					    if '404 Not Found' in htmlcode:
 | 
				
			||||||
        htmlcode=get_html('https://www.dmm.co.jp/mono/dvd/-/detail/=/cid='+number)
 | 
					        htmlcode=get_html('https://www.dmm.co.jp/mono/dvd/-/detail/=/cid='+number)
 | 
				
			||||||
        url = 'https://www.dmm.co.jp/mono/dvd/-/detail/=/cid='+number
 | 
					        url = 'https://www.dmm.co.jp/mono/dvd/-/detail/=/cid='+number
 | 
				
			||||||
 | 
					    try:
 | 
				
			||||||
        dic = {
 | 
					        dic = {
 | 
				
			||||||
            'title': getTitle(htmlcode).strip(getActor(htmlcode)),
 | 
					            'title': getTitle(htmlcode).strip(getActor(htmlcode)),
 | 
				
			||||||
            'studio': getStudio(htmlcode),
 | 
					            'studio': getStudio(htmlcode),
 | 
				
			||||||
@ -100,6 +101,10 @@ def main(number):
 | 
				
			|||||||
            'website': url,
 | 
					            'website': url,
 | 
				
			||||||
            'source': 'siro.py',
 | 
					            'source': 'siro.py',
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					    except :
 | 
				
			||||||
 | 
					        dic = {
 | 
				
			||||||
 | 
					            'title': '',
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    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
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user