v1.5.0 프록시 설정 추가
프록시 설정 추가 API에 archive 추가 status API의 시간 형식 변경 (ISO 8601)
This commit is contained in:
@@ -74,6 +74,7 @@ API에선 직접 비트레이트를 설정할 수 있습니다.
|
||||
`preferedformat` | 변환할 비디오 포맷. 가능한 포맷은 https://ffmpeg.org/general.html#File-Formats 참고. 미지정 시 변환하지 않음 | X | String
|
||||
`preferredcodec` | 추출할 오디오 코덱. 가능한 값은 `"best"`, `"mp3"`, `"aac"`, `"flac"`, `"m4a"`, `"opus"`, `"vorbis"`, `"wav"`. 미지정 시 추출하지 않음 | X | String
|
||||
`preferredquality` | 추출한 오디오의 비트레이트. 0 ~ 9 사이의 VBR 퀄리티 값(0에 가까울수록 좋음) 혹은 특정 비트레이트 값. `preferredcodec` 키가 있을 때만 유효. 기본값: `192` | X | Integer
|
||||
`archive` | 다운로드한 동영상의 ID를 기록할 파일 경로. 파일이 이미 있을 경우 이미 다운로드한 동영상은 다운로드 하지 않음. 미지정 시 기록하지 않음 | X | String
|
||||
`start` | 다운로드 준비 후 바로 다운로드를 시작할지 여부. 기본값: `false` | X | Boolean
|
||||
#### Response
|
||||
키 | 설명 | 타입
|
||||
@@ -127,10 +128,16 @@ API에선 직접 비트레이트를 설정할 수 있습니다.
|
||||
`temp_path` | 임시 폴더 경로 | String
|
||||
`save_path` | 저장 폴더 경로 | String
|
||||
|
||||
`start_time` 키와 `end_time` 키에 들어있는 시간은 "년 월 일 시 분 초" 형식으로 공백으로 분리된 숫자들이 모여있는 문자열입니다.
|
||||
`start_time` 키와 `end_time` 키에 들어있는 시간은 "YYYY-MM-DDThh:mm:ss" 형식의 문자열입니다.
|
||||
물론 해당 정보가 없으면 null입니다.
|
||||
|
||||
## Changelog
|
||||
v1.5.0
|
||||
* 프록시 설정 추가
|
||||
* API에 archive 추가
|
||||
download-archive 기능으로 다운로드한 동영상의 ID를 기록하여 이미 다운로드한 동영상은 다운로드 하지 않는 옵션입니다.
|
||||
* status API의 시간 형식 변경 (ISO 8601)
|
||||
|
||||
v1.4.2
|
||||
* --rm-cache-dir 옵션 추가
|
||||
* 플러그인 최초 설치 시 작동 안 되는 문제 수정
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"description": "\uc720\ud29c\ube0c, \ub124\uc774\ubc84TV \ub4f1 \ub3d9\uc601\uc0c1 \uc0ac\uc774\ud2b8\uc5d0\uc11c \ub3d9\uc601\uc0c1 \ub2e4\uc6b4\ub85c\ub4dc", "name": "youtube-dl", "more": "", "version": "1.4.2", "home": "https://github.com/joyfuI/youtube-dl", "category_name": "vod", "developer": "joyfuI"}
|
||||
{"description": "\uc720\ud29c\ube0c, \ub124\uc774\ubc84TV \ub4f1 \ub3d9\uc601\uc0c1 \uc0ac\uc774\ud2b8\uc5d0\uc11c \ub3d9\uc601\uc0c1 \ub2e4\uc6b4\ub85c\ub4dc", "name": "youtube-dl", "more": "", "version": "1.5.0", "home": "https://github.com/joyfuI/youtube-dl", "category_name": "vod", "developer": "joyfuI"}
|
||||
1
logic.py
1
logic.py
@@ -23,6 +23,7 @@ class Logic(object):
|
||||
'temp_path': os.path.join(path_data, 'download_tmp'),
|
||||
'save_path': os.path.join(path_data, 'download'),
|
||||
'default_filename': '%(title)s-%(id)s.%(ext)s',
|
||||
'proxy': '',
|
||||
'activate_cors': False
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ class Youtube_dl(object):
|
||||
_index = 0
|
||||
_last_msg = ''
|
||||
|
||||
def __init__(self, plugin, url, filename, temp_path, save_path, format_code=None, postprocessor=None):
|
||||
def __init__(self, plugin, url, filename, temp_path, save_path, format_code=None, postprocessor=None, proxy='', archive=None):
|
||||
self.plugin = plugin
|
||||
self.url = url
|
||||
self.filename = filename
|
||||
@@ -55,6 +55,8 @@ class Youtube_dl(object):
|
||||
self.save_path = save_path
|
||||
self.format_code = format_code
|
||||
self.postprocessor = postprocessor
|
||||
self.proxy = proxy
|
||||
self.archive = archive
|
||||
self.index = Youtube_dl._index
|
||||
Youtube_dl._index += 1
|
||||
self._status = Status.READY
|
||||
@@ -111,6 +113,10 @@ class Youtube_dl(object):
|
||||
ydl_opts['format'] = self.format_code
|
||||
if self.postprocessor is not None:
|
||||
ydl_opts['postprocessors'] = self.postprocessor
|
||||
if not self.proxy:
|
||||
ydl_opts['proxy'] = self.proxy
|
||||
if self.archive is not None:
|
||||
ydl_opts['download_archive'] = self.archive
|
||||
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
|
||||
ydl.download([self.url])
|
||||
if self.status == Status.FINISHED: # 다운로드 성공
|
||||
|
||||
13
plugin.py
13
plugin.py
@@ -34,7 +34,7 @@ menu = {
|
||||
}
|
||||
|
||||
plugin_info = {
|
||||
'version': '1.4.2',
|
||||
'version': '1.5.0',
|
||||
'name': 'youtube-dl',
|
||||
'category_name': 'vod',
|
||||
'developer': 'joyfuI',
|
||||
@@ -105,6 +105,7 @@ def ajax(sub):
|
||||
save_path = ModelSetting.get('save_path')
|
||||
format_code = request.form['format'] if request.form['format'] else None
|
||||
postprocessor = request.form['postprocessor'] if request.form['postprocessor'] else None
|
||||
proxy = ModelSetting.get('proxy')
|
||||
video_convertor, extract_audio = LogicNormal.get_postprocessor()
|
||||
if postprocessor in video_convertor:
|
||||
postprocessor = [{
|
||||
@@ -117,7 +118,7 @@ def ajax(sub):
|
||||
'preferredcodec': postprocessor,
|
||||
'preferredquality': '192'
|
||||
}]
|
||||
youtube_dl = Youtube_dl(package_name, url, filename, temp_path, save_path, format_code, postprocessor)
|
||||
youtube_dl = Youtube_dl(package_name, url, filename, temp_path, save_path, format_code, postprocessor, proxy)
|
||||
LogicNormal.youtube_dl_list.append(youtube_dl) # 리스트 추가
|
||||
youtube_dl.start()
|
||||
socketio_emit('add', youtube_dl)
|
||||
@@ -179,6 +180,7 @@ def api(sub):
|
||||
preferedformat = request.form.get('preferedformat', None)
|
||||
preferredcodec = request.form.get('preferredcodec', None)
|
||||
preferredquality = request.form.get('preferredquality', 192)
|
||||
archive = request.form.get('archive', None)
|
||||
start = request.form.get('start', False)
|
||||
ret = {
|
||||
'errorCode': 0,
|
||||
@@ -202,7 +204,8 @@ def api(sub):
|
||||
'preferredcodec': preferredcodec,
|
||||
'preferredquality': str(preferredquality)
|
||||
})
|
||||
youtube_dl = Youtube_dl(plugin, url, filename, temp_path, save_path, format_code, postprocessor)
|
||||
proxy = ModelSetting.get('proxy')
|
||||
youtube_dl = Youtube_dl(plugin, url, filename, temp_path, save_path, format_code, postprocessor, proxy, archive)
|
||||
youtube_dl.key = key
|
||||
LogicNormal.youtube_dl_list.append(youtube_dl) # 리스트 추가
|
||||
ret['index'] = youtube_dl.index
|
||||
@@ -274,8 +277,8 @@ def api(sub):
|
||||
if youtube_dl.key != key:
|
||||
return LogicNormal.abort(ret, 4) # 키가 일치하지 않음
|
||||
ret['status'] = youtube_dl.status.name
|
||||
ret['start_time'] = youtube_dl.start_time.strftime('%Y %m %d %H %M %S') if youtube_dl.start_time is not None else None
|
||||
ret['end_time'] = youtube_dl.end_time.strftime('%Y %m %d %H %M %S') if youtube_dl.end_time is not None else None
|
||||
ret['start_time'] = youtube_dl.start_time.strftime('%Y-%m-%dT%H:%M:%S') if youtube_dl.start_time is not None else None
|
||||
ret['end_time'] = youtube_dl.end_time.strftime('%Y-%m-%dT%H:%M:%S') if youtube_dl.end_time is not None else None
|
||||
ret['temp_path'] = youtube_dl.temp_path
|
||||
ret['save_path'] = youtube_dl.save_path
|
||||
return jsonify(ret)
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
var package_name = '{{ arg["package_name"] }}';
|
||||
const package_name = '{{ arg["package_name"] }}';
|
||||
|
||||
$(function () {
|
||||
// 프리셋 변경
|
||||
@@ -64,7 +64,7 @@
|
||||
|
||||
// 다운로드
|
||||
$('#download_start').click(function () {
|
||||
var url = $('#url').val();
|
||||
let url = $('#url').val();
|
||||
if (url.startsWith('http') === false) {
|
||||
$.notify('<strong>URL을 입력하세요.</strong>', {
|
||||
type: 'warning'
|
||||
@@ -82,7 +82,7 @@
|
||||
postprocessor: $('#postprocessor').val()
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
success: function () {
|
||||
$.notify('<strong>분석중..</strong>', {
|
||||
type: 'info'
|
||||
});
|
||||
|
||||
@@ -37,10 +37,10 @@
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
var package_name = '{{ arg["package_name"] }}';
|
||||
const package_name = '{{ arg["package_name"] }}';
|
||||
|
||||
$(function () {
|
||||
var socket = io.connect(location.origin + "/" + package_name);
|
||||
let socket = io.connect(location.origin + "/" + package_name);
|
||||
|
||||
socket.on('add', function (data) {
|
||||
$('#list').append(make_item(data));
|
||||
@@ -57,16 +57,16 @@
|
||||
data: { },
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
var str = '';
|
||||
for (var i in data) {
|
||||
str += make_item(data[i]);
|
||||
let str = '';
|
||||
for (let i of data) {
|
||||
str += make_item(i);
|
||||
}
|
||||
$('#list').html(str);
|
||||
}
|
||||
});
|
||||
|
||||
$('#list').on('click', '.youtube-dl_stop', function () {
|
||||
var index = $(this).data('index');
|
||||
let index = $(this).data('index');
|
||||
$.ajax({
|
||||
url: '/' + package_name + '/ajax/stop',
|
||||
type: 'POST',
|
||||
@@ -75,7 +75,7 @@
|
||||
index: index
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
success: function () {
|
||||
location.reload(); // 새로고침
|
||||
}
|
||||
});
|
||||
@@ -84,7 +84,7 @@
|
||||
});
|
||||
|
||||
function make_item(data) {
|
||||
var str = '<tr id="item_' + data.index + '" style="cursor: pointer;" data-toggle="collapse" data-target="#collapse_' + data.index + '" aria-expanded="true">';
|
||||
let str = '<tr id="item_' + data.index + '" style="cursor: pointer;" data-toggle="collapse" data-target="#collapse_' + data.index + '" aria-expanded="true">';
|
||||
str += get_item(data);
|
||||
str += '</tr>';
|
||||
str += '<tr class="collapse tableRowHoverOff" style="cursor: pointer;" id="collapse_' + data.index + '">';
|
||||
@@ -98,19 +98,19 @@
|
||||
}
|
||||
|
||||
function get_item(data) {
|
||||
var str = '<td scope="col">' + (data.index + 1) + '</td>';
|
||||
str += '<td scope="col">' + data.plugin + '</td>';
|
||||
str += '<td scope="col">' + data.start_time + '</td>';
|
||||
str += '<td scope="col">' + data.extractor + '</td>';
|
||||
str += '<td scope="col">' + data.title + '</td>';
|
||||
str += '<td scope="col">' + data.status_ko + '</td>';
|
||||
var visi = 'hidden';
|
||||
let str = '<td>' + (data.index + 1) + '</td>';
|
||||
str += '<td>' + data.plugin + '</td>';
|
||||
str += '<td>' + data.start_time + '</td>';
|
||||
str += '<td>' + data.extractor + '</td>';
|
||||
str += '<td>' + data.title + '</td>';
|
||||
str += '<td>' + data.status_ko + '</td>';
|
||||
let visi = 'hidden';
|
||||
if (parseInt(data.percent) > 0 && data.status_str !== 'STOP') {
|
||||
visi = 'visible';
|
||||
}
|
||||
str += '<td scope="col"><div class="progress"><div class="progress-bar" style="visibility: ' + visi + '; width:' + data.percent + '%">' + data.percent + '%</div></div></td>';
|
||||
str += '<td scope="col">' + data.download_time + '</td>';
|
||||
str += '<td scope="col" class="tableRowHoverOff">';
|
||||
str += '<td><div class="progress"><div class="progress-bar" style="visibility: ' + visi + '; width:' + data.percent + '%">' + data.percent + '%</div></div></td>';
|
||||
str += '<td>' + data.download_time + '</td>';
|
||||
str += '<td class="tableRowHoverOff">';
|
||||
if (data.status_str === 'START' || data.status_str === 'DOWNLOADING' || data.status_str === 'FINISHED') {
|
||||
str += '<button class="align-middle btn btn-outline-danger btn-sm youtube-dl_stop" data-index="' + data.index + '">중지</button>';
|
||||
}
|
||||
@@ -119,7 +119,7 @@
|
||||
}
|
||||
|
||||
function get_detail(data) {
|
||||
var str = info_html('URL', data.url, data.url);
|
||||
let str = info_html('URL', data.url, data.url);
|
||||
str += info_html('업로더', data.uploader, data.uploader_url);
|
||||
str += info_html('임시폴더', data.temp_path);
|
||||
str += info_html('저장폴더', data.save_path);
|
||||
@@ -135,8 +135,8 @@
|
||||
}
|
||||
|
||||
function info_html(left, right, option) {
|
||||
var str = '<div class="row">';
|
||||
var link = (left === 'URL' || left === '업로더');
|
||||
let str = '<div class="row">';
|
||||
let link = (left === 'URL' || left === '업로더');
|
||||
str += '<div class="col-sm-2">';
|
||||
str += '<b>' + left + '</b>';
|
||||
str += '</div>';
|
||||
|
||||
@@ -4,22 +4,23 @@
|
||||
<div>
|
||||
{{ macros.setting_input_text('youtube_dl_version', 'youtube-dl 버전', value=arg['youtube_dl_version']) }}
|
||||
<form id="setting">
|
||||
{{ macros.setting_input_text('temp_path', '임시 폴더', value=arg['temp_path'], placeholder='임시 폴더 경로', desc='다운로드 파일이 임시로 저장될 폴더 입니다.') }}
|
||||
{{ macros.setting_input_text('save_path', '저장 폴더', value=arg['save_path'], placeholder='저장 폴더 경로', desc='정상적으로 완료된 파일이 이동할 폴더 입니다.') }}
|
||||
{{ macros.setting_input_text('default_filename', '기본 파일명', value=arg['default_filename'], placeholder='저장 폴더 경로', desc=['템플릿 규칙은 https://github.com/ytdl-org/youtube-dl/blob/master/README.md#output-template 참고', '기본값은 "%(title)s-%(id)s.%(ext)s"입니다.']) }}
|
||||
{{ macros.setting_checkbox('activate_cors', 'CORS 허용', value=arg['activate_cors'], desc='API로의 크로스 도메인 요청을 허용합니다. 설정 저장 후 재시작이 필요합니다.') }}
|
||||
{{ macros.setting_button([['setting_save', '저장']]) }}
|
||||
{{ macros.setting_input_text('temp_path', '임시 폴더', value=arg['temp_path'], placeholder='임시 폴더 경로', desc='다운로드 파일이 임시로 저장될 폴더 입니다.') }}
|
||||
{{ macros.setting_input_text('save_path', '저장 폴더', value=arg['save_path'], placeholder='저장 폴더 경로', desc='정상적으로 완료된 파일이 이동할 폴더 입니다.') }}
|
||||
{{ macros.setting_input_text('default_filename', '기본 파일명', value=arg['default_filename'], placeholder='저장 폴더 경로', desc=['템플릿 규칙은 https://github.com/ytdl-org/youtube-dl/blob/master/README.md#output-template 참고', '기본값은 "%(title)s-%(id)s.%(ext)s"입니다.']) }}
|
||||
{{ macros.setting_input_text('proxy', '프록시', value=arg['proxy'], placeholder='프록시 주소', desc=['HTTP/HTTPS/SOCKS를 지원합니다. 예) socks5://127.0.0.1:1080/', '빈칸으로 두면 프록시를 사용하지 않습니다.']) }}
|
||||
{{ macros.setting_checkbox('activate_cors', 'CORS 허용', value=arg['activate_cors'], desc='API로의 크로스 도메인 요청을 허용합니다. 설정 저장 후 재시작이 필요합니다.') }}
|
||||
{{ macros.setting_button([['setting_save', '저장']]) }}
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
var package_name = '{{ arg["package_name"] }}';
|
||||
const package_name = '{{ arg["package_name"] }}';
|
||||
|
||||
$(function () {
|
||||
// 설정 저장
|
||||
$('#setting_save').click(function () {
|
||||
var formData = get_formdata('#setting');
|
||||
let formData = get_formdata('#setting');
|
||||
$.ajax({
|
||||
url: '/' + package_name + '/ajax/setting_save',
|
||||
type: 'POST',
|
||||
|
||||
Reference in New Issue
Block a user