fix: 목록 뽑기 — 주소 없는 영상 제외 + nocookie 도메인 인식

업로드 영상처럼 외부 source_url 이 없는 항목은 `[ID] [URL]` 두 칸
형식이 깨지므로 목록에서 제외한다. youtube-nocookie.com/embed/... 도
YouTube 로 인식해 https://youtu.be/ID 로 간결화한다.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Claude (owner)
2026-06-14 01:55:33 +09:00
parent 745b1db1cc
commit 692a824e78

View File

@@ -308,10 +308,10 @@ opRouter.get(
// ─── 목록 뽑기 (영상 ID + 실제 영상 주소 txt) ──────────────────────────
/** YouTube URL 의 11자 영상 ID 추출. watch?v= / youtu.be / embed / shorts / live 형식 지원. */
/** YouTube URL 의 11자 영상 ID 추출. watch?v= / youtu.be / embed / shorts / live, nocookie 도메인 지원. */
function extractYoutubeId(url: string): string | null {
const m = url.match(
/(?:youtu\.be\/|youtube\.com\/(?:watch\?(?:[^#]*&)?v=|embed\/|shorts\/|live\/|v\/))([\w-]{11})/
/(?:youtu\.be\/|(?:youtube\.com|youtube-nocookie\.com)\/(?:watch\?(?:[^#]*&)?v=|embed\/|shorts\/|live\/|v\/))([\w-]{11})/
)
return m ? m[1] : null
}
@@ -333,9 +333,12 @@ opRouter.get(
res.status(404).send('폴더를 찾을 수 없습니다.')
return
}
const lines = listVideosInFolder(folder.id).map((v) =>
`${v.id} ${videoSourceUrl(v.sourceUrl)}`.trimEnd()
)
// 실제 외부 주소(유튜브/네이버 등)가 있는 영상만. 업로드 영상처럼 주소가
// 없는 항목은 `[ID] [URL]` 두 칸 형식이 깨지므로 목록에서 제외한다.
const lines = listVideosInFolder(folder.id)
.map((v) => ({ id: v.id, url: videoSourceUrl(v.sourceUrl) }))
.filter((r) => r.url !== '')
.map((r) => `${r.id} ${r.url}`)
const body = lines.join('\n') + (lines.length ? '\n' : '')
const baseName = folderPathNames(folder.id).join('_') || 'list'
const asciiName = baseName.replace(/[^\x20-\x7e]+/g, '_').replace(/["\\]/g, '_')