Skip to content

Conversation

@IwantT0Cry
Copy link

This commit includes a series of changes aimed at improving error handling, logging, and playback/download resilience, based on a review of several outstanding issues.

Key changes:

  1. Download Error Handling (DownloadUtil.kt):

    • I enhanced logging in dataSourceFactory when playabilityStatus from YouTube.player() is not "OK", providing more details (status, reason, mediaId) for download preparation failures.
  2. Discord RPC Error Handling (KizzyRPC.kt, DiscordRPC.kt):

    • I added try-catch blocks and android.util.Log statements in KizzyRPC.setActivity() around WebSocket connect and send operations to catch and log potential errors.
    • I added specific error logging in DiscordRPC.updateSong() via .onFailure to better diagnose issues when calling the underlying RPC library.
  3. Innertube Cookie Usage Logging (InnerTube.kt):

    • I added detailed diagnostic logging to the ytClient() method to output the state of setLogin parameter, cookie presence, and useLoginForBrowse property. This will help you verify runtime decisions for making authenticated requests.
  4. Playback Resilience & Error Propagation (YouTube.kt, MusicService.kt, DownloadUtil.kt):

    • I modified innertube/YouTube.kt player() method to ensure that if all client attempts (ANDROID_MUSIC, IOS, TVHTML5) fail to get an "OK" playability status, the error response from the final TVHTML5 attempt is prioritized for return. This provides more relevant error information.
    • I strengthened media format selection logic in MusicService.createDataSourceFactory() and DownloadUtil.dataSourceFactory() by filtering out adaptive formats that have null or blank URLs or mimeTypes before attempting to select the best format. This aims to prevent errors from unusable stream data.
    • I improved handling in DownloadUtil.kt for cases where no suitable download format is found after filtering.

Investigations:

  • My re-investigation of "fix deleted liked in albums" did not uncover new Kotlin code paths that would cause this. Diagnostic logging I added previously remains key.
  • My investigation of "Use cookie in priority if user logged in" (leading to the logging in InnerTube.kt) suggests the core logic for respecting preferences is in place.
  • The playback resilience improvements are aimed at addressing aspects of "Song not playing" and issues related to "Unknown Error" from InnerTube API changes (Update quick pick  #468) by making the client more robust and error information clearer, though a full fix for Update quick pick  #468 would require specific knowledge of that PR.

This commit includes a series of changes aimed at improving error handling, logging, and playback/download resilience, based on a review of several outstanding issues.

Key changes:

1.  **Download Error Handling (`DownloadUtil.kt`):**
    *   I enhanced logging in `dataSourceFactory` when `playabilityStatus` from `YouTube.player()` is not "OK", providing more details (status, reason, mediaId) for download preparation failures.

2.  **Discord RPC Error Handling (`KizzyRPC.kt`, `DiscordRPC.kt`):**
    *   I added try-catch blocks and `android.util.Log` statements in `KizzyRPC.setActivity()` around WebSocket connect and send operations to catch and log potential errors.
    *   I added specific error logging in `DiscordRPC.updateSong()` via `.onFailure` to better diagnose issues when calling the underlying RPC library.

3.  **Innertube Cookie Usage Logging (`InnerTube.kt`):**
    *   I added detailed diagnostic logging to the `ytClient()` method to output the state of `setLogin` parameter, cookie presence, and `useLoginForBrowse` property. This will help you verify runtime decisions for making authenticated requests.

4.  **Playback Resilience & Error Propagation (`YouTube.kt`, `MusicService.kt`, `DownloadUtil.kt`):**
    *   I modified `innertube/YouTube.kt player()` method to ensure that if all client attempts (ANDROID_MUSIC, IOS, TVHTML5) fail to get an "OK" playability status, the error response from the final TVHTML5 attempt is prioritized for return. This provides more relevant error information.
    *   I strengthened media format selection logic in `MusicService.createDataSourceFactory()` and `DownloadUtil.dataSourceFactory()` by filtering out adaptive formats that have null or blank URLs or mimeTypes before attempting to select the best format. This aims to prevent errors from unusable stream data.
    *   I improved handling in `DownloadUtil.kt` for cases where no suitable download format is found after filtering.

Investigations:
*   My re-investigation of "fix deleted liked in albums" did not uncover new Kotlin code paths that would cause this. Diagnostic logging I added previously remains key.
*   My investigation of "Use cookie in priority if user logged in" (leading to the logging in `InnerTube.kt`) suggests the core logic for respecting preferences is in place.
*   The playback resilience improvements are aimed at addressing aspects of "Song not playing" and issues related to "Unknown Error" from InnerTube API changes (z-huang#468) by making the client more robust and error information clearer, though a full fix for z-huang#468 would require specific knowledge of that PR.
@rcky844
Copy link

rcky844 commented Jun 18, 2025

AI generated nonsense, do not merge and close it please.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants