Switch to user Chrome CDP for YouTube transcript, fix auth and ads
- Replace Playwright standalone browser with CDP connection to user Chrome (bypasses YouTube bot detection by using logged-in Chrome session) - Add video playback, ad detection/skip, and play confirmation before transcript extraction - Extract transcript JS to separate resource files (fix SyntaxError in evaluate) - Add ytInitialPlayerResponse-based transcript extraction as primary method - Fix token refresh: retry on network error during backend restart - Fix null userId logout, CLOB type hint for structured_content - Disable XFCE screen lock/screensaver - Add troubleshooting entries (#10-12) and YouTube transcript guide Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -210,3 +210,100 @@ sudo firewall-cmd --reload
|
||||
```
|
||||
|
||||
자세한 내용은 [setup-xwindow.md](setup-xwindow.md) 참조.
|
||||
|
||||
---
|
||||
|
||||
## 10. VNC 접속 시 스크린 락(화면 잠금) 걸림
|
||||
|
||||
### 증상
|
||||
- VNC로 접속하면 검은 화면에 로그인 다이얼로그가 뜸
|
||||
- 잠시 자리를 비운 뒤 접속하면 사용자 비밀번호를 요구
|
||||
|
||||
### 원인
|
||||
XFCE 스크린세이버가 기본 활성화되어 있어, 일정 시간 비활성 후 화면을 잠금.
|
||||
|
||||
### 해결
|
||||
|
||||
```bash
|
||||
export DISPLAY=:1
|
||||
|
||||
# 스크린세이버 비활성화
|
||||
xfconf-query -c xfce4-screensaver -p /saver/enabled --create -t bool -s false
|
||||
|
||||
# 화면 잠금 비활성화
|
||||
xfconf-query -c xfce4-screensaver -p /lock/enabled --create -t bool -s false
|
||||
xfconf-query -c xfce4-screensaver -p /lock/saver-activation/enabled --create -t bool -s false
|
||||
|
||||
# 모니터 절전(DPMS) 비활성화
|
||||
xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/dpms-enabled --create -t bool -s false
|
||||
xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/lock-screen-suspend-hibernate --create -t bool -s false
|
||||
|
||||
# 잠금 명령 제거
|
||||
xfconf-query -c xfce4-session -p /general/LockCommand --create -t string -s ""
|
||||
|
||||
# 실행 중인 screensaver 프로세스 종료
|
||||
ps aux | grep -E 'xfce4-screensaver|screensaver-dialog' | grep -v grep | awk '{print $2}' | xargs kill 2>/dev/null
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 11. YouTube 자막 추출 시 광고 때문에 실패
|
||||
|
||||
### 증상
|
||||
- Playwright로 YouTube 페이지 로드 후 자막 패널이 열리지 않음
|
||||
- VNC에서 보면 광고가 재생 중
|
||||
|
||||
### 원인
|
||||
YouTube 동영상 앞에 프리롤 광고가 삽입되면 본 영상 UI(자막 패널 등)가 활성화되지 않음.
|
||||
|
||||
### 해결
|
||||
코드에 `waitForAdsToFinish()` 로직이 포함되어 있음:
|
||||
- 최대 60초간 2초 간격으로 광고 상태 확인
|
||||
- 스킵 버튼(`.ytp-skip-ad-button` 등)이 나타나면 자동 클릭
|
||||
- 광고가 끝나면 자막 추출 진행
|
||||
|
||||
수동으로 확인하려면 VNC에서 Playwright 브라우저 창을 직접 관찰.
|
||||
|
||||
---
|
||||
|
||||
## 12. 백엔드 재시작 시 로그인이 풀림
|
||||
|
||||
### 증상
|
||||
- 백엔드(`pm2 restart sundol-backend`) 후 프론트엔드에서 로그인 화면으로 튕김
|
||||
- 로그에 `User logged out: null` 표시
|
||||
|
||||
### 원인
|
||||
1. 백엔드 재시작 중 프론트엔드가 API 호출 → 연결 실패(네트워크 에러)
|
||||
2. axios 인터셉터가 401로 인식 → refresh 시도 → 서버 아직 안 떠서 실패
|
||||
3. `onRefreshFailed` 콜백 → 자동 로그아웃 실행
|
||||
|
||||
### 해결
|
||||
프론트엔드 axios 인터셉터에서 refresh 실패 시 네트워크 에러이면 3초 후 최대 2회 재시도:
|
||||
|
||||
```typescript
|
||||
const attemptRefresh = async (retryCount: number): Promise<string> => {
|
||||
try {
|
||||
const res = await api.post<LoginResponse>("/api/auth/refresh");
|
||||
return res.data.accessToken;
|
||||
} catch (err) {
|
||||
const isNetworkError = !((err as AxiosError).response);
|
||||
if (isNetworkError && retryCount < 2) {
|
||||
await new Promise((r) => setTimeout(r, 3000));
|
||||
return attemptRefresh(retryCount + 1);
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
백엔드 logout에도 userId null 체크 추가:
|
||||
```java
|
||||
if (userId == null) {
|
||||
log.warn("Logout called with null userId, ignoring");
|
||||
return;
|
||||
}
|
||||
```
|
||||
|
||||
### 예방
|
||||
- 백엔드 재시작 시 기동 완료까지 약 10~25초 소요
|
||||
- 프론트엔드는 네트워크 에러 시 최대 9초(3초 × 3회) 대기 후 재시도
|
||||
|
||||
Reference in New Issue
Block a user