fix(scan): #291 YouTubeService.fetchChannelVideos publishedAfter 조기 종료 버그

업로드 재생목록(uploads playlist) 스캔에서 publishedAfter 이전 영상을 만나
break해도, do-while 조건이 응답의 nextPageToken을 보고 paging을 지속하던 결함.

수정:
- stopPaging boolean 플래그 추가
- inner-loop 조기 break에서 stopPaging = true
- outer paging 갱신 시 stopPaging 검사 우선

영향:
- 백필 효율 향상 (불필요한 API quota 소모 방지)
- 봇 감지 회피 (과한 페이징 요청 안 함)
- daemon 자동 모드의 안정적 동작 기반

Refs: #291 #321
This commit is contained in:
joungmin
2026-06-15 12:41:35 +09:00
parent dc8a8e9b4c
commit 51dcacc728

View File

@@ -59,6 +59,7 @@ public class YouTubeService {
String uploadsPlaylistId = "UU" + channelId.substring(2);
List<Map<String, Object>> 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);