This commit is contained in:
flaskfarm
2022-10-22 23:10:07 +09:00
parent 2e46777d12
commit dd32e8a04e
7 changed files with 81 additions and 30 deletions

View File

@@ -113,8 +113,14 @@ class Framework:
if os.path.exists(_): if os.path.exists(_):
plugins = os.listdir(_) plugins = os.listdir(_)
if self.config['path_dev'] != None and os.path.exists(self.config['path_dev']): if self.config['path_dev'] != None:
plugins += os.listdir(self.config['path_dev']) if type(self.config['path_dev']) == type(''):
plugin_path_list = [self.config['path_dev']]
elif type(self.config['path_dev']) == type([]):
plugin_path_list = self.config['path_dev']
for __ in plugin_path_list:
if os.path.exists(__):
plugins += os.listdir(__)
for package_name in plugins: for package_name in plugins:
db_path = os.path.join(self.config['path_data'], 'db', f'{package_name}.db') db_path = os.path.join(self.config['path_data'], 'db', f'{package_name}.db')

View File

@@ -46,16 +46,23 @@ class PluginManager:
try: try:
#plugin_path = F.SystemModelSetting.get('plugin_dev_path') #plugin_path = F.SystemModelSetting.get('plugin_dev_path')
plugin_path = F.config['path_dev'] plugin_path = F.config['path_dev']
if plugin_path != None and plugin_path != '':
if os.path.exists(plugin_path): if type(plugin_path) == type(''):
sys.path.insert(0, plugin_path) plugin_path_list = [plugin_path]
tmps = os.listdir(plugin_path) elif type(plugin_path) == type([]):
add_plugin_list = [] plugin_path_list = plugin_path
for t in tmps:
if not t.startswith('_') and os.path.isdir(os.path.join(plugin_path, t)): for __ in plugin_path_list:
add_plugin_list.append(t) if __ != None and __ != '':
cls.all_package_list[t] = {'pos':'dev', 'path':os.path.join(plugin_path, t), 'loading':True} if os.path.exists(__):
plugins = plugins + add_plugin_list sys.path.insert(0, __)
tmps = os.listdir(__)
add_plugin_list = []
for t in tmps:
if not t.startswith('_') and os.path.isdir(os.path.join(__, t)):
add_plugin_list.append(t)
cls.all_package_list[t] = {'pos':'dev', 'path':os.path.join(__, t), 'loading':True}
plugins = plugins + add_plugin_list
except Exception as exception: except Exception as exception:
F.logger.error('Exception:%s', exception) F.logger.error('Exception:%s', exception)
F.logger.error(traceback.format_exc()) F.logger.error(traceback.format_exc())

View File

@@ -118,9 +118,11 @@ def videojs():
@F.app.route("/headers", methods=['GET', 'POST'])
def headers():
from support import d
F.logger.info(d(request.headers))
return jsonify(d(request.headers))
# 3.10에서 이거 필수 # 3.10에서 이거 필수

View File

@@ -57,10 +57,6 @@ function j_row_end() {
return str; return str;
} }
function j_hr(margin='5') { function j_hr(margin='5') {
var str = '<hr style="width: 100%; margin:'+margin+'px;" />'; var str = '<hr style="width: 100%; margin:'+margin+'px;" />';
return str; return str;
@@ -73,6 +69,20 @@ function j_hr_black() {
// 한줄 왼쪽
function j_row_info(left, right, l=2, r=8) {
var str =' \
<div class="row"> \
<div class="col-sm-'+1+'" style="text-align:right;"></div> \
<div class="col-sm-'+l+'" style="text-align:right;"> \
<strong>'+ left +'</strong> \
</div> \
<div class="col-sm-'+r+'" style="word-break:break-all;"> \
<span class="text-left" style="padding-left:10px; padding-top:3px;">'+right +'</span> \
</div> \
</div>';
return str;
}

View File

@@ -1 +1 @@
VERSION="4.0.28" VERSION="4.0.29"

View File

@@ -64,7 +64,7 @@ class PluginBase(object):
self.module_list.append(mod_ins) self.module_list.append(mod_ins)
except Exception as e: except Exception as e:
F.logger.error(f'Exception:{str(e)}') F.logger.error(f'[{self.package_name}] Exception:{str(e)}')
F.logger.error(traceback.format_exc()) F.logger.error(traceback.format_exc())

View File

@@ -5,10 +5,11 @@ import re
import shutil import shutil
import subprocess import subprocess
import threading import threading
import time
import traceback import traceback
from datetime import datetime from datetime import datetime
from support import SupportSubprocess, SupportUtil, logger from support import SupportFile, SupportSubprocess, SupportUtil, logger
class SupportFfmpeg(object): class SupportFfmpeg(object):
@@ -92,6 +93,7 @@ class SupportFfmpeg(object):
try: try:
self.status = SupportFfmpeg.Status.USER_STOP self.status = SupportFfmpeg.Status.USER_STOP
self.kill() self.kill()
logger.warning('stop')
except Exception as e: except Exception as e:
logger.error(f'Exception:{str(e)}') logger.error(f'Exception:{str(e)}')
logger.error(traceback.format_exc()) logger.error(traceback.format_exc())
@@ -111,22 +113,29 @@ class SupportFfmpeg(object):
def thread_fuction(self): def thread_fuction(self):
try: try:
header_count = 0
if self.proxy is None: if self.proxy is None:
if self.headers is None: if self.headers is None:
command = [self.__ffmpeg_path, '-y', '-i', self.url, '-c', 'copy', '-bsf:a', 'aac_adtstoasc'] command = [self.__ffmpeg_path, '-y', '-i', self.url, '-c', 'copy', '-bsf:a', 'aac_adtstoasc']
else: else:
headers_command = [] headers_command = []
tmp = ""
for key, value in self.headers.items(): for key, value in self.headers.items():
if key.lower() == 'user-agent': if key.lower() == 'user-agent':
headers_command.append('-user_agent') headers_command.append('-user_agent')
headers_command.append(value) headers_command.append(f"{value}")
pass pass
else: else:
headers_command.append('-headers') #headers_command.append('-headers')
if platform.system() == 'Windows': if platform.system() == 'Windows':
headers_command.append('\'%s:%s\''%(key,value)) tmp += f'{key}:{value}\r\n'
header_count += 1
else: else:
headers_command.append(f'{key}:{value}') #tmp.append(f'{key}:{value}')
tmp += f'{key}:{value}\r\n'
if len(tmp) > 0:
headers_command.append('-headers')
headers_command.append(f'{tmp}')
command = [self.__ffmpeg_path, '-y'] + headers_command + ['-i', self.url, '-c', 'copy', '-bsf:a', 'aac_adtstoasc'] command = [self.__ffmpeg_path, '-y'] + headers_command + ['-i', self.url, '-c', 'copy', '-bsf:a', 'aac_adtstoasc']
else: else:
command = [self.__ffmpeg_path, '-y', '-http_proxy', self.proxy, '-i', self.url, '-c', 'copy', '-bsf:a', 'aac_adtstoasc'] command = [self.__ffmpeg_path, '-y', '-http_proxy', self.proxy, '-i', self.url, '-c', 'copy', '-bsf:a', 'aac_adtstoasc']
@@ -140,8 +149,9 @@ class SupportFfmpeg(object):
else: else:
command.append(self.temp_fullpath) command.append(self.temp_fullpath)
try: try:
logger.debug(' '.join(command)) #logger.debug(' '.join(command))
if os.path.exists(self.temp_fullpath): if os.path.exists(self.temp_fullpath):
for f in SupportFfmpeg.__instance_list: for f in SupportFfmpeg.__instance_list:
if f.__idx != self.__idx and f.temp_fullpath == self.temp_fullpath and f.status in [SupportFfmpeg.Status.DOWNLOADING, SupportFfmpeg.Status.READY]: if f.__idx != self.__idx and f.temp_fullpath == self.temp_fullpath and f.status in [SupportFfmpeg.Status.DOWNLOADING, SupportFfmpeg.Status.READY]:
@@ -149,8 +159,24 @@ class SupportFfmpeg(object):
return return
except: except:
pass pass
logger.error(' '.join(command)) #logger.error(' '.join(command))
command = SupportSubprocess.command_for_windows(command) command = SupportSubprocess.command_for_windows(command)
if platform.system() == 'Windows' and header_count > 1:
if os.environ.get('FF'):
from framework import F
batfilepath = os.path.join(F.config['path_data'], 'tmp', f"{time.time()}.bat")
else:
batfilepath = f"{time.time()}.bat"
tmp = command.replace('\r\n', '!CRLF!')
text = f"""setlocal enabledelayedexpansion
SET CRLF=^
{tmp}"""
SupportFile.write_file(batfilepath, text)
command = batfilepath
self.process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, encoding='utf8') self.process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, encoding='utf8')
self.status = SupportFfmpeg.Status.READY self.status = SupportFfmpeg.Status.READY
@@ -320,7 +346,7 @@ class SupportFfmpeg(object):
def send_to_listener(self, **arg): def send_to_listener(self, **arg):
if self.total_callback_function != None: if self.total_callback_function != None:
self.total_callback_function(**arg) self.total_callback_function(**arg)
if self.callback_function is not None: if self.callback_function is not None and self.callback_function != self.total_callback_function:
arg['callback_id'] = self.callback_id arg['callback_id'] = self.callback_id
self.callback_function(**arg) self.callback_function(**arg)