feat: 연령제한 영상용 YouTube 쿠키(cookies.txt) 등록 + yt-dlp --cookies 적용
연령 제한("Sign in to confirm your age") 영상이 플레이리스트 임포트에서
실패하던 문제 해결. 관리자 대시보드에서 Netscape cookies.txt 를 등록하면
단일/플레이리스트 probe 와 실제 다운로드에 모두 --cookies 로 적용된다.
쿠키는 data/cookies.txt 에 0600 으로 저장(git 제외). 연령/로그인 실패 시
yt-dlp 원문 대신 쿠키 등록을 안내하는 메시지를 표시.
Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
This commit is contained in:
@@ -128,4 +128,74 @@
|
||||
})
|
||||
|
||||
if (document.querySelector('.toolsSection')) loadTools()
|
||||
|
||||
// YouTube 쿠키 관리
|
||||
var cookieSection = document.getElementById('cookiesSection')
|
||||
if (cookieSection) {
|
||||
var cookieStatusEl = document.getElementById('cookieStatus')
|
||||
var cookieFileEl = document.getElementById('cookieFile')
|
||||
var cookieUploadBtn = document.getElementById('cookieUploadBtn')
|
||||
var cookieDeleteBtn = document.getElementById('cookieDeleteBtn')
|
||||
var cookieMsgEl = document.getElementById('cookieMsg')
|
||||
|
||||
function renderCookies(c) {
|
||||
if (c && c.present) {
|
||||
var kb = Math.max(1, Math.round(c.bytes / 1024))
|
||||
var when = c.updatedAt ? new Date(c.updatedAt).toLocaleString() : ''
|
||||
cookieStatusEl.textContent = '등록됨 (' + kb + ' KB' + (when ? ' · ' + when : '') + ')'
|
||||
cookieDeleteBtn.hidden = false
|
||||
} else {
|
||||
cookieStatusEl.textContent = '등록되지 않음'
|
||||
cookieDeleteBtn.hidden = true
|
||||
}
|
||||
}
|
||||
|
||||
function loadCookies() {
|
||||
fetch('/op/cookies').then(function (r) { return r.json() }).then(function (j) {
|
||||
if (j.ok) renderCookies(j.cookies)
|
||||
}).catch(function () {})
|
||||
}
|
||||
|
||||
cookieUploadBtn.addEventListener('click', function () {
|
||||
var file = cookieFileEl.files && cookieFileEl.files[0]
|
||||
if (!file) { cookieMsgEl.textContent = '파일을 선택해 주세요.'; return }
|
||||
var fd = new FormData()
|
||||
fd.append('file', file)
|
||||
cookieUploadBtn.disabled = true
|
||||
cookieMsgEl.textContent = '등록 중…'
|
||||
fetch('/op/cookies', { method: 'POST', body: fd })
|
||||
.then(function (r) { return r.json() })
|
||||
.then(function (j) {
|
||||
if (j.ok) {
|
||||
cookieMsgEl.textContent = '등록 완료'
|
||||
cookieFileEl.value = ''
|
||||
renderCookies(j.cookies)
|
||||
} else {
|
||||
cookieMsgEl.textContent = '실패: ' + (j.message || '알 수 없는 오류')
|
||||
}
|
||||
})
|
||||
.catch(function (err) {
|
||||
cookieMsgEl.textContent = '실패: ' + (err && err.message ? err.message : '요청 오류')
|
||||
})
|
||||
.then(function () { cookieUploadBtn.disabled = false })
|
||||
})
|
||||
|
||||
cookieDeleteBtn.addEventListener('click', function () {
|
||||
if (!window.confirm('등록된 YouTube 쿠키를 삭제할까요?')) return
|
||||
cookieDeleteBtn.disabled = true
|
||||
cookieMsgEl.textContent = '삭제 중…'
|
||||
fetch('/op/cookies/delete', { method: 'POST' })
|
||||
.then(function (r) { return r.json() })
|
||||
.then(function (j) {
|
||||
if (j.ok) { cookieMsgEl.textContent = '삭제됨'; renderCookies(j.cookies) }
|
||||
else cookieMsgEl.textContent = '실패: ' + (j.message || '알 수 없는 오류')
|
||||
})
|
||||
.catch(function (err) {
|
||||
cookieMsgEl.textContent = '실패: ' + (err && err.message ? err.message : '요청 오류')
|
||||
})
|
||||
.then(function () { cookieDeleteBtn.disabled = false })
|
||||
})
|
||||
|
||||
loadCookies()
|
||||
}
|
||||
})()
|
||||
|
||||
Reference in New Issue
Block a user