v1.6.4 FFmpeg 경로 설정 추가
FFmpeg 경로 설정 추가 API에서 GET 요청 지원
This commit is contained in:
@@ -9,15 +9,19 @@ from flask import jsonify
|
||||
|
||||
# 패키지
|
||||
from .plugin import logger
|
||||
from .my_youtube_dl import Status
|
||||
from .my_youtube_dl import MyYoutubeDL, Status
|
||||
#########################################################
|
||||
|
||||
class LogicNormal(object):
|
||||
youtube_dl_list = []
|
||||
|
||||
@staticmethod
|
||||
def get_youtube_dl_version():
|
||||
return MyYoutubeDL.get_version()
|
||||
|
||||
@staticmethod
|
||||
def get_preset_list():
|
||||
preset_list = [
|
||||
return [
|
||||
['bestvideo+bestaudio/best', '최고 화질'],
|
||||
['bestvideo[height<=1080]+bestaudio/best[height<=1080]', '1080p'],
|
||||
['worstvideo+worstaudio/worst', '최저 화질'],
|
||||
@@ -27,11 +31,10 @@ class LogicNormal(object):
|
||||
['bestaudio/best', '오디오만'],
|
||||
['_custom', '사용자 정의']
|
||||
]
|
||||
return preset_list
|
||||
|
||||
@staticmethod
|
||||
def get_postprocessor_list():
|
||||
postprocessor_list = [
|
||||
return [
|
||||
['', '후처리 안함', None],
|
||||
['mp4', 'MP4', '비디오 변환'],
|
||||
['flv', 'FLV', '비디오 변환'],
|
||||
@@ -51,7 +54,6 @@ class LogicNormal(object):
|
||||
['vorbis', 'Vorbis', '오디오 추출'],
|
||||
['wav', 'WAV', '오디오 추출']
|
||||
]
|
||||
return postprocessor_list
|
||||
|
||||
@staticmethod
|
||||
def get_postprocessor():
|
||||
@@ -64,6 +66,42 @@ class LogicNormal(object):
|
||||
extract_audio.append(i[0])
|
||||
return video_convertor, extract_audio
|
||||
|
||||
@staticmethod
|
||||
def download(**kwagrs):
|
||||
logger.debug(kwagrs)
|
||||
plugin = kwagrs['plugin']
|
||||
url = kwagrs['url']
|
||||
filename = kwagrs['filename']
|
||||
temp_path = kwagrs['temp_path']
|
||||
save_path = kwagrs['save_path']
|
||||
opts = {}
|
||||
if 'format' in kwagrs and kwagrs['format']:
|
||||
opts['format'] = kwagrs['format']
|
||||
postprocessor = []
|
||||
if 'preferedformat' in kwagrs and kwagrs['preferedformat']:
|
||||
postprocessor.append({
|
||||
'key': 'FFmpegVideoConvertor',
|
||||
'preferedformat': kwagrs['preferedformat']
|
||||
})
|
||||
if 'preferredcodec' in kwagrs and kwagrs['preferredcodec']:
|
||||
postprocessor.append({
|
||||
'key': 'FFmpegExtractAudio',
|
||||
'preferredcodec': kwagrs['preferredcodec'],
|
||||
'preferredquality': str(kwagrs['preferredquality'])
|
||||
})
|
||||
if postprocessor:
|
||||
opts['postprocessors'] = postprocessor
|
||||
if 'archive' in kwagrs and kwagrs['archive']:
|
||||
opts['download_archive'] = kwagrs['archive']
|
||||
if 'proxy' in kwagrs and kwagrs['proxy']:
|
||||
opts['proxy'] = kwagrs['proxy']
|
||||
if 'ffmpeg_path' in kwagrs and kwagrs['ffmpeg_path']:
|
||||
opts['ffmpeg_location'] = kwagrs['ffmpeg_path']
|
||||
youtube_dl = MyYoutubeDL(plugin, url, filename, temp_path, save_path, opts)
|
||||
youtube_dl.key = kwagrs.get('key')
|
||||
LogicNormal.youtube_dl_list.append(youtube_dl) # 리스트 추가
|
||||
return youtube_dl
|
||||
|
||||
@staticmethod
|
||||
def get_data(youtube_dl):
|
||||
try:
|
||||
@@ -86,16 +124,16 @@ class LogicNormal(object):
|
||||
data['percent'] = '0'
|
||||
data['eta'] = youtube_dl.progress_hooks['eta'] if youtube_dl.progress_hooks['eta'] is not None else ''
|
||||
data['speed_str'] = LogicNormal.human_readable_size(youtube_dl.progress_hooks['speed'], '/s') if youtube_dl.progress_hooks['speed'] is not None else ''
|
||||
if youtube_dl.status == Status.READY: # 다운로드 전
|
||||
if youtube_dl.status == Status.READY: # 다운로드 전
|
||||
data['start_time'] = ''
|
||||
data['download_time'] = ''
|
||||
else:
|
||||
if youtube_dl.end_time is None: # 완료 전
|
||||
if youtube_dl.end_time is None: # 완료 전
|
||||
download_time = datetime.now() - youtube_dl.start_time
|
||||
else:
|
||||
download_time = youtube_dl.end_time - youtube_dl.start_time
|
||||
data['end_time'] = youtube_dl.end_time.strftime('%m-%d %H:%M:%S')
|
||||
if None not in (youtube_dl.progress_hooks['downloaded_bytes'], youtube_dl.progress_hooks['total_bytes']): # 둘 다 값이 있으면
|
||||
if None not in (youtube_dl.progress_hooks['downloaded_bytes'], youtube_dl.progress_hooks['total_bytes']): # 둘 다 값이 있으면
|
||||
data['downloaded_bytes_str'] = LogicNormal.human_readable_size(youtube_dl.progress_hooks['downloaded_bytes'])
|
||||
data['total_bytes_str'] = LogicNormal.human_readable_size(youtube_dl.progress_hooks['total_bytes'])
|
||||
data['percent'] = '%.2f' % (float(youtube_dl.progress_hooks['downloaded_bytes']) / float(youtube_dl.progress_hooks['total_bytes']) * 100)
|
||||
@@ -107,6 +145,10 @@ class LogicNormal(object):
|
||||
logger.error(traceback.format_exc())
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def get_info_dict(url, proxy):
|
||||
MyYoutubeDL.get_info_dict(url, proxy)
|
||||
|
||||
@staticmethod
|
||||
def human_readable_size(size, suffix=''):
|
||||
for unit in ('Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB'):
|
||||
|
||||
Reference in New Issue
Block a user