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

Hotfixes for YouTube and improve unavailable cases #267

Merged
merged 11 commits into from
Mar 1, 2020

Conversation

mauriciocolli
Copy link
Contributor

Fix the issues that I mentioned in #262, and some more that I found along the way.


YouTube

  • Take into account videos that have their views hidden.
  • Handle videos with no views or with "Recommended to you" text.
  • Handle video premiere's date and duration.
  • Avoid crashing by letting exceptions bubble up.
    • reCAPTCHAS, for example, were not reaching where they should, resulting in a crash instead of opening it for the user to solve.
    • Maybe there's a better way/approach to how the exceptions are handled in the extractor (e.g. communicate error to front end, error propagation), I'll take a look some time.
  • Fix bug when url isn't present in the browseEndpoint object.
  • Detect simple 404s in the standard fetch method.
  • Detect deleted/nonexistent/invalid channels and playlists.
  • Detect when a stream is deleted or doesn't exist.

Downloader

  • Make test downloader return a response instead of throwing an exception.
  • Add latest url to the response to make detection of a redirect possible.
  • Ignore null-keyed entries when iterating through the response headers.

@wb9688
Copy link
Contributor

wb9688 commented Mar 1, 2020

Thanks a lot for your PR! I wanted to implement the things you wrote about, but now that's not needed anymore. I'll take a closer look in a few hours.

@wb9688
Copy link
Contributor

wb9688 commented Mar 1, 2020

I just found another bug, which could be fixed by looping over all badges in getStreamType() in YoutubeStreamInfoItemExtractor. Could you please do that?

final String viewCount = getTextFromObject(viewCountObject);

if (viewCount.toLowerCase().contains("no views")) {
return 0;
Copy link
Member

Choose a reason for hiding this comment

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

Are there no other ways than relying on English?

Copy link
Member

@TobiGr TobiGr Mar 1, 2020

Choose a reason for hiding this comment

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

At the moment there is no other way. We might need to check whether the value contains specific words like "no" or "you", which should be quite similar in most languages. In that way, we do not need to make a list for all translations later, but can reduce that to a minimum of items to check. But that ca wait for a later PR.

@TobiGr
Copy link
Member

TobiGr commented Mar 1, 2020

I just found another bug, which could be fixed by looping over all badges in getStreamType() in YoutubeStreamInfoItemExtractor. Could you please do that?

@wb9688 Do you mean something like

JsonArray badges = videoInfo.getArray("badges");
for (Object badge : badges) {
    if (((JsonObject) badge).getObject("metadataBadgeRenderer").getString("label").equals("LIVE NOW")) {
        return StreamType.LIVE_STREAM;
    }
}

@wb9688
Copy link
Contributor

wb9688 commented Mar 1, 2020

@TobiGr: That's exactly what I meant.

@TobiGr
Copy link
Member

TobiGr commented Mar 1, 2020

@wb9688 I could not find any StreamInfoItem which has two badges while running the tests from #266. Do you have a link to a document which contains such a case? I found one.

@B0pol
Copy link
Member

B0pol commented Mar 1, 2020

@wb9688 I could not find any StreamInfoItem which has two badges while running the tests from #266. Do you have a link to a document which contains such a case? I found one.

can you give me a link please?

@TobiGr
Copy link
Member

TobiGr commented Mar 1, 2020

@TobiGr TobiGr merged commit 830b7d3 into TeamNewPipe:dev Mar 1, 2020
@mauriciocolli
Copy link
Contributor Author

One more issue though: when opening a premiere video, it's not throwing the right exception.

We should add more status checks here.

@mauriciocolli
Copy link
Contributor Author

Also, @TobiGr what about we disable these protected branches shenanigans?

In a lot of pull requests I see, it's infested with "merge branch dev into <branch>", because people keep pressing the update button.

For example, this one and #265 should be perfectly able to perform a simple merge. Then you don't need to overwrite the commits and rewrite history (I like seeing those verified commits).

@TobiGr
Copy link
Member

TobiGr commented Mar 1, 2020

@mauriciocolli
Should I add request.url() to https://github.com/TeamNewPipe/NewPipe/blob/b1eaf5616ad25abf2907d3283abae04334cbcdb2/app/src/main/java/org/schabi/newpipe/DownloaderImpl.java#L174? I think that is what you intended to have there. Is that correct?

@TobiGr
Copy link
Member

TobiGr commented Mar 1, 2020

In a lot of pull requests I see, it's infested with "merge branch dev into ", because people keep pressing the update button.

Yes, I hate that, too. I'd like people to rebase their commits to a have a readable history. We need to find a solution for this.

@wb9688
Copy link
Contributor

wb9688 commented Mar 1, 2020

@TobiGr: Does GitHub not have a rebase and merge button?

@mauriciocolli
Copy link
Contributor Author

mauriciocolli commented Mar 1, 2020

@TobiGr no, it should be latest url that response was produced to. In case of a redirection, the response would be made to the redirected url.

Here's a diff of what should be done:

diff --git a/app/src/main/java/org/schabi/newpipe/DownloaderImpl.java b/app/src/main/java/org/schabi/newpipe/DownloaderImpl.java
index 0ae072c66..6591fcbda 100644
--- a/app/src/main/java/org/schabi/newpipe/DownloaderImpl.java
+++ b/app/src/main/java/org/schabi/newpipe/DownloaderImpl.java
@@ -171,7 +171,9 @@ public class DownloaderImpl extends Downloader {
             responseBodyToReturn = body.string();
         }
 
-        return new Response(response.code(), response.message(), response.headers().toMultimap(), responseBodyToReturn);
+        final String latestUrl = response.request().url().toString();
+
+        return new Response(response.code(), response.message(), response.headers().toMultimap(), responseBodyToReturn, latestUrl);
     }
 
     /**

The Response#request returns the request that it originated from, then we can get the url.

Also, there's the other issue that I mentioned, so please wait a little bit longer.

Yes, I hate that, too. I'd like people to rebase their commits to a have a readable history. We need to find a solution for this.

Edit: I was thinking of the merge situation when I wrote below, but yes, would be nice.

I think this is about the protected branch:

protected_branch

I think if we disable that, we can merge requests without that merge hell. Imagine 10 pull requests and having to update each one. I think the update button would work, but then even more merge commits would be produced.

@TobiGr
Copy link
Member

TobiGr commented Mar 1, 2020

Here's a diff of what should be done:

Thanks. I'll change this when updating the extractor version.

One more issue though: when opening a premiere video, it's not throwing the right exception.

Ok. Are you on it, or should I take a look at it?

I think if we disable that, we can merge requests without that merge hell. Imagine 10 pull requests and having to update each one. I think the update button would work, but then even more merge commits would be produced.

ok.

@mauriciocolli
Copy link
Contributor Author

@wb9688: I just found another bug, which could be fixed by looping over all badges in getStreamType() in YoutubeStreamInfoItemExtractor. Could you please do that?

TobiGr pushed this 3525223.

@TobiGr: Ok. Are you on it, or should I take a look at it?

I'm currently testing it., I'll open another pull request soon.

@mauriciocolli
Copy link
Contributor Author

Oh, and @TobiGr, sorry if it caused a misunderstanding, but you would have to disable it, as I don't have permissions to change that setting (I don't even see here, screenshot from another repo).

@mauriciocolli mauriciocolli deleted the hotfixes branch March 7, 2020 20:01
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.

5 participants