[Bug] Ytmusic SAPISIDHASH guard/timestamp bugs and silent getMixedForYou failure cause HTTP 401 & infinite loading
Maintainer thường phản hồi trong vòng 2 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 32/100
Hướng nghiên cứu
Read service/kotlinYtmusicScraper/src/commonMain/kotlin/com/maxrave/kotlinytmusicscraper/Ytmusic.kt around lines 254-260 and 270-275, where the SAPISIDHASH guard, timestamp and Authorization header are built; compare against how InnerTube builds the same header for WEB_REMIX. Then read getMixedForYou() in data/src/commonMain/kotlin/com/maxrave/data/repository/PlaylistRepositoryImpl.kt (lines 677-742) next to getLibraryPlaylist() (lines 634-674) to see the missing failure path. Done means the header carries a current Unix-seconds timestamp with the available __Secure-1PAPISID/__Secure-3PAPISID cookies, and the mixed-for-you Flow emits on failure instead of hanging. Note a pull request (#63) is already open, so coordinate before starting.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
While investigating why the Mix for you (FEmusic_mixed_for_you) tab in SimpMusic v2.6.0 fails with HTTP 401 and hangs on an infinite loading spinner, we traced two bugs in core (multiplatform @ c834002):
1. Broken SAPISIDHASH guard & timestamp in Ytmusic.kt (lines 254-260 & 270-275)
In service/kotlinYtmusicScraper/src/commonMain/kotlin/com/maxrave/kotlinytmusicscraper/Ytmusic.kt:
if ("SAPISID" !in cookieMap || "__Secure-3PAPISID" !in cookieMap) return@let
val currentTime = now().toInstant(TimeZone.currentSystemDefault()).epochSeconds / 1000
val sapisidCookie = cookieMap["SAPISID"] ?: cookieMap["__Secure-3PAPISID"]
val sapisidHash = sha1("$currentTime $sapisidCookie https://music.youtube.com")
append("Authorization", "SAPISIDHASH ${currentTime}_$sapisidHash")
- Inverted boolean guard (
||instead of&&): Line 256 falls back fromSAPISIDto__Secure-3PAPISID, but line 254 (and line 270 ingetAuthorizationHeader()) aborts withreturn@letif either cookie is absent. Modern Chromium/Firefox YouTube sessions frequently carry__Secure-3PAPISID(and/or__Secure-1PAPISID) without legacySAPISID, causingytClientto omit theAuthorizationheader completely. epochSeconds / 1000divides seconds by 1000:Instant.epochSecondsis already in Unix seconds (~1.79e9), so dividing by1000produces~1,795,000(January 1970). When both cookies are present, InnerTube rejects the stale timestamp on strict endpoints likeFEmusic_mixed_for_youwithHTTP 401 UNAUTHENTICATED.- Modern
WEB_REMIXrequests also sendSAPISID1PHASHandSAPISID3PHASHalongsideSAPISIDHASHwhen__Secure-1PAPISID/__Secure-3PAPISIDare present.
2. Missing .onFailure in PlaylistRepositoryImpl.getMixedForYou() (lines 677-742)
In data/src/commonMain/kotlin/com/maxrave/data/repository/PlaylistRepositoryImpl.kt:
- Unlike
getLibraryPlaylist()right above it (lines 634-674),getMixedForYou()only chains.onSuccess { ... }onyouTube.getMixedForYou()and has no.onFailure { emit(null) }handler (and indexestabs?.get(0)/contents?.get(0)rather thanfirstOrNull()). - Whenever
youTube.getMixedForYou()fails (HTTP 401, offline, or timeout), theFlowcompletes with zero emissions, causingLibraryViewModel.getYouTubeMixedForYou()inSimpMusicto remain stuck inLocalResource.Loading()indefinitely.
- Ngôn ngữ chính
- Kotlin
- Star
- 25
- Fork
- 104
- Merge trung bình
- 1 phút
- Pull request đã merge (30 ngày)
- 2
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue tương tự
-
feature request needs decision
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
tswistak/Battery-Monitor#207 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
IzzyOnDroid inclusionĐang mởF-Droid FOSS question
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
d4rken-org/butler#365 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
panel-assistant/android#224 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày