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

Add new exceptions to be able to display different error messages in apps #509

Merged
merged 13 commits into from
Mar 7, 2021

Conversation

AudricV
Copy link
Member

@AudricV AudricV commented Jan 10, 2021

This PR add six new exceptions to be able to display different error messages in NewPipe when user tries to play an unplayable content. All of these exceptions extend the ContentNotAvailableException.

  • AgeRestrictedContentException, for age-restricted content which has no video or audio streams.

  • GeographicRestrictionException, for georestricted content (used for SoundCloud and YouTube georestricted videos, not working on YouTube Music georestricted tracks because YouTube shows "This video is not available")

  • PaidContentException, for paid content like YouTube movies or YouTube videos that require a channel subscription

  • PrivateContentException, for private YouTube videos (can be used for other services)

  • SoundCloudGoPlusContentException, for SoundCloud Go+ tracks

  • YoutubeMusicPremiumContentException, for YouTube videos restricted to YouTube Music Premium members

  • I carefully read the contribution guidelines and agree to them.

  • I have tested the API against NewPipe.

  • I agree to create a pull request for NewPipe as soon as possible to make it compatible with the changed API. Better error messages for SoundCloud and YouTube unavailable contents NewPipe#5385

@Stypox
Copy link
Member

Stypox commented Jan 17, 2021

That's normal for soundcloud. It happens since there there are no valid audio formats to play

@Stypox
Copy link
Member

Stypox commented Jan 17, 2021

You could do that in another PR and not touch anything about streams here

@AudricV AudricV force-pushed the soundcloud-improvements branch 3 times, most recently from 639ed9a to fc2734f Compare January 18, 2021 17:49
@AudricV AudricV changed the title Add two new exceptions to extractor + try to support SoundCloud HLS playback (with a workaround) Add two new exceptions to extractor Jan 18, 2021
@AudricV AudricV marked this pull request as ready for review January 18, 2021 17:50
@AudricV
Copy link
Member Author

AudricV commented Jan 18, 2021

@Stypox Done. Code is ready for review.

@AudricV AudricV force-pushed the soundcloud-improvements branch from fc2734f to c20d35d Compare January 18, 2021 18:15
Copy link
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

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

Except from that one thing it looks good ;-)

@AudricV
Copy link
Member Author

AudricV commented Jan 20, 2021

@Stypox Changes requested applied.

Copy link
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

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

Looks good, thank you! This will be merged after 0.20.9 is released

@AudricV AudricV force-pushed the soundcloud-improvements branch 2 times, most recently from 6742295 to 2956d8e Compare January 23, 2021 17:02
@AudricV AudricV force-pushed the soundcloud-improvements branch 2 times, most recently from 35e497c to d27b627 Compare February 5, 2021 18:13
@AudricV AudricV force-pushed the soundcloud-improvements branch from d27b627 to 716edef Compare February 14, 2021 14:25
@AudricV AudricV changed the title Add two new exceptions to extractor Add five new exceptions to be able to display different error messages in apps Feb 14, 2021
@AudricV AudricV force-pushed the soundcloud-improvements branch from 716edef to 646649a Compare February 15, 2021 16:53
Copy link
Contributor

@TobiGr TobiGr left a comment

Choose a reason for hiding this comment

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

Looks good.
Can be merge once the conflict is solved.

@AudricV
Copy link
Member Author

AudricV commented Feb 15, 2021

@TobiGr Unfortunately, it doesn't work for some videos from type of https://www.youtube.com/watch?v=ayI2iBwGdxw (members-only content), so it shouldn't be merged until this is fixed.

@opusforlife2
Copy link
Collaborator

@TiA4f8R You could always do that in a later PR and let this one be merged. 4 out of 5 or 80% is pretty good, no?

@AudricV AudricV force-pushed the soundcloud-improvements branch from 646649a to 38a2927 Compare February 19, 2021 17:53
@AudricV
Copy link
Member Author

AudricV commented Feb 19, 2021

@opusforlife2 You're right. Also, when I updated my PR, I added a check and if the reason message is null, NewPipe shows now the default Content Unavailable message. With this check, no Could not get any stream exception is thrown so this bug isn't a blocker and the PR can be merged without something strange.

@TobiGr
Copy link
Contributor

TobiGr commented Feb 19, 2021

Some tests fail, because the exceptions changed. Please fix them

@AudricV
Copy link
Member Author

AudricV commented Feb 19, 2021

@TobiGr Done. Thanks to letting me know this because it would have broken the extraction of unexisiting YouTube videos. So it was not tests but my code.

@TobiGr TobiGr added enhancement New feature or request soundcloud service, https://soundcloud.com/ youtube service, https://www.youtube.com/ labels Feb 22, 2021
@rocketinventor
Copy link

Hi, I was testing this out with the apk from Pull Request #5385 by @TiA4f8R (which implements these error messages) and I found another type of error that is not on this list - Restricted Mode errors...

If YouTube's restricted mode is enabled in NewPipe and a "restricted" video is opened in the player then a generic "Content unavailable" message will be displayed. Someone who is unaware of this will think that there is an issue with the video extractor.

There should be a way to detect this... Does anybody know how to do this?

@TobiGr
Copy link
Contributor

TobiGr commented Feb 23, 2021

@rocketinventor That might need an exception. However, we detected that before, but after some refactoring, the detection does not work any more. Good catch!
That should be easy to fix in this PR.

I suggest to do the following (@XiangRongLin, @B0pol, @Stypox any other ideas how to solve this?):

For later (maybe not in this PR): we should a add a AgeRestrictedContentException. We will need this in the future once YouTube disabled age restricted videos completely for users who are not logged in. As far as I can see, it is not possible to obtain the streamingData from the given JSON now. I don't know how much info is going to be available after YouTube applied some more changes to age restricted content.


And why the hell are the tests failing again -_-

@AudricV
Copy link
Member Author

AudricV commented Feb 23, 2021

And why the hell are the tests failing again -_-

It's a SoundCloud intermittent test failure (the search test), so don't worry ;)

@rocketinventor
Copy link

@TiA4f8R would your method work for opening a video through a direct link, or only from within the app?


Also, just to be clear, there are two levels of age restricted content (in YouTube) - each corresponding with thier own setting in NewPipe:

Potentially Mature Content - Videos
blocked by "Restricted Mode":

Turn on YouTube's "Restricted Mode"
YouTube provides a "Restricted Mode" which hides potentially mature content

Restricted (Mature) Content - Videos unblocked through the following opt-in:

Show age restricted content
Show content possibly unsuitable for children because it has an age limit (like 18+)

If there is a way to detect one of these vs the other, then they should probably each have there own exceptions. If not, the error messages, at least, should be different (depending on which content restriction settings are in place from within NewPipe).

I.e. If a video is blocked while "Restricted Mode" is on then the message maybe should suggest to disable "Restricted Mode" to see the video.

@rocketinventor
Copy link

I just tested this with the video URL for a "restricted" video from #4869 (same apk as before). The "This video is age restricted." error message definitely does work when "restricted mode" is off.

@TobiGr TobiGr changed the title Add five new exceptions to be able to display different error messages in apps Add new exceptions to be able to display different error messages in apps Feb 24, 2021
@TobiGr TobiGr requested a review from Stypox February 24, 2021 13:28
@AudricV AudricV force-pushed the soundcloud-improvements branch from 5499df7 to f62404d Compare February 26, 2021 14:53
AudricV added 6 commits March 5, 2021 16:38
…ewPipe Extractor to be able to display different error messages

This commit adds two new exceptions in NewPipe Extractor: GeographicRestrictionException and SoundCloudGoPlusException (which extend to ContentNotAvailableException). These exceptions allow showing different error messages to user when a content isn't available in his/her/its country (only used for now by SoundCloudStreamExtractor) or when the content is a SoundCloud Go+ track.
These exceptions are thrown on a test with the error messages text, because YouTube returns only "UNPLAYABLE" status in most error cases.
Tests are based with English strings, so changing the lang used by
extractor will throw the generic exception (ContentNotAvailableException).
@AudricV AudricV force-pushed the soundcloud-improvements branch from f62404d to e55284b Compare March 5, 2021 15:38
TobiGr and others added 7 commits March 5, 2021 16:38
Also check if related streams are empty if they are expected to be empty.
The ContentNotSupportedException is thrown because no supported audio streams where extracted. However, SoundCLoud does not check, whether there are any streams available. 
This commit should be reverted in TeamNewPipe#526
AgeRestrictedException will be thrown only if the reason message equals to "Sign in to confirm your age" and if the age limit is 18.
Use final where possible in YoutubeStreamExtractor and do some other code style improvements
@TobiGr TobiGr merged commit 7e6f464 into TeamNewPipe:dev Mar 7, 2021
@AudricV AudricV deleted the soundcloud-improvements branch March 7, 2021 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request soundcloud service, https://soundcloud.com/ youtube service, https://www.youtube.com/
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants