Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Videos: Use android test suite client #4650

Merged
merged 4 commits into from Apr 26, 2024

Conversation

SamantazFox
Copy link
Member

@SamantazFox SamantazFox commented Apr 26, 2024

Until a better and more permanent solution is found...
At least, it allows playing regular videos.

Closes #4584

@SamantazFox SamantazFox requested a review from a team as a code owner April 26, 2024 20:04
@SamantazFox SamantazFox requested review from syeopite and removed request for a team April 26, 2024 20:04
@unixfox
Copy link
Member

unixfox commented Apr 26, 2024

We should also use the IOS client for getting the missing pieces. From my draft:

if !new_player_response.nil?
    client_config.client_type = YoutubeAPI::ClientType::IOS
    new_player_response_ios = try_fetch_streaming_data(video_id, client_config)
    if !new_player_response_ios.nil?
      puts typeof(new_player_response["streamingData"])
      adaptiveFormats_to_merge = new_player_response.dig("streamingData", "adaptiveFormats")
      adaptiveFormats_to_merge_ios = new_player_response_ios.dig("streamingData", "adaptiveFormats")
      #puts adaptiveFormats_to_merge
      puts "-----------------------------------------------------------------"
      puts adaptiveFormats_to_merge_ios.as_h
      puts typeof(adaptiveFormats_to_merge_ios)
      #adaptiveFormats_to_merge.as_h.merge(adaptiveFormats_to_merge_ios.as_h)
      #new_player_response["streamingData"] = streamingData_to_merge["streamingData"]
      new_player_response["captions"] = new_player_response_ios["captions"]
      new_player_response["storyboards"] = new_player_response_ios["storyboards"]
    end
    # Preserve storyboard data before replacement
    new_player_response["storyboards"] = player_response["storyboards"] if player_response["storyboards"]?

    player_response = new_player_response
    #puts player_response["streamingData"]
    params.delete("reason")
  end

@SamantazFox
Copy link
Member Author

SamantazFox commented Apr 26, 2024

@unixfox I realized we don't need the storyboards from the IOS client, as we already extract those from the original WEB client request:

# Replace player response and reset reason
if !new_player_response.nil?
# Preserve storyboard data before replacement
new_player_response["storyboards"] = player_response["storyboards"] if player_response["storyboards"]?
player_response = new_player_response
params.delete("reason")
end

All we have to do is also copy the captions over

src/invidious/videos/parser.cr Outdated Show resolved Hide resolved
@SamantazFox SamantazFox merged commit 0ab6d9e into iv-org:master Apr 26, 2024
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] The video returned by YouTube isn't the requested one. (Android client) (VideoNotAvailableException)
3 participants