From f3a280dcb6fd95f4f720a5ce1959010ad83d5e99 Mon Sep 17 00:00:00 2001 From: Aris Poloway Date: Wed, 4 Apr 2018 20:11:13 -0400 Subject: [PATCH 1/4] Don't preemptively clean url and save StreamInfo with PlayQueueItem --- .../main/java/org/schabi/newpipe/RouterActivity.java | 5 +++-- .../org/schabi/newpipe/playlist/PlayQueueItem.java | 10 +++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/RouterActivity.java b/app/src/main/java/org/schabi/newpipe/RouterActivity.java index ad79c40b4..ab560111e 100644 --- a/app/src/main/java/org/schabi/newpipe/RouterActivity.java +++ b/app/src/main/java/org/schabi/newpipe/RouterActivity.java @@ -122,7 +122,7 @@ public class RouterActivity extends AppCompatActivity { currentService = NewPipe.getServiceByUrl(url); currentServiceId = currentService.getServiceId(); currentLinkType = currentService.getLinkTypeByUrl(url); - currentUrl = NavigationHelper.getCleanUrl(currentService, url, currentLinkType); + currentUrl = url; } else { currentService = NewPipe.getService(currentServiceId); } @@ -307,7 +307,8 @@ public class RouterActivity extends AppCompatActivity { // StreamDetailFragment can fetch data itself if(playerChoiceKey.equals(getString(R.string.show_info_key))) { disposables.add(Observable - .fromCallable(() -> NavigationHelper.getIntentByLink(this, currentUrl)) + .fromCallable(() -> NavigationHelper.getIntentByLink(this, + NavigationHelper.getCleanUrl(currentService, currentUrl, currentLinkType))) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(intent -> { diff --git a/app/src/main/java/org/schabi/newpipe/playlist/PlayQueueItem.java b/app/src/main/java/org/schabi/newpipe/playlist/PlayQueueItem.java index df4d19720..4b7f96ce9 100644 --- a/app/src/main/java/org/schabi/newpipe/playlist/PlayQueueItem.java +++ b/app/src/main/java/org/schabi/newpipe/playlist/PlayQueueItem.java @@ -29,11 +29,13 @@ public class PlayQueueItem implements Serializable { private Throwable error; private transient Single stream; + private StreamInfo info; PlayQueueItem(@NonNull final StreamInfo info) { this(info.getName(), info.getUrl(), info.getServiceId(), info.getDuration(), info.getThumbnailUrl(), info.getUploaderName(), info.getStreamType()); this.stream = Single.just(info); + this.info = info; } PlayQueueItem(@NonNull final StreamInfoItem item) { @@ -105,7 +107,13 @@ public class PlayQueueItem implements Serializable { @NonNull private Single getInfo() { - return ExtractorHelper.getStreamInfo(this.serviceId, this.url, false) + Single single; + if (this.info != null){ + single = Single.just(info); + } else { + single = ExtractorHelper.getStreamInfo(this.serviceId, this.url, false); + } + return single .subscribeOn(Schedulers.io()) .doOnError(throwable -> error = throwable); } From b3c49ac86ba089993735b05ed37b8bc2017af8d5 Mon Sep 17 00:00:00 2001 From: Aris Poloway Date: Thu, 5 Apr 2018 16:45:00 -0400 Subject: [PATCH 2/4] Revert unnecessary url clean --- app/src/main/java/org/schabi/newpipe/RouterActivity.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/RouterActivity.java b/app/src/main/java/org/schabi/newpipe/RouterActivity.java index ab560111e..e0221fc22 100644 --- a/app/src/main/java/org/schabi/newpipe/RouterActivity.java +++ b/app/src/main/java/org/schabi/newpipe/RouterActivity.java @@ -307,8 +307,7 @@ public class RouterActivity extends AppCompatActivity { // StreamDetailFragment can fetch data itself if(playerChoiceKey.equals(getString(R.string.show_info_key))) { disposables.add(Observable - .fromCallable(() -> NavigationHelper.getIntentByLink(this, - NavigationHelper.getCleanUrl(currentService, currentUrl, currentLinkType))) + .fromCallable(() -> NavigationHelper.getIntentByLink(this, currentUrl)) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(intent -> { From 2b281c43575b7cdb1943bf2150509954388b7bc4 Mon Sep 17 00:00:00 2001 From: Aris Poloway Date: Thu, 5 Apr 2018 23:47:20 -0400 Subject: [PATCH 3/4] Don't save stream and store recovery position from StreamInfo --- .../newpipe/playlist/PlayQueueItem.java | 21 ++++--------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/playlist/PlayQueueItem.java b/app/src/main/java/org/schabi/newpipe/playlist/PlayQueueItem.java index 4b7f96ce9..2d543fb4e 100644 --- a/app/src/main/java/org/schabi/newpipe/playlist/PlayQueueItem.java +++ b/app/src/main/java/org/schabi/newpipe/playlist/PlayQueueItem.java @@ -28,14 +28,12 @@ public class PlayQueueItem implements Serializable { private long recoveryPosition; private Throwable error; - private transient Single stream; - private StreamInfo info; - PlayQueueItem(@NonNull final StreamInfo info) { this(info.getName(), info.getUrl(), info.getServiceId(), info.getDuration(), info.getThumbnailUrl(), info.getUploaderName(), info.getStreamType()); - this.stream = Single.just(info); - this.info = info; + + if (info.getStartPosition() > 0) + setRecoveryPosition(info.getStartPosition() * 1000); } PlayQueueItem(@NonNull final StreamInfoItem item) { @@ -102,18 +100,7 @@ public class PlayQueueItem implements Serializable { @NonNull public Single getStream() { - return stream == null ? stream = getInfo() : stream; - } - - @NonNull - private Single getInfo() { - Single single; - if (this.info != null){ - single = Single.just(info); - } else { - single = ExtractorHelper.getStreamInfo(this.serviceId, this.url, false); - } - return single + return ExtractorHelper.getStreamInfo(this.serviceId, this.url, false) .subscribeOn(Schedulers.io()) .doOnError(throwable -> error = throwable); } From 140fb864011680abf6e4c81dd4bce6ce4b8acc90 Mon Sep 17 00:00:00 2001 From: Mauricio Colli Date: Fri, 6 Apr 2018 04:35:44 -0300 Subject: [PATCH 4/4] Fix Info's start time when using VideoDetailFragment - Update extractor dependency --- app/build.gradle | 2 +- .../fragments/detail/VideoDetailFragment.java | 19 ++++++++++--------- .../schabi/newpipe/util/NavigationHelper.java | 15 --------------- 3 files changed, 11 insertions(+), 25 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index b6ce0ffd4..e20535ee4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -54,7 +54,7 @@ dependencies { exclude module: 'support-annotations' } - implementation 'com.github.TeamNewPipe:NewPipeExtractor:a6b6235644474' + implementation 'com.github.TeamNewPipe:NewPipeExtractor:77a74b8' testImplementation 'junit:junit:4.12' diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java index 74e561f99..611cd8bfb 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java @@ -70,7 +70,6 @@ import org.schabi.newpipe.player.helper.PlayerHelper; import org.schabi.newpipe.player.old.PlayVideoActivity; import org.schabi.newpipe.playlist.PlayQueue; import org.schabi.newpipe.playlist.SinglePlayQueue; -import org.schabi.newpipe.report.ErrorActivity; import org.schabi.newpipe.report.UserAction; import org.schabi.newpipe.util.Constants; import org.schabi.newpipe.util.ExtractorHelper; @@ -205,7 +204,7 @@ public class VideoDetailFragment } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.fragment_video_detail, container, false); } @@ -681,15 +680,15 @@ public class VideoDetailFragment int id = item.getItemId(); switch (id) { case R.id.menu_item_share: { - if(currentInfo != null) { - shareUrl(currentInfo.getName(), url); - } else { - shareUrl(url, url); + if (currentInfo != null) { + shareUrl(currentInfo.getName(), currentInfo.getUrl()); } return true; } case R.id.menu_item_openInBrowser: { - openUrlInBrowser(url); + if (currentInfo != null) { + openUrlInBrowser(currentInfo.getUrl()); + } return true; } case R.id.action_play_with_kodi: @@ -818,7 +817,7 @@ public class VideoDetailFragment public void prepareAndHandleInfo(final StreamInfo info, boolean scrollToTop) { if (DEBUG) Log.d(TAG, "prepareAndHandleInfo() called with: info = [" + info + "], scrollToTop = [" + scrollToTop + "]"); - setInitialData(info.getServiceId(), info.getUrl(), info.getName()); + setInitialData(info.getServiceId(), info.getOriginalUrl(), info.getName()); pushToStack(serviceId, url, name); showLoading(); @@ -1112,7 +1111,7 @@ public class VideoDetailFragment public void handleResult(@NonNull StreamInfo info) { super.handleResult(info); - setInitialData(info.getServiceId(), info.getUrl(), info.getName()); + setInitialData(info.getServiceId(), info.getOriginalUrl(), info.getName()); pushToStack(serviceId, url, name); animateView(thumbnailPlayButton, true, 200); @@ -1192,7 +1191,9 @@ public class VideoDetailFragment toggleExpandRelatedVideos(currentInfo); wasRelatedStreamsExpanded = false; } + setTitleToUrl(info.getServiceId(), info.getUrl(), info.getName()); + setTitleToUrl(info.getServiceId(), info.getOriginalUrl(), info.getName()); if (!info.getErrors().isEmpty()) { showSnackBarError(info.getErrors(), diff --git a/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java b/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java index 26088a64c..3d9a3e0de 100644 --- a/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java @@ -475,7 +475,6 @@ public class NavigationHelper { throw new ExtractionException("Url not known to service. service=" + service + " url=" + url); } - url = getCleanUrl(service, url, linkType); Intent rIntent = getOpenIntent(context, url, service.getServiceId(), linkType); switch (linkType) { @@ -488,20 +487,6 @@ public class NavigationHelper { return rIntent; } - public static String getCleanUrl(StreamingService service, String dirtyUrl, StreamingService.LinkType linkType) throws ExtractionException { - switch (linkType) { - case STREAM: - return service.getStreamUrlIdHandler().cleanUrl(dirtyUrl); - case CHANNEL: - return service.getChannelUrlIdHandler().cleanUrl(dirtyUrl); - case PLAYLIST: - return service.getPlaylistUrlIdHandler().cleanUrl(dirtyUrl); - case NONE: - break; - } - return null; - } - private static Uri openMarketUrl(String packageName) { return Uri.parse("market://details") .buildUpon()