Skip to content

Add fallback to TvSimply client #5345

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

Open
wants to merge 6 commits into
base: tvsimply-client
Choose a base branch
from

Conversation

Fijxu
Copy link
Member

@Fijxu Fijxu commented Jun 12, 2025

@unixfox
Copy link
Member

unixfox commented Jun 12, 2025

IMO it's better to create just one PR instead of two.

@syeopite syeopite added ready and removed ready labels Jun 12, 2025
Copy link
Member

@syeopite syeopite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the condition below also needs to check for the existence of signatureCipher

if player_fallback_response.dig?("streamingData", "adaptiveFormats", 0, "url")

@Fijxu
Copy link
Member Author

Fijxu commented Jun 12, 2025

You're right. I'll fix it and test it later.

@Fijxu Fijxu force-pushed the fallback-to-tvsimply branch from 08f9169 to 0c96e09 Compare June 12, 2025 20:08
@Fijxu
Copy link
Member Author

Fijxu commented Jun 12, 2025

I wasn't able to test it since Innertube didn't return signatureCipher to me. I added https://github.com/iv-org/invidious-companion/blob/d0c4bb79ae4688d019fb281257859e334adb7d8b/src/lib/helpers/youtubePlayerReq.ts#L92 to companion because when I was working on it, I got signatureCipher but not url.

Maybe we should really add some mocks, test data and crystal tests :/

@@ -146,6 +146,9 @@ def extract_video_info(video_id : String)
if streaming_data = player_response["streamingData"]?
%w[formats adaptiveFormats].each do |key|
streaming_data.as_h[key]?.try &.as_a.each do |format|
if format.as_h["url"].nil?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if format.as_h["url"].nil?
if format.as_h["url"]?.nil?

@@ -146,6 +146,9 @@ def extract_video_info(video_id : String)
if streaming_data = player_response["streamingData"]?
%w[formats adaptiveFormats].each do |key|
streaming_data.as_h[key]?.try &.as_a.each do |format|
if format.as_h["url"].nil?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hash conversion should be called as_h only once:

format = format.as_h

@syeopite
Copy link
Member

syeopite commented Jun 12, 2025

Technically there already are mocks and tests, there's just not enough of it and imo the current system is confusing to understand.

I don't fully understand it myself if I'm being honest but I believe you'll need to update iv-org/mocks with the mock json for this, pull the latest version of the submodule in the invidious repo, and then finally add a test for it here.


players_fallback.each do |player_fallback|
client_config.client_type = player_fallback

next if !(player_fallback_response = try_fetch_streaming_data(video_id, client_config))

if player_fallback_response.dig?("streamingData", "adaptiveFormats", 0, "url")
if player_fallback_response.dig?("streamingData", "adaptiveFormats", 0, "url") || player_fallback_response.dig?("streamingData", "adaptiveFormats", 0, "signatureCipher")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you save the result of player_fallback_response.dig?("streamingData", "adaptiveFormats", 0) to a temporary variable first so that there isn't a double traversal?

Copy link
Member Author

@Fijxu Fijxu Jun 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is cf0a68b good enough?

@Fijxu Fijxu force-pushed the fallback-to-tvsimply branch from 018b666 to cf0a68b Compare June 15, 2025 21:43
@Fijxu
Copy link
Member Author

Fijxu commented Jun 15, 2025

I have taken the opportunity to remove the TV fallback here because of iv-org/invidious-companion#157
TvSimply works fine enough on my instance (https://inv.nadeko.net)

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.

3 participants