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

Refactor and bugfix #1623

Merged
merged 11 commits into from
Aug 28, 2018
Merged

Refactor and bugfix #1623

merged 11 commits into from
Aug 28, 2018

Conversation

theScrabi
Copy link
Member

This PR covers:

Copy link
Contributor

@karyogamy karyogamy left a comment

Choose a reason for hiding this comment

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

Good work, thanks for the service player time fix.

I've only skimmed through a little bit. Will look into the download stuff some more tomorrow.

@@ -309,7 +309,6 @@ private void updateNotificationThumbnail() {
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
super.onLoadingComplete(imageUri, view, loadedImage);
resetNotification();
Copy link
Contributor

Choose a reason for hiding this comment

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

This is still required for cleaning up the existing notification (and the bitmap in it) to prevent memory leak, as described in #799. It might be a good idea to put some comments on it though.

We should eventually consider using ExoPlayer's built-in notification, which doesn't have this problem the last time I tried. However, it hardcoded the intent strings so we couldn't support multiple players concurrently. We can look into it later.

Copy link
Member Author

Choose a reason for hiding this comment

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

We may want to make this reset more Inteligent, on android 8+ it made the thumbnail not show up.
When we create the notification we reset it mutliple times, even after the thumbnail got set, this removes it again.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok I added the resetNotificateions() again, i found that the issues was that we didnt call updateNotificatinThumbnail() inside onUpdateProgress().

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I have tried doing this too, but updateNotificatinThumbnail is very costly and can lag the phone updating bitmap every half a second. Could you try benchmarking this again, preferably on an older phone?

final List<Throwable> exceptions = result.getErrors();
if (!exceptions.isEmpty()
&& !(exceptions.size() == 1
&& exceptions.get(0) instanceof SearchExtractor.NothingFoundException)){
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should later consider removing this exception from the extractor. Is it still needed for some reason?

Copy link
Member Author

@theScrabi theScrabi Aug 24, 2018

Choose a reason for hiding this comment

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

I thought it was including additional information. However the intention is to skip some code parts in order to jump directly to the "nothing found" routine.

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like bad practice if it's just there to speed up the collector process. But this is a problem for another PR, I suppose.

Copy link
Member Author

@theScrabi theScrabi Aug 26, 2018

Choose a reason for hiding this comment

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

But this is a problem for another PR, I suppose.

I see. Another thing I thought of was that if the search result is empty, but no error is thrown, it could be an error that did not get detected. If we tell the fronted explicitly that there was nothing found, than at least we know there was no error. Maybe we can implement that without an exception, but by setting a flag.

@@ -1,8 +1,10 @@
package org.schabi.newpipe.player;

import android.content.ComponentName;
import android.content.Context;
Copy link
Contributor

Choose a reason for hiding this comment

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

Unneeded imports?

Copy link
Member Author

Choose a reason for hiding this comment

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

removed

@theScrabi theScrabi mentioned this pull request Aug 24, 2018
1 task
@@ -168,6 +168,8 @@
<string name="search_history_deleted">Search history deleted.</string>
<!-- error strings -->
<string name="general_error">Error</string>
<string name="download_to_sdcard_error_title">External storage not available.</string>
<string name="download_to_sdcard_error_message">Download to external SD Card is not possible yet. Should the download place be reseted?</string>
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 it should be Should the download place be reset? as reset behaves like set and both are irregular.

Copy link
Member Author

Choose a reason for hiding this comment

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

I changed it.

@gregordr
Copy link
Contributor

gregordr commented Aug 24, 2018

I have taken a look at the link part.

  • Links to other videos still get shortened, like in this video: https://www.youtube.com/watch?v=ipY0bhU2fe4
  • I generally prefer the solution youtube has, where the link looks shortened, because descriptions look really messy now.
  • For non-youtube links, it looks like everything works well 👍

@theScrabi
Copy link
Member Author

I generally prefer the solution youtube has, where the link looks shortened, because descriptions look really messy now.

True, but can the description view handle html?

@gregordr
Copy link
Contributor

@theScrabi

I have just taken a look at my old PR, and yeah it is possible: https://streamable.com/xo0q7

@@ -23,7 +35,8 @@
private static final String TAG = DownloadManagerImpl.class.getSimpleName();
private final DownloadDataSource mDownloadDataSource;

private final ArrayList<DownloadMission> mMissions = new ArrayList<DownloadMission>();
private final ArrayList<DownloadMission> mMissions = new ArrayList<>();
private final Context context;
Copy link
Contributor

Choose a reason for hiding this comment

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

This should at least be labelled as NonNull.

Ideally, it's better to pass in a listener/runnable with a function to call when an exception occurs in this case, just to avoid keeping Context in a class unless there's no better solution.

private static void resetDownloadFolder(SharedPreferences prefs, String key, String defaultDirectoryName) {
final File folder = getFolder(defaultDirectoryName);
SharedPreferences.Editor spEditor = prefs.edit();
spEditor.putString(key, new File(folder, "NewPipe").getAbsolutePath());
Copy link
Contributor

Choose a reason for hiding this comment

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

Might want to extract new File(folder, "NewPipe").getAbsolutePath() to a variable since it is reused a couple lines above.

@theScrabi
Copy link
Member Author

@Somethingweirdhere Could you please try to figure out what to change in order to make our textview use the href instead of what is writting in the a tag :)

@gregordr
Copy link
Contributor

@theScrabi Sure, here you go:

videoDescriptionView.setAutoLinkMask(Linkify.WEB_URLS);

This line needs to be gone, or anything in the Href will be overridden by the displayed text.

But now you have a problem: Your hrefs don't work.

<a href="/redirect?q=https%3A%2F%2Fwww.facebook.com%2FTrueDetective&amp;v=YpUznQds8p4&amp;event=video_description&amp;redir_token=tDtfcIHTYhl0iYimJbvVW9I33P58MTUzNTQ4MjQ5M0AxNTM1Mzk2MDkz" class="yt-uix-sessionlink " data-url="/redirect?q=https%3A%2F%2Fwww.facebook.com%2FTrueDetective&amp;v=YpUznQds8p4&amp;event=video_description&amp;redir_token=tDtfcIHTYhl0iYimJbvVW9I33P58MTUzNTQ4MjQ5M0AxNTM1Mzk2MDkz" data-sessionlink="itct=CDUQ6TgYACITCMSpypX0jd0CFU_RFQodxGAK1ij4HUie5bO70PPMymI" data-target-new-window="True" rel=" noopener" target="_blank">https://www.facebook.com/TrueDetective</a>

This is how they look with the extractor right now.

You have to make them look like this:

<a href="https://www.facebook.com/TrueDetective" class="yt-uix-sessionlink " data-sessionlink="itct=CDUQ6TgYACITCP7y8KL2jd0CFQawVQodY0gNByj4HUie5bO70PPMymI" data-target-new-window="True" data-url="/redirect?q=https%3A%2F%2Fwww.facebook.com%2FTrueDetective&amp;event=video_description&amp;redir_token=7xMZ9ZYoGiSxYNc0Mplf3H2aL0V8MTUzNTQ4MzA1N0AxNTM1Mzk2NjU3&amp;v=YpUznQds8p4" target="_blank" rel=" noopener">https://www.facebook.com/TrueDetective</a>

It's what I did here, in my old PR. It works, but I agree that the solution maybe could be prettier.

@theScrabi
Copy link
Member Author

@Somethingweirdhere I experimented with it for a while, removed that line and tried to override the href in the links, however it did not work as expected.

fixes moreacording to code review

fixed link handling once more
@theScrabi
Copy link
Member Author

@karyogamy The changes you requested should be good by now, could you please release the block.

@theScrabi theScrabi mentioned this pull request Aug 28, 2018
@gregordr
Copy link
Contributor

gregordr commented Aug 28, 2018

@theScrabi Do you think you could Upload what you tried (NewPipe and extractor) so I can take a look at it?

@theScrabi
Copy link
Member Author

theScrabi commented Aug 28, 2018

If you use this commit 3aa7ff6 from the NewPipeExctractor you can try it. This was thought to replace the href instead of the text.

@theScrabi theScrabi dismissed karyogamy’s stale review August 28, 2018 14:29

So far all acomplished, the thing with the NothingFoundException can be done in ohter PR.

@theScrabi theScrabi merged commit ad065e9 into dev Aug 28, 2018
@gregordr
Copy link
Contributor

@theScrabi I tried NewPipe Dev and NewPipe Extractor 3aa7ff6.

When debugging, it looks like this:

<a href="/redirect?q=https%3A%2F%2Fwww.twitter.com%2Flongbeachgriffy&amp;v=cuL2SZmLrR0&amp;event=video_description&amp;redir_token=EvkYDHO1dvjA3tsBZJ0_QUymTDN8MTUzNTU2MzkzMkAxNTM1NDc3NTMy" class="yt-uix-sessionlink " data-sessionlink="itct=CDUQ6TgYACITCNuf7MajkN0CFUG3VQodU9kLsCj4HUid2q7Mmcm98XI" data-url="/redirect?q=https%3A%2F%2Fwww.twitter.com%2Flongbeachgriffy&amp;v=cuL2SZmLrR0&amp;event=video_description&amp;redir_token=EvkYDHO1dvjA3tsBZJ0_QUymTDN8MTUzNTU2MzkzMkAxNTM1NDc3NTMy" data-target-new-window="True" target="_blank" rel=" noopener" abs:href="https://www.twitter.com/longbeachgriffy">https://www.twitter.com/longbeachgriffy</a>

It seems like you added a new attribute called abs:href instead of editing href? Manually changing it while debugging makes it work, so the problem is that href exists.

https://github.com/Somethingweirdhere/NewPipe/tree/dirtyLinkFix

Check this out for a dirty fix. It's only here to demonstrate the problem, I feel like it's not regarded as best practice,

@theScrabi
Copy link
Member Author

@Somethingweirdhere all right, I will fix it in the release_v0.14.0 branch.

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.

None yet

4 participants