From 25688db3765d4aff533dffa0da439a1fd9474a9d Mon Sep 17 00:00:00 2001 From: projectdx Date: Tue, 27 Jan 2026 16:01:52 +0900 Subject: [PATCH] Linkkf Fixes: resolve unknown sub add_queue and JS errors, refactor file handling, bump version to 0.7.16 --- info.yaml | 2 +- lib/util.py | 11 ++-- mod_linkkf.py | 1 + .../anime_downloader_linkkf_request.html | 52 +++++++++++-------- 4 files changed, 35 insertions(+), 31 deletions(-) diff --git a/info.yaml b/info.yaml index 9153a27..03853f2 100644 --- a/info.yaml +++ b/info.yaml @@ -1,5 +1,5 @@ title: "애니 다운로더" -version: 0.7.15 +version: 0.7.16 package_name: "anime_downloader" developer: "projectdx" description: "anime downloader" diff --git a/lib/util.py b/lib/util.py index 76e1954..4387f49 100644 --- a/lib/util.py +++ b/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()) diff --git a/mod_linkkf.py b/mod_linkkf.py index 544f9b5..923e345 100644 --- a/mod_linkkf.py +++ b/mod_linkkf.py @@ -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 diff --git a/templates/anime_downloader_linkkf_request.html b/templates/anime_downloader_linkkf_request.html index 82057e7..4966fe6 100644 --- a/templates/anime_downloader_linkkf_request.html +++ b/templates/anime_downloader_linkkf_request.html @@ -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('다운로드 작업을 추가 하였습니다.', {type: 'success'}); - } else if (data.ret == 'queue_exist') { + } else if (ret.ret == 'queue_exist') { $.notify('이미 큐에 있습니다. 삭제 후 추가하세요.', {type: 'warning'}); - } else if (data.ret == 'db_completed') { + } else if (ret.ret == 'db_completed') { $.notify('DB에 완료 기록이 있습니다.', {type: 'warning'}); - } else if (data.ret == 'file_exists') { + } else if (ret.ret == 'file_exists') { $.notify('파일이 이미 존재합니다.', {type: 'warning'}); + } else if (ret.ret == 'extract_failed') { + $.notify('추가 실패: 영상 주소 추출에 실패하였습니다.', {type: 'warning'}); } else { - $.notify('추가 실패
' + ret.log, {type: 'warning'}); + const msg = ret.log || '알 수 없는 이유로 추가에 실패하였습니다.'; + $.notify('추가 실패
' + 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('선택하세요.', {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('백그라운드로 작업을 추가합니다.', {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('선택하세요.', {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('백그라운드로 자막 다운로드를 시작합니다.', {type: 'success'}); } else { - $.notify('자막 다운로드 요청 실패: ' + data.log + '', {type: 'warning'}); + const msg = ret.log || '알 수 없는 이유로 요청에 실패하였습니다.'; + $.notify('자막 다운로드 요청 실패: ' + msg + '', {type: 'warning'}); } } });