Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e0d2058fa0 | ||
|
|
dd3d394d58 | ||
|
|
6e5831d7d6 | ||
|
|
ea54a149a8 | ||
|
|
9e7c798cd1 | ||
|
|
b4e2530b6f | ||
|
|
6b5af440f1 | ||
|
|
c362e7a4d7 | ||
|
|
068dc86480 | ||
|
|
87db5b5426 | ||
|
|
9b6cd74caa | ||
|
|
6cbfd2ab0e | ||
|
|
a46391c6b2 | ||
|
|
2c2867e3c6 | ||
|
|
9102c28247 | ||
|
|
05d1ac50c1 | ||
|
|
7d5da45567 | ||
|
|
03a4669e48 | ||
|
|
123b2f4cfc | ||
|
|
cab36be6a2 | ||
|
|
4660b1cdf2 | ||
|
|
8190da3d3e | ||
|
|
5105051f53 | ||
|
|
de1c9231ad |
+73
-64
@@ -6,24 +6,14 @@ import os
|
||||
import time
|
||||
import re
|
||||
from ADC_function import *
|
||||
from core import *
|
||||
import json
|
||||
import shutil
|
||||
import fnmatch
|
||||
from configparser import ConfigParser
|
||||
os.chdir(os.getcwd())
|
||||
import argparse
|
||||
|
||||
# ============global var===========
|
||||
|
||||
version='2.3'
|
||||
|
||||
config = ConfigParser()
|
||||
config.read(config_file, encoding='UTF-8')
|
||||
|
||||
Platform = sys.platform
|
||||
|
||||
# ==========global var end=========
|
||||
|
||||
def UpdateCheck():
|
||||
def UpdateCheck(version):
|
||||
if UpdateCheckSwitch() == '1':
|
||||
html2 = get_html('https://raw.githubusercontent.com/yoshiko2/AV_Data_Capture/master/update_check.json')
|
||||
html = json.loads(str(html2))
|
||||
@@ -35,33 +25,46 @@ def UpdateCheck():
|
||||
print('[*]======================================================')
|
||||
else:
|
||||
print('[+]Update Check disabled!')
|
||||
def movie_lists():
|
||||
global exclude_directory_1
|
||||
global exclude_directory_2
|
||||
|
||||
def argparse_get_file():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("file", default='',nargs='?', help="Write the file path on here")
|
||||
args = parser.parse_args()
|
||||
if args.file == '':
|
||||
return ''
|
||||
else:
|
||||
return args.file
|
||||
|
||||
def movie_lists(escape_folder):
|
||||
escape_folder = re.split('[,,]', escape_folder)
|
||||
total = []
|
||||
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']
|
||||
exclude_directory_2 = config['common']['success_output_folder']
|
||||
file_type = ['.mp4', '.avi', '.rmvb', '.wmv', '.mov', '.mkv', '.flv', '.ts', '.webm', '.MP4', '.AVI', '.RMVB', '.WMV','.MOV', '.MKV', '.FLV', '.TS', '.WEBM', ]
|
||||
file_root = os.getcwd()
|
||||
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:
|
||||
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
|
||||
def CreatFailedFolder():
|
||||
if not os.path.exists('failed/'): # 新建failed文件夹
|
||||
|
||||
|
||||
def CreatFailedFolder(failed_folder):
|
||||
if not os.path.exists(failed_folder + '/'): # 新建failed文件夹
|
||||
try:
|
||||
os.makedirs('failed/')
|
||||
os.makedirs(failed_folder + '/')
|
||||
except:
|
||||
print("[-]failed!can not be make folder 'failed'\n[-](Please run as Administrator)")
|
||||
os._exit(0)
|
||||
def lists_from_test(custom_nuber): #电影列表
|
||||
a=[]
|
||||
a.append(custom_nuber)
|
||||
return a
|
||||
|
||||
|
||||
def CEF(path):
|
||||
try:
|
||||
files = os.listdir(path) # 获取路径下的子文件(夹)列表
|
||||
@@ -70,24 +73,20 @@ def CEF(path):
|
||||
print('[+]Deleting empty folder', path + '/' + file)
|
||||
except:
|
||||
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):
|
||||
filepath = filepath.replace('.\\','')
|
||||
|
||||
|
||||
def getNumber(filepath,absolute_path = False):
|
||||
if absolute_path == True:
|
||||
filepath=filepath.replace('\\','/')
|
||||
file_number = str(re.findall(r'(.+?)\.', str(re.search('([^<>/\\\\|:""\\*\\?]+)\\.\\w+$', filepath).group()))).strip("['']").replace('_', '-')
|
||||
return file_number
|
||||
if '-' in filepath or '_' in filepath: # 普通提取番号 主要处理包含减号-和_的番号
|
||||
filepath = filepath.replace("_", "-")
|
||||
filepath.strip('22-sht.me').strip('-HD').strip('-hd')
|
||||
filename = str(re.sub("\[\d{4}-\d{1,2}-\d{1,2}\] - ", "", filepath)) # 去除文件名中时间
|
||||
if 'FC2' or 'fc2' in filename:
|
||||
filename=filename.replace('-PPV','').replace('PPV-','')
|
||||
try:
|
||||
file_number = re.search('\w+-\d+', filename).group()
|
||||
except: # 提取类似mkbd-s120番号
|
||||
file_number = re.search('\w+-\w+\d+', filename).group()
|
||||
filename = filename.replace('-PPV', '').replace('PPV-', '').replace('FC2PPV-','FC2-').replace('FC2PPV_','FC2-')
|
||||
file_number = re.search('\w+-\w+', filename).group()
|
||||
return file_number
|
||||
else: # 提取不含减号-的番号,FANZA CID
|
||||
try:
|
||||
@@ -95,34 +94,36 @@ def getNumber(filepath):
|
||||
except:
|
||||
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__':
|
||||
version = '2.6'
|
||||
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('[*] Version ' + version)
|
||||
print('[*]======================================================')
|
||||
|
||||
CreatFailedFolder()
|
||||
UpdateCheck()
|
||||
UpdateCheck(version)
|
||||
CreatFailedFolder(failed_folder)
|
||||
os.chdir(os.getcwd())
|
||||
movie_list=movie_lists()
|
||||
movie_list = movie_lists(escape_folder)
|
||||
|
||||
#========== 野鸡番号拖动 ==========
|
||||
number_argparse=argparse_get_file()
|
||||
if not number_argparse == '':
|
||||
print("[!]Making Data for [" + number_argparse + "], the number is [" + getNumber(number_argparse,absolute_path = True) + "]")
|
||||
core_main(number_argparse, getNumber(number_argparse,absolute_path = True))
|
||||
print("[*]======================================================")
|
||||
CEF(success_folder)
|
||||
CEF(failed_folder)
|
||||
print("[+]All finished!!!")
|
||||
input("[+][+]Press enter key exit, you can check the error messge before you exit.")
|
||||
os._exit(0)
|
||||
# ========== 野鸡番号拖动 ==========
|
||||
|
||||
count = 0
|
||||
count_all = str(len(movie_list))
|
||||
@@ -133,9 +134,12 @@ if __name__ =='__main__':
|
||||
count = count + 1
|
||||
percentage = str(count / int(count_all) * 100)[:4] + '%'
|
||||
print('[!] - ' + percentage + ' [' + str(count) + '/' + count_all + '] -')
|
||||
# print("[!]Making Data for [" + i + "], the number is [" + getNumber(i) + "]")
|
||||
# core_main(i, getNumber(i))
|
||||
# print("[*]======================================================")
|
||||
try:
|
||||
print("[!]Making Data for [" + i + "], the number is [" + getNumber(i) + "]")
|
||||
RunCore()
|
||||
core_main(i, getNumber(i))
|
||||
print("[*]======================================================")
|
||||
except: # 番号提取异常
|
||||
print('[-]' + i + ' Cannot catch the number :')
|
||||
@@ -143,11 +147,16 @@ if __name__ =='__main__':
|
||||
print('[-]Link', i, 'to failed folder')
|
||||
os.symlink(i, str(os.getcwd()) + '/' + 'failed/')
|
||||
else:
|
||||
try:
|
||||
print('[-]Move ' + i + ' to failed folder')
|
||||
shutil.move(i, str(os.getcwd()) + '/' + 'failed/')
|
||||
except FileExistsError:
|
||||
print('[!]File exists in failed!')
|
||||
except:
|
||||
print('[+]skip')
|
||||
continue
|
||||
|
||||
CEF(exclude_directory_1)
|
||||
CEF(exclude_directory_2)
|
||||
CEF(success_folder)
|
||||
CEF(failed_folder)
|
||||
print("[+]All finished!!!")
|
||||
input("[+][+]Press enter key exit, you can check the error messge before you exit.")
|
||||
@@ -1,15 +1,23 @@
|
||||
# AV Data Capture
|
||||
|
||||
# AV Data Capture (CLI)
|
||||
|
||||
CLI版本
|
||||
<a title="Hits" target="_blank" href="https://github.com/yoshiko2/AV_Data_Capture"><img src="https://hits.b3log.org/yoshiko2/AV_Data_Capture.svg"></a>
|
||||

|
||||
<br>
|
||||

|
||||

|
||||

|
||||
<br>
|
||||
[GUI版本](https://github.com/moyy996/AVDC)
|
||||
<a title="Hits" target="_blank" href="https://github.com/moyy996/avdc"><img src="https://hits.b3log.org/moyy996/AVDC.svg"></a>
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
<br>
|
||||
|
||||
|
||||
**日本电影元数据 抓取工具 | 刮削器**,配合本地影片管理软件EMBY,KODI等管理本地影片,该软件起到分类与元数据抓取作用,利用元数据信息来分类,供本地影片分类整理使用。
|
||||
**日本电影元数据 抓取工具 | 刮削器**,配合本地影片管理软件EMBY,KODI等管理本地影片,该软件起到分类与元数据抓取作用,利用元数据信息来分类,供本地影片分类整理使用,本地电影刮削,整理一体化解决方案。
|
||||
|
||||
# 目录
|
||||
* [声明](#声明)
|
||||
@@ -27,6 +35,7 @@
|
||||
* [运行软件](#5运行-av_data_capturepyexe)
|
||||
* [影片原路径处理](#4建议把软件拷贝和电影的统一目录下)
|
||||
* [异常处理(重要)](#51异常处理重要)
|
||||
* [**拖动法**](#拖动法)
|
||||
* [导入至媒体库](#7把jav_output文件夹导入到embykodi中等待元数据刷新完成)
|
||||
* [关于群晖NAS](#8关于群晖NAS)
|
||||
* [写在后面](#9写在后面)
|
||||
@@ -50,6 +59,8 @@
|
||||
* 软件永久免费。**除了作者钦点以外**
|
||||
### 软件运行异常怎么办?
|
||||
* 认真看 [异常处理(重要)](#5异常处理重要)
|
||||
### 为什么程序要单线程运行?
|
||||
如果多线程爬取会触发网站反爬机制,而且也违背了些道德,故单线程运行
|
||||
|
||||
# 故事
|
||||
[点击跳转至作者博客文章](https://yoshiko2.github.io/2019/10/18/AVDC/)
|
||||
@@ -109,6 +120,7 @@ pip install pillow
|
||||
|
||||
---
|
||||
#### 软链接
|
||||
方便PT下载完既想刮削又想继续上传的仓鼠党同志
|
||||
>[common]
|
||||
>soft_link=0
|
||||
|
||||
@@ -159,18 +171,12 @@ pip install pillow
|
||||
如果是PLEX,请安装插件:```XBMCnfoMoviesImporter```
|
||||
|
||||
---
|
||||
### 抓取目录
|
||||
### 排除指定字符和目录
|
||||
>[escape]
|
||||
>literals=\
|
||||
|
||||
>folders=failed,JAV_output
|
||||
```literals=``` 标题指定字符删除,例如```iterals=\()```,删除标题中```\()```字符
|
||||
|
||||
---
|
||||
### 抓取目录选择
|
||||
>[movie_location]<br>
|
||||
>path=<br>
|
||||
|
||||
如果directory后面为空,则抓取和程序同一目录下的影片
|
||||
```folders=``` 排指定目录,例如```folders=failed,JAV_output```,多目录刮削时跳过failed,JAV_output
|
||||
|
||||
---
|
||||
### 调试模式
|
||||
@@ -257,19 +263,20 @@ pip install pillow
|
||||

|
||||
|
||||
目前作者已经完善了番号提取机制,功能较为强大,可提取上述文件名的的番号,如果出现提取失败或者异常的情况,请用以下规则命名<br>
|
||||
**妈蛋不要喂软件那么多野鸡片子,不让软件好好活了,操**
|
||||
|
||||
```
|
||||
COSQ-004.mp4
|
||||
```
|
||||
|
||||
针对 **野鸡番号** ,你需要把文件名命名为与抓取网站提供的番号一致(文件拓展名除外),然后把文件拖拽至core.exe/.py<br>
|
||||
**野鸡番号**:比如 ```XXX-XXX-1```, ```1301XX-MINA_YUKA``` 这种**野鸡**番号,在javbus等资料库存在的作品。<br>**重要**:除了 **影片文件名** ```XXXX-XXX-C```,后面这种-C的是指电影有中文字幕!<br>
|
||||
条件:文件名中间要有下划线或者减号"_","-",没有多余的内容只有番号为最佳,可以让软件更好获取元数据
|
||||
对于多影片重命名,可以用[ReNamer](http://www.den4b.com/products/renamer)来批量重命名<br>
|
||||
|
||||
---
|
||||
### 关于PIL/image.py
|
||||
暂时无解,可能是网络问题或者pillow模块打包问题,你可以用源码运行(要安装好第一步的模块)
|
||||
### 拖动法
|
||||
针对格式比较奇葩的番号
|
||||
影片放在和程序同一目录下,拖动至```AV_Data_Capture.exe```,即可完成刮削和整理
|
||||
|
||||
|
||||
## 6.软件会自动把元数据获取成功的电影移动到JAV_output文件夹中,根据演员分类,失败的电影移动到failed文件夹中。
|
||||
|
||||
@@ -3,6 +3,9 @@ from lxml import etree
|
||||
import json
|
||||
from bs4 import BeautifulSoup
|
||||
from ADC_function import *
|
||||
# import sys
|
||||
# import io
|
||||
# sys.stdout = io.TextIOWrapper(sys.stdout.buffer, errors = 'replace', line_buffering = True)
|
||||
|
||||
def getActorPhoto(htmlcode): #//*[@id="star_qdt"]/li/a/img
|
||||
soup = BeautifulSoup(htmlcode, 'lxml')
|
||||
|
||||
@@ -22,6 +22,7 @@ media_warehouse=emby
|
||||
|
||||
[escape]
|
||||
literals=\()
|
||||
folders=failed,JAV_output
|
||||
|
||||
[debug_mode]
|
||||
switch=0
|
||||
@@ -17,103 +17,35 @@ import avsox
|
||||
import javbus
|
||||
import javdb
|
||||
import fanza
|
||||
# =========website========
|
||||
|
||||
|
||||
# 初始化全局变量
|
||||
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'] #成功输出目录
|
||||
import requests
|
||||
|
||||
|
||||
# =====================本地文件处理===========================
|
||||
|
||||
def escapePath(path): # Remove escape literals
|
||||
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():
|
||||
global filepath
|
||||
|
||||
def moveFailedFolder(filepath, failed_folder):
|
||||
print('[-]Move to Failed output folder')
|
||||
shutil.move(filepath, str(os.getcwd()) + '/' + failed_folder + '/')
|
||||
os._exit(0)
|
||||
return
|
||||
|
||||
|
||||
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():
|
||||
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)
|
||||
return
|
||||
|
||||
|
||||
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
|
||||
|
||||
def getDataFromJSON(file_number, filepath, failed_folder): # 从JSON返回元数据
|
||||
# ================================================网站规则添加开始================================================
|
||||
|
||||
if re.match('^\d{5,}', file_number):
|
||||
@@ -129,23 +61,18 @@ def getDataFromJSON(file_number): # 从JSON返回元数据
|
||||
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_','')))
|
||||
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))
|
||||
# ==
|
||||
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(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))
|
||||
@@ -155,15 +82,15 @@ def getDataFromJSON(file_number): # 从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_list = str(json_data['actor']).strip("[ ]").replace("'", '').split(',') # 字符串转列表
|
||||
release = json_data['release']
|
||||
number = json_data['number']
|
||||
cover = json_data['cover']
|
||||
studio = json_data['studio']
|
||||
source = json_data['source']
|
||||
runtime = json_data['runtime']
|
||||
outline = json_data['runtime']
|
||||
label = json_data['label']
|
||||
year = json_data['year']
|
||||
try:
|
||||
cover_small = json_data['cover_small']
|
||||
except:
|
||||
@@ -171,16 +98,15 @@ def getDataFromJSON(file_number): # 从JSON返回元数据
|
||||
imagecut = json_data['imagecut']
|
||||
tag = str(json_data['tag']).strip("[ ]").replace("'", '').replace(" ", '').split(',') # 字符串转列表 @
|
||||
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 == '':
|
||||
print('[-]Movie Data not found!')
|
||||
moveFailedFolder()
|
||||
moveFailedFolder(filepath, failed_folder)
|
||||
return
|
||||
|
||||
if imagecut == '3':
|
||||
DownloadFileWithFilename()
|
||||
# if imagecut == '3':
|
||||
# DownloadFileWithFilename()
|
||||
|
||||
# ====================处理异常字符====================== #\/:*?"<>|
|
||||
title = title.replace('\\', '')
|
||||
@@ -201,11 +127,37 @@ def getDataFromJSON(file_number): # 从JSON返回元数据
|
||||
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
|
||||
json_data['year'] = year
|
||||
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 option == 'emby':
|
||||
DownloadFileWithFilename(cover_small, '1.jpg', path)
|
||||
DownloadFileWithFilename(cover_small, '1.jpg', path, Config, filepath, failed_folder)
|
||||
try:
|
||||
img = Image.open(path + '/1.jpg')
|
||||
except Exception:
|
||||
@@ -216,7 +168,7 @@ def smallCoverCheck():
|
||||
time.sleep(1)
|
||||
os.remove(path + '/1.jpg')
|
||||
if option == 'kodi':
|
||||
DownloadFileWithFilename(cover_small, '1.jpg', path)
|
||||
DownloadFileWithFilename(cover_small, '1.jpg', path, Config, filepath, failed_folder)
|
||||
try:
|
||||
img = Image.open(path + '/1.jpg')
|
||||
except Exception:
|
||||
@@ -227,7 +179,7 @@ def smallCoverCheck():
|
||||
time.sleep(1)
|
||||
os.remove(path + '/1.jpg')
|
||||
if option == 'plex':
|
||||
DownloadFileWithFilename(cover_small, '1.jpg', path)
|
||||
DownloadFileWithFilename(cover_small, '1.jpg', path, Config, filepath, failed_folder)
|
||||
try:
|
||||
img = Image.open(path + '/1.jpg')
|
||||
except Exception:
|
||||
@@ -238,26 +190,31 @@ def smallCoverCheck():
|
||||
os.remove(path + '/1.jpg')
|
||||
|
||||
|
||||
def creatFolder(): # 创建文件夹
|
||||
global actor
|
||||
global path
|
||||
if len(os.getcwd() + path) > 240: # 新建成功输出文件夹
|
||||
path = success_folder+'/'+location_rule.replace("'actor'","'manypeople'",3).replace("actor","'manypeople'",3) #path为影片+元数据所在目录
|
||||
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)
|
||||
path = escapePath(path, Config)
|
||||
try:
|
||||
os.makedirs(path)
|
||||
except:
|
||||
path = success_folder + '/' + location_rule.replace('/[' + number + ']-' + title, "/number")
|
||||
path = escapePath(path)
|
||||
path = escapePath(path, Config)
|
||||
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:
|
||||
proxy = Config['proxy']['proxy']
|
||||
timeout = int(Config['proxy']['timeout'])
|
||||
@@ -277,7 +234,7 @@ def DownloadFileWithFilename(url, filename, path): # path = examle:photo , vide
|
||||
proxies={"http": "http://" + str(proxy), "https": "https://" + str(proxy)})
|
||||
if r == '':
|
||||
print('[-]Movie Data not found!')
|
||||
os._exit(0)
|
||||
return
|
||||
with open(str(path) + "/" + filename, "wb") as code:
|
||||
code.write(r.content)
|
||||
return
|
||||
@@ -289,7 +246,7 @@ def DownloadFileWithFilename(url, filename, path): # path = examle:photo , vide
|
||||
r = requests.get(url, timeout=timeout, headers=headers)
|
||||
if r == '':
|
||||
print('[-]Movie Data not found!')
|
||||
os._exit(0)
|
||||
return
|
||||
with open(str(path) + "/" + filename, "wb") as code:
|
||||
code.write(r.content)
|
||||
return
|
||||
@@ -306,14 +263,16 @@ def DownloadFileWithFilename(url, filename, path): # path = examle:photo , vide
|
||||
i += 1
|
||||
print('[-]Image Download : Connect retry ' + str(i) + '/' + str(retry_count))
|
||||
print('[-]Connect Failed! Please check your Proxy or Network!')
|
||||
moveFailedFolder()
|
||||
moveFailedFolder(filepath, failed_folder)
|
||||
return
|
||||
|
||||
|
||||
def imageDownload(): # 封面是否下载成功,否则移动到failed
|
||||
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) == 'failed':
|
||||
moveFailedFolder()
|
||||
DownloadFileWithFilename(cover, number + c_word + '.jpg', path)
|
||||
if DownloadFileWithFilename(cover, number + c_word + '.jpg', path, Config, filepath, failed_folder) == 'failed':
|
||||
moveFailedFolder(filepath, failed_folder)
|
||||
return
|
||||
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
|
||||
@@ -321,7 +280,7 @@ def imageDownload(): # 封面是否下载成功,否则移动到failed
|
||||
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)
|
||||
DownloadFileWithFilename(cover, number + c_word + '.jpg', path, Config, filepath, failed_folder)
|
||||
i = i + 1
|
||||
continue
|
||||
else:
|
||||
@@ -334,9 +293,10 @@ def imageDownload(): # 封面是否下载成功,否则移动到failed
|
||||
else:
|
||||
print('[+]Image Downloaded!', path + '/' + number + c_word + '.jpg')
|
||||
elif option == 'plex':
|
||||
if DownloadFileWithFilename(cover, 'fanart.jpg', path) == 'failed':
|
||||
moveFailedFolder()
|
||||
DownloadFileWithFilename(cover, 'fanart.jpg', path)
|
||||
if DownloadFileWithFilename(cover, 'fanart.jpg', path, Config, filepath, failed_folder) == 'failed':
|
||||
moveFailedFolder(filepath, failed_folder)
|
||||
return
|
||||
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
|
||||
@@ -344,19 +304,20 @@ def imageDownload(): # 封面是否下载成功,否则移动到failed
|
||||
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)
|
||||
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)
|
||||
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) == 'failed':
|
||||
moveFailedFolder()
|
||||
DownloadFileWithFilename(cover, number + c_word + '-fanart.jpg', path)
|
||||
if DownloadFileWithFilename(cover, number + c_word + '-fanart.jpg', path, Config, filepath, failed_folder) == 'failed':
|
||||
moveFailedFolder(filepath, failed_folder)
|
||||
return
|
||||
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
|
||||
@@ -364,7 +325,7 @@ def imageDownload(): # 封面是否下载成功,否则移动到failed
|
||||
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)
|
||||
DownloadFileWithFilename(cover, number + c_word + '-fanart.jpg', path, Config, filepath, failed_folder)
|
||||
i = i + 1
|
||||
continue
|
||||
else:
|
||||
@@ -372,7 +333,8 @@ def imageDownload(): # 封面是否下载成功,否则移动到failed
|
||||
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:
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
@@ -522,14 +484,16 @@ def PrintFiles():
|
||||
except IOError as e:
|
||||
print("[-]Write Failed!")
|
||||
print(e)
|
||||
moveFailedFolder()
|
||||
moveFailedFolder(filepath, failed_folder)
|
||||
return
|
||||
except Exception as e1:
|
||||
print(e1)
|
||||
print("[-]Write Failed!")
|
||||
moveFailedFolder()
|
||||
moveFailedFolder(filepath, failed_folder)
|
||||
return
|
||||
|
||||
|
||||
def cutImage():
|
||||
def cutImage(option, imagecut, path, number, c_word):
|
||||
if option == 'plex':
|
||||
if imagecut == 1:
|
||||
try:
|
||||
@@ -585,8 +549,7 @@ def cutImage():
|
||||
img.save(path + '/' + number + c_word + '-poster.jpg')
|
||||
|
||||
|
||||
def pasteFileToFolder(filepath, path): # 文件路径,番号,后缀,要移动至的位置
|
||||
global houzhui
|
||||
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 使用软链接
|
||||
@@ -605,19 +568,16 @@ def pasteFileToFolder(filepath, path): # 文件路径,番号,后缀,要
|
||||
except FileExistsError:
|
||||
print('[-]File Exists! Please check your movie!')
|
||||
print('[-]move to the root folder of the program.')
|
||||
os._exit(0)
|
||||
return
|
||||
except PermissionError:
|
||||
print('[-]Error! Please run as administrator!')
|
||||
os._exit(0)
|
||||
return
|
||||
|
||||
|
||||
def pasteFileToFolder_mode2(filepath, path): # 文件路径,番号,后缀,要移动至的位置
|
||||
global houzhui
|
||||
global number
|
||||
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())
|
||||
path = success_folder + '/' + location_rule
|
||||
try:
|
||||
if config['common']['soft_link'] == '1':
|
||||
os.symlink(filepath, path + '/' + number + part + c_word + houzhui)
|
||||
@@ -636,13 +596,13 @@ def pasteFileToFolder_mode2(filepath, path): # 文件路径,番号,后缀
|
||||
except FileExistsError:
|
||||
print('[-]File Exists! Please check your movie!')
|
||||
print('[-]move to the root folder of the program.')
|
||||
os._exit(0)
|
||||
return
|
||||
except PermissionError:
|
||||
print('[-]Error! Please run as administrator!')
|
||||
os._exit(0)
|
||||
return
|
||||
|
||||
|
||||
def copyRenameJpgToBackdrop():
|
||||
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')
|
||||
@@ -652,7 +612,7 @@ def copyRenameJpgToBackdrop():
|
||||
shutil.copy(path + '/' + number + c_word + '-fanart.jpg', path + '/Backdrop.jpg')
|
||||
|
||||
|
||||
def get_part(filepath):
|
||||
def get_part(filepath, failed_folder):
|
||||
try:
|
||||
if re.search('-CD\d+', filepath):
|
||||
return re.findall('-CD\d+', filepath)[0]
|
||||
@@ -660,10 +620,11 @@ def get_part(filepath):
|
||||
return re.findall('-cd\d+', filepath)[0]
|
||||
except:
|
||||
print("[-]failed!Please rename the filename again!")
|
||||
moveFailedFolder()
|
||||
moveFailedFolder(filepath, failed_folder)
|
||||
return
|
||||
|
||||
|
||||
def debug_mode():
|
||||
def debug_mode(json_data):
|
||||
try:
|
||||
if config['debug_mode']['switch'] == '1':
|
||||
print('[+] ---Debug info---')
|
||||
@@ -679,38 +640,49 @@ def debug_mode():
|
||||
aaa = ''
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
filepath = argparse_get_file()[0] # 影片的路径
|
||||
|
||||
def core_main(file_path, number_th):
|
||||
# =======================================================================初始化所需变量
|
||||
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:
|
||||
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:
|
||||
cn_sub = '1'
|
||||
c_word = '-C' # 中文字幕影片后缀
|
||||
|
||||
if argparse_get_file()[1] == '': # 如果第二个运行参数为空,获取从第一个参数影片路径的番号
|
||||
try:
|
||||
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() # 创建文件夹
|
||||
CreatFailedFolder(failed_folder) # 创建输出失败目录
|
||||
debug_mode(json_data) # 调试模式检测
|
||||
path = creatFolder(success_folder, json_data['location_rule'], json_data, Config) # 创建文件夹
|
||||
# =======================================================================刮削模式
|
||||
if program_mode == '1':
|
||||
if multi_part == 1:
|
||||
number += part # 这时number会被附加上CD1后缀
|
||||
smallCoverCheck() # 检查小封面
|
||||
imageDownload() # creatFoder会返回番号路径
|
||||
cutImage() # 裁剪图
|
||||
copyRenameJpgToBackdrop()
|
||||
PrintFiles() # 打印文件
|
||||
# renameBackdropToJpg_copy()
|
||||
pasteFileToFolder(filepath, path) # 移动文件
|
||||
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) # 移动文件
|
||||
pasteFileToFolder_mode2(filepath, path, multi_part, number, part, c_word) # 移动文件
|
||||
|
||||
@@ -0,0 +1,678 @@
|
||||
# -*- 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) # 移动文件
|
||||
@@ -50,17 +50,17 @@ def getYear(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')
|
||||
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')
|
||||
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(" ['']")
|
||||
result1 = html.xpath("//td[contains(text(),'ジャンル:')]/following-sibling::td/a/text()")
|
||||
except:
|
||||
result1 = str(html.xpath("//td[contains(text(),'ジャンル:')]/following-sibling::td/text()")).strip(" ['']")
|
||||
return result1.replace("', '",",")
|
||||
result1 = html.xpath("//td[contains(text(),'ジャンル:')]/following-sibling::td/text()")
|
||||
return result1
|
||||
def getCover(htmlcode,number):
|
||||
html = etree.fromstring(htmlcode, etree.HTMLParser())
|
||||
result = html.xpath('//*[@id="'+number+'"]/@href')[0]
|
||||
@@ -82,6 +82,7 @@ def main(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),
|
||||
@@ -100,9 +101,13 @@ def main(number):
|
||||
'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('ssni00384'))
|
||||
#print(main('ipx292'))
|
||||
|
||||
+76
-3
@@ -2,6 +2,9 @@ import re
|
||||
from lxml import etree#need install
|
||||
import json
|
||||
import ADC_function
|
||||
# import sys
|
||||
# import io
|
||||
# sys.stdout = io.TextIOWrapper(sys.stdout.buffer, errors = 'replace', line_buffering = True)
|
||||
|
||||
def getTitle(htmlcode): #获取厂商
|
||||
#print(htmlcode)
|
||||
@@ -55,8 +58,53 @@ def getYear(release):
|
||||
except:
|
||||
return ''
|
||||
|
||||
def getTitle_fc2com(htmlcode): #获取厂商
|
||||
html = etree.fromstring(htmlcode,etree.HTMLParser())
|
||||
result = html.xpath('//*[@id="top"]/div[1]/section[1]/div/section/div[2]/h3/text()')[0]
|
||||
return result
|
||||
def getActor_fc2com(htmlcode):
|
||||
try:
|
||||
html = etree.fromstring(htmlcode, etree.HTMLParser())
|
||||
result = html.xpath('//*[@id="top"]/div[1]/section[1]/div/section/div[2]/ul/li[3]/a/text()')[0]
|
||||
return result
|
||||
except:
|
||||
return ''
|
||||
def getStudio_fc2com(htmlcode): #获取厂商
|
||||
try:
|
||||
html = etree.fromstring(htmlcode, etree.HTMLParser())
|
||||
result = str(html.xpath('//*[@id="top"]/div[1]/section[1]/div/section/div[2]/ul/li[3]/a/text()')).strip(" ['']")
|
||||
return result
|
||||
except:
|
||||
return ''
|
||||
def getNum_fc2com(htmlcode): #获取番号
|
||||
html = etree.fromstring(htmlcode, etree.HTMLParser())
|
||||
result = str(html.xpath('/html/body/div[5]/div[1]/div[2]/p[1]/span[2]/text()')).strip(" ['']")
|
||||
return result
|
||||
def getRelease_fc2com(htmlcode2): #
|
||||
html=etree.fromstring(htmlcode2,etree.HTMLParser())
|
||||
result = str(html.xpath('//*[@id="container"]/div[1]/div/article/section[1]/div/div[2]/dl/dd[4]/text()')).strip(" ['']")
|
||||
return result
|
||||
def getCover_fc2com(htmlcode2): #获取厂商 #
|
||||
html = etree.fromstring(htmlcode2, etree.HTMLParser())
|
||||
result = str(html.xpath('//*[@id="top"]/div[1]/section[1]/div/section/div[1]/span/img/@src')).strip(" ['']")
|
||||
return 'http:' + result
|
||||
def getOutline_fc2com(htmlcode2): #获取番号 #
|
||||
html = etree.fromstring(htmlcode2, etree.HTMLParser())
|
||||
result = str(html.xpath('/html/body/div/text()')).strip(" ['']").replace("\\n",'',10000).replace("'",'',10000).replace(', ,','').strip(' ').replace('。,',',')
|
||||
return result
|
||||
def getTag_fc2com(number): #获取番号
|
||||
htmlcode = str(bytes(ADC_function.get_html('http://adult.contents.fc2.com/api/v4/article/'+number+'/tag?'),'utf-8').decode('unicode-escape'))
|
||||
result = re.findall('"tag":"(.*?)"', htmlcode)
|
||||
return result
|
||||
def getYear_fc2com(release):
|
||||
try:
|
||||
result = re.search('\d{4}',release).group()
|
||||
return result
|
||||
except:
|
||||
return ''
|
||||
|
||||
def main(number):
|
||||
htmlcode2 = ADC_function.get_html('http://adult.contents.fc2.com/article_search.php?id='+number+'&utm_source=aff_php&utm_medium=source_code&utm_campaign=from_aff_php')
|
||||
htmlcode2 = ADC_function.get_html('https://adult.contents.fc2.com/article/'+number+'/')
|
||||
htmlcode = ADC_function.get_html('https://fc2club.com//html/FC2-' + number + '.html')
|
||||
actor = getActor(htmlcode)
|
||||
if getActor(htmlcode) == '':
|
||||
@@ -65,12 +113,13 @@ def main(number):
|
||||
'title': getTitle(htmlcode),
|
||||
'studio': getStudio(htmlcode),
|
||||
'year': '',#str(re.search('\d{4}',getRelease(number)).group()),
|
||||
'outline': getOutline(htmlcode2),
|
||||
'outline': '',#getOutline(htmlcode2),
|
||||
'runtime': getYear(getRelease(htmlcode)),
|
||||
'director': getStudio(htmlcode),
|
||||
'actor': actor,
|
||||
'release': getRelease(number),
|
||||
'number': 'FC2-'+number,
|
||||
'label': '',
|
||||
'cover': getCover(htmlcode,number,htmlcode2),
|
||||
'imagecut': 0,
|
||||
'tag': getTag(htmlcode),
|
||||
@@ -78,7 +127,31 @@ def main(number):
|
||||
'website': 'https://fc2club.com//html/FC2-' + number + '.html',
|
||||
'source':'https://fc2club.com//html/FC2-' + number + '.html',
|
||||
}
|
||||
if dic['title'] == '':
|
||||
htmlcode2 = ADC_function.get_html('https://adult.contents.fc2.com/article/' + number + '/',cookies={'wei6H':'1'})
|
||||
actor = getActor(htmlcode)
|
||||
if getActor(htmlcode) == '':
|
||||
actor = 'FC2系列'
|
||||
dic = {
|
||||
'title': getTitle_fc2com(htmlcode2),
|
||||
'studio': getStudio_fc2com(htmlcode2),
|
||||
'year': '', # str(re.search('\d{4}',getRelease(number)).group()),
|
||||
'outline': getOutline_fc2com(htmlcode2),
|
||||
'runtime': getYear_fc2com(getRelease(htmlcode2)),
|
||||
'director': getStudio_fc2com(htmlcode2),
|
||||
'actor': actor,
|
||||
'release': getRelease_fc2com(number),
|
||||
'number': 'FC2-' + number,
|
||||
'cover': getCover_fc2com(htmlcode2),
|
||||
'imagecut': 0,
|
||||
'tag': getTag_fc2com(number),
|
||||
'label': '',
|
||||
'actor_photo': '',
|
||||
'website': 'http://adult.contents.fc2.com/article/' + number + '/',
|
||||
'source': 'http://adult.contents.fc2.com/article/' + number + '/',
|
||||
}
|
||||
js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'),)#.encode('UTF-8')
|
||||
return js
|
||||
|
||||
#print(main('1051725'))
|
||||
|
||||
#print(main('1252953'))
|
||||
|
||||
@@ -8,12 +8,9 @@ from ADC_function import *
|
||||
# sys.stdout = io.TextIOWrapper(sys.stdout.buffer, errors = 'replace', line_buffering = True)
|
||||
|
||||
def getTitle(a):
|
||||
try:
|
||||
html = etree.fromstring(a, etree.HTMLParser())
|
||||
result = str(html.xpath('/html/body/section/div/h2/strong/text()')).strip(" ['']")
|
||||
return re.sub('.*\] ', '', result.replace('/', ',').replace('\\xa0', '').replace(' : ', ''))
|
||||
except:
|
||||
return re.sub('.*\] ', '', result.replace('/', ',').replace('\\xa0', ''))
|
||||
result = html.xpath("/html/body/section/div/h2/strong/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()) # //table/tr[1]/td[1]/text()
|
||||
result1 = str(html.xpath('//strong[contains(text(),"演員")]/../following-sibling::span/text()')).strip(" ['']")
|
||||
@@ -83,16 +80,13 @@ def getOutline(htmlcode):
|
||||
return result
|
||||
def main(number):
|
||||
number = number.upper()
|
||||
try:
|
||||
a = get_html('https://javdb.com/search?q=' + number + '&f=all').replace(u'\xa0', u' ')
|
||||
a = get_html('https://javdb.com/search?q=' + number + '&f=all')
|
||||
html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text()
|
||||
result1 = html.xpath('//*[@id="videos"]/div/div/a/@href')[0]
|
||||
b = get_html('https://javdb.com' + result1).replace(u'\xa0', u' ')
|
||||
b = get_html('https://javdb.com' + result1)
|
||||
dic = {
|
||||
'actor': getActor(b),
|
||||
'title': getTitle(b).replace("\\n", '').replace(' ', '').replace(getActor(a), '').replace(getNum(a),
|
||||
'').replace(
|
||||
'无码', '').replace('有码', '').lstrip(' ').replace(number,''),
|
||||
'title': getTitle(b),
|
||||
'studio': getStudio(b),
|
||||
'outline': getOutline(b),
|
||||
'runtime': getRuntime(b),
|
||||
@@ -109,45 +103,9 @@ def main(number):
|
||||
'website': 'https://javdb.com' + result1,
|
||||
'source': 'javdb.py',
|
||||
}
|
||||
if getNum(b) != number: # 与搜索到的番号不匹配
|
||||
dic['title'] = ''
|
||||
dic['number'] = ''
|
||||
js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'), ) # .encode('UTF-8')
|
||||
return js
|
||||
except:
|
||||
a = get_html('https://javdb.com/search?q=' + number + '&f=all').replace(u'\xa0', u' ')
|
||||
html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text()
|
||||
result1 = html.xpath('//*[@id="videos"]/div/div/a/@href')[0]
|
||||
print(html.xpath('//*[@id="videos"]/div/div/a/@href'))
|
||||
b = get_html('https://javdb.com' + result1).replace(u'\xa0', u' ')
|
||||
dic = {
|
||||
'actor': getActor(b),
|
||||
'title': getTitle(b).replace("\\n", '').replace(' ', '').replace(getActor(a), '').replace(
|
||||
getNum(b),
|
||||
'').replace(
|
||||
'无码', '').replace('有码', '').lstrip(' ').replace(number,''),
|
||||
'studio': getStudio(b),
|
||||
'outline': getOutline(b),
|
||||
'runtime': getRuntime(b),
|
||||
'director': getDirector(b),
|
||||
'release': getRelease(b),
|
||||
'number': getNum(b),
|
||||
'cover': getCover(b),
|
||||
'cover_small': getCover_small(a),
|
||||
'imagecut': 3,
|
||||
'tag': getTag(b),
|
||||
'label': getLabel(b),
|
||||
'year': getYear(getRelease(b)), # str(re.search('\d{4}',getRelease(a)).group()),
|
||||
'actor_photo': getActorPhoto(getActor(b)),
|
||||
'website': 'https://javdb3.com' + result1,
|
||||
'source': 'javdb.py',
|
||||
}
|
||||
if getNum(b) != number: # 与搜索到的番号不匹配
|
||||
dic['title'] = ''
|
||||
dic['number'] = ''
|
||||
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('YMDD-178'))
|
||||
#print(main('ipx-292'))
|
||||
|
||||
@@ -3,6 +3,9 @@ from lxml import etree
|
||||
import json
|
||||
from bs4 import BeautifulSoup
|
||||
from ADC_function import *
|
||||
# import sys
|
||||
# import io
|
||||
# sys.stdout = io.TextIOWrapper(sys.stdout.buffer, errors = 'replace', line_buffering = True)
|
||||
|
||||
def getTitle(a):
|
||||
try:
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "2.3",
|
||||
"version_show":"2.3",
|
||||
"version": "2.6",
|
||||
"version_show":"2.6",
|
||||
"download": "https://github.com/yoshiko2/AV_Data_Capture/releases"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user