Add parameter -p, specify the path
This commit is contained in:
@@ -64,7 +64,9 @@ def get_html(url, cookies: dict = None, ua: str = None, return_type: str = None)
|
|||||||
return result.content
|
return result.content
|
||||||
else:
|
else:
|
||||||
return result.text
|
return result.text
|
||||||
|
except requests.exceptions.ProxyError:
|
||||||
|
print("[-]Proxy error! Please check your Proxy")
|
||||||
|
return
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("[-]Connect retry {}/{}".format(i + 1, retry_count))
|
print("[-]Connect retry {}/{}".format(i + 1, retry_count))
|
||||||
print("[-]" + str(e))
|
print("[-]" + str(e))
|
||||||
|
|||||||
@@ -1,34 +1,37 @@
|
|||||||
import argparse
|
import argparse
|
||||||
|
import json
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
import config
|
||||||
|
from ADC_function import get_html
|
||||||
from number_parser import get_number
|
from number_parser import get_number
|
||||||
from core import *
|
from core import core_main
|
||||||
|
|
||||||
|
|
||||||
def check_update(local_version):
|
def check_update(local_version):
|
||||||
try:
|
try:
|
||||||
data = json.loads(get_html("https://api.github.com/repos/yoshiko2/AV_Data_Capture/releases/latest"))
|
data = json.loads(get_html("https://api.github.com/repos/yoshiko2/AV_Data_Capture/releases/latest"))
|
||||||
except Exception as e:
|
except:
|
||||||
print("[-] Failed to update! Please check new version manually:")
|
print("[-]Failed to update! Please check new version manually:")
|
||||||
print("[-] https://github.com/yoshiko2/AV_Data_Capture/releases")
|
print("[-]https://github.com/yoshiko2/AV_Data_Capture/releases")
|
||||||
print("[*]======================================================")
|
print("[*]======================================================")
|
||||||
return
|
return
|
||||||
|
|
||||||
remote = data["tag_name"]
|
remote = data["tag_name"]
|
||||||
local = local_version
|
if not local_version == remote:
|
||||||
|
print("[*]" + ("* New update " + str(remote) + " *").center(54))
|
||||||
if not local == remote:
|
|
||||||
line1 = "* New update " + str(remote) + " *"
|
|
||||||
print("[*]" + line1.center(54))
|
|
||||||
print("[*]" + "↓ Download ↓".center(54))
|
print("[*]" + "↓ Download ↓".center(54))
|
||||||
print("[*] https://github.com/yoshiko2/AV_Data_Capture/releases")
|
print("[*]https://github.com/yoshiko2/AV_Data_Capture/releases")
|
||||||
print("[*]======================================================")
|
print("[*]======================================================")
|
||||||
|
|
||||||
|
|
||||||
def argparse_function(ver: str) -> [str, str, bool]:
|
def argparse_function(ver: str) -> [str, str, bool]:
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument("file", default='', nargs='?', help="Single Movie file path.")
|
parser.add_argument("file", default='', nargs='?', help="Single Movie file path.")
|
||||||
|
parser.add_argument("-p","--path",default='',nargs='?',help="Analysis folder path.")
|
||||||
parser.add_argument("-c", "--config", default='config.ini', nargs='?', help="The config file Path.")
|
parser.add_argument("-c", "--config", default='config.ini', nargs='?', help="The config file Path.")
|
||||||
parser.add_argument("-n", "--number", default='', nargs='?', help="Custom file number")
|
parser.add_argument("-n", "--number", default='', nargs='?', help="Custom file number")
|
||||||
parser.add_argument("-a", "--auto-exit", dest='autoexit', action="store_true",
|
parser.add_argument("-a", "--auto-exit", dest='autoexit', action="store_true",
|
||||||
@@ -36,13 +39,12 @@ def argparse_function(ver: str) -> [str, str, bool]:
|
|||||||
parser.add_argument("-v", "--version", action="version", version=ver)
|
parser.add_argument("-v", "--version", action="version", version=ver)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
return args.file, args.config, args.number, args.autoexit
|
return args.file, args.path, args.config, args.number, args.autoexit
|
||||||
|
|
||||||
|
|
||||||
def movie_lists(root, escape_folder):
|
def movie_lists(root, escape_folder):
|
||||||
for folder in escape_folder:
|
if os.path.basename(root) in escape_folder:
|
||||||
if folder in root:
|
return []
|
||||||
return []
|
|
||||||
total = []
|
total = []
|
||||||
file_type = conf.media_type().upper().split(",")
|
file_type = conf.media_type().upper().split(",")
|
||||||
dirs = os.listdir(root)
|
dirs = os.listdir(root)
|
||||||
@@ -51,7 +53,7 @@ def movie_lists(root, escape_folder):
|
|||||||
if os.path.isdir(f):
|
if os.path.isdir(f):
|
||||||
total += movie_lists(f, escape_folder)
|
total += movie_lists(f, escape_folder)
|
||||||
elif os.path.splitext(f)[1].upper() in file_type:
|
elif os.path.splitext(f)[1].upper() in file_type:
|
||||||
total.append(f)
|
total.append(os.path.abspath(f))
|
||||||
return total
|
return total
|
||||||
|
|
||||||
|
|
||||||
@@ -71,12 +73,13 @@ def rm_empty_folder(path):
|
|||||||
os.rmdir(path + '/' + file) # 删除这个空文件夹
|
os.rmdir(path + '/' + file) # 删除这个空文件夹
|
||||||
print('[+]Deleting empty folder', path + '/' + file)
|
print('[+]Deleting empty folder', path + '/' + file)
|
||||||
except:
|
except:
|
||||||
a = ''
|
pass
|
||||||
|
|
||||||
|
|
||||||
def create_data_and_move(file_path: str, c: config.Config, debug):
|
def create_data_and_move(file_path: str, c: config.Config, debug):
|
||||||
# Normalized number, eg: 111xxx-222.mp4 -> xxx-222.mp4
|
# Normalized number, eg: 111xxx-222.mp4 -> xxx-222.mp4
|
||||||
n_number = get_number(debug, file_path)
|
n_number = get_number(debug, os.path.basename(file_path))
|
||||||
|
file_path = os.path.abspath(file_path)
|
||||||
|
|
||||||
if debug == True:
|
if debug == True:
|
||||||
print("[!]Making Data for [{}], the number is [{}]".format(file_path, n_number))
|
print("[!]Making Data for [{}], the number is [{}]".format(file_path, n_number))
|
||||||
@@ -132,53 +135,45 @@ if __name__ == '__main__':
|
|||||||
version = '4.3.2'
|
version = '4.3.2'
|
||||||
|
|
||||||
# Parse command line args
|
# Parse command line args
|
||||||
single_file_path, config_file, custom_number, auto_exit = argparse_function(version)
|
single_file_path, folder_path, config_file, custom_number, auto_exit = argparse_function(version)
|
||||||
|
|
||||||
# Read config.ini
|
# Read config.ini
|
||||||
conf = config.Config(path=config_file)
|
conf = config.Config(path=config_file)
|
||||||
|
|
||||||
version_print = 'Version ' + version
|
|
||||||
print('[*]================== AV Data Capture ===================')
|
|
||||||
print('[*]' + version_print.center(54))
|
|
||||||
print('[*]======================================================')
|
print('[*]======================================================')
|
||||||
|
print('[*]' + ('AV Data Capture ver.' + version).center(54))
|
||||||
|
|
||||||
if conf.update_check():
|
if conf.update_check():
|
||||||
check_update(version)
|
check_update(version)
|
||||||
|
|
||||||
|
if conf.debug():
|
||||||
|
print('[+]Enable debug')
|
||||||
|
if conf.soft_link():
|
||||||
|
print('[!]Enable soft link')
|
||||||
|
|
||||||
create_failed_folder(conf.failed_folder())
|
create_failed_folder(conf.failed_folder())
|
||||||
|
|
||||||
# ========== Single File ==========
|
if not single_file_path == '': #Single File
|
||||||
if not single_file_path == '':
|
|
||||||
print('[+]==================== Single File =====================')
|
print('[+]==================== Single File =====================')
|
||||||
create_data_and_move_with_custom_number(single_file_path, conf, custom_number)
|
create_data_and_move_with_custom_number(single_file_path, conf, custom_number)
|
||||||
rm_empty_folder(conf.success_folder())
|
else:
|
||||||
rm_empty_folder(conf.failed_folder())
|
if folder_path == '':
|
||||||
print("[+]All finished!!!")
|
folder_path = os.path.abspath(".")
|
||||||
input("[+][+]Press enter key exit, you can check the error messge before you exit.")
|
|
||||||
sys.exit(0)
|
|
||||||
# ========== Single File ==========
|
|
||||||
|
|
||||||
movie_list = movie_lists(".", re.split("[,,]", conf.escape_folder()))
|
movie_list = movie_lists(folder_path, re.split("[,,]", conf.escape_folder()))
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
count_all = str(len(movie_list))
|
count_all = str(len(movie_list))
|
||||||
print('[+]Find', count_all, 'movies')
|
print('[+]Find', count_all, 'movies')
|
||||||
if conf.debug() == True:
|
for movie_path in movie_list: # 遍历电影列表 交给core处理
|
||||||
print('[+]' + ' DEBUG MODE ON '.center(54, '-'))
|
count = count + 1
|
||||||
if conf.soft_link():
|
percentage = str(count / int(count_all) * 100)[:4] + '%'
|
||||||
print('[!] --- Soft link mode is ENABLE! ----')
|
print('[!] - ' + percentage + ' [' + str(count) + '/' + count_all + '] -')
|
||||||
for movie_path in movie_list: # 遍历电影列表 交给core处理
|
create_data_and_move(movie_path, conf, conf.debug())
|
||||||
count = count + 1
|
|
||||||
percentage = str(count / int(count_all) * 100)[:4] + '%'
|
|
||||||
print('[!] - ' + percentage + ' [' + str(count) + '/' + count_all + '] -')
|
|
||||||
create_data_and_move(movie_path, conf, conf.debug())
|
|
||||||
|
|
||||||
rm_empty_folder(conf.success_folder())
|
rm_empty_folder(conf.success_folder())
|
||||||
rm_empty_folder(conf.failed_folder())
|
rm_empty_folder(conf.failed_folder())
|
||||||
print("[+]All finished!!!")
|
print("[+]All finished!!!")
|
||||||
if conf.auto_exit():
|
if not (conf.auto_exit() or auto_exit):
|
||||||
sys.exit(0)
|
input("Press enter key exit, you can check the error message before you exit...")
|
||||||
if auto_exit:
|
|
||||||
sys.exit(0)
|
|
||||||
input("Press enter key exit, you can check the error message before you exit...")
|
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|||||||
Reference in New Issue
Block a user