Compare commits

...
39 Commits
Author SHA1 Message Date
Yoshiko 566a5658b9 Revert "修正封面读取失败,增加路径escape字符,powershell预处理" 2019-11-01 21:24:36 +08:00
Yoshiko 5fe2874892 Merge pull request #53 from ninjadogz/master
修正封面读取失败,增加路径escape字符,powershell预处理
2019-11-01 21:24:32 +08:00
Yoshiko 460c6ee868 Merge branch 'master' into master 2019-11-01 21:24:15 +08:00
ninjadogz 9663f7b473 core.py同期
core.py同期
2019-10-31 22:15:43 +09:00
ninjadogz fb666feec5 更新重名skip
更新重名skip
2019-10-27 17:35:24 +09:00
Yoshiko b980538946 Update README.md 2019-10-27 16:29:38 +08:00
Yoshiko 3323400937 Update LICENSE 2019-10-27 16:28:51 +08:00
Yoshiko 2f29fde426 Update README.md 2019-10-27 16:26:05 +08:00
Yoshiko bc5c08a54c Update README.md 2019-10-27 16:21:33 +08:00
Yoshiko a5b0931bce Update README.md 2019-10-27 16:19:56 +08:00
ninjadogz 5a6361897a 预处理更新
①视频源文件夹内文件移动到AV_Data_Capture文件夹后处理。
②config.ini内增加[movie][path]设置
2019-10-27 00:09:41 +09:00
Yoshiko e7090682c8 Merge pull request #52 from biaji/patch-1
修正某些情况下网站数据导致的错误
2019-10-26 17:39:58 +08:00
Yoshiko 724f3a0d32 Merge pull request #51 from lhiqwj173/master
增加kodi选项,完善kodi图片显示与分集处理
2019-10-26 17:37:51 +08:00
biaji 3c6741ec82 Update core.py 2019-10-25 23:07:16 +08:00
biaji a0260d96cb Update core.py 2019-10-25 22:59:39 +08:00
ninjadogz bab350e8dd Create moveVideos.ps1
文件移动
2019-10-25 00:02:18 +09:00
ninjadogz 72fafef059 更新
更新内容
1.从DB读取的path里有escape文字时自动替换成空。config.ini里追加escape文字列
2.封面下载成功,但无法读取时使用dummy封面分类
3.生产文件夹时去除中文文字列
2019-10-22 20:08:28 +09:00
lhiqwj173 021830b31b 增加kodi选项,完善kodi图片显示,完善kodi分集处理 2019-10-19 23:50:13 +08:00
lhiqwj173 e082cf336e 增加kodi选项,完善kodi图片显示,完善kodi分集处理 2019-10-19 23:49:52 +08:00
lhiqwj173 3b9ab41dcc 增加kodi选项,完善kodi图片显示,完善kodi分集处理 2019-10-19 23:43:18 +08:00
lhiqwj173 f285a1ab6b 增加kodi选项,完善kodi分集处理 2019-10-19 20:05:25 +08:00
Yoshiko 9fb813ae97 Update README.md 2019-10-19 13:16:22 +08:00
Yoshiko 29259b7e5a Update README.md 2019-10-12 22:17:28 +08:00
Yoshiko 952f759e90 Update README.md 2019-10-12 22:04:25 +08:00
Yoshiko e8f823f34c Update README.md 2019-10-07 11:07:21 +08:00
Yoshiko 52e9d407be Update README.md 2019-10-07 00:13:09 +08:00
Yoshiko 62bb672a83 Update README.md 2019-10-07 00:08:56 +08:00
Yoshiko 1eef0fa48d Update README.md 2019-10-07 00:08:04 +08:00
Yoshiko 63bc397599 Update README.md 2019-10-07 00:07:17 +08:00
Yoshiko f99def64bb Update README.md 2019-10-06 01:24:11 +08:00
Yoshiko 94c4838b42 Update update_check.json 2019-10-06 01:15:05 +08:00
Yoshiko 73c0126fb8 Update 1.3 2019-10-06 01:14:12 +08:00
Yoshiko ae99c652f5 Update README.md 2019-09-23 09:27:29 +08:00
Yoshiko 2b9ce63601 Version 1.2 Update 2019-08-29 22:21:59 +08:00
Yoshiko 6928df8c3f Version 1.2 Update 2019-08-29 22:20:54 +08:00
Yoshiko 8ccdf7dc5a Merge pull request #36 from moyy996/master
AV_Data_Capture-1.1(支持分集)
2019-08-19 22:04:22 +08:00
mo_yy b438312c97 Update core.py 2019-08-19 12:23:45 +08:00
mo_yy fd05706636 Update core.py
支持分集
2019-08-19 10:18:32 +08:00
mo_yy 1e407ef962 Update core.py 2019-08-19 00:50:43 +08:00
8 changed files with 974 additions and 578 deletions
+4 -6
View File
@@ -1,3 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import requests import requests
@@ -18,18 +19,13 @@ if os.path.exists(config_file):
else: else:
print('[+]config.ini: not found, creating...') print('[+]config.ini: not found, creating...')
with open("config.ini", "wt", encoding='UTF-8') as code: with open("config.ini", "wt", encoding='UTF-8') as code:
print("[common]", file=code)
print("main_mode=1", file=code)
print("failed_output_folder=failed", file=code)
print("success_output_folder=JAV_output", file=code)
print("", file=code)
print("[proxy]",file=code) print("[proxy]",file=code)
print("proxy=127.0.0.1:1080",file=code) print("proxy=127.0.0.1:1080",file=code)
print("timeout=10", file=code) print("timeout=10", file=code)
print("retry=3", file=code) print("retry=3", file=code)
print("", file=code) print("", file=code)
print("[Name_Rule]", file=code) print("[Name_Rule]", file=code)
print("location_rule=actor+'/'+number",file=code) print("location_rule='JAV_output/'+actor+'/'+number",file=code)
print("naming_rule=number+'-'+title",file=code) print("naming_rule=number+'-'+title",file=code)
print("", file=code) print("", file=code)
print("[update]",file=code) print("[update]",file=code)
@@ -41,8 +37,10 @@ else:
print("#plex only test!", file=code) print("#plex only test!", file=code)
print("", file=code) print("", file=code)
print("[directory_capture]", file=code) print("[directory_capture]", file=code)
print("switch=0", file=code)
print("directory=", file=code) print("directory=", file=code)
print("", file=code) print("", file=code)
print("everyone switch:1=on, 0=off", file=code)
time.sleep(2) time.sleep(2)
print('[+]config.ini: created!') print('[+]config.ini: created!')
try: try:
+34 -47
View File
@@ -14,7 +14,7 @@ os.chdir(os.getcwd())
# ============global var=========== # ============global var===========
version='1.1' version='1.3'
config = ConfigParser() config = ConfigParser()
config.read(config_file, encoding='UTF-8') config.read(config_file, encoding='UTF-8')
@@ -36,36 +36,26 @@ def UpdateCheck():
else: else:
print('[+]Update Check disabled!') print('[+]Update Check disabled!')
def movie_lists(): def movie_lists():
global exclude_directory_1
global exclude_directory_2
directory = config['directory_capture']['directory'] directory = config['directory_capture']['directory']
mp4=[] total=[]
avi=[] file_type = ['mp4','avi','rmvb','wmv','mov','mkv','flv','ts']
rmvb=[] exclude_directory_1 = config['common']['failed_output_folder']
wmv=[] exclude_directory_2 = config['common']['success_output_folder']
mov=[]
mkv=[]
flv=[]
ts=[]
if directory=='*': if directory=='*':
remove_total = []
for o in file_type:
remove_total += glob.glob(r"./" + exclude_directory_1 + "/*." + o)
remove_total += glob.glob(r"./" + exclude_directory_2 + "/*." + o)
for i in os.listdir(os.getcwd()): for i in os.listdir(os.getcwd()):
mp4 += glob.glob(r"./" + i + "/*.mp4") for a in file_type:
avi += glob.glob(r"./" + i + "/*.avi") total += glob.glob(r"./" + i + "/*." + a)
rmvb += glob.glob(r"./" + i + "/*.rmvb") for b in remove_total:
wmv += glob.glob(r"./" + i + "/*.wmv") total.remove(b)
mov += glob.glob(r"./" + i + "/*.mov")
mkv += glob.glob(r"./" + i + "/*.mkv")
flv += glob.glob(r"./" + i + "/*.flv")
ts += glob.glob(r"./" + i + "/*.ts")
total = mp4 + avi + rmvb + wmv + mov + mkv + flv + ts
return total return total
mp4 = glob.glob(r"./" + directory + "/*.mp4") for a in file_type:
avi = glob.glob(r"./" + directory + "/*.avi") total += glob.glob(r"./" + directory + "/*." + a)
rmvb = glob.glob(r"./" + directory + "/*.rmvb")
wmv = glob.glob(r"./" + directory + "/*.wmv")
mov = glob.glob(r"./" + directory + "/*.mov")
mkv = glob.glob(r"./" + directory + "/*.mkv")
flv = glob.glob(r"./" + directory + "/*.flv")
ts = glob.glob(r"./" + directory + "/*.ts")
total = mp4 + avi + rmvb + wmv + mov + mkv + flv + ts
return total return total
def CreatFailedFolder(): def CreatFailedFolder():
if not os.path.exists('failed/'): # 新建failed文件夹 if not os.path.exists('failed/'): # 新建failed文件夹
@@ -79,11 +69,11 @@ def lists_from_test(custom_nuber): #电影列表
a.append(custom_nuber) a.append(custom_nuber)
return a return a
def CEF(path): def CEF(path):
try:
files = os.listdir(path) # 获取路径下的子文件(夹)列表 files = os.listdir(path) # 获取路径下的子文件(夹)列表
for file in files: for file in files:
try: #试图删除空目录,非空目录删除会报错
os.removedirs(path + '/' + file) # 删除这个空文件夹 os.removedirs(path + '/' + file) # 删除这个空文件夹
print('[+]Deleting empty folder',path + '/' + file) print('[+]Deleting empty folder', path + '/' + file)
except: except:
a='' a=''
def rreplace(self, old, new, *max): def rreplace(self, old, new, *max):
@@ -93,30 +83,27 @@ def rreplace(self, old, new, *max):
count = max[0] count = max[0]
return new.join(self.rsplit(old, count)) return new.join(self.rsplit(old, count))
def getNumber(filepath): def getNumber(filepath):
filepath = filepath.replace('.\\','')
try: # 普通提取番号 主要处理包含减号-的番号 try: # 普通提取番号 主要处理包含减号-的番号
filepath = filepath.replace("_", "-")
filepath.strip('22-sht.me').strip('-HD').strip('-hd')
filename = str(re.sub("\[\d{4}-\d{1,2}-\d{1,2}\] - ", "", filepath)) # 去除文件名中时间
try: try:
filepath1 = filepath.replace("_", "-")
filepath1.strip('22-sht.me').strip('-HD').strip('-hd')
filename = str(re.sub("\[\d{4}-\d{1,2}-\d{1,2}\] - ", "", filepath1)) # 去除文件名中时间
file_number = re.search('\w+-\d+', filename).group() file_number = re.search('\w+-\d+', filename).group()
return file_number except: # 提取类似mkbd-s120番号
except: file_number = re.search('\w+-\w+\d+', filename).group()
filepath1 = filepath.replace("_", "-")
filepath1.strip('22-sht.me').strip('-HD').strip('-hd')
filename = str(re.sub("\[\d{4}-\d{1,2}-\d{1,2}\] - ", "", filepath1)) # 去除文件名中时间
file_number = re.search('\w+-\w+', filename).group()
return file_number return file_number
except: # 提取不含减号-的番号 except: # 提取不含减号-的番号
try: try:
filename1 = str(re.sub("ts6\d", "", filepath)).strip('Tokyo-hot').strip('tokyo-hot') filename = str(re.sub("ts6\d", "", filepath)).strip('Tokyo-hot').strip('tokyo-hot')
filename0 = str(re.sub(".*?\.com-\d+", "", filename1)).strip('_') filename = str(re.sub(".*?\.com-\d+", "", filename)).replace('_', '')
file_number = str(re.search('\w+\d{4}', filename0).group(0)) file_number = str(re.search('\w+\d{4}', filename).group(0))
return file_number return file_number
except: # 提取无减号番号 except: # 提取无减号番号
filename1 = str(re.sub("ts6\d", "", filepath)) # 去除ts64/265 filename = str(re.sub("ts6\d", "", filepath)) # 去除ts64/265
filename0 = str(re.sub(".*?\.com-\d+", "", filename1)) filename = str(re.sub(".*?\.com-\d+", "", filename))
file_number2 = str(re.match('\w+', filename0).group()) file_number = str(re.match('\w+', filename).group())
file_number = str(file_number2.replace(re.match("^[A-Za-z]+", file_number2).group(),re.match("^[A-Za-z]+", file_number2).group() + '-')) file_number = str(file_number.replace(re.match("^[A-Za-z]+", file_number).group(),re.match("^[A-Za-z]+", file_number).group() + '-'))
return file_number return file_number
def RunCore(): def RunCore():
@@ -160,7 +147,7 @@ if __name__ =='__main__':
shutil.move(i, str(os.getcwd()) + '/' + 'failed/') shutil.move(i, str(os.getcwd()) + '/' + 'failed/')
continue continue
CEF(exclude_directory_1)
CEF('JAV_output') CEF(exclude_directory_2)
print("[+]All finished!!!") print("[+]All finished!!!")
input("[+][+]Press enter key exit, you can check the error messge before you exit.\n[+][+]按回车键结束,你可以在结束之前查看和错误信息。") input("[+][+]Press enter key exit, you can check the error messge before you exit.\n[+][+]按回车键结束,你可以在结束之前查看和错误信息。")
+674 -373
View File
File diff suppressed because it is too large Load Diff
+38 -26
View File
@@ -9,12 +9,12 @@
![](https://img.shields.io/badge/Python-3.7-yellow.svg?style=flat-square&logo=python)<br> ![](https://img.shields.io/badge/Python-3.7-yellow.svg?style=flat-square&logo=python)<br>
**日本电影元数据 抓取工具 | 刮削器**,配合本地影片管理软件EMBY,KODI管理本地影片,该软件起到分类与元数据抓取作用,利用元数据信息来分类,供本地影片分类整理使用。 **日本电影元数据 抓取工具 | 刮削器**,配合本地影片管理软件EMBY,KODI等管理本地影片,该软件起到分类与元数据抓取作用,利用元数据信息来分类,供本地影片分类整理使用。
# 目录 # 目录
* [免责声明](#免责声明) * [声明](#声明)
* [注意](#注意)
* [你问我答 FAQ](#你问我答-faq) * [你问我答 FAQ](#你问我答-faq)
* [故事](#故事)
* [效果图](#效果图) * [效果图](#效果图)
* [如何使用](#如何使用) * [如何使用](#如何使用)
* [下载](#下载) * [下载](#下载)
@@ -29,25 +29,29 @@
* [关于群晖NAS](#8关于群晖NAS) * [关于群晖NAS](#8关于群晖NAS)
* [写在后面](#9写在后面) * [写在后面](#9写在后面)
# 免责声明 # 声明
1.本软件仅供**技术交流,学术交流**使用,本项目旨在学习 Python3<br> * 本软件仅供**技术交流,学术交流**使用<br>
2.本软件禁止用于任何非法用途<br> * 本软件作者编写出该软件旨在学习Python3,提高编程水平<br>
3.使用者使用该软件产生的一切法律后果由使用者承担<br> * 用户在使用该软件前,请用户自觉遵守当地法律法规,如果该软件使用过程中存在违反当地法律法规的行为,请勿使用该软件<br>
4.不可使用于商业和个人其他意图<br> * 用户使用该软件时,若产生一切违法行为由用户承担<br>
* 严禁用户使用于商业和个人其他意图<br>
* 本软件作者保留最终决定权和最终解释权<br>
**若用户不同意上述条款任意一条,请勿使用该软件**<br>
# 注意
**推荐用法: 使用该软件后,对于不能正常获取元数据的电影可以用 Everaver 来补救**<br>
暂不支持多P电影<br>
# 你问我答 FAQ # 你问我答 FAQ
### F:这软件能下片吗? ### 这软件能下片吗?
**Q**:该软件不提供任何影片下载地址,仅供本地影片分类整理使用。 * 该软件不提供任何影片下载地址,仅供本地影片分类整理使用。
### F:什么是元数据? ### 什么是元数据?
**Q**:元数据包括了影片的:封面,导演,演员,简介,类型...... * 元数据包括了影片的:封面,导演,演员,简介,类型......
### F:软件收费吗? ### 软件收费吗?
**Q**:软件永久免费。除了 **作者** 钦点以外,给那些 **利用本软件牟利** 的人送上 **骨灰盒-全家族 | 崭新出厂** * 软件永久免费。**除了作者钦点以外**
### F:软件运行异常怎么办? ### 软件运行异常怎么办?
**Q**:认真看 [异常处理(重要)](#5异常处理重要) * 认真看 [异常处理(重要)](#5异常处理重要)
# 故事
[点击跳转至作者博客文章](https://yoshiko2.github.io/2019/10/18/AVDC/)
# 效果图 # 效果图
**图片来自网络**,由于相关法律法规,具体效果请自行联想 **图片来自网络**,由于相关法律法规,具体效果请自行联想
@@ -88,7 +92,6 @@ pip install pillow
### ###
## 2.配置config.ini ## 2.配置config.ini
config.ini
>[common]<br> >[common]<br>
>main_mode=1<br> >main_mode=1<br>
>failed_output_folder=failed<br> >failed_output_folder=failed<br>
@@ -113,13 +116,13 @@ config.ini
>[directory_capture]<br> >[directory_capture]<br>
>directory=<br> >directory=<br>
### 全局设置
--- ---
#### 软件模式 #### 运行模式
>[common]<br> >[common]<br>
>main_mode=1<br> >main_mode=1<br>
1为普通模式,2为整理模式:仅根据女优把电影命名为番号并分类到女优名称的文件夹下 1为普通模式<br>
2为整理模式:仅根据女优把电影命名为番号并分类到女优名称的文件夹下
>failed_output_folder=failed<br> >failed_output_folder=failed<br>
>success_output_folder=JAV_outputd<br> >success_output_folder=JAV_outputd<br>
@@ -167,8 +170,17 @@ config.ini
#### 抓取目录选择 #### 抓取目录选择
>[directory_capture]<br> >[directory_capture]<br>
>directory=<br> >directory=<br>
如果directory后面为空,则抓取和程序同一目录下的影片,设置为``` * ```可抓取软件所在目录下的所有子目录中的影片 如果directory后面为空,则抓取和程序同一目录下的影片,设置为``` * ```可抓取软件所在目录下的所有子目录中的影片<br>如果出错请不要加*
## 3.(可选)设置自定义目录和影片重命名规则
---
#### 调试模式
>[debug_mode]<br>switch=1<br>
如要开启调试模式,请手动输入以上代码到```config.ini```中,开启后可在抓取中显示影片元数据
### 3.(可选)设置自定义目录和影片重命名规则
>[Name_Rule]<br> >[Name_Rule]<br>
>location_rule=actor+'/'+number<br> >location_rule=actor+'/'+number<br>
>naming_rule=number+'-'+title<br> >naming_rule=number+'-'+title<br>
@@ -196,10 +208,10 @@ config.ini
目录结构规则:默认 ```location_rule=actor+'/'+number```<br> **不推荐修改时在这里添加title**,有时title过长,因为Windows API问题,抓取数据时新建文件夹容易出错。<br> 目录结构规则:默认 ```location_rule=actor+'/'+number```<br> **不推荐修改时在这里添加title**,有时title过长,因为Windows API问题,抓取数据时新建文件夹容易出错。<br>
影片命名规则:默认 ```naming_rule=number+'-'+title```<br> **在EMBY,KODI等本地媒体库显示的标题,不影响目录结构下影片文件的命名**,依旧是 番号+后缀。 影片命名规则:默认 ```naming_rule=number+'-'+title```<br> **在EMBY,KODI等本地媒体库显示的标题,不影响目录结构下影片文件的命名**,依旧是 番号+后缀。
---
### 更新开关 ### 更新开关
>[update]<br>update_check=1<br> >[update]<br>update_check=1<br>
1为开,0为关 1为开,0为关
## 4.建议把软件拷贝和电影的统一目录下 ## 4.建议把软件拷贝和电影的统一目录下
如果```config.ini```中```directory=```后面为空的情况下 如果```config.ini```中```directory=```后面为空的情况下
## 5.运行 ```AV_Data_capture.py/.exe``` ## 5.运行 ```AV_Data_capture.py/.exe```
+1 -1
View File
@@ -17,7 +17,7 @@ update_check=1
[media] [media]
media_warehouse=emby media_warehouse=emby
#emby or plex #emby or plex or kodi
[directory_capture] [directory_capture]
directory= directory=
+170 -62
View File
@@ -18,14 +18,13 @@ import javbus
import javdb import javdb
#=========website======== #=========website========
#初始化全局变量
Config = ConfigParser() Config = ConfigParser()
Config.read(config_file, encoding='UTF-8') Config.read(config_file, encoding='UTF-8')
try: try:
option = ReadMediaWarehouse() option = ReadMediaWarehouse()
except: except:
print('[-]Config media_warehouse read failed!') print('[-]Config media_warehouse read failed!')
#初始化全局变量
title='' title=''
studio='' studio=''
year='' year=''
@@ -40,6 +39,8 @@ cover=''
imagecut='' imagecut=''
tag=[] tag=[]
cn_sub='' cn_sub=''
multi_part=0
part=''
path='' path=''
houzhui='' houzhui=''
website='' website=''
@@ -49,9 +50,10 @@ cover_small=''
naming_rule =''#eval(config['Name_Rule']['naming_rule']) naming_rule =''#eval(config['Name_Rule']['naming_rule'])
location_rule=''#eval(config['Name_Rule']['location_rule']) location_rule=''#eval(config['Name_Rule']['location_rule'])
program_mode = Config['common']['main_mode'] program_mode = Config['common']['main_mode']
failed_folder= Config['common']['failed_output_folder'] failed_folder = Config['common']['failed_output_folder']
success_folder=Config['common']['success_output_folder'] success_folder = Config['common']['success_output_folder']
#=====================本地文件处理=========================== #=====================本地文件处理===========================
def moveFailedFolder(): def moveFailedFolder():
global filepath global filepath
print('[-]Move to Failed output folder') print('[-]Move to Failed output folder')
@@ -94,40 +96,39 @@ def getDataFromJSON(file_number): #从JSON返回元数据
global website global website
global actor_photo global actor_photo
global cover_small global cover_small
global json_data
global naming_rule global naming_rule
global location_rule global location_rule
# ================================================网站规则添加开始================================================ # ================================================网站规则添加开始================================================
try: # 添加 需要 正则表达式的规则 if re.match('^\d{5,}', file_number):
if re.search('^\d{5,}', file_number).group() in file_number:
json_data = json.loads(avsox.main(file_number)) json_data = json.loads(avsox.main(file_number))
if getDataState(json_data) == 0: #如果元数据获取失败,请求番号至其他网站抓取 if getDataState(json_data) == 0: # 如果元数据获取失败,请求番号至其他网站抓取
json_data = json.loads(javdb.main(file_number)) json_data = json.loads(javdb.main(file_number))
#==
elif re.search('\d+\D+', file_number).group() in file_number: elif re.match('\d+\D+', file_number):
json_data = json.loads(siro.main(file_number)) json_data = json.loads(siro.main(file_number))
if getDataState(json_data) == 0: #如果元数据获取失败,请求番号至其他网站抓取 if getDataState(json_data) == 0: # 如果元数据获取失败,请求番号至其他网站抓取
json_data = json.loads(javbus.main(file_number)) json_data = json.loads(javbus.main(file_number))
elif getDataState(json_data) == 0: #如果元数据获取失败,请求番号至其他网站抓取 elif getDataState(json_data) == 0: # 如果元数据获取失败,请求番号至其他网站抓取
json_data = json.loads(javdb.main(file_number)) json_data = json.loads(javdb.main(file_number))
# ==
except: # 添加 无需 正则表达式的规则 elif 'fc2' in file_number or 'FC2' in file_number:
if 'fc2' in file_number: json_data = json.loads(fc2fans_club.main(file_number))
json_data = json.loads(fc2fans_club.main(file_number.strip('fc2_').strip('fc2-').strip('ppv-').strip('PPV-').strip('FC2_').strip('FC2-').strip('ppv-').strip('PPV-'))) # ==
elif 'FC2' in file_number:
json_data = json.loads(fc2fans_club.main(file_number.strip('FC2_').strip('FC2-').strip('ppv-').strip('PPV-').strip('fc2_').strip('fc2-').strip('ppv-').strip('PPV-')))
elif 'HEYZO' in number or 'heyzo' in number or 'Heyzo' in number: elif 'HEYZO' in number or 'heyzo' in number or 'Heyzo' in number:
json_data = json.loads(avsox.main(file_number)) json_data = json.loads(avsox.main(file_number))
# ==
elif 'siro' in file_number or 'SIRO' in file_number or 'Siro' in file_number: elif 'siro' in file_number or 'SIRO' in file_number or 'Siro' in file_number:
json_data = json.loads(siro.main(file_number)) json_data = json.loads(siro.main(file_number))
# ==
else: else:
json_data = json.loads(javbus.main(file_number)) json_data = json.loads(javbus.main(file_number))
if getDataState(json_data) == 0: #如果元数据获取失败,请求番号至其他网站抓取 if getDataState(json_data) == 0: # 如果元数据获取失败,请求番号至其他网站抓取
json_data = json.loads(avsox.main(file_number)) json_data = json.loads(avsox.main(file_number))
elif getDataState(json_data) == 0: #如果元数据获取失败,请求番号至其他网站抓取 elif getDataState(json_data) == 0: # 如果元数据获取失败,请求番号至其他网站抓取
json_data = json.loads(javdb.main(file_number)) json_data = json.loads(javdb.main(file_number))
# ================================================网站规则添加结束================================================ # ================================================网站规则添加结束================================================
@@ -145,9 +146,9 @@ def getDataFromJSON(file_number): #从JSON返回元数据
try: try:
cover_small = json_data['cover_small'] cover_small = json_data['cover_small']
except: except:
aaaaaaa='' cover_small=''
imagecut = json_data['imagecut'] imagecut = json_data['imagecut']
tag = str(json_data['tag']).strip("[ ]").replace("'", '').replace(" ", '').split(',') # 字符串转列表 tag = str(json_data['tag']).strip("[ ]").replace("'", '').replace(" ", '').split(',') # 字符串转列表 @
actor = str(actor_list).strip("[ ]").replace("'", '').replace(" ", '') actor = str(actor_list).strip("[ ]").replace("'", '').replace(" ", '')
actor_photo = json_data['actor_photo'] actor_photo = json_data['actor_photo']
website = json_data['website'] website = json_data['website']
@@ -162,24 +163,18 @@ def getDataFromJSON(file_number): #从JSON返回元数据
# ====================处理异常字符====================== #\/:*?"<>| # ====================处理异常字符====================== #\/:*?"<>|
if '\\' in title: title = title.replace('\\', '')
title=title.replace('\\', ' ') title = title.replace('/', '')
elif r'/' in title: title = title.replace(':', '')
title=title.replace(r'/', '') title = title.replace('*', '')
elif ':' in title: title = title.replace('?', '')
title=title.replace(':', '') title = title.replace('"', '')
elif '*' in title: title = title.replace('<', '')
title=title.replace('*', '') title = title.replace('>', '')
elif '?' in title: title = title.replace('|', '')
title=title.replace('?', '') tmpArr = cover_small.split(',')
elif '"' in title: if len(tmpArr) > 0:
title=title.replace('"', '') cover_small = tmpArr[0].strip('\"').strip('\'')
elif '<' in title:
title=title.replace('<', '')
elif '>' in title:
title=title.replace('>', '')
elif '|' in title:
title=title.replace('|', '')
# ====================处理异常字符 END================== #\/:*?"<>| # ====================处理异常字符 END================== #\/:*?"<>|
naming_rule = eval(config['Name_Rule']['naming_rule']) naming_rule = eval(config['Name_Rule']['naming_rule'])
@@ -194,6 +189,14 @@ def smallCoverCheck():
img.save(path + '/' + number + '.png') img.save(path + '/' + number + '.png')
time.sleep(1) time.sleep(1)
os.remove(path + '/1.jpg') os.remove(path + '/1.jpg')
if option == 'kodi':
DownloadFileWithFilename(cover_small, '1.jpg', path)
img = Image.open(path + '/1.jpg')
w = img.width
h = img.height
img.save(path + '/' + number + '-poster.jpg')
time.sleep(1)
os.remove(path + '/1.jpg')
if option == 'plex': if option == 'plex':
DownloadFileWithFilename(cover_small, '1.jpg', path) DownloadFileWithFilename(cover_small, '1.jpg', path)
img = Image.open(path + '/1.jpg') img = Image.open(path + '/1.jpg')
@@ -204,9 +207,8 @@ def smallCoverCheck():
def creatFolder(): #创建文件夹 def creatFolder(): #创建文件夹
global actor global actor
global path global path
if len(actor) > 240: #新建成功输出文件夹 if len(os.getcwd()+path) > 240: #新建成功输出文件夹
path = success_folder+'/'+location_rule.replace("'actor'","'超多人'",3).replace("actor","'超多人'",3) #path为影片+元数据所在目录 path = success_folder+'/'+location_rule.replace("'actor'","'超多人'",3).replace("actor","'超多人'",3) #path为影片+元数据所在目录
#print(path)
else: else:
path = success_folder+'/'+location_rule path = success_folder+'/'+location_rule
#print(path) #print(path)
@@ -272,17 +274,24 @@ def imageDownload(filepath): #封面是否下载成功,否则移动到failed
if DownloadFileWithFilename(cover, number + '.jpg', path) == 'failed': if DownloadFileWithFilename(cover, number + '.jpg', path) == 'failed':
moveFailedFolder() moveFailedFolder()
DownloadFileWithFilename(cover, number + '.jpg', path) DownloadFileWithFilename(cover, number + '.jpg', path)
if multi_part == 1:
old_name = os.path.join(path, number + '.jpg')
new_name = os.path.join(path, number + part + '.jpg')
os.rename(old_name, new_name)
print('[+]Image Downloaded!', path + '/' + number + part + '.jpg')
else:
print('[+]Image Downloaded!', path + '/' + number + '.jpg') print('[+]Image Downloaded!', path + '/' + number + '.jpg')
elif option == 'kodi':
if DownloadFileWithFilename(cover, number + '-fanart.jpg', path) == 'failed':
moveFailedFolder()
DownloadFileWithFilename(cover, number + '-fanart.jpg', path)
print('[+]Image Downloaded!', path + '/' + number + '-fanart.jpg')
elif option == 'plex': elif option == 'plex':
if DownloadFileWithFilename(cover, 'fanart.jpg', path) == 'failed': if DownloadFileWithFilename(cover, 'fanart.jpg', path) == 'failed':
moveFailedFolder() moveFailedFolder()
DownloadFileWithFilename(cover, 'fanart.jpg', path) DownloadFileWithFilename(cover, 'fanart.jpg', path)
print('[+]Image Downloaded!', path + '/fanart.jpg') print('[+]Image Downloaded!', path + '/fanart.jpg')
def PrintFiles(filepath): def PrintFiles(filepath):
#global path
global title
global cn_sub
global actor_photo
try: try:
if not os.path.exists(path): if not os.path.exists(path):
os.makedirs(path) os.makedirs(path)
@@ -316,12 +325,12 @@ def PrintFiles(filepath):
if cn_sub == '1': if cn_sub == '1':
print(" <tag>中文字幕</tag>", file=code) print(" <tag>中文字幕</tag>", file=code)
try: try:
for i in tag: for i in str(json_data['tag']).strip("[ ]").replace("'", '').replace(" ", '').split(','):
print(" <tag>" + i + "</tag>", file=code) print(" <tag>" + i + "</tag>", file=code)
except: except:
aaaaa = '' aaaaa = ''
try: try:
for i in tag: for i in str(json_data['tag']).strip("[ ]").replace("'", '').replace(" ", '').split(','):
print(" <genre>" + i + "</genre>", file=code) print(" <genre>" + i + "</genre>", file=code)
except: except:
aaaaaaaa = '' aaaaaaaa = ''
@@ -380,6 +389,52 @@ def PrintFiles(filepath):
print(" <website>" + "https://www.javbus.com/" + number + "</website>", file=code) print(" <website>" + "https://www.javbus.com/" + number + "</website>", file=code)
print("</movie>", file=code) print("</movie>", file=code)
print("[+]Writeed! " + path + "/" + number + ".nfo") print("[+]Writeed! " + path + "/" + number + ".nfo")
elif option == 'kodi':
with open(path + "/" + number + ".nfo", "wt", encoding='UTF-8') as code:
print("<movie>", file=code)
print(" <title>" + naming_rule + "</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 + "-poster.jpg</poster>", file=code)
print(" <fanart>" + number + '-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 actor_photo == '': # 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 + ".nfo")
except IOError as e: except IOError as e:
print("[-]Write Failed!") print("[-]Write Failed!")
print(e) print(e)
@@ -421,24 +476,36 @@ def cutImage():
w = img.width w = img.width
h = img.height h = img.height
img.save(path + '/' + number + '.png') img.save(path + '/' + number + '.png')
elif option == 'kodi':
if imagecut == 1:
try:
img = Image.open(path + '/' + number + '-fanart.jpg')
imgSize = img.size
w = img.width
h = img.height
img2 = img.crop((w / 1.9, 0, w, h))
img2.save(path + '/' + number + '-poster.jpg')
except:
print('[-]Cover cut failed!')
elif imagecut == 0:
img = Image.open(path + '/' + number + '-fanart.jpg')
w = img.width
h = img.height
img.save(path + '/' + number + '-poster.jpg')
def pasteFileToFolder(filepath, path): #文件路径,番号,后缀,要移动至的位置 def pasteFileToFolder(filepath, path): #文件路径,番号,后缀,要移动至的位置
global houzhui 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())
if part == '-CD1' and option == 'kodi':
global number
number += part
try: try:
os.rename(filepath, path + '/' + number + houzhui) os.rename(filepath, path + '/' + number + houzhui)
except FileExistsError: except FileExistsError:
print('[-]File Exists! Please check your movie!') print('[-]File Exists! Please check your movie!')
print('[-]move to the root folder of the program.') print('[-]move to the root folder of the program.')
os._exit(0) os._exit(0)
def pasteFileToFolder_mode2(filepath, path): #文件路径,番号,后缀,要移动至的位置 except PermissionError:
global houzhui print('[-]Error! Please run as administrator!')
houzhui = str(re.search('[.](AVI|RMVB|WMV|MOV|MP4|MKV|FLV|TS|avi|rmvb|wmv|mov|mp4|mkv|flv|ts)$', filepath).group())
try:
os.rename(filepath, path + houzhui)
print('[+]Movie ' + number + ' move to target folder Finished!')
except:
print('[-]File Exists! Please check your movie!')
print('[-]move to the root folder of the program.')
os._exit(0) os._exit(0)
def renameJpgToBackdrop_copy(): def renameJpgToBackdrop_copy():
if option == 'plex': if option == 'plex':
@@ -446,10 +513,44 @@ def renameJpgToBackdrop_copy():
shutil.copy(path + '/poster.png', path + '/thumb.png') shutil.copy(path + '/poster.png', path + '/thumb.png')
if option == 'emby': if option == 'emby':
shutil.copy(path + '/' + number + '.jpg', path + '/Backdrop.jpg') shutil.copy(path + '/' + number + '.jpg', path + '/Backdrop.jpg')
if option == 'kodi':
shutil.copy(path + '/' + number + '-fanart.jpg', path + '/Backdrop.jpg')
def renameBackdropToJpg_copy():
if option == 'plex':
shutil.copy(path + '/fanart.jpg', path + '/Backdrop.jpg')
shutil.copy(path + '/poster.png', path + '/thumb.png')
if option == 'emby':
shutil.copy(path + '/Backdrop.jpg', path + '/' + number + '.jpg')
print('[+]Image Downloaded!', path + '/' + number + '.jpg')
if option == 'kodi':
print('跳过分集图片下载')
def get_part(filepath):
try:
if re.search('-CD\d+', filepath):
return re.findall('-CD\d+', filepath)[0]
except:
print("[-]failed!Please rename the filename again!")
moveFailedFolder()
def debug_mode():
try:
if config['debug_mode']['switch'] == '1':
print('[+] ---Debug info---')
for i, v in json_data.items():
if i == 'outline':
print('[+] -', i, ':', len(v), 'characters')
continue
if i == 'actor_photo' or i == 'year':
continue
print('[+] -', i, ':', v)
print('[+] ---Debug info---')
except:
aaa=''
if __name__ == '__main__': if __name__ == '__main__':
filepath=argparse_get_file()[0] #影片的路径 filepath=argparse_get_file()[0] #影片的路径
if '-CD' in filepath or '-cd' in filepath:
multi_part = 1
part = get_part(filepath)
if '-c.' in filepath or '-C.' in filepath or '中文' in filepath or '字幕' in filepath: if '-c.' in filepath or '-C.' in filepath or '中文' in filepath or '字幕' in filepath:
cn_sub='1' cn_sub='1'
@@ -464,13 +565,20 @@ if __name__ == '__main__':
number = argparse_get_file()[1] number = argparse_get_file()[1]
CreatFailedFolder() CreatFailedFolder()
getDataFromJSON(number) # 定义番号 getDataFromJSON(number) # 定义番号
debug_mode()
creatFolder() # 创建文件夹 creatFolder() # 创建文件夹
if program_mode == '1': if program_mode == '1':
imageDownload(filepath) # creatFoder会返回番号路径 if part == '-CD1' or multi_part == 0:
PrintFiles(filepath) # 打印文件
smallCoverCheck() smallCoverCheck()
imageDownload(filepath) # creatFoder会返回番号路径
if multi_part == 1 and option != 'kodi':
number += part
PrintFiles(filepath) # 打印文件
cutImage() # 裁剪图 cutImage() # 裁剪图
pasteFileToFolder(filepath, path) # 移动文件
renameJpgToBackdrop_copy() renameJpgToBackdrop_copy()
else:
number += part
renameBackdropToJpg_copy()
pasteFileToFolder(filepath, path) # 移动文件
elif program_mode == '2': elif program_mode == '2':
pasteFileToFolder_mode2(filepath, path) # 移动文件 pasteFileToFolder(filepath, path) # 移动文件
+29 -39
View File
@@ -4,51 +4,43 @@ import json
import ADC_function import ADC_function
def getTitle(htmlcode): #获取厂商 def getTitle(htmlcode): #获取厂商
#print(htmlcode)
html = etree.fromstring(htmlcode,etree.HTMLParser()) html = etree.fromstring(htmlcode,etree.HTMLParser())
result = str(html.xpath('/html/body/div[2]/div/div[1]/h3/text()')).strip(" ['']") result = str(html.xpath('//*[@id="container"]/div[1]/div/article/section[1]/h2/text()')).strip(" ['']")
result2 = str(re.sub('\D{2}2-\d+','',result)).replace(' ','',1) return result
#print(result2)
return result2
def getActor(htmlcode): def getActor(htmlcode):
try: try:
html = etree.fromstring(htmlcode, etree.HTMLParser()) html = etree.fromstring(htmlcode, etree.HTMLParser())
result = str(html.xpath('/html/body/div[2]/div/div[1]/h5[5]/a/text()')).strip(" ['']") result = str(html.xpath('//*[@id="container"]/div[1]/div/article/section[1]/div/div[2]/dl/dd[5]/a/text()')).strip(" ['']")
return result return result
except: except:
return '' return ''
def getStudio(htmlcode): #获取厂商 def getStudio(htmlcode): #获取厂商
html = etree.fromstring(htmlcode,etree.HTMLParser()) try:
result = str(html.xpath('/html/body/div[2]/div/div[1]/h5[3]/a[1]/text()')).strip(" ['']") html = etree.fromstring(htmlcode, etree.HTMLParser())
result = str(html.xpath('//*[@id="container"]/div[1]/div/article/section[1]/div/div[2]/dl/dd[5]/a/text()')).strip(" ['']")
return result return result
except:
return ''
def getNum(htmlcode): #获取番号 def getNum(htmlcode): #获取番号
html = etree.fromstring(htmlcode, etree.HTMLParser()) html = etree.fromstring(htmlcode, etree.HTMLParser())
result = str(html.xpath('/html/body/div[5]/div[1]/div[2]/p[1]/span[2]/text()')).strip(" ['']") result = str(html.xpath('/html/body/div[5]/div[1]/div[2]/p[1]/span[2]/text()')).strip(" ['']")
#print(result)
return result return result
def getRelease(htmlcode2): # def getRelease(htmlcode2): #
#a=ADC_function.get_html('http://adult.contents.fc2.com/article_search.php?id='+str(number).lstrip("FC2-").lstrip("fc2-").lstrip("fc2_").lstrip("fc2-")+'&utm_source=aff_php&utm_medium=source_code&utm_campaign=from_aff_php')
html=etree.fromstring(htmlcode2,etree.HTMLParser()) html=etree.fromstring(htmlcode2,etree.HTMLParser())
result = str(html.xpath('//*[@id="container"]/div[1]/div/article/section[1]/div/div[2]/dl/dd[4]/text()')).strip(" ['']") result = str(html.xpath('//*[@id="container"]/div[1]/div/article/section[1]/div/div[2]/dl/dd[4]/text()')).strip(" ['']")
return result return result
def getCover(htmlcode,number,htmlcode2): #获取厂商 # def getCover(htmlcode2): #获取厂商 #
#a = ADC_function.get_html('http://adult.contents.fc2.com/article_search.php?id=' + str(number).lstrip("FC2-").lstrip("fc2-").lstrip("fc2_").lstrip("fc2-") + '&utm_source=aff_php&utm_medium=source_code&utm_campaign=from_aff_php')
html = etree.fromstring(htmlcode2, etree.HTMLParser()) html = etree.fromstring(htmlcode2, etree.HTMLParser())
result = str(html.xpath('//*[@id="container"]/div[1]/div/article/section[1]/div/div[1]/a/img/@src')).strip(" ['']") result = str(html.xpath('//*[@id="container"]/div[1]/div/article/section[1]/div/div[1]/a/img/@src')).strip(" ['']")
if result == '':
html = etree.fromstring(htmlcode, etree.HTMLParser())
result2 = str(html.xpath('//*[@id="slider"]/ul[1]/li[1]/img/@src')).strip(" ['']")
return 'http://fc2fans.club' + result2
return 'http:' + result return 'http:' + result
def getOutline(htmlcode2,number): #获取番号 # def getOutline(htmlcode2): #获取番号 #
#a = ADC_function.get_html('http://adult.contents.fc2.com/article_search.php?id=' + str(number).lstrip("FC2-").lstrip("fc2-").lstrip("fc2_").lstrip("fc2-") + '&utm_source=aff_php&utm_medium=source_code&utm_campaign=from_aff_php')
html = etree.fromstring(htmlcode2, etree.HTMLParser()) html = etree.fromstring(htmlcode2, etree.HTMLParser())
result = str(html.xpath('//*[@id="container"]/div[1]/div/article/section[4]/p/text()')).replace("\\n",'',10000).strip(" ['']").replace("'",'',10000) result = str(html.xpath('//*[@id="container"]/div[1]/div/article/section[4]/p/text()')).strip(" ['']").replace("\\n",'',10000).replace("'",'',10000).replace(', ,','').strip(' ').replace('。,',',')
return result return result
def getTag(htmlcode): #获取番号 def getTag(htmlcode): #获取番号
html = etree.fromstring(htmlcode, etree.HTMLParser()) html = etree.fromstring(htmlcode, etree.HTMLParser())
result = str(html.xpath('/html/body/div[2]/div/div[1]/h5[4]/a/text()')) result = html.xpath('//*[@id="container"]/div[1]/div/article/section[6]/ul/li/a/text()')
return result.strip(" ['']").replace("'",'').replace(' ','') return result
def getYear(release): def getYear(release):
try: try:
result = re.search('\d{4}',release).group() result = re.search('\d{4}',release).group()
@@ -56,30 +48,28 @@ def getYear(release):
except: except:
return '' return ''
def main(number2): def main(number):
number=number2.replace('PPV','').replace('ppv','') number=number.replace('PPV','').replace('ppv','').strip('fc2_').strip('fc2-').strip('ppv-').strip('PPV-').strip('FC2_').strip('FC2-').strip('ppv-').strip('PPV-').replace('fc2ppv-','').replace('FC2PPV-','')
htmlcode2 = ADC_function.get_html('http://adult.contents.fc2.com/article_search.php?id='+str(number).lstrip("FC2-").lstrip("fc2-").lstrip("fc2_").lstrip("fc2-")+'&utm_source=aff_php&utm_medium=source_code&utm_campaign=from_aff_php') htmlcode2 = ADC_function.get_html('http://adult.contents.fc2.com/article_search.php?id='+str(number).lstrip("FC2-").lstrip("fc2-").lstrip("fc2_").lstrip("fc2-")+'')
htmlcode = ADC_function.get_html('http://fc2fans.club/html/FC2-' + number + '.html') #htmlcode = ADC_function.get_html('http://fc2fans.club/html/FC2-' + number + '.html')
dic = { dic = {
'title': getTitle(htmlcode), 'title': getTitle(htmlcode2),
'studio': getStudio(htmlcode), 'studio': getStudio(htmlcode2),
'year': '',#str(re.search('\d{4}',getRelease(number)).group()), 'year': getYear(getRelease(htmlcode2)),
'outline': getOutline(htmlcode,number), 'outline': getOutline(htmlcode2),
'runtime': getYear(getRelease(htmlcode)), 'runtime': getYear(getRelease(htmlcode2)),
'director': getStudio(htmlcode), 'director': getStudio(htmlcode2),
'actor': getActor(htmlcode), 'actor': getStudio(htmlcode2),
'release': getRelease(number), 'release': getRelease(htmlcode2),
'number': 'FC2-'+number, 'number': 'FC2-'+number,
'cover': getCover(htmlcode,number,htmlcode2), 'cover': getCover(htmlcode2),
'imagecut': 0, 'imagecut': 0,
'tag': getTag(htmlcode), 'tag': getTag(htmlcode2),
'actor_photo':'', 'actor_photo':'',
'website': 'http://fc2fans.club/html/FC2-' + number + '.html', 'website': 'http://adult.contents.fc2.com/article_search.php?id=' + number,
'source': 'fc2fans_club.py', 'source': 'fc2fans_club.py',
} }
#print(getTitle(htmlcode))
#print(getNum(htmlcode))
js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'),)#.encode('UTF-8') js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'),)#.encode('UTF-8')
return js return js
#print(main('1051725')) #print(main('1145465'))
+2 -2
View File
@@ -1,5 +1,5 @@
{ {
"version": "1.1", "version": "1.3",
"version_show":"Beta 1.1", "version_show":"1.3",
"download": "https://github.com/wenead99/AV_Data_Capture/releases" "download": "https://github.com/wenead99/AV_Data_Capture/releases"
} }