From 51dcacc7283d17f02eb6ffad38ff886eb38f4c02 Mon Sep 17 00:00:00 2001 From: joungmin Date: Mon, 15 Jun 2026 12:41:35 +0900 Subject: [PATCH] =?UTF-8?q?fix(scan):=20#291=20YouTubeService.fetchChannel?= =?UTF-8?q?Videos=20publishedAfter=20=EC=A1=B0=EA=B8=B0=20=EC=A2=85?= =?UTF-8?q?=EB=A3=8C=20=EB=B2=84=EA=B7=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 업로드 재생목록(uploads playlist) 스캔에서 publishedAfter 이전 영상을 만나 break해도, do-while 조건이 응답의 nextPageToken을 보고 paging을 지속하던 결함. 수정: - stopPaging boolean 플래그 추가 - inner-loop 조기 break에서 stopPaging = true - outer paging 갱신 시 stopPaging 검사 우선 영향: - 백필 효율 향상 (불필요한 API quota 소모 방지) - 봇 감지 회피 (과한 페이징 요청 안 함) - daemon 자동 모드의 안정적 동작 기반 Refs: #291 #321 --- .../src/main/java/com/tasteby/service/YouTubeService.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/backend-java/src/main/java/com/tasteby/service/YouTubeService.java b/backend-java/src/main/java/com/tasteby/service/YouTubeService.java index fcf8e44..34f29dc 100644 --- a/backend-java/src/main/java/com/tasteby/service/YouTubeService.java +++ b/backend-java/src/main/java/com/tasteby/service/YouTubeService.java @@ -59,6 +59,7 @@ public class YouTubeService { String uploadsPlaylistId = "UU" + channelId.substring(2); List> allVideos = new ArrayList<>(); String nextPage = null; + boolean stopPaging = false; try { do { @@ -88,7 +89,7 @@ public class YouTubeService { // publishedAfter 필터: 이미 스캔한 영상 이후만 if (publishedAfter != null && publishedAt.compareTo(publishedAfter) <= 0) { // 업로드 재생목록은 최신순이므로 이전 날짜 만나면 중단 - nextPage = null; + stopPaging = true; break; } @@ -105,7 +106,9 @@ public class YouTubeService { } allVideos.addAll(pageVideos); - if (nextPage != null || data.has("nextPageToken")) { + if (stopPaging) { + nextPage = null; + } else { nextPage = data.has("nextPageToken") ? data.path("nextPageToken").asText() : null; } } while (nextPage != null);