Skip to content

Conversation

@Redirion
Copy link
Member

@Redirion Redirion commented Dec 25, 2019

  • I carefully read the contribution guidelines and agree to them.
  • I did test the API against NewPipe.
  • I agree to ASAP create a PULL request for NewPipe for making in compatible when I changed the api.

This fixes #228

But in NewPipe we should also add a handling that will show the proper Youtube Error Message. At least it won't crash anymore if getName fails.

P.S.: don't judge me for committing on Christmas please. I have slow internet and thought I could do something useful while waiting.

@Redirion Redirion changed the title do not crash if getName fails, do not crash if getName fails Dec 25, 2019
@Redirion Redirion changed the title do not crash if getName fails ChannelInfo: do not crash if getName fails Dec 25, 2019
@TobiGr TobiGr added the bug Issue is related to a bug label Dec 26, 2019
info.addError(nameFailure);
// this is so severe, that other extractions most likely fail anyway,
// so skip them
return info;
Copy link
Contributor

Choose a reason for hiding this comment

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

That's not good and will fail in a NullPointerExcepetion. The frontend assumes, that when a ChannelInfo is returned there is information which can be processed. We need to fail here because we cannot get any information.
Just throw the ParsingException when obtainErrorMessage() brings no result. When obtainErrorMessage() returned an error message, I suggest to throw a ContentNotAvailableException with the message and then adjust the frontend handlers to display it. Can you check how long the other messages are, which are passed to other ContentNotAvailableException's? If they are too long or not helpful, we might need to add a new displayMessage attribute.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's not good and will fail in a NullPointerException. The frontend assumes, that when a ChannelInfo is returned there is information which can be processed.

but this is inline with the other cases. For instance

try {
           info.setOriginalUrl(extractor.getOriginalUrl());
       } catch (Exception e) {
           info.addError(e);
       }

would also render a NullPointerException if the originalUrl would be obtained without checking in frontend as there is no setting of an empty url in error case.

Copy link
Member Author

@Redirion Redirion Jan 8, 2020

Choose a reason for hiding this comment

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

I am now throwing the ContentNotAvailableException as requested. So I have renamed the PR as it now basically just gets a user readable error message.

Copy link
Contributor

Choose a reason for hiding this comment

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

I thought about extending the ContentNotAvailableException like this:

public class ContentNotAvailableException extends ParsingException {
    /**
     * Reason why content is not available.
     * Can be displayed to the user
     */
    private String reason;

   ....

    public ContentNotAvailableException(String message, String reason) {
        super(message);
        this.reason = reason;
    }

   public ContentNotAvailableException(String message, String reason, Throwable cause) {
        super(message, cause);
        this.reason = reason;
    }

    ....

    /**
     * {@link ContentNotAvailableException#reason}
     * @return null when no reason is available
     */
    public String getReason() {
        return reason;
    }

This allows us to display the reason in the app by checking if the reason is not null, otherwise display the generic "content unavailable" message.
We could also create an ContentNotAvailableErrorInfo Class which holds this information. @yausername @Stypox @Redirion What do you think?

Copy link
Member Author

@Redirion Redirion Feb 7, 2020

Choose a reason for hiding this comment

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

maybe instead of adding a new method (getReason) we could use an Java API method that should be fitting:
getLocalizedMessage (it actually is localized)

Copy link
Member

Choose a reason for hiding this comment

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

I think @Redirion idea is good, since it follows the answer provided here: https://stackoverflow.com/questions/24988491/difference-between-e-getmessage-and-e-getlocalizedmessage
The issue is: what would getMessage() return? In theory it should return a non-localized reason, but obviously it can't, so is it OK for it to also return a localized message?

Copy link
Member Author

Choose a reason for hiding this comment

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

If I understood @TobiGr correctly, he wants to have getMessage() return the none localized text "Could not get channel name" when getName() fails. Which was the state prior to this PR. With this PR getMessage() would return the localized error message from youtube that is now extracted with "obtainErrorMessage".

getLocalizedMessage just returns what getName returns if not overridden. So if we want to have both we could use getLocalizedMessage() (as an alternative to adding a new method like Tobi suggested)

Copy link
Member

Choose a reason for hiding this comment

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

Oh that makes sense, then I agree with you, getLocalizedMessage is a good idea

@Redirion Redirion changed the title ChannelInfo: do not crash if getName fails ChannelInfo: if getName() fails, try to check if there is a user readable error message Jan 8, 2020
@ShareASmile
Copy link
Collaborator

@TobiGr @Stypox this also needs to be implemented. Just a reminder.

@TobiGr
Copy link
Contributor

TobiGr commented Feb 24, 2020

@gillhash Thanks.
@Redirion We might need to update this after we solved #258

@Redirion
Copy link
Member Author

#228 (comment)

@Redirion Redirion closed this Apr 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue is related to a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ParsingException is thrown on deleted or non-existant channels

4 participants