2022.11.12 (01. bug fixed)

This commit is contained in:
2022-11-30 23:03:41 +09:00
parent e7bb53c33b
commit ebed736c2f
12 changed files with 1341 additions and 1600 deletions

View File

@@ -1,368 +0,0 @@
import abc
import os
import queue
import threading
import time
import traceback
from datetime import datetime
import requests
# from flaskfarm.lib.plugin import get_model_setting
from flaskfarm.lib.support.expand.ffmpeg import SupportFfmpeg
# from flaskfarm.lib.system.setup import SystemModelSetting
from flaskfarm.lib.tool import ToolUtil
# from flaskfarm.lib.system.setup import P as SM
# from flaskfarm.lib.system.mod_setting import ModuleSetting as SM
from ..setup import *
class FfmpegQueueEntity(abc.ABCMeta('ABC', (object,), {'__slots__': ()})):
def __init__(self, P, module_logic, info):
self.P = P
# SupportFfmpeg.initialize()
self.module_logic = module_logic
self.entity_id = -1 # FfmpegQueueEntity.static_index
self.info = info
self.url = None
self.ffmpeg_status = -1
self.ffmpeg_status_kor = u'대기중'
self.ffmpeg_percent = 0
self.ffmpeg_arg = None
self.cancel = False
self.created_time = datetime.now().strftime('%m-%d %H:%M:%S')
self.savepath = None
self.filename = None
self.filepath = None
self.quality = None
self.headers = None
# FfmpegQueueEntity.static_index += 1
# FfmpegQueueEntity.entity_list.append(self)
def get_video_url(self):
return self.url
def get_video_filepath(self):
return self.filepath
@abc.abstractmethod
def refresh_status(self):
pass
@abc.abstractmethod
def info_dict(self, tmp):
pass
def download_completed(self):
pass
def as_dict(self):
tmp = {}
tmp['entity_id'] = self.entity_id
tmp['url'] = self.url
tmp['ffmpeg_status'] = self.ffmpeg_status
tmp['ffmpeg_status_kor'] = self.ffmpeg_status_kor
tmp['ffmpeg_percent'] = self.ffmpeg_percent
tmp['ffmpeg_arg'] = self.ffmpeg_arg
tmp['cancel'] = self.cancel
tmp['created_time'] = self.created_time # .strftime('%m-%d %H:%M:%S')
tmp['savepath'] = self.savepath
tmp['filename'] = self.filename
tmp['filepath'] = self.filepath
tmp['quality'] = self.quality
# tmp['current_speed'] = self.ffmpeg_arg['current_speed'] if self.ffmpeg_arg is not None else ''
tmp = self.info_dict(tmp)
return tmp
class FfmpegQueue(object):
def __init__(self, P, max_ffmpeg_count):
self.P = P
self.static_index = 1
self.entity_list = []
self.current_ffmpeg_count = 0
self.download_queue = None
self.download_thread = None
self.max_ffmpeg_count = max_ffmpeg_count
if self.max_ffmpeg_count is None or self.max_ffmpeg_count == '':
self.max_ffmpeg_count = 1
def queue_start(self):
try:
if self.download_queue is None:
self.download_queue = queue.Queue()
if self.download_thread is None:
self.download_thread = threading.Thread(target=self.download_thread_function, args=())
self.download_thread.daemon = True
self.download_thread.start()
except Exception as exception:
self.P.logger.error('Exception:%s', exception)
self.P.logger.error(traceback.format_exc())
def download_thread_function(self):
while True:
try:
while True:
try:
if self.current_ffmpeg_count < self.max_ffmpeg_count:
break
time.sleep(5)
except Exception as exception:
self.P.logger.error('Exception:%s', exception)
self.P.logger.error(traceback.format_exc())
self.P.logger.error('current_ffmpeg_count : %s', self.current_ffmpeg_count)
self.P.logger.error('max_ffmpeg_count : %s', self.max_ffmpeg_count)
break
entity = self.download_queue.get()
if entity.cancel:
continue
# from .logic_ani24 import LogicAni24
# entity.url = LogicAni24.get_video_url(entity.info['code'])
video_url = entity.get_video_url()
if video_url is None:
entity.ffmpeg_status_kor = 'URL실패'
entity.refresh_status()
# plugin.socketio_list_refresh()
continue
# import ffmpeg
# max_pf_count = 0
# save_path = ModelSetting.get('download_path')
# if ModelSetting.get('auto_make_folder') == 'True':
# program_path = os.path.join(save_path, entity.info['filename'].split('.')[0])
# save_path = program_path
# try:
# if not os.path.exists(save_path):
# os.makedirs(save_path)
# except:
# logger.debug('program path make fail!!')
# 파일 존재여부 체크
print(entity.info)
filepath = entity.get_video_filepath()
P.logger.debug(f'filepath:: {filepath}')
if os.path.exists(filepath):
entity.ffmpeg_status_kor = '파일 있음'
entity.ffmpeg_percent = 100
entity.refresh_status()
# plugin.socketio_list_refresh()
continue
dirname = os.path.dirname(filepath)
# filename = os.path.f
if not os.path.exists(dirname):
os.makedirs(dirname)
# f = ffmpeg.Ffmpeg(video_url, os.path.basename(filepath), plugin_id=entity.entity_id, listener=self.ffmpeg_listener, call_plugin=self.P.package_name, save_path=dirname, headers=entity.headers)
# print(filepath)
# print(os.path.basename(filepath))
# print(dirname)
# aa_sm = get_model_setting("system", P.logger)
P.logger.debug(P)
# P.logger.debug(P.system_setting.get("port"))
ffmpeg = SupportFfmpeg(video_url, os.path.basename(str(filepath)),
callback_function=self.callback_function,
max_pf_count=0, save_path=ToolUtil.make_path(dirname), timeout_minute=60,
)
#
ffmpeg.start()
self.current_ffmpeg_count += 1
self.download_queue.task_done()
except Exception as exception:
self.P.logger.error('Exception:%s', exception)
self.P.logger.error(traceback.format_exc())
def callback_function(self, **args):
refresh_type = None
if args['type'] == 'status_change':
if args['status'] == SupportFfmpeg.Status.DOWNLOADING:
refresh_type = 'status_change'
elif args['status'] == SupportFfmpeg.Status.COMPLETED:
refresh_type = 'status_change'
elif args['status'] == SupportFfmpeg.Status.READY:
data = {'type': 'info',
'msg': '다운로드중 Duration(%s)' % args['data']['duration_str'] + '<br>' + args['data'][
'save_fullpath'], 'url': '/ffmpeg/download/list'}
socketio.emit("notify", data, namespace='/framework', broadcast=True)
refresh_type = 'add'
elif args['type'] == 'last':
if args['status'] == SupportFfmpeg.Status.WRONG_URL:
data = {'type': 'warning', 'msg': '잘못된 URL입니다'}
socketio.emit("notify", data, namespace='/framework', broadcast=True)
refresh_type = 'add'
elif args['status'] == SupportFfmpeg.Status.WRONG_DIRECTORY:
data = {'type': 'warning', 'msg': '잘못된 디렉토리입니다.<br>' + args['data']['save_fullpath']}
socketio.emit("notify", data, namespace='/framework', broadcast=True)
refresh_type = 'add'
elif args['status'] == SupportFfmpeg.Status.ERROR or args['status'] == SupportFfmpeg.Status.EXCEPTION:
data = {'type': 'warning', 'msg': '다운로드 시작 실패.<br>' + args['data']['save_fullpath']}
socketio.emit("notify", data, namespace='/framework', broadcast=True)
refresh_type = 'add'
elif args['status'] == SupportFfmpeg.Status.USER_STOP:
data = {'type': 'warning', 'msg': '다운로드가 중지 되었습니다.<br>' + args['data']['save_fullpath'],
'url': '/ffmpeg/download/list'}
socketio.emit("notify", data, namespace='/framework', broadcast=True)
refresh_type = 'last'
elif args['status'] == SupportFfmpeg.Status.COMPLETED:
data = {'type': 'success', 'msg': '다운로드가 완료 되었습니다.<br>' + args['data']['save_fullpath'],
'url': '/ffmpeg/download/list'}
socketio.emit("notify", data, namespace='/framework', broadcast=True)
refresh_type = 'last'
elif args['status'] == SupportFfmpeg.Status.TIME_OVER:
data = {'type': 'warning', 'msg': '시간초과로 중단 되었습니다.<br>' + args['data']['save_fullpath'],
'url': '/ffmpeg/download/list'}
socketio.emit("notify", data, namespace='/framework', broadcast=True)
refresh_type = 'last'
elif args['status'] == SupportFfmpeg.Status.PF_STOP:
data = {'type': 'warning', 'msg': 'PF초과로 중단 되었습니다.<br>' + args['data']['save_fullpath'],
'url': '/ffmpeg/download/list'}
socketio.emit("notify", data, namespace='/framework', broadcast=True)
refresh_type = 'last'
elif args['status'] == SupportFfmpeg.Status.FORCE_STOP:
data = {'type': 'warning', 'msg': '강제 중단 되었습니다.<br>' + args['data']['save_fullpath'],
'url': '/ffmpeg/download/list'}
socketio.emit("notify", data, namespace='/framework', broadcast=True)
refresh_type = 'last'
elif args['status'] == SupportFfmpeg.Status.HTTP_FORBIDDEN:
data = {'type': 'warning', 'msg': '403에러로 중단 되었습니다.<br>' + args['data']['save_fullpath'],
'url': '/ffmpeg/download/list'}
socketio.emit("notify", data, namespace='/framework', broadcast=True)
refresh_type = 'last'
elif args['status'] == SupportFfmpeg.Status.ALREADY_DOWNLOADING:
data = {'type': 'warning', 'msg': '임시파일폴더에 파일이 있습니다.<br>' + args['data']['temp_fullpath'],
'url': '/ffmpeg/download/list'}
socketio.emit("notify", data, namespace='/framework', broadcast=True)
refresh_type = 'last'
elif args['type'] == 'normal':
if args['status'] == SupportFfmpeg.Status.DOWNLOADING:
refresh_type = 'status'
# P.logger.info(refresh_type)
self.socketio_callback(refresh_type, args['data'])
def ffmpeg_listener(self, **arg):
import ffmpeg
entity = self.get_entity_by_entity_id(arg['plugin_id'])
if entity is None:
return
if arg['type'] == 'status_change':
if arg['status'] == ffmpeg.Status.DOWNLOADING:
pass
elif arg['status'] == ffmpeg.Status.COMPLETED:
entity.donwload_completed()
elif arg['status'] == ffmpeg.Status.READY:
pass
elif arg['type'] == 'last':
self.current_ffmpeg_count += -1
elif arg['type'] == 'log':
pass
elif arg['type'] == 'normal':
pass
entity.ffmpeg_arg = arg
entity.ffmpeg_status = int(arg['status'])
entity.ffmpeg_status_kor = str(arg['status'])
entity.ffmpeg_percent = arg['data']['percent']
entity.ffmpeg_arg['status'] = str(arg['status'])
# self.P.logger.debug(arg)
# import plugin
# arg['status'] = str(arg['status'])
# plugin.socketio_callback('status', arg)
entity.refresh_status()
# FfmpegQueueEntity.static_index += 1
# FfmpegQueueEntity.entity_list.append(self)
def add_queue(self, entity):
try:
# entity = QueueEntity.create(info)
# if entity is not None:
# LogicQueue.download_queue.put(entity)
# return True
entity.entity_id = self.static_index
self.static_index += 1
self.entity_list.append(entity)
self.download_queue.put(entity)
return True
except Exception as exception:
self.P.logger.error('Exception:%s', exception)
self.P.logger.error(traceback.format_exc())
return False
def set_max_ffmpeg_count(self, max_ffmpeg_count):
self.max_ffmpeg_count = max_ffmpeg_count
def get_max_ffmpeg_count(self):
return self.max_ffmpeg_count
def command(self, cmd, entity_id):
self.P.logger.debug('command :%s %s', cmd, entity_id)
ret = {}
try:
if cmd == 'cancel':
self.P.logger.debug('command :%s %s', cmd, entity_id)
entity = self.get_entity_by_entity_id(entity_id)
if entity is not None:
if entity.ffmpeg_status == -1:
entity.cancel = True
entity.ffmpeg_status_kor = "취소"
# entity.refresh_status()
ret['ret'] = 'refresh'
elif entity.ffmpeg_status != 5:
ret['ret'] = 'notify'
ret['log'] = '다운로드중 상태가 아닙니다.'
else:
idx = entity.ffmpeg_arg['data']['idx']
import ffmpeg
ffmpeg.Ffmpeg.stop_by_idx(idx)
entity.refresh_status()
ret['ret'] = 'refresh'
elif cmd == 'reset':
if self.download_queue is not None:
with self.download_queue.mutex:
self.download_queue.queue.clear()
for _ in self.entity_list:
if _.ffmpeg_status == 5:
import ffmpeg
idx = _.ffmpeg_arg['data']['idx']
ffmpeg.Ffmpeg.stop_by_idx(idx)
self.entity_list = []
ret['ret'] = 'refresh'
elif cmd == 'delete_completed':
new_list = []
for _ in self.entity_list:
if _.ffmpeg_status_kor in [u'파일 있음', u'취소', u'사용자중지']:
continue
if _.ffmpeg_status != 7:
new_list.append(_)
self.entity_list = new_list
ret['ret'] = 'refresh'
elif cmd == 'remove':
new_list = []
for _ in self.entity_list:
if _.entity_id == entity_id:
continue
new_list.append(_)
self.entity_list = new_list
ret['ret'] = 'refresh'
return ret
except Exception as exception:
self.P.logger.error('Exception:%s', exception)
self.P.logger.error(traceback.format_exc())
def get_entity_by_entity_id(self, entity_id):
for _ in self.entity_list:
if _.entity_id == entity_id:
return _
return None
def get_entity_list(self):
ret = []
P.logger.debug(self)
for x in self.entity_list:
tmp = x.as_dict()
ret.append(tmp)
return ret

View File

@@ -23,7 +23,9 @@ class FfmpegQueueEntity(abc.ABCMeta('ABC', (object,), {'__slots__': ()})):
self.P = P self.P = P
# SupportFfmpeg.initialize() # SupportFfmpeg.initialize()
self.module_logic = module_logic self.module_logic = module_logic
self.entity_id = -1 # FfmpegQueueEntity.static_index self.entity_id = -1
self.entity_list = []
# FfmpegQueueEntity.static_index
self.info = info self.info = info
self.url = None self.url = None
self.ffmpeg_status = -1 self.ffmpeg_status = -1
@@ -97,8 +99,8 @@ class FfmpegQueue(object):
if self.download_thread is None: if self.download_thread is None:
self.download_thread = threading.Thread(target=self.download_thread_function, args=()) self.download_thread = threading.Thread(target=self.download_thread_function, args=())
self.download_thread.daemon = True self.download_thread.daemon = True
# todo: # todo: 동작 방식 고찰
# self.download_thread.start() self.download_thread.start()
except Exception as exception: except Exception as exception:
self.P.logger.error(f'Exception: {exception}') self.P.logger.error(f'Exception: {exception}')
self.P.logger.error(traceback.format_exc()) self.P.logger.error(traceback.format_exc())
@@ -170,7 +172,7 @@ class FfmpegQueue(object):
) )
# #
# todo: 임시로 start() 중지 # todo: 임시로 start() 중지
# ffmpeg.start() ffmpeg.start()
self.current_ffmpeg_count += 1 self.current_ffmpeg_count += 1
self.download_queue.task_done() self.download_queue.task_done()
@@ -178,72 +180,72 @@ class FfmpegQueue(object):
self.P.logger.error('Exception:%s', exception) self.P.logger.error('Exception:%s', exception)
self.P.logger.error(traceback.format_exc()) self.P.logger.error(traceback.format_exc())
def callback_function(self, **args): # def callback_function(self, **args):
refresh_type = None # refresh_type = None
if args['type'] == 'status_change': # if args['type'] == 'status_change':
if args['status'] == SupportFfmpeg.Status.DOWNLOADING: # if args['status'] == SupportFfmpeg.Status.DOWNLOADING:
refresh_type = 'status_change' # refresh_type = 'status_change'
elif args['status'] == SupportFfmpeg.Status.COMPLETED: # elif args['status'] == SupportFfmpeg.Status.COMPLETED:
refresh_type = 'status_change' # refresh_type = 'status_change'
elif args['status'] == SupportFfmpeg.Status.READY: # elif args['status'] == SupportFfmpeg.Status.READY:
data = {'type': 'info', # data = {'type': 'info',
'msg': '다운로드중 Duration(%s)' % args['data']['duration_str'] + '<br>' + args['data'][ # 'msg': '다운로드중 Duration(%s)' % args['data']['duration_str'] + '<br>' + args['data'][
'save_fullpath'], 'url': '/ffmpeg/download/list'} # 'save_fullpath'], 'url': '/ffmpeg/download/list'}
socketio.emit("notify", data, namespace='/framework', broadcast=True) # socketio.emit("notify", data, namespace='/framework', broadcast=True)
refresh_type = 'add' # refresh_type = 'add'
elif args['type'] == 'last': # elif args['type'] == 'last':
if args['status'] == SupportFfmpeg.Status.WRONG_URL: # if args['status'] == SupportFfmpeg.Status.WRONG_URL:
data = {'type': 'warning', 'msg': '잘못된 URL입니다'} # data = {'type': 'warning', 'msg': '잘못된 URL입니다'}
socketio.emit("notify", data, namespace='/framework', broadcast=True) # socketio.emit("notify", data, namespace='/framework', broadcast=True)
refresh_type = 'add' # refresh_type = 'add'
elif args['status'] == SupportFfmpeg.Status.WRONG_DIRECTORY: # elif args['status'] == SupportFfmpeg.Status.WRONG_DIRECTORY:
data = {'type': 'warning', 'msg': '잘못된 디렉토리입니다.<br>' + args['data']['save_fullpath']} # data = {'type': 'warning', 'msg': '잘못된 디렉토리입니다.<br>' + args['data']['save_fullpath']}
socketio.emit("notify", data, namespace='/framework', broadcast=True) # socketio.emit("notify", data, namespace='/framework', broadcast=True)
refresh_type = 'add' # refresh_type = 'add'
elif args['status'] == SupportFfmpeg.Status.ERROR or args['status'] == SupportFfmpeg.Status.EXCEPTION: # elif args['status'] == SupportFfmpeg.Status.ERROR or args['status'] == SupportFfmpeg.Status.EXCEPTION:
data = {'type': 'warning', 'msg': '다운로드 시작 실패.<br>' + args['data']['save_fullpath']} # data = {'type': 'warning', 'msg': '다운로드 시작 실패.<br>' + args['data']['save_fullpath']}
socketio.emit("notify", data, namespace='/framework', broadcast=True) # socketio.emit("notify", data, namespace='/framework', broadcast=True)
refresh_type = 'add' # refresh_type = 'add'
elif args['status'] == SupportFfmpeg.Status.USER_STOP: # elif args['status'] == SupportFfmpeg.Status.USER_STOP:
data = {'type': 'warning', 'msg': '다운로드가 중지 되었습니다.<br>' + args['data']['save_fullpath'], # data = {'type': 'warning', 'msg': '다운로드가 중지 되었습니다.<br>' + args['data']['save_fullpath'],
'url': '/ffmpeg/download/list'} # 'url': '/ffmpeg/download/list'}
socketio.emit("notify", data, namespace='/framework', broadcast=True) # socketio.emit("notify", data, namespace='/framework', broadcast=True)
refresh_type = 'last' # refresh_type = 'last'
elif args['status'] == SupportFfmpeg.Status.COMPLETED: # elif args['status'] == SupportFfmpeg.Status.COMPLETED:
data = {'type': 'success', 'msg': '다운로드가 완료 되었습니다.<br>' + args['data']['save_fullpath'], # data = {'type': 'success', 'msg': '다운로드가 완료 되었습니다.<br>' + args['data']['save_fullpath'],
'url': '/ffmpeg/download/list'} # 'url': '/ffmpeg/download/list'}
socketio.emit("notify", data, namespace='/framework', broadcast=True) # socketio.emit("notify", data, namespace='/framework', broadcast=True)
refresh_type = 'last' # refresh_type = 'last'
elif args['status'] == SupportFfmpeg.Status.TIME_OVER: # elif args['status'] == SupportFfmpeg.Status.TIME_OVER:
data = {'type': 'warning', 'msg': '시간초과로 중단 되었습니다.<br>' + args['data']['save_fullpath'], # data = {'type': 'warning', 'msg': '시간초과로 중단 되었습니다.<br>' + args['data']['save_fullpath'],
'url': '/ffmpeg/download/list'} # 'url': '/ffmpeg/download/list'}
socketio.emit("notify", data, namespace='/framework', broadcast=True) # socketio.emit("notify", data, namespace='/framework', broadcast=True)
refresh_type = 'last' # refresh_type = 'last'
elif args['status'] == SupportFfmpeg.Status.PF_STOP: # elif args['status'] == SupportFfmpeg.Status.PF_STOP:
data = {'type': 'warning', 'msg': 'PF초과로 중단 되었습니다.<br>' + args['data']['save_fullpath'], # data = {'type': 'warning', 'msg': 'PF초과로 중단 되었습니다.<br>' + args['data']['save_fullpath'],
'url': '/ffmpeg/download/list'} # 'url': '/ffmpeg/download/list'}
socketio.emit("notify", data, namespace='/framework', broadcast=True) # socketio.emit("notify", data, namespace='/framework', broadcast=True)
refresh_type = 'last' # refresh_type = 'last'
elif args['status'] == SupportFfmpeg.Status.FORCE_STOP: # elif args['status'] == SupportFfmpeg.Status.FORCE_STOP:
data = {'type': 'warning', 'msg': '강제 중단 되었습니다.<br>' + args['data']['save_fullpath'], # data = {'type': 'warning', 'msg': '강제 중단 되었습니다.<br>' + args['data']['save_fullpath'],
'url': '/ffmpeg/download/list'} # 'url': '/ffmpeg/download/list'}
socketio.emit("notify", data, namespace='/framework', broadcast=True) # socketio.emit("notify", data, namespace='/framework', broadcast=True)
refresh_type = 'last' # refresh_type = 'last'
elif args['status'] == SupportFfmpeg.Status.HTTP_FORBIDDEN: # elif args['status'] == SupportFfmpeg.Status.HTTP_FORBIDDEN:
data = {'type': 'warning', 'msg': '403에러로 중단 되었습니다.<br>' + args['data']['save_fullpath'], # data = {'type': 'warning', 'msg': '403에러로 중단 되었습니다.<br>' + args['data']['save_fullpath'],
'url': '/ffmpeg/download/list'} # 'url': '/ffmpeg/download/list'}
socketio.emit("notify", data, namespace='/framework', broadcast=True) # socketio.emit("notify", data, namespace='/framework', broadcast=True)
refresh_type = 'last' # refresh_type = 'last'
elif args['status'] == SupportFfmpeg.Status.ALREADY_DOWNLOADING: # elif args['status'] == SupportFfmpeg.Status.ALREADY_DOWNLOADING:
data = {'type': 'warning', 'msg': '임시파일폴더에 파일이 있습니다.<br>' + args['data']['temp_fullpath'], # data = {'type': 'warning', 'msg': '임시파일폴더에 파일이 있습니다.<br>' + args['data']['temp_fullpath'],
'url': '/ffmpeg/download/list'} # 'url': '/ffmpeg/download/list'}
socketio.emit("notify", data, namespace='/framework', broadcast=True) # socketio.emit("notify", data, namespace='/framework', broadcast=True)
refresh_type = 'last' # refresh_type = 'last'
elif args['type'] == 'normal': # elif args['type'] == 'normal':
if args['status'] == SupportFfmpeg.Status.DOWNLOADING: # if args['status'] == SupportFfmpeg.Status.DOWNLOADING:
refresh_type = 'status' # refresh_type = 'status'
# P.logger.info(refresh_type) # # P.logger.info(refresh_type)
self.socketio_callback(refresh_type, args['data']) # self.socketio_callback(refresh_type, args['data'])
def ffmpeg_listener(self, **arg): def ffmpeg_listener(self, **arg):
import ffmpeg import ffmpeg

View File

@@ -49,7 +49,8 @@ from framework import F
from plugin import ( from plugin import (
PluginModuleBase PluginModuleBase
) )
from .lib.ffmpeg_queue import FfmpegQueueEntity, FfmpegQueue from .lib.ffmpeg_queue_v1 import FfmpegQueueEntity, FfmpegQueue
from support.expand.ffmpeg import SupportFfmpeg
from .lib.crawler import Crawler from .lib.crawler import Crawler
# from tool_base import d # from tool_base import d
@@ -547,6 +548,40 @@ class LogicAniLife(PluginModuleBase):
P.logger.error("Exception:%s", e) P.logger.error("Exception:%s", e)
P.logger.error(traceback.format_exc()) P.logger.error(traceback.format_exc())
def process_command(self, command, arg1, arg2, arg3, req):
ret = {'ret': 'success'}
logger.debug('queue_list')
if command == 'queue_list':
logger.debug(f"self.queue.get_entity_list():: {self.queue.get_entity_list()}")
ret = [x for x in self.queue.get_entity_list()]
return ret
elif command == 'download_program':
_pass = arg2
db_item = ModelOhli24Program.get(arg1)
if _pass == 'false' and db_item != None:
ret['ret'] = 'warning'
ret['msg'] = '이미 DB에 있는 항목 입니다.'
elif _pass == 'true' and db_item != None and ModelOhli24Program.get_by_id_in_queue(db_item.id) != None:
ret['ret'] = 'warning'
ret['msg'] = '이미 큐에 있는 항목 입니다.'
else:
if db_item == None:
db_item = ModelOhli24Program(arg1, self.get_episode(arg1))
db_item.save()
db_item.init_for_queue()
self.download_queue.put(db_item)
ret['msg'] = '다운로드를 추가 하였습니다.'
elif command == 'list':
ret = []
for ins in SupportFfmpeg.get_list():
ret.append(ins.get_data())
return jsonify(ret)
@staticmethod @staticmethod
def add_whitelist(*args): def add_whitelist(*args):
ret = {} ret = {}
@@ -650,7 +685,7 @@ class LogicAniLife(PluginModuleBase):
import json import json
post_data = { post_data = {
"url": url, "url": url,
"headless": True, "headless": False,
"engine": "webkit" "engine": "webkit"
} }
payload = json.dumps(post_data) payload = json.dumps(post_data)
@@ -830,8 +865,9 @@ class LogicAniLife(PluginModuleBase):
import json import json
post_data = { post_data = {
"url": url, "url": url,
"headless": True, "headless": False,
"engine": "chromium" "engine": "chrome",
"reload": True,
} }
payload = json.dumps(post_data) payload = json.dumps(post_data)
logger.debug(payload) logger.debug(payload)
@@ -877,6 +913,7 @@ class LogicAniLife(PluginModuleBase):
# real_url = LogicAniLife.get_real_link(url=entity["link"]) # real_url = LogicAniLife.get_real_link(url=entity["link"])
entity["code"] = entity["link"].split("/")[-1] entity["code"] = entity["link"].split("/")[-1]
entity["epx"] = item.xpath(".//span[@class='epx']/text()")[0].strip()
entity["title"] = item.xpath(".//div[@class='tt']/text()")[0].strip() entity["title"] = item.xpath(".//div[@class='tt']/text()")[0].strip()
entity["image_link"] = item.xpath(".//div[@class='limit']/img/@src")[ entity["image_link"] = item.xpath(".//div[@class='limit']/img/@src")[
0 0
@@ -986,14 +1023,15 @@ class AniLifeQueueEntity(FfmpegQueueEntity):
logger.info(f"self.info:::> {self.info}") logger.info(f"self.info:::> {self.info}")
referer = "https://anilife.live/g/l?id=13fd4d28-ff18-4764-9968-7e7ea7347c51" referer = "https://anilife.live/g/l?id=13fd4d28-ff18-4764-9968-7e7ea7347c51"
referer = LogicAniLife.episode_url
# text = requests.get(url, headers=headers).text # text = requests.get(url, headers=headers).text
# text = LogicAniLife.get_html_seleniumwire(url, referer=referer, wired=True) # text = LogicAniLife.get_html_seleniumwire(url, referer=referer, wired=True)
# https://anilife.live/ani/provider/10f60832-20d1-4918-be62-0f508bf5460c # https://anilife.live/ani/provider/10f60832-20d1-4918-be62-0f508bf5460c
referer_url = ( referer_url = (
"https://anilife.live/g/l?id=d4be1e0e-301b-403b-be1b-cf19f3ccfd23" "https://anilife.live/g/l?id=b012a355-a997-449a-ae2b-408a81a9b464"
) )
referer_url = LogicAniLife.episode_url referer_url = LogicAniLife.episode_url
logger.debug(f"LogicAniLife.episode_url:: {LogicAniLife.episode_url}") logger.debug(f"LogicAniLife.episode_url:: {LogicAniLife.episode_url}")
@@ -1017,14 +1055,16 @@ class AniLifeQueueEntity(FfmpegQueueEntity):
# )) # ))
# loop = asyncio.new_event_loop() # loop = asyncio.new_event_loop()
logger.debug(url, referer_url)
import json import json
post_data = { post_data = {
"url": url, "url": url,
"headless": True, "headless": False,
"engine": "chromium", # "engine": "chromium",
"engine": "webkit",
"referer": referer_url, "referer": referer_url,
"stealth": "False" "stealth": "False",
"reload": True,
} }
payload = json.dumps(post_data) payload = json.dumps(post_data)
logger.debug(payload) logger.debug(payload)
@@ -1114,14 +1154,14 @@ class AniLifeQueueEntity(FfmpegQueueEntity):
# vod_1080p_url = asyncio.run( # vod_1080p_url = asyncio.run(
# LogicAniLife.get_vod_url(jawcloud_url, headless=True) # LogicAniLife.get_vod_url(jawcloud_url, headless=True)
# ) # )
vod_1080p_url = LogicAniLife.get_vod_url_v2(jawcloud_url, headless=True) vod_1080p_url = LogicAniLife.get_vod_url_v2(jawcloud_url, headless=False)
print(f"vod_1080p_url:: {vod_1080p_url}") print(f"vod_1080p_url:: {vod_1080p_url}")
self.url = vod_1080p_url self.url = vod_1080p_url
logger.info(self.url) logger.info(self.url)
except Exception as e: except Exception as e:
P.logger.error("Exception:%s", e) P.logger.error(f"Exception: str(e)")
P.logger.error(traceback.format_exc()) P.logger.error(traceback.format_exc())

View File

@@ -52,7 +52,7 @@ from framework import F
from plugin import ( from plugin import (
PluginModuleBase PluginModuleBase
) )
from .lib.ffmpeg_queue import FfmpegQueueEntity, FfmpegQueue from .lib.ffmpeg_queue_v1 import FfmpegQueueEntity, FfmpegQueue
from support.expand.ffmpeg import SupportFfmpeg from support.expand.ffmpeg import SupportFfmpeg
from .lib.util import Util from .lib.util import Util
@@ -118,7 +118,7 @@ class LogicOhli24(PluginModuleBase):
} }
self.queue = None self.queue = None
# default_route_socketio(P, self) # default_route_socketio(P, self)
default_route_socketio_module(self, attach='/search') default_route_socketio_module(self, attach='/queue')
@staticmethod @staticmethod
def db_init(): def db_init():
@@ -219,10 +219,6 @@ class LogicOhli24(PluginModuleBase):
# if db_item == None: # if db_item == None:
# db_item = ModelOhli24Program(info['_id'], self.get_episode(info['_id'])) # db_item = ModelOhli24Program(info['_id'], self.get_episode(info['_id']))
# db_item.save() # db_item.save()
elif sub == "entity_list": elif sub == "entity_list":
return jsonify(self.queue.get_entity_list()) return jsonify(self.queue.get_entity_list())
elif sub == "queue_list": elif sub == "queue_list":
@@ -255,7 +251,8 @@ class LogicOhli24(PluginModuleBase):
thread.daemon = True thread.daemon = True
thread.start() thread.start()
return jsonify("") return jsonify("")
elif sub == "web_list": elif sub == "web_list2":
logger.debug("web_list2")
return jsonify(ModelOhli24Item.web_list(request)) return jsonify(ModelOhli24Item.web_list(request))
elif sub == "db_remove": elif sub == "db_remove":
return jsonify(ModelOhli24Item.delete_by_id(req.form["id"])) return jsonify(ModelOhli24Item.delete_by_id(req.form["id"]))
@@ -287,8 +284,9 @@ class LogicOhli24(PluginModuleBase):
def process_command(self, command, arg1, arg2, arg3, req): def process_command(self, command, arg1, arg2, arg3, req):
ret = {'ret': 'success'} ret = {'ret': 'success'}
logger.debug('queue_list')
if command == 'queue_list': if command == 'queue_list':
logger.debug('queue_list')
logger.debug(f"self.queue.get_entity_list():: {self.queue.get_entity_list()}") logger.debug(f"self.queue.get_entity_list():: {self.queue.get_entity_list()}")
ret = [x for x in self.queue.get_entity_list()] ret = [x for x in self.queue.get_entity_list()]
@@ -315,6 +313,19 @@ class LogicOhli24(PluginModuleBase):
for ins in SupportFfmpeg.get_list(): for ins in SupportFfmpeg.get_list():
ret.append(ins.get_data()) ret.append(ins.get_data())
elif command == 'queue_command':
if arg1 == 'cancel':
pass
elif arg1 == 'reset':
logger.debug('reset')
# if self.queue is not None:
# with self.queue.mutex:
# self.queue.queue.clear()
if self.download_queue is not None:
with self.download_queue.mutex:
self.download_queue.queue.clear()
return jsonify(ret) return jsonify(ret)
@staticmethod @staticmethod
@@ -751,8 +762,8 @@ class LogicOhli24(PluginModuleBase):
# self.callback_function, ffmpeg_modelsetting.get_int('max_pf_count')) # self.callback_function, ffmpeg_modelsetting.get_int('max_pf_count'))
# plugin loading download_queue 가 없으면 생성 # plugin loading download_queue 가 없으면 생성
if self.download_queue is None: # if self.download_queue is None:
self.download_queue = queue.Queue() # self.download_queue = queue.Queue()
SupportFfmpeg.initialize("ffmpeg", os.path.join(F.config['path_data'], 'tmp'), SupportFfmpeg.initialize("ffmpeg", os.path.join(F.config['path_data'], 'tmp'),
self.callback_function, 1) self.callback_function, 1)
@@ -762,7 +773,7 @@ class LogicOhli24(PluginModuleBase):
P, P.ModelSetting.get_int("ohli24_max_ffmpeg_process_count") P, P.ModelSetting.get_int("ohli24_max_ffmpeg_process_count")
) )
self.current_data = None self.current_data = None
# self.queue.queue_start() self.queue.queue_start()
except Exception as e: except Exception as e:
logger.error("Exception:%s", e) logger.error("Exception:%s", e)
@@ -859,13 +870,16 @@ class LogicOhli24(PluginModuleBase):
return "db_completed" return "db_completed"
def is_exist(self, info): def is_exist(self, info):
print(self.queue.entity_list) # print(self.queue)
# print(self.queue.entity_list)
for en in self.queue.entity_list: for en in self.queue.entity_list:
if en.info["_id"] == info["_id"]: if en.info["_id"] == info["_id"]:
return True return True
# return False # return False
def callback_function(self, **args): def callback_function(self, **args):
logger.debug('callback_function============')
logger.debug(args)
refresh_type = None refresh_type = None
if args['type'] == 'status_change': if args['type'] == 'status_change':
if args['status'] == SupportFfmpeg.Status.DOWNLOADING: if args['status'] == SupportFfmpeg.Status.DOWNLOADING:
@@ -876,7 +890,7 @@ class LogicOhli24(PluginModuleBase):
data = {'type': 'info', data = {'type': 'info',
'msg': '다운로드중 Duration(%s)' % args['data']['duration_str'] + '<br>' + args['data'][ 'msg': '다운로드중 Duration(%s)' % args['data']['duration_str'] + '<br>' + args['data'][
'save_fullpath'], 'url': '/ffmpeg/download/list'} 'save_fullpath'], 'url': '/ffmpeg/download/list'}
socketio.emit("notify", data, namespace='/framework', broadcast=True) # socketio.emit("notify", data, namespace='/framework', broadcast=True)
refresh_type = 'add' refresh_type = 'add'
elif args['type'] == 'last': elif args['type'] == 'last':
if args['status'] == SupportFfmpeg.Status.WRONG_URL: if args['status'] == SupportFfmpeg.Status.WRONG_URL:
@@ -899,7 +913,9 @@ class LogicOhli24(PluginModuleBase):
elif args['status'] == SupportFfmpeg.Status.COMPLETED: elif args['status'] == SupportFfmpeg.Status.COMPLETED:
data = {'type': 'success', 'msg': '다운로드가 완료 되었습니다.<br>' + args['data']['save_fullpath'], data = {'type': 'success', 'msg': '다운로드가 완료 되었습니다.<br>' + args['data']['save_fullpath'],
'url': '/ffmpeg/download/list'} 'url': '/ffmpeg/download/list'}
socketio.emit("notify", data, namespace='/framework', broadcast=True)
# socketio.emit("notify", data, namespace='/framework', broadcast=True)
refresh_type = 'last' refresh_type = 'last'
elif args['status'] == SupportFfmpeg.Status.TIME_OVER: elif args['status'] == SupportFfmpeg.Status.TIME_OVER:
data = {'type': 'warning', 'msg': '시간초과로 중단 되었습니다.<br>' + args['data']['save_fullpath'], data = {'type': 'warning', 'msg': '시간초과로 중단 되었습니다.<br>' + args['data']['save_fullpath'],

View File

@@ -1,175 +1,231 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block content %} {% block content %}
<div>
{{ macros.m_button_group([['reset_btn', '초기화'], ['delete_completed_btn', '완료 목록 삭제'], ['go_ffmpeg_btn', 'Go FFMPEG']]) }}
</div>
<table id="result_table" class="table table-sm tableRowHover">
<thead class="thead-dark">
<tr>
<th style="width:5%; text-align:center;">IDX</th>
<th style="width:8%; text-align:center;">Plugin</th>
<th style="width:10%; text-align:center;">시작시간</th>
<th style="width:20%; text-align:center;">파일명</th>
<th style="width:8%; text-align:center;">상태</th>
<th style="width:15%; text-align:center;">진행률</th>
<th style="width:5%; text-align:center;">길이</th>
<th style="width:5%; text-align:center;">PF</th>
<th style="width:8%; text-align:center;">배속</th>
<th style="width:8%; text-align:center;">진행시간</th>
<th style="width:8%; text-align:center;">Action</th>
</tr>
</thead>
<tbody id="list"></tbody>
</table>
<table id="result_table" class="table table-sm tableRowHover"> <script type="text/javascript">
<thead class="thead-dark"> const package_name = "{{arg['package_name'] }}";
<tr> const sub = "{{arg['sub'] }}";
<th style="width:5%; text-align:center;">IDX</th>
<th style="width:8%; text-align:center;">Plugin</th>
<th style="width:10%; text-align:center;">시작시간</th>
<th style="width:20%; text-align:center;">파일명</th>
<th style="width:8%; text-align:center;">상태</th>
<th style="width:15%; text-align:center;">진행률</th>
<th style="width:5%; text-align:center;">길이</th>
<th style="width:5%; text-align:center;">PF</th>
<th style="width:8%; text-align:center;">배속</th>
<th style="width:8%; text-align:center;">진행시간</th>
<th style="width:8%; text-align:center;">Action</th>
</tr>
</thead>
<tbody id="list"></tbody>
</table>
<script type="text/javascript"> function on_start() {
$.ajax({
url: '/' + package_name + '/ajax/' + sub + '/entity_list',
type: "POST",
cache: false,
data: {},
dataType: "json",
success: function (data) {
make_download_list(data)
}
});
}
$(document).ready(function(){ $(document).ready(function () {
var socket = io.connect(window.location.href); const socket = io.connect(window.location.href);
socket.on('on_start', function(data){ {#socket = io.connect(window.location.protocol + "//" + document.domain + ":" + location.port + "/" + package_name + '/' + sub);#}
document.getElementById("log").innerHTML += data.data;
document.getElementById("log").scrollTop = document.getElementById("log").scrollHeight;
document.getElementById("log").style.visibility = 'visible';
$('#loading').hide();
});
socket.on('add', function(data){ socket.on('start', function (data) {
str = make_item(data); on_start();
if (current_data == null || current_data.length == 0) { });
current_data = Array(); socket.on('list_refresh', function (data) {
$("#list").html(str); on_start()
} else { });
$("#list").html($("#list").html() + str);
}
current_data.push(data);
});
socket.on('status_change', function(data) { socket.on('status', function (data) {
button_html(data); console.log(data);
}); on_status(data)
});
socket.on('status', function(data){ socket.on('on_start', function (data) {
status_html(data); document.getElementById("log").innerHTML += data.data;
}); document.getElementById("log").scrollTop = document.getElementById("log").scrollHeight;
document.getElementById("log").style.visibility = 'visible';
$('#loading').hide();
});
socket.on('last', function(data){ socket.on('add', function (data) {
status_html(data); str = make_item(data);
button_html(data); if (current_data == null || current_data.length == 0) {
}); current_data = Array();
$("#list").html(str);
} else {
$("#list").html($("#list").html() + str);
}
current_data.push(data);
});
globalSendCommand('list', null, null, null, function(data) { socket.on('status_change', function (data) {
current_data = data; button_html(data);
$("#list").html(''); });
console.log(data)
if (data.length == 0) { socket.on('status', function (data) {
str = "<tr><td colspan='10'><h4>작업이 없습니다.</h4><td><tr>"; status_html(data);
} else { });
str = ''
for(i in data) { socket.on('last', function (data) {
str += make_item(data[i]); status_html(data);
} button_html(data);
} });
$("#list").html(str);
}); globalSendCommand('list', null, null, null, function (data) {
}); current_data = data;
$("#list").html('');
console.log(data)
if (data.length == 0) {
str = "<tr><td colspan='10'><h4>작업이 없습니다.</h4><td><tr>";
} else {
str = ''
for (i in data) {
str += make_item(data[i]);
}
}
$("#list").html(str);
});
$("body").on('click', '#stop_btn', function(e){ });
e.stopPropagation();
e.preventDefault();
globalSendCommand('stop', $(this).data('idx'), null, null, function(ret){
refresh_item(ret.data);
});
});
function refresh_item(data) { $("body").on('click', '#stop_btn', function (e) {
$('#tr1_'+data.idx).html(make_item1(data)); e.stopPropagation();
$('#collapse_'+data.idx).html(make_item2(data)); e.preventDefault();
} globalSendCommand('stop', $(this).data('idx'), null, null, function (ret) {
refresh_item(ret.data);
function make_item(data) { });
str = '<tr id="tr1_'+data.idx+'" style="cursor: pointer;" data-toggle="collapse" data-target="#collapse_'+ data.idx + '" aria-expanded="true" >'; });
str += make_item1(data);
str += '</tr>';
str += '<tr class="collapse tableRowHoverOff" style="cursor: pointer;" id="collapse_' + data.idx + '">';
str += make_item2(data);
str += '</tr>';
return str;
}
function make_item1(data) {
//console.log(data);
str = '';
str += '<td scope="col" style="width:5%; text-align:center;">'+ data.idx + '</td>';
str += '<td scope="col" style="width:8%; text-align:center;">'+ data.callback_id + '</td>';
str += '<td scope="col" style="width:10%; text-align:center;">'+ data.start_time + '</td>';
str += '<td scope="col" style="width:20%; text-align:center;">'+ data.filename + '</td>';
str += '<td id="status_'+data.idx+'" scope="col" style="width:8%; text-align:center;">'+ data.status_kor + '</td>';
var visi = 'hidden';
if (parseInt(data.percent) > 0) {
visi = 'visible';
}
str += '<td scope="col" style="width:20%; text-align:center;"><div class="progress"><div id="progress_'+data.idx+'" class="progress-bar" style="visibility: '+visi+'; width:'+data.percent+'%">'+data.percent +'%</div></div></td>';
str += '<td scope="col" style="width:5%; text-align:center;">'+ data.duration_str + '</td>';
str += '<td id="current_pf_count_'+data.idx+'" scope="col" style="width:5%; text-align:center;">'+ data.current_pf_count + '</td>';
str += '<td id="current_speed_'+data.idx+'" scope="col" style="width:8%; text-align:center;">'+ data.current_speed + '</td>';
str += '<td id="download_time_'+data.idx+'" scope="col" style="width:8%; text-align:center;">'+ data.download_time + '</td>';
str += '<td id="button_'+data.idx+'" scope="col" style="width:8%; text-align:center;">';
if (data.status_str == 'DOWNLOADING') {
str += j_button('stop_btn', '중지', {'idx':data.idx}, 'danger', false, false);
}
str += '</td>'
return str;
}
function make_item2(data) {
str = '';
str += '<td colspan="11">';
str += '<div id="detail_'+data.idx+'">';
str += get_detail(data);
str += '</div>';
str += '</td>';
return str
}
function get_detail(data) { function refresh_item(data) {
var str = j_row_info('URL', data.url); $('#tr1_' + data.idx).html(make_item1(data));
str += j_row_info('임시경로', data.temp_fullpath); $('#collapse_' + data.idx).html(make_item2(data));
str += j_row_info('저장경로', data.save_fullpath); }
str += j_row_info('진행률(current/total)', data.percent+ '% (' + data.current_duration + ' / ' + data.duration + ')');
str += j_row_info('현재 비트레이트', data.current_bitrate);
str += j_row_info('종료시간', data.end_time);
str += j_row_info('허용 Packet Fail 수', data.max_pf_count);
str += j_row_info('파일 Exist', data.exist);
if (data.status_str == 'COMPLETED') {
str += j_row_info('파일 크기', data.filesize_str);
str += j_row_info('다운 속도', data.download_speed);
}
return str;
}
function button_html(data) { function make_item(data) {
//console.log(data) str = '<tr id="tr1_' + data.idx + '" style="cursor: pointer;" data-toggle="collapse" data-target="#collapse_' + data.idx + '" aria-expanded="true" >';
str = ''; str += make_item1(data);
if (data.status_str == 'DOWNLOADING') { str += '</tr>';
str = j_button('stop_btn', '중지', {'idx':data.idx}, 'danger', false, false); str += '<tr class="collapse tableRowHoverOff" style="cursor: pointer;" id="collapse_' + data.idx + '">';
} str += make_item2(data);
$("#button_" + data.idx).html(str); str += '</tr>';
} return str;
}
function status_html(data) { function make_item1(data) {
var progress = document.getElementById("progress_" + data.idx); //console.log(data);
progress.style.width = data.percent+ '%'; str = '';
progress.innerHTML = data.percent+ '%'; str += '<td scope="col" style="width:5%; text-align:center;">' + data.idx + '</td>';
progress.style.visibility = 'visible'; str += '<td scope="col" style="width:8%; text-align:center;">' + data.callback_id + '</td>';
document.getElementById("status_" + data.idx).innerHTML = data.status_kor; str += '<td scope="col" style="width:10%; text-align:center;">' + data.start_time + '</td>';
document.getElementById("current_pf_count_" + data.idx).innerHTML = data.current_pf_count; str += '<td scope="col" style="width:20%; text-align:center;">' + data.filename + '</td>';
document.getElementById("current_speed_" + data.idx).innerHTML = data.current_speed; str += '<td id="status_' + data.idx + '" scope="col" style="width:8%; text-align:center;">' + data.status_kor + '</td>';
document.getElementById("download_time_" + data.idx).innerHTML = data.download_time; var visi = 'hidden';
document.getElementById("detail_" + data.idx).innerHTML = get_detail(data); if (parseInt(data.percent) > 0) {
} visi = 'visible';
}
str += '<td scope="col" style="width:20%; text-align:center;"><div class="progress"><div id="progress_' + data.idx + '" class="progress-bar" style="visibility: ' + visi + '; width:' + data.percent + '%">' + data.percent + '%</div></div></td>';
str += '<td scope="col" style="width:5%; text-align:center;">' + data.duration_str + '</td>';
str += '<td id="current_pf_count_' + data.idx + '" scope="col" style="width:5%; text-align:center;">' + data.current_pf_count + '</td>';
str += '<td id="current_speed_' + data.idx + '" scope="col" style="width:8%; text-align:center;">' + data.current_speed + '</td>';
str += '<td id="download_time_' + data.idx + '" scope="col" style="width:8%; text-align:center;">' + data.download_time + '</td>';
str += '<td id="button_' + data.idx + '" scope="col" style="width:8%; text-align:center;">';
if (data.status_str == 'DOWNLOADING') {
str += j_button('stop_btn', '중지', {'idx': data.idx}, 'danger', false, false);
}
str += '</td>'
return str;
}
</script> function make_item2(data) {
str = '';
str += '<td colspan="11">';
str += '<div id="detail_' + data.idx + '">';
str += get_detail(data);
str += '</div>';
str += '</td>';
return str
}
function get_detail(data) {
var str = j_row_info('URL', data.url);
str += j_row_info('임시경로', data.temp_fullpath);
str += j_row_info('저장경로', data.save_fullpath);
str += j_row_info('진행률(current/total)', data.percent + '% (' + data.current_duration + ' / ' + data.duration + ')');
str += j_row_info('현재 비트레이트', data.current_bitrate);
str += j_row_info('종료시간', data.end_time);
str += j_row_info('허용 Packet Fail 수', data.max_pf_count);
str += j_row_info('파일 Exist', data.exist);
if (data.status_str == 'COMPLETED') {
str += j_row_info('파일 크기', data.filesize_str);
str += j_row_info('다운 속도', data.download_speed);
}
return str;
}
function button_html(data) {
//console.log(data)
str = '';
if (data.status_str == 'DOWNLOADING') {
str = j_button('stop_btn', '중지', {'idx': data.idx}, 'danger', false, false);
}
$("#button_" + data.idx).html(str);
}
function status_html(data) {
var progress = document.getElementById("progress_" + data.idx);
progress.style.width = data.percent + '%';
progress.innerHTML = data.percent + '%';
progress.style.visibility = 'visible';
document.getElementById("status_" + data.idx).innerHTML = data.status_kor;
document.getElementById("current_pf_count_" + data.idx).innerHTML = data.current_pf_count;
document.getElementById("current_speed_" + data.idx).innerHTML = data.current_speed;
document.getElementById("download_time_" + data.idx).innerHTML = data.download_time;
document.getElementById("detail_" + data.idx).innerHTML = get_detail(data);
}
$("body").on('click', '#reset_btn', function (e) {
e.preventDefault();
entity_id = $(this).data('id')
send_data = {'command': 'reset', 'entity_id': -1}
queue_command(send_data)
});
function queue_command(data) {
$.ajax({
url: '/' + package_name + '/ajax/' + sub + '/queue_command',
type: "POST",
cache: false,
data: data,
dataType: "json",
success: function (ret) {
if (ret.ret == 'notify') {
$.notify('<strong>' + ret.log + '</strong>', {type: 'warning'});
}
on_start();
}
});
}
</script>
{% endblock %} {% endblock %}

View File

@@ -222,6 +222,7 @@
$(document).ready(function () { $(document).ready(function () {
$("#loader").css("display", 'none') $("#loader").css("display", 'none')
console.log({{ arg['code'] }})
// console.log('wr_id::', params.wr_id) // console.log('wr_id::', params.wr_id)

View File

@@ -187,6 +187,7 @@
// {# '<span data-tooltip-text="'+data.episode[i].title+'">' + data.episode[i].code + '</span></button></div>';#} // {# '<span data-tooltip-text="'+data.episode[i].title+'">' + data.episode[i].code + '</span></button></div>';#}
tmp += '<h5 class="card-title">' + data.anime_list[i].title + '</h5>'; tmp += '<h5 class="card-title">' + data.anime_list[i].title + '</h5>';
tmp += '<p class="card-text">' + data.anime_list[i].code + '</p>'; tmp += '<p class="card-text">' + data.anime_list[i].code + '</p>';
tmp += '<p class="card-text">' + data.anime_list[i].epx + '</p>';
tmp += '<a href="./request?code=' + data.anime_list[i].code + '" class="btn btn-primary cut-text">' + data.anime_list[i].title + '</a>'; tmp += '<a href="./request?code=' + data.anime_list[i].code + '" class="btn btn-primary cut-text">' + data.anime_list[i].title + '</a>';
tmp += '</div>'; tmp += '</div>';
tmp += '</div>'; tmp += '</div>';
@@ -247,6 +248,7 @@
// {# '<span data-tooltip-text="'+data.episode[i].title+'">' + data.episode[i].code + '</span></button></div>';#} // {# '<span data-tooltip-text="'+data.episode[i].title+'">' + data.episode[i].code + '</span></button></div>';#}
tmp += '<h5 class="card-title">' + data.anime_list[i].title + '</h5>'; tmp += '<h5 class="card-title">' + data.anime_list[i].title + '</h5>';
tmp += '<p class="card-text">' + data.anime_list[i].code + '</p>'; tmp += '<p class="card-text">' + data.anime_list[i].code + '</p>';
tmp += '<p class="card-text">' + data.anime_list[i].epx + '</p>';
tmp += '<a href="' + request_url + '" class="btn btn-primary cut-text">' + data.anime_list[i].title + '</a>'; tmp += '<a href="' + request_url + '" class="btn btn-primary cut-text">' + data.anime_list[i].title + '</a>';
tmp += '</div>'; tmp += '</div>';
tmp += '</div>'; tmp += '</div>';
@@ -602,254 +604,261 @@
max-width: 80%; max-width: 80%;
margin: 0 auto; margin: 0 auto;
} }
}
[data-tooltip-text]:hover { [data-tooltip-text]:hover {
position: relative; position: relative;
} }
[data-tooltip-text]:after { [data-tooltip-text]:after {
-webkit-transition: bottom 0.3s ease-in-out, opacity 0.3s ease-in-out; -webkit-transition: bottom 0.3s ease-in-out, opacity 0.3s ease-in-out;
-moz-transition: bottom 0.3s ease-in-out, opacity 0.3s ease-in-out; -moz-transition: bottom 0.3s ease-in-out, opacity 0.3s ease-in-out;
transition: bottom 0.3s ease-in-out, opacity 0.3s ease-in-out; transition: bottom 0.3s ease-in-out, opacity 0.3s ease-in-out;
background-color: rgba(0, 0, 0, 0.8); background-color: rgba(0, 0, 0, 0.8);
-webkit-box-shadow: 0px 0px 3px 1px rgba(50, 50, 50, 0.4); -webkit-box-shadow: 0px 0px 3px 1px rgba(50, 50, 50, 0.4);
-moz-box-shadow: 0px 0px 3px 1px rgba(50, 50, 50, 0.4); -moz-box-shadow: 0px 0px 3px 1px rgba(50, 50, 50, 0.4);
box-shadow: 0px 0px 3px 1px rgba(50, 50, 50, 0.4); box-shadow: 0px 0px 3px 1px rgba(50, 50, 50, 0.4);
-webkit-border-radius: 5px; -webkit-border-radius: 5px;
-moz-border-radius: 5px; -moz-border-radius: 5px;
border-radius: 5px; border-radius: 5px;
color: #ffffff; color: #ffffff;
font-size: 12px; font-size: 12px;
margin-bottom: 10px; margin-bottom: 10px;
padding: 7px 12px; padding: 7px 12px;
position: absolute; position: absolute;
width: auto; width: auto;
min-width: 50px; min-width: 50px;
max-width: 300px; max-width: 300px;
word-wrap: break-word; word-wrap: break-word;
z-index: 9999; z-index: 9999;
opacity: 0; opacity: 0;
left: -9999px; left: -9999px;
top: 90%; top: 90%;
content: attr(data-tooltip-text); content: attr(data-tooltip-text);
} }
[data-tooltip-text]:hover:after { [data-tooltip-text]:hover:after {
top: 230%; top: 230%;
left: 0; left: 0;
opacity: 1; opacity: 1;
} }
[data-tooltip-text]:hover { [data-tooltip-text]:hover {
position: relative; position: relative;
} }
[data-tooltip-text]:after { [data-tooltip-text]:after {
-webkit-transition: bottom 0.3s ease-in-out, opacity 0.3s ease-in-out; -webkit-transition: bottom 0.3s ease-in-out, opacity 0.3s ease-in-out;
-moz-transition: bottom 0.3s ease-in-out, opacity 0.3s ease-in-out; -moz-transition: bottom 0.3s ease-in-out, opacity 0.3s ease-in-out;
transition: bottom 0.3s ease-in-out, opacity 0.3s ease-in-out; transition: bottom 0.3s ease-in-out, opacity 0.3s ease-in-out;
background-color: rgba(0, 0, 0, 0.8); background-color: rgba(0, 0, 0, 0.8);
-webkit-box-shadow: 0px 0px 3px 1px rgba(50, 50, 50, 0.4); -webkit-box-shadow: 0px 0px 3px 1px rgba(50, 50, 50, 0.4);
-moz-box-shadow: 0px 0px 3px 1px rgba(50, 50, 50, 0.4); -moz-box-shadow: 0px 0px 3px 1px rgba(50, 50, 50, 0.4);
box-shadow: 0px 0px 3px 1px rgba(50, 50, 50, 0.4); box-shadow: 0px 0px 3px 1px rgba(50, 50, 50, 0.4);
-webkit-border-radius: 5px; -webkit-border-radius: 5px;
-moz-border-radius: 5px; -moz-border-radius: 5px;
border-radius: 5px; border-radius: 5px;
color: #ffffff; color: #ffffff;
font-size: 12px; font-size: 12px;
margin-bottom: 10px; margin-bottom: 10px;
padding: 7px 12px; padding: 7px 12px;
position: absolute; position: absolute;
width: auto; width: auto;
min-width: 50px; min-width: 50px;
max-width: 300px; max-width: 300px;
word-wrap: break-word; word-wrap: break-word;
z-index: 9999; z-index: 9999;
opacity: 0; opacity: 0;
left: -9999px; left: -9999px;
top: -210% !important; top: -210% !important;
content: attr(data-tooltip-text); content: attr(data-tooltip-text);
} }
[data-tooltip-text]:hover:after { [data-tooltip-text]:hover:after {
top: 130%; top: 130%;
left: 0; left: 0;
opacity: 1; opacity: 1;
} }
#airing_list { #airing_list {
display: none; display: none;
} }
.cut-text { .cut-text {
text-overflow: ellipsis; text-overflow: ellipsis;
overflow: hidden; overflow: hidden;
white-space: nowrap; white-space: nowrap;
width: 100%; width: 100%;
} }
#screen_movie_list { .btn {
margin-top: 10px; white-space: normal !important;
} word-wrap: break-word;
}
.card-body { #screen_movie_list {
padding: 0 !important; margin-top: 10px;
} }
.card-title { .card-body {
padding: 1rem !important; padding: 0 !important;
} }
button#add_whitelist { .card-title {
float: right; padding: 1rem !important;
} }
button.btn-favorite { button#add_whitelist {
background-color: #e0ff42; float: right;
} }
body { button.btn-favorite {
font-family: NanumSquareNeo, system-ui, -apple-system, Segoe UI, Roboto, Helvetica Neue, Noto Sans, Liberation Sans, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji; background-color: #e0ff42;
} }
body { body {
background-image: linear-gradient(90deg, #233f48, #6c6fa2, #768dae); font-family: NanumSquareNeo, system-ui, -apple-system, Segoe UI, Roboto, Helvetica Neue, Noto Sans, Liberation Sans, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;
} }
.demo { body {
width: 100px; background-image: linear-gradient(90deg, #233f48, #6c6fa2, #768dae);
height: 102px; }
border-radius: 100%;
position: absolute;
top: 45%;
left: calc(50% - 50px);
}
.circle { .demo {
width: 100%; width: 100px;
height: 100%; height: 102px;
position: absolute; border-radius: 100%;
} position: absolute;
top: 45%;
left: calc(50% - 50px);
}
.circle .inner { .circle {
width: 100%; width: 100%;
height: 100%; height: 100%;
border-radius: 100%; position: absolute;
border: 5px solid rgba(0, 255, 170, 0.7); }
border-right: none;
border-top: none;
backgroudn-clip: padding;
box-shadow: inset 0px 0px 10px rgba(0, 255, 170, 0.15);
}
@-webkit-keyframes spin { .circle .inner {
from { width: 100%;
transform: rotate(0deg); height: 100%;
} border-radius: 100%;
to { border: 5px solid rgba(0, 255, 170, 0.7);
transform: rotate(360deg); border-right: none;
} border-top: none;
} backgroudn-clip: padding;
box-shadow: inset 0px 0px 10px rgba(0, 255, 170, 0.15);
}
@keyframes spin { @-webkit-keyframes spin {
from { from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
.circle:nth-of-type(0) {
transform: rotate(0deg); transform: rotate(0deg);
} }
to {
.circle:nth-of-type(0) .inner { transform: rotate(360deg);
-webkit-animation: spin 2s infinite linear;
animation: spin 2s infinite linear;
} }
}
.circle:nth-of-type(1) { @keyframes spin {
transform: rotate(70deg); from {
transform: rotate(0deg);
} }
to {
.circle:nth-of-type(1) .inner { transform: rotate(360deg);
-webkit-animation: spin 2s infinite linear;
animation: spin 2s infinite linear;
} }
}
.circle:nth-of-type(2) { .circle:nth-of-type(0) {
transform: rotate(140deg); transform: rotate(0deg);
} }
.circle:nth-of-type(2) .inner { .circle:nth-of-type(0) .inner {
-webkit-animation: spin 2s infinite linear; -webkit-animation: spin 2s infinite linear;
animation: spin 2s infinite linear; animation: spin 2s infinite linear;
} }
.demo { .circle:nth-of-type(1) {
-webkit-animation: spin 5s infinite linear; transform: rotate(70deg);
animation: spin 5s infinite linear; }
background: rgba(0, 0, 0, 0.2);
background: radial-gradient(#222, #000);
bottom: 0;
left: 0;
overflow: hidden;
/*position: fixed;*/
right: 0;
/*top: 0;*/
z-index: 99999;
opacity: 0.5;
margin: 0 auto;
transform: translate(-50%, -50%);
position: absolute;
top: 50%;
} .circle:nth-of-type(1) .inner {
-webkit-animation: spin 2s infinite linear;
animation: spin 2s infinite linear;
}
.loader-inner { .circle:nth-of-type(2) {
bottom: 0; transform: rotate(140deg);
height: 60px; }
left: 0;
margin: auto; .circle:nth-of-type(2) .inner {
position: absolute; -webkit-animation: spin 2s infinite linear;
right: 0; animation: spin 2s infinite linear;
top: 0; }
width: 100px;
} .demo {
-webkit-animation: spin 5s infinite linear;
animation: spin 5s infinite linear;
background: rgba(0, 0, 0, 0.2);
background: radial-gradient(#222, #000);
bottom: 0;
left: 0;
overflow: hidden;
/*position: fixed;*/
right: 0;
/*top: 0;*/
z-index: 99999;
opacity: 0.5;
margin: 0 auto;
transform: translate(-50%, -50%);
position: absolute;
top: 50%;
}
.loader-inner {
bottom: 0;
height: 60px;
left: 0;
margin: auto;
position: absolute;
right: 0;
top: 0;
width: 100px;
}
#preloader {
/*background-color: green;*/
/*color: white;*/
/*height: 100vh;*/
/*width: 100%;*/
/*position: fixed;*/
/*z-index: 100;*/
background: rgba(0, 0, 0, 0.2);
background: radial-gradient(#222, #000);
bottom: 0;
left: 0;
overflow: hidden;
position: fixed;
right: 0;
top: 0;
z-index: 99999;
opacity: 0.5;
}
#preloader {
/*background-color: green;*/
/*color: white;*/
/*height: 100vh;*/
/*width: 100%;*/
/*position: fixed;*/
/*z-index: 100;*/
background: rgba(0, 0, 0, 0.2);
background: radial-gradient(#222, #000);
bottom: 0;
left: 0;
overflow: hidden;
position: fixed;
right: 0;
top: 0;
z-index: 99999;
opacity: 0.5;
}
</style> </style>
{% endblock %} {% endblock %}

View File

@@ -8,7 +8,7 @@
<span class="col-md-4"> <span class="col-md-4">
<select id="order" name="order" class="form-control form-control-sm"> <select id="order" name="order" class="form-control form-control-sm">
<option value="desc">최근순</option> <option value="desc">최근순</option>
<option value="asc">오래된순</option> <option value="asc">오래된 </option>
</select> </select>
<select id="option" name="option" class="form-control form-control-sm"> <select id="option" name="option" class="form-control form-control-sm">
<option value="all">전체</option> <option value="all">전체</option>
@@ -34,18 +34,23 @@
<div id='page2'></div> <div id='page2'></div>
</div> </div>
{# <script src="{{ url_for('.static', filename='js/sjva_global1.js') }}"></script>#}
{# <script src="{{ url_for('.static', filename='js/sjva_ui14.js') }}"></script>#}
<script type="text/javascript"> <script type="text/javascript">
var package_name = "{{arg['package_name']}}"; var package_name = "{{arg['package_name']}}";
var sub = "{{arg['sub']}}"; var sub = "{{arg['sub']}}";
var current_data = null; var current_data = null;
$(document).ready(function(){ $(document).ready(function(){
global_sub_request_search('1'); {#global_sub_request_search('1');#}
console.log('ready')
globalRequestSearch2('1');
}); });
$("#search").click(function(e) { $("#search").click(function(e) {
e.preventDefault(); e.preventDefault();
global_sub_request_search('1'); {#global_sub_request_search('1');#}
globalRequestSearch2('1');
}); });
$("body").on('click', '#page', function(e){ $("body").on('click', '#page', function(e){

View File

@@ -1,175 +1,141 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block content %} {% block content %}
<div>
{{ macros.m_button_group([['reset_btn', '초기화'], ['delete_completed_btn', '완료 목록 삭제'], ['go_ffmpeg_btn', 'Go FFMPEG']]) }}
{{ macros.m_row_start('0') }}
{{ macros.m_row_end() }}
{{ macros.m_hr_head_top() }}
{{ macros.m_row_start('0') }}
{{ macros.m_col(1, macros.m_strong('Idx')) }}
{{ macros.m_col(2, macros.m_strong('CreatedTime')) }}
{{ macros.m_col(4, macros.m_strong('Filename')) }}
{{ macros.m_col(3, macros.m_strong('Status')) }}
{{ macros.m_col(2, macros.m_strong('Action')) }}
{{ macros.m_row_end() }}
{{ macros.m_hr_head_bottom() }}
<div id="download_list_div"></div>
</div> <!--전체-->
<table id="result_table" class="table table-sm tableRowHover"> <script type="text/javascript">
<thead class="thead-dark"> var package_name = "{{arg['package_name'] }}";
<tr> var sub = "{{arg['sub'] }}";
<th style="width:5%; text-align:center;">IDX</th> var current_data = null;
<th style="width:8%; text-align:center;">Plugin</th> {#socket = io.connect(window.location.protocol + "//" + document.domain + ":" + location.port + "/" + package_name + '/' + sub);#}
<th style="width:10%; text-align:center;">시작시간</th>
<th style="width:20%; text-align:center;">파일명</th>
<th style="width:8%; text-align:center;">상태</th>
<th style="width:15%; text-align:center;">진행률</th>
<th style="width:5%; text-align:center;">길이</th>
<th style="width:5%; text-align:center;">PF</th>
<th style="width:8%; text-align:center;">배속</th>
<th style="width:8%; text-align:center;">진행시간</th>
<th style="width:8%; text-align:center;">Action</th>
</tr>
</thead>
<tbody id="list"></tbody>
</table>
<script type="text/javascript">
$(document).ready(function(){
var socket = io.connect(window.location.href);
socket.on('on_start', function(data){
document.getElementById("log").innerHTML += data.data;
document.getElementById("log").scrollTop = document.getElementById("log").scrollHeight;
document.getElementById("log").style.visibility = 'visible';
$('#loading').hide();
});
socket.on('add', function(data){
str = make_item(data);
if (current_data == null || current_data.length == 0) {
current_data = Array();
$("#list").html(str);
} else {
$("#list").html($("#list").html() + str);
}
current_data.push(data);
});
socket.on('status_change', function(data) {
button_html(data);
});
socket.on('status', function(data){
status_html(data);
});
socket.on('last', function(data){
status_html(data);
button_html(data);
});
globalSendCommand('list', null, null, null, function(data) {
current_data = data;
$("#list").html('');
console.log(data)
if (data.length == 0) {
str = "<tr><td colspan='10'><h4>작업이 없습니다.</h4><td><tr>";
} else {
str = ''
for(i in data) {
str += make_item(data[i]);
}
}
$("#list").html(str);
});
});
$("body").on('click', '#stop_btn', function(e){ $(document).ready(function () {
e.stopPropagation(); console.log(window.location.href)
e.preventDefault(); var socket = io.connect(window.location.href);
globalSendCommand('stop', $(this).data('idx'), null, null, function(ret){ console.log(socket)
refresh_item(ret.data); socket.on('on_start', (data) => {
}); console.log('on_start().............')
}); console.log(data)
})
socket.on('start', function (data) {
console.log('socket start()')
on_start();
});
socket.on('list_refresh', function (data) {
on_start()
});
socket.on('status', function (data) {
console.log(data);
on_status(data)
});
function refresh_item(data) { });
$('#tr1_'+data.idx).html(make_item1(data));
$('#collapse_'+data.idx).html(make_item2(data));
}
function make_item(data) {
str = '<tr id="tr1_'+data.idx+'" style="cursor: pointer;" data-toggle="collapse" data-target="#collapse_'+ data.idx + '" aria-expanded="true" >';
str += make_item1(data);
str += '</tr>';
str += '<tr class="collapse tableRowHoverOff" style="cursor: pointer;" id="collapse_' + data.idx + '">';
str += make_item2(data);
str += '</tr>';
return str;
}
function make_item1(data) {
//console.log(data);
str = '';
str += '<td scope="col" style="width:5%; text-align:center;">'+ data.idx + '</td>';
str += '<td scope="col" style="width:8%; text-align:center;">'+ data.callback_id + '</td>';
str += '<td scope="col" style="width:10%; text-align:center;">'+ data.start_time + '</td>';
str += '<td scope="col" style="width:20%; text-align:center;">'+ data.filename + '</td>';
str += '<td id="status_'+data.idx+'" scope="col" style="width:8%; text-align:center;">'+ data.status_kor + '</td>';
var visi = 'hidden';
if (parseInt(data.percent) > 0) {
visi = 'visible';
}
str += '<td scope="col" style="width:20%; text-align:center;"><div class="progress"><div id="progress_'+data.idx+'" class="progress-bar" style="visibility: '+visi+'; width:'+data.percent+'%">'+data.percent +'%</div></div></td>';
str += '<td scope="col" style="width:5%; text-align:center;">'+ data.duration_str + '</td>';
str += '<td id="current_pf_count_'+data.idx+'" scope="col" style="width:5%; text-align:center;">'+ data.current_pf_count + '</td>';
str += '<td id="current_speed_'+data.idx+'" scope="col" style="width:8%; text-align:center;">'+ data.current_speed + '</td>';
str += '<td id="download_time_'+data.idx+'" scope="col" style="width:8%; text-align:center;">'+ data.download_time + '</td>';
str += '<td id="button_'+data.idx+'" scope="col" style="width:8%; text-align:center;">';
if (data.status_str == 'DOWNLOADING') {
str += j_button('stop_btn', '중지', {'idx':data.idx}, 'danger', false, false);
}
str += '</td>'
return str;
}
function make_item2(data) {
str = '';
str += '<td colspan="11">';
str += '<div id="detail_'+data.idx+'">';
str += get_detail(data);
str += '</div>';
str += '</td>';
return str
}
function get_detail(data) { function on_start() {
var str = j_row_info('URL', data.url); $.ajax({
str += j_row_info('임시경로', data.temp_fullpath); url: '/' + package_name + '/ajax/' + sub + '/entity_list',
str += j_row_info('저장경로', data.save_fullpath); type: "POST",
str += j_row_info('진행률(current/total)', data.percent+ '% (' + data.current_duration + ' / ' + data.duration + ')'); cache: false,
str += j_row_info('현재 비트레이트', data.current_bitrate); data: {},
str += j_row_info('종료시간', data.end_time); dataType: "json",
str += j_row_info('허용 Packet Fail 수', data.max_pf_count); success: function (data) {
str += j_row_info('파일 Exist', data.exist); make_download_list(data)
if (data.status_str == 'COMPLETED') { }
str += j_row_info('파일 크기', data.filesize_str); });
str += j_row_info('다운 속도', data.download_speed); }
}
return str;
}
function button_html(data) {
//console.log(data)
str = '';
if (data.status_str == 'DOWNLOADING') {
str = j_button('stop_btn', '중지', {'idx':data.idx}, 'danger', false, false);
}
$("#button_" + data.idx).html(str);
}
function status_html(data) { function on_status(data) {
var progress = document.getElementById("progress_" + data.idx); //console.log(data)
progress.style.width = data.percent+ '%'; tmp = document.getElementById("progress_" + data.entity_id)
progress.innerHTML = data.percent+ '%'; if (tmp != null) {
progress.style.visibility = 'visible'; document.getElementById("progress_" + data.entity_id).style.width = data.ffmpeg_percent + '%';
document.getElementById("status_" + data.idx).innerHTML = data.status_kor; document.getElementById("progress_" + data.entity_id + "_label").innerHTML = data.ffmpeg_status_kor + "(" + data.ffmpeg_percent + "%)" + ' ' + ((data.ffmpeg_arg != null) ? data.ffmpeg_arg.data.current_speed : '')
document.getElementById("current_pf_count_" + data.idx).innerHTML = data.current_pf_count; }
document.getElementById("current_speed_" + data.idx).innerHTML = data.current_speed; }
document.getElementById("download_time_" + data.idx).innerHTML = data.download_time;
document.getElementById("detail_" + data.idx).innerHTML = get_detail(data);
}
</script> function make_download_list(data) {
str = '';
for (i in data) {
str += m_row_start();
str += m_col(1, data[i].entity_id);
str += m_col(2, data[i].created_time);
str += m_col(4, (data[i].filename != null) ? data[i].filename : '');
label = data[i].ffmpeg_status_kor
if (data[i].ffmpeg_percent != 0) {
label += '(' + data[i].ffmpeg_percent + '%)'
}
tmp = m_progress('progress_' + data[i].entity_id, data[i].ffmpeg_percent, label)
str += m_col(3, tmp);
tmp = m_button('program_cancel_btn', '취소', [{'key': 'id', 'value': data[i].entity_id}]);
tmp = m_button_group(tmp)
str += m_col(2, tmp)
str += m_row_end();
if (i != data.length - 1) str += m_hr(0);
}
document.getElementById("download_list_div").innerHTML = str;
}
$("body").on('click', '#program_cancel_btn', function (e) {
e.preventDefault();
entity_id = $(this).data('id')
send_data = {'command': 'cancel', 'entity_id': entity_id}
queue_command(send_data)
});
$("body").on('click', '#reset_btn', function (e) {
e.preventDefault();
entity_id = $(this).data('id')
send_data = {'command': 'reset', 'entity_id': -1}
queue_command(send_data)
});
$("body").on('click', '#delete_completed_btn', function (e) {
e.preventDefault();
entity_id = $(this).data('id')
send_data = {'command': 'delete_completed', 'entity_id': -1}
queue_command(send_data)
});
function queue_command(data) {
$.ajax({
url: '/' + package_name + '/ajax/' + sub + '/queue_command',
type: "POST",
cache: false,
data: data,
dataType: "json",
success: function (ret) {
if (ret.ret == 'notify') {
$.notify('<strong>' + ret.log + '</strong>', {type: 'warning'});
}
on_start();
}
});
}
$("body").on('click', '#go_ffmpeg_btn', function (e) {
e.preventDefault();
$(location).attr('href', '/ffmpeg')
});
</script>
{% endblock %} {% endblock %}

File diff suppressed because it is too large Load Diff

View File

@@ -30,7 +30,7 @@
{{ macros.setting_global_scheduler_sub_button(arg['scheduler'], arg['is_running']) }} {{ macros.setting_global_scheduler_sub_button(arg['scheduler'], arg['is_running']) }}
{{ macros.setting_input_text('ohli24_interval', '스케쥴링 실행 정보', value=arg['ohli24_interval'], col='3', desc=['Inverval(minute 단위)이나 Cron 설정']) }} {{ macros.setting_input_text('ohli24_interval', '스케쥴링 실행 정보', value=arg['ohli24_interval'], col='3', desc=['Inverval(minute 단위)이나 Cron 설정']) }}
{{ macros.setting_checkbox('ohli24_auto_start', '시작시 자동실행', value=arg['ohli24_auto_start'], desc='On : 시작시 자동으로 스케쥴러에 등록됩니다.') }} {{ macros.setting_checkbox('ohli24_auto_start', '시작시 자동실행', value=arg['ohli24_auto_start'], desc='On : 시작시 자동으로 스케쥴러에 등록됩니다.') }}
{{ macros.setting_input_textarea('ohli24_auto_code_list', '자동 다운로드할 작품 코드', desc=['all 입력시 모두 받기', '구분자 | 또는 엔터'], value=arg['ohli24_auto_code_list'], row='10') }} {{ macros.setting_input_textarea('ohli24_auto_code_list', '자동 다운로드할 작품 코드', desc=['구분자 | 또는 엔터'], value=arg['ohli24_auto_code_list'], row='10') }}
{{ macros.setting_checkbox('ohli24_auto_mode_all', '에피소드 모두 받기', value=arg['ohli24_auto_mode_all'], desc=['On : 이전 에피소드를 모두 받습니다.', 'Off : 최신 에피소드만 받습니다.']) }} {{ macros.setting_checkbox('ohli24_auto_mode_all', '에피소드 모두 받기', value=arg['ohli24_auto_mode_all'], desc=['On : 이전 에피소드를 모두 받습니다.', 'Off : 최신 에피소드만 받습니다.']) }}
{{ macros.m_tab_content_end() }} {{ macros.m_tab_content_end() }}

View File

@@ -7,7 +7,7 @@ WORK_DIR="/Volumes/WD/Users/Work/python/ff_dev_plugins/anime_downloader/yommi_ap
echo "$LINE" echo "$LINE"
echo "* fast api running..." echo "* fast api running..."
echo "$LINE" echo "$LINE"
pip install fastapi uvicorn[standard] playwright #pip install fastapi uvicorn[standard] playwright
# shellcheck disable=SC2164 # shellcheck disable=SC2164
cd "$WORK_DIR" cd "$WORK_DIR"
uvicorn main:app --reload --port=$PORT uvicorn main:app --reload --port=$PORT