Linkkf Fixes: resolve unknown sub add_queue and JS errors, refactor file handling, bump version to 0.7.16
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
title: "애니 다운로더"
|
||||
version: 0.7.15
|
||||
version: 0.7.16
|
||||
package_name: "anime_downloader"
|
||||
developer: "projectdx"
|
||||
description: "anime downloader"
|
||||
|
||||
11
lib/util.py
11
lib/util.py
@@ -32,10 +32,8 @@ def download(url, file_name):
|
||||
def read_file(filename):
|
||||
try:
|
||||
import codecs
|
||||
ifp = codecs.open(filename, 'r', encoding='utf8')
|
||||
data = ifp.read()
|
||||
ifp.close()
|
||||
return data
|
||||
with codecs.open(filename, 'r', encoding='utf8') as ifp:
|
||||
return ifp.read()
|
||||
except Exception as exception:
|
||||
logger.error('Exception:%s', exception)
|
||||
logger.error(traceback.format_exc())
|
||||
@@ -79,9 +77,8 @@ class Util(object):
|
||||
def write_file(data, filename):
|
||||
try:
|
||||
import codecs
|
||||
ofp = codecs.open(filename, 'w', encoding='utf8')
|
||||
ofp.write(data)
|
||||
ofp.close()
|
||||
with codecs.open(filename, 'w', encoding='utf8') as ofp:
|
||||
ofp.write(data)
|
||||
except Exception as exception:
|
||||
logger.debug('Exception:%s', exception)
|
||||
logger.debug(traceback.format_exc())
|
||||
|
||||
@@ -196,6 +196,7 @@ class LogicLinkkf(AnimeModuleBase):
|
||||
logger.error(traceback.format_exc())
|
||||
ret["ret"] = "error"
|
||||
ret["log"] = str(e)
|
||||
return jsonify(ret)
|
||||
elif sub == "add_queue_checked_list":
|
||||
# 선택된 에피소드 일괄 추가 (백그라운드 스레드로 처리)
|
||||
import threading
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
const package_name = "{{arg['package_name'] }}";
|
||||
const sub = "{{arg['sub'] }}";
|
||||
const ohli24_url = "{{arg['ohli24_url']}}";
|
||||
// let current_data = '';
|
||||
var current_data = null;
|
||||
|
||||
const params = new Proxy(new URLSearchParams(window.location.search), {
|
||||
get: (searchParams, prop) => searchParams.get(prop),
|
||||
@@ -288,26 +288,29 @@
|
||||
|
||||
$("body").on('click', '#add_queue_btn', function (e) {
|
||||
e.preventDefault();
|
||||
data = current_data.episode[$(this).data('idx')];
|
||||
// console.log('data:::>', data)
|
||||
let episode_data = current_data.episode[$(this).data('idx')];
|
||||
// console.log('episode_data:::>', episode_data)
|
||||
$.ajax({
|
||||
url: '/' + package_name + '/ajax/' + sub + '/add_queue',
|
||||
type: "POST",
|
||||
cache: false,
|
||||
data: {data: JSON.stringify(data)},
|
||||
data: {data: JSON.stringify(episode_data)},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
// console.log('#add_queue_btn::data >>', data)
|
||||
if (data.ret == 'enqueue_db_append' || data.ret == 'enqueue_db_exist') {
|
||||
success: function (ret) {
|
||||
// console.log('#add_queue_btn::ret >>', ret)
|
||||
if (ret.ret == 'enqueue_db_append' || ret.ret == 'enqueue_db_exist' || ret.ret == 'enqueue_gdm_success') {
|
||||
$.notify('<strong>다운로드 작업을 추가 하였습니다.</strong>', {type: 'success'});
|
||||
} else if (data.ret == 'queue_exist') {
|
||||
} else if (ret.ret == 'queue_exist') {
|
||||
$.notify('<strong>이미 큐에 있습니다. 삭제 후 추가하세요.</strong>', {type: 'warning'});
|
||||
} else if (data.ret == 'db_completed') {
|
||||
} else if (ret.ret == 'db_completed') {
|
||||
$.notify('<strong>DB에 완료 기록이 있습니다.</strong>', {type: 'warning'});
|
||||
} else if (data.ret == 'file_exists') {
|
||||
} else if (ret.ret == 'file_exists') {
|
||||
$.notify('<strong>파일이 이미 존재합니다.</strong>', {type: 'warning'});
|
||||
} else if (ret.ret == 'extract_failed') {
|
||||
$.notify('<strong>추가 실패: 영상 주소 추출에 실패하였습니다.</strong>', {type: 'warning'});
|
||||
} else {
|
||||
$.notify('<strong>추가 실패</strong><br>' + ret.log, {type: 'warning'});
|
||||
const msg = ret.log || '알 수 없는 이유로 추가에 실패하였습니다.';
|
||||
$.notify('<strong>추가 실패</strong><br>' + msg, {type: 'warning'});
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -316,13 +319,14 @@
|
||||
|
||||
$("body").on('click', '#check_download_btn', function (e) {
|
||||
e.preventDefault();
|
||||
let selected_data = [];
|
||||
$('input[id^="checkbox_"]').each(function() {
|
||||
if ($(this).prop('checked')) {
|
||||
idx = parseInt($(this).attr('id').split('_')[1])
|
||||
data.push(current_data.episode[idx]);
|
||||
let idx = parseInt($(this).attr('id').split('_')[1]);
|
||||
selected_data.push(current_data.episode[idx]);
|
||||
}
|
||||
});
|
||||
if (data.length == 0) {
|
||||
if (selected_data.length == 0) {
|
||||
$.notify('<strong>선택하세요.</strong>', {type: 'warning'});
|
||||
return;
|
||||
}
|
||||
@@ -330,9 +334,9 @@
|
||||
url: '/' + package_name + '/ajax/' + sub + '/add_queue_checked_list',
|
||||
type: "POST",
|
||||
cache: false,
|
||||
data: {data: JSON.stringify(data)},
|
||||
data: {data: JSON.stringify(selected_data)},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
success: function (ret) {
|
||||
$.notify('<strong>백그라운드로 작업을 추가합니다.</strong>', {type: 'success'});
|
||||
}
|
||||
});
|
||||
@@ -340,13 +344,14 @@
|
||||
|
||||
$("body").on('click', '#down_subtitle_btn', function (e) {
|
||||
e.preventDefault();
|
||||
let selected_data = [];
|
||||
$('input[id^="checkbox_"]').each(function() {
|
||||
if ($(this).prop('checked')) {
|
||||
idx = parseInt($(this).attr('id').split('_')[1]);
|
||||
data.push(current_data.episode[idx]);
|
||||
let idx = parseInt($(this).attr('id').split('_')[1]);
|
||||
selected_data.push(current_data.episode[idx]);
|
||||
}
|
||||
});
|
||||
if (data.length == 0) {
|
||||
if (selected_data.length == 0) {
|
||||
$.notify('<strong>선택하세요.</strong>', {type: 'warning'});
|
||||
return;
|
||||
}
|
||||
@@ -354,13 +359,14 @@
|
||||
url: '/' + package_name + '/ajax/' + sub + '/add_sub_queue_checked_list',
|
||||
type: "POST",
|
||||
cache: false,
|
||||
data: {data: JSON.stringify(data)},
|
||||
data: {data: JSON.stringify(selected_data)},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (data.ret == "success") {
|
||||
success: function (ret) {
|
||||
if (ret.ret == "success") {
|
||||
$.notify('<strong>백그라운드로 자막 다운로드를 시작합니다.</strong>', {type: 'success'});
|
||||
} else {
|
||||
$.notify('<strong>자막 다운로드 요청 실패: ' + data.log + '</strong>', {type: 'warning'});
|
||||
const msg = ret.log || '알 수 없는 이유로 요청에 실패하였습니다.';
|
||||
$.notify('<strong>자막 다운로드 요청 실패: ' + msg + '</strong>', {type: 'warning'});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user