Merge pull request #53 from ninjadogz/master
修正封面读取失败,增加路径escape字符,powershell预处理
This commit is contained in:
commit
5fe2874892
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import glob
|
import glob
|
||||||
@ -10,6 +10,7 @@ from ADC_function import *
|
|||||||
import json
|
import json
|
||||||
import shutil
|
import shutil
|
||||||
from configparser import ConfigParser
|
from configparser import ConfigParser
|
||||||
|
import fnmatch
|
||||||
os.chdir(os.getcwd())
|
os.chdir(os.getcwd())
|
||||||
|
|
||||||
# ============global var===========
|
# ============global var===========
|
||||||
@ -18,11 +19,28 @@ version='1.3'
|
|||||||
|
|
||||||
config = ConfigParser()
|
config = ConfigParser()
|
||||||
config.read(config_file, encoding='UTF-8')
|
config.read(config_file, encoding='UTF-8')
|
||||||
|
fromPath=config['movie']['path']
|
||||||
Platform = sys.platform
|
Platform = sys.platform
|
||||||
|
|
||||||
# ==========global var end=========
|
# ==========global var end=========
|
||||||
|
|
||||||
|
def moveMovies(fromPath):
|
||||||
|
movieFiles = []
|
||||||
|
if Platform == 'win32':
|
||||||
|
movieFormat = ["avi", "rmvb", "wmv", "mov", "mp4", "mkv", "flv", "ts"]
|
||||||
|
else:
|
||||||
|
movieFormat = ["AVI", "RMVB", "WMV", "MOV", "MP4", "MKV", "FLV", "TS","avi", "rmvb", "wmv", "mov", "mp4", "mkv", "flv", "ts"]
|
||||||
|
for fm in movieFormat:
|
||||||
|
movieFiles = movieFiles + [os.path.join(dirpath, f)
|
||||||
|
for dirpath, dirnames, files in os.walk(fromPath)
|
||||||
|
for f in fnmatch.filter(files, '*.' + fm)]
|
||||||
|
for movie in movieFiles:
|
||||||
|
movieName = movie.split('/')[-1]
|
||||||
|
print("Move file " + movieName)
|
||||||
|
if (os.path.exists(os.path.curdir + '/' + movieName)):
|
||||||
|
print(movieName + "exists, skip.")
|
||||||
|
else:
|
||||||
|
shutil.move(movie, os.path.curdir)
|
||||||
def UpdateCheck():
|
def UpdateCheck():
|
||||||
if UpdateCheckSwitch() == '1':
|
if UpdateCheckSwitch() == '1':
|
||||||
html2 = get_html('https://raw.githubusercontent.com/yoshiko2/AV_Data_Capture/master/update_check.json')
|
html2 = get_html('https://raw.githubusercontent.com/yoshiko2/AV_Data_Capture/master/update_check.json')
|
||||||
@ -128,6 +146,7 @@ if __name__ =='__main__':
|
|||||||
print('[*]=====================================')
|
print('[*]=====================================')
|
||||||
CreatFailedFolder()
|
CreatFailedFolder()
|
||||||
UpdateCheck()
|
UpdateCheck()
|
||||||
|
moveMovies(fromPath)
|
||||||
os.chdir(os.getcwd())
|
os.chdir(os.getcwd())
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
|
@ -4,7 +4,8 @@ failed_output_folder=failed
|
|||||||
success_output_folder=JAV_output
|
success_output_folder=JAV_output
|
||||||
|
|
||||||
[proxy]
|
[proxy]
|
||||||
proxy=127.0.0.1:1080
|
proxy=10.168.1.254:3128
|
||||||
|
#proxy=127.0.0.1:1080
|
||||||
timeout=10
|
timeout=10
|
||||||
retry=3
|
retry=3
|
||||||
|
|
||||||
@ -21,3 +22,9 @@ media_warehouse=emby
|
|||||||
|
|
||||||
[directory_capture]
|
[directory_capture]
|
||||||
directory=
|
directory=
|
||||||
|
|
||||||
|
[escape]
|
||||||
|
literals=\()
|
||||||
|
|
||||||
|
[movie]
|
||||||
|
path=/root/sort/test
|
||||||
|
14
core.py
14
core.py
@ -54,6 +54,12 @@ failed_folder = Config['common']['failed_output_folder']
|
|||||||
success_folder = Config['common']['success_output_folder']
|
success_folder = Config['common']['success_output_folder']
|
||||||
#=====================本地文件处理===========================
|
#=====================本地文件处理===========================
|
||||||
|
|
||||||
|
def escapePath(path): # Remove escape literals
|
||||||
|
escapeLiterals = Config['escape']['literals']
|
||||||
|
backslash = '\\'
|
||||||
|
for literal in escapeLiterals:
|
||||||
|
path = path.replace(backslash+literal,'')
|
||||||
|
return path
|
||||||
def moveFailedFolder():
|
def moveFailedFolder():
|
||||||
global filepath
|
global filepath
|
||||||
print('[-]Move to Failed output folder')
|
print('[-]Move to Failed output folder')
|
||||||
@ -183,7 +189,10 @@ def smallCoverCheck():
|
|||||||
if imagecut == 3:
|
if imagecut == 3:
|
||||||
if option == 'emby':
|
if option == 'emby':
|
||||||
DownloadFileWithFilename(cover_small, '1.jpg', path)
|
DownloadFileWithFilename(cover_small, '1.jpg', path)
|
||||||
|
try:
|
||||||
img = Image.open(path + '/1.jpg')
|
img = Image.open(path + '/1.jpg')
|
||||||
|
except Exception:
|
||||||
|
img = Image.open('1.jpg')
|
||||||
w = img.width
|
w = img.width
|
||||||
h = img.height
|
h = img.height
|
||||||
img.save(path + '/' + number + '.png')
|
img.save(path + '/' + number + '.png')
|
||||||
@ -199,7 +208,10 @@ def smallCoverCheck():
|
|||||||
os.remove(path + '/1.jpg')
|
os.remove(path + '/1.jpg')
|
||||||
if option == 'plex':
|
if option == 'plex':
|
||||||
DownloadFileWithFilename(cover_small, '1.jpg', path)
|
DownloadFileWithFilename(cover_small, '1.jpg', path)
|
||||||
|
try:
|
||||||
img = Image.open(path + '/1.jpg')
|
img = Image.open(path + '/1.jpg')
|
||||||
|
except Exception:
|
||||||
|
img = Image.open('1.jpg')
|
||||||
w = img.width
|
w = img.width
|
||||||
h = img.height
|
h = img.height
|
||||||
img.save(path + '/poster.png')
|
img.save(path + '/poster.png')
|
||||||
@ -213,10 +225,12 @@ def creatFolder(): #创建文件夹
|
|||||||
path = success_folder+'/'+location_rule
|
path = success_folder+'/'+location_rule
|
||||||
#print(path)
|
#print(path)
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
|
path = escapePath(path)
|
||||||
try:
|
try:
|
||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
except:
|
except:
|
||||||
path = success_folder+'/'+location_rule.replace('/['+number+']-'+title,"/number")
|
path = success_folder+'/'+location_rule.replace('/['+number+']-'+title,"/number")
|
||||||
|
path = escapePath(path)
|
||||||
#print(path)
|
#print(path)
|
||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
#=====================资源下载部分===========================
|
#=====================资源下载部分===========================
|
||||||
|
Loading…
Reference in New Issue
Block a user