Merge pull request #26 from RRRRRm/master
Fix the path error under Linux and specify Python3 as the runtime.
This commit is contained in:
commit
2adcfacf27
1
ADC_function.py
Normal file → Executable file
1
ADC_function.py
Normal file → Executable file
@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import requests
|
||||
|
123
AV_Data_Capture.py
Normal file → Executable file
123
AV_Data_Capture.py
Normal file → Executable file
@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import glob
|
||||
@ -7,12 +8,16 @@ import re
|
||||
import sys
|
||||
from ADC_function import *
|
||||
import json
|
||||
import subprocess
|
||||
import shutil
|
||||
from configparser import ConfigParser
|
||||
|
||||
version='0.11.6'
|
||||
os.chdir(os.getcwd())
|
||||
|
||||
input_dir='.' # 电影的读取与输出路径, 默认为当前路径
|
||||
output_dir='.'
|
||||
|
||||
config = ConfigParser()
|
||||
config.read(config_file, encoding='UTF-8')
|
||||
|
||||
@ -28,36 +33,50 @@ def UpdateCheck():
|
||||
print('[*]=====================================')
|
||||
else:
|
||||
print('[+]Update Check disabled!')
|
||||
|
||||
def set_directory(): # 设置读取与存放路径
|
||||
global input_dir
|
||||
global output_dir
|
||||
# 配置项switch为1且定义了新的路径时, 更改默认存取路径
|
||||
if config['directory_capture']['switch'] == '1':
|
||||
custom_input = config['directory_capture']['input_directory']
|
||||
custom_output = config['directory_capture']['output_directory']
|
||||
if custom_input != '': # 自定义了输入路径
|
||||
input_dir = format_path(custom_input)
|
||||
# 若自定义了输入路径, 输出路径默认在输入路径下
|
||||
output_dir = input_dir
|
||||
output_dir = format_path(custom_output) if custom_output != '' else output_dir # 自定义了输出路径
|
||||
CreatFolder(output_dir)
|
||||
CreatFolder(input_dir)
|
||||
print('[+]Working directory is "' + os.getcwd() + '".')
|
||||
print('[+]Using "' + input_dir + '" as input directory.')
|
||||
print('[+]Using "' + output_dir + '" as output directory.')
|
||||
|
||||
def format_path(path): # 使路径兼容Linux与MacOS
|
||||
if path.find('\\'): # 是仅兼容Windows的路径格式
|
||||
path_list=path.split('\\')
|
||||
path='/'.join(path_list) # 转换为可移植的路径格式
|
||||
return path
|
||||
|
||||
|
||||
def movie_lists():
|
||||
if config['directory_capture']['switch'] == '0' or config['directory_capture']['switch'] == '':
|
||||
a2 = glob.glob(r".\*.mp4")
|
||||
b2 = glob.glob(r".\*.avi")
|
||||
c2 = glob.glob(r".\*.rmvb")
|
||||
d2 = glob.glob(r".\*.wmv")
|
||||
e2 = glob.glob(r".\*.mov")
|
||||
f2 = glob.glob(r".\*.mkv")
|
||||
g2 = glob.glob(r".\*.flv")
|
||||
h2 = glob.glob(r".\*.ts")
|
||||
total = a2 + b2 + c2 + d2 + e2 + f2 + g2 + h2
|
||||
return total
|
||||
elif config['directory_capture']['switch'] == '1':
|
||||
directory = config['directory_capture']['directory']
|
||||
a2 = glob.glob(r".\\" + directory + "\*.mp4")
|
||||
b2 = glob.glob(r".\\" + directory + "\*.avi")
|
||||
c2 = glob.glob(r".\\" + directory + "\*.rmvb")
|
||||
d2 = glob.glob(r".\\" + directory + "\*.wmv")
|
||||
e2 = glob.glob(r".\\" + directory + "\*.mov")
|
||||
f2 = glob.glob(r".\\" + directory + "\*.mkv")
|
||||
g2 = glob.glob(r".\\" + directory + "\*.flv")
|
||||
h2 = glob.glob(r".\\" + directory + "\*.ts")
|
||||
total = a2 + b2 + c2 + d2 + e2 + f2 + g2 + h2
|
||||
return total
|
||||
def CreatFailedFolder():
|
||||
if not os.path.exists('failed/'): # 新建failed文件夹
|
||||
a2 = glob.glob( input_dir + "/*.mp4")
|
||||
b2 = glob.glob( input_dir + "/*.avi")
|
||||
c2 = glob.glob( input_dir + "/*.rmvb")
|
||||
d2 = glob.glob( input_dir + "/*.wmv")
|
||||
e2 = glob.glob( input_dir + "/*.mov")
|
||||
f2 = glob.glob( input_dir + "/*.mkv")
|
||||
g2 = glob.glob( input_dir + "/*.flv")
|
||||
h2 = glob.glob( input_dir + "/*.ts")
|
||||
total = a2 + b2 + c2 + d2 + e2 + f2 + g2 + h2
|
||||
return total
|
||||
def CreatFolder(folder_path):
|
||||
if not os.path.exists(folder_path): # 新建文件夹
|
||||
try:
|
||||
os.makedirs('failed/')
|
||||
print('[+]Creating ' + folder_path)
|
||||
os.makedirs(folder_path)
|
||||
except:
|
||||
print("[-]failed!can not be make folder 'failed'\n[-](Please run as Administrator)")
|
||||
print("[-]failed!can not be make folder '"+folder_path+"'\n[-](Please run as Administrator)")
|
||||
os._exit(0)
|
||||
def lists_from_test(custom_nuber): #电影列表
|
||||
a=[]
|
||||
@ -111,40 +130,56 @@ def getNumber(filepath):
|
||||
print('[-]' + str(os.path.basename(filepath)) + ' Cannot catch the number :')
|
||||
print('[-]' + str(os.path.basename(filepath)) + ' :', e)
|
||||
print('[-]Move ' + os.path.basename(filepath) + ' to failed folder')
|
||||
|
||||
shutil.move(filepath, str(os.getcwd()) + '/' + 'failed/')
|
||||
print('[-]' + filepath + ' -> ' + output_dir + '/failed/')
|
||||
shutil.move(filepath, output_dir + '/failed/')
|
||||
except IOError as e2:
|
||||
print('[-]' + str(os.path.basename(filepath)) + ' Cannot catch the number :')
|
||||
print('[-]' + str(os.path.basename(filepath)) + ' :', e2)
|
||||
print('[-]Move ' + os.path.basename(filepath) + ' to failed folder')
|
||||
shutil.move(filepath, str(os.getcwd()) + '/' + 'failed/')
|
||||
print('[-]' + filepath + ' -> ' + output_dir + '/failed/')
|
||||
shutil.move(filepath, output_dir + '/failed/')
|
||||
|
||||
def RunCore():
|
||||
def RunCore(movie):
|
||||
# 异步调用core.py, core.py作为子线程执行, 本程序继续执行.
|
||||
if os.path.exists('core.py'):
|
||||
os.system('python core.py' + ' "' + i + '" --number "'+getNumber(i)+'"') #从py文件启动(用于源码py)
|
||||
cmd_arg=[sys.executable,'core.py',movie,'--number',getNumber(movie),'--output',output_dir] #从py文件启动(用于源码py)
|
||||
elif os.path.exists('core.exe'):
|
||||
os.system('core.exe' + ' "' + i + '" --number "'+getNumber(i)+'"') #从exe启动(用于EXE版程序)
|
||||
cmd_arg=['core.exe',movie,'--number',getNumber(movie),'--output',output_dir] #从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)
|
||||
cmd_arg=[sys.executable,'core.py',movie,'--number',getNumber(movie),'--output',output_dir] #从py文件启动(用于源码py)
|
||||
process=subprocess.Popen(cmd_arg)
|
||||
return process
|
||||
|
||||
if __name__ =='__main__':
|
||||
print('[*]===========AV Data Capture===========')
|
||||
print('[*] Version '+version)
|
||||
print('[*]=====================================')
|
||||
CreatFailedFolder()
|
||||
UpdateCheck()
|
||||
os.chdir(os.getcwd())
|
||||
set_directory()
|
||||
CreatFolder(output_dir+'/failed')
|
||||
|
||||
count = 0
|
||||
count_all = str(len(movie_lists()))
|
||||
for i in movie_lists(): #遍历电影列表 交给core处理
|
||||
count = count + 1
|
||||
percentage = str(count/int(count_all)*100)[:4]+'%'
|
||||
movies = movie_lists()
|
||||
count_all = str(len(movies))
|
||||
print('[+]Find ' + str(len(movies)) + ' movies.')
|
||||
process_list=[]
|
||||
for movie in movies: #遍历电影列表 交给core处理
|
||||
num=getNumber(movie) # 获取番号
|
||||
if num is None:
|
||||
movies.remove(movie) # 未获取到番号, 则将影片从列表移除
|
||||
count_all=count_all-1
|
||||
continue
|
||||
print("[!]Making Data for [" + movie + "], the number is [" + num + "]")
|
||||
process=RunCore(movie)
|
||||
process_list.append(process)
|
||||
print("[*]=====================================")
|
||||
for i in range(len(movies)):
|
||||
process_list[i].communicate()
|
||||
percentage = str((i+1)/int(count_all)*100)[:4]+'%'
|
||||
print('[!] - '+percentage+' ['+str(count)+'/'+count_all+'] -')
|
||||
print("[!]Making Data for [" + i + "], the number is [" + getNumber(i) + "]")
|
||||
RunCore()
|
||||
print("[*]=====================================")
|
||||
print("[!]The [" + getNumber(movies[i]) + "] process is done.")
|
||||
print("[*]=====================================")
|
||||
|
||||
CEF('JAV_output')
|
||||
CEF(input_dir)
|
||||
print("[+]All finished!!!")
|
||||
input("[+][+]Press enter key exit, you can check the error messge before you exit.\n[+][+]按回车键结束,你可以在结束之前查看和错误信息。")
|
@ -141,8 +141,9 @@ PLEX请安装插件:```XBMCnfoMoviesImporter```
|
||||
#### 抓取目录选择
|
||||
>[directory_capture]<br>
|
||||
>switch=0<br>
|
||||
>directory=<br>
|
||||
switch为1时,directory才会被触发,抓取程序目录下的directory目录下的电影;如果为0则不触发,抓取和程序同一目录下的影片,directory不生效
|
||||
>input_directory=<br>
|
||||
>output_directory=<br>
|
||||
switch为1时,目录自定义才会被触发,此时可以指定抓取任意目录下的影片, 并指定存放的目录;如果为0则不触发,抓取和程序同一目录下的影片,directory不生效. 如果仅指定input_directory, output_directory默认与input_directory相同.
|
||||
|
||||
### (可选)设置自定义目录和影片重命名规则
|
||||
**已有默认配置**<br>
|
||||
|
@ -1,5 +1,5 @@
|
||||
[proxy]
|
||||
proxy=127.0.0.1:1080
|
||||
proxy=127.0.0.1:8001
|
||||
timeout=10
|
||||
retry=3
|
||||
|
||||
@ -16,7 +16,8 @@ media_warehouse=emby
|
||||
#plex only test!
|
||||
|
||||
[directory_capture]
|
||||
switch=0
|
||||
directory=
|
||||
switch=1
|
||||
input_directory=
|
||||
output_directory=
|
||||
|
||||
#everyone switch:1=on, 0=off
|
31
core.py
Normal file → Executable file
31
core.py
Normal file → Executable file
@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import re
|
||||
@ -31,6 +32,7 @@ imagecut=''
|
||||
tag=[]
|
||||
cn_sub=''
|
||||
path=''
|
||||
output_dir=''
|
||||
houzhui=''
|
||||
website=''
|
||||
json_data={}
|
||||
@ -49,18 +51,20 @@ except:
|
||||
def moveFailedFolder():
|
||||
global filepath
|
||||
print('[-]Move to "failed"')
|
||||
shutil.move(filepath, str(os.getcwd()) + '/' + 'failed/')
|
||||
print('[-]' + filepath + ' -> ' + output_dir + '/failed/')
|
||||
os.rename(filepath, output_dir + '/failed/')
|
||||
os._exit(0)
|
||||
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")
|
||||
parser.add_argument("--number", help="Enter Number on here", default='')
|
||||
parser.add_argument("--output", help="Enter Output directory here", default='')
|
||||
args = parser.parse_args()
|
||||
return (args.file, args.number)
|
||||
return (args.file, args.number, args.output)
|
||||
def CreatFailedFolder():
|
||||
if not os.path.exists('failed/'): # 新建failed文件夹
|
||||
if not os.path.exists(output_dir+'/failed/'): # 新建failed文件夹
|
||||
try:
|
||||
os.makedirs('failed/')
|
||||
os.makedirs(output_dir+'/failed/')
|
||||
except:
|
||||
print("[-]failed!can not be make folder 'failed'\n[-](Please run as Administrator)")
|
||||
os._exit(0)
|
||||
@ -154,10 +158,10 @@ def creatFolder(): #创建文件夹
|
||||
global actor
|
||||
global path
|
||||
if len(actor) > 240: #新建成功输出文件夹
|
||||
path = location_rule.replace("'actor'","'超多人'",3).replace("actor","'超多人'",3) #path为影片+元数据所在目录
|
||||
path = output_dir + '/' + location_rule.replace("'actor'","'超多人'",3).replace("actor","'超多人'",3) #path为影片+元数据所在目录
|
||||
#print(path)
|
||||
else:
|
||||
path = location_rule
|
||||
path = output_dir + '/' + location_rule
|
||||
#print(path)
|
||||
if not os.path.exists(path):
|
||||
try:
|
||||
@ -374,18 +378,20 @@ def pasteFileToFolder(filepath, path): #文件路径,番号,后缀,要移
|
||||
global houzhui
|
||||
houzhui = str(re.search('[.](AVI|RMVB|WMV|MOV|MP4|MKV|FLV|TS|avi|rmvb|wmv|mov|mp4|mkv|flv|ts)$', filepath).group())
|
||||
try:
|
||||
os.rename(filepath, number + houzhui)
|
||||
print('[*]' + filepath + ' -> ' + output_dir + number + houzhui)
|
||||
os.rename(filepath, output_dir + '/' + number + houzhui)
|
||||
except FileExistsError:
|
||||
print('[-]File Exists! Please check your movie!')
|
||||
print('[-]move to the root folder of the program.')
|
||||
os._exit(0)
|
||||
try:
|
||||
shutil.move(number + houzhui, path)
|
||||
print('[*]' + output_dir + '/' + number + houzhui + ' -> ' + path)
|
||||
os.rename(output_dir + '/' + number + houzhui, path)
|
||||
except:
|
||||
print('[-]File Exists! Please check your movie!')
|
||||
print('[-]move to the root folder of the program.')
|
||||
os._exit(0)
|
||||
def renameJpgToBackdrop_copy():
|
||||
def moveJpgToBackdrop_copy():
|
||||
if option == 'plex':
|
||||
shutil.copy(path + '/fanart.jpg', path + '/Backdrop.jpg')
|
||||
shutil.copy(path + '/poster.png', path + '/thumb.png')
|
||||
@ -403,10 +409,11 @@ if __name__ == '__main__':
|
||||
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!")
|
||||
print("[-]failed!Please move the filename again!")
|
||||
moveFailedFolder()
|
||||
else:
|
||||
number = argparse_get_file()[1]
|
||||
output_dir = argparse_get_file()[2]
|
||||
CreatFailedFolder()
|
||||
getDataFromJSON(number) # 定义番号
|
||||
creatFolder() # 创建文件夹
|
||||
@ -414,4 +421,4 @@ if __name__ == '__main__':
|
||||
PrintFiles(filepath) # 打印文件
|
||||
cutImage() # 裁剪图
|
||||
pasteFileToFolder(filepath, path) # 移动文件
|
||||
renameJpgToBackdrop_copy()
|
||||
moveJpgToBackdrop_copy()
|
||||
|
1
fc2fans_club.py
Normal file → Executable file
1
fc2fans_club.py
Normal file → Executable file
@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
import re
|
||||
from lxml import etree#need install
|
||||
import json
|
||||
|
1
javbus.py
Normal file → Executable file
1
javbus.py
Normal file → Executable file
@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
import re
|
||||
import requests #need install
|
||||
from pyquery import PyQuery as pq#need install
|
||||
|
1
javdb.py
Normal file → Executable file
1
javdb.py
Normal file → Executable file
@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
import re
|
||||
from lxml import etree
|
||||
import json
|
||||
|
Loading…
Reference in New Issue
Block a user