From f3a280dcb6fd95f4f720a5ce1959010ad83d5e99 Mon Sep 17 00:00:00 2001 From: Aris Poloway Date: Wed, 4 Apr 2018 20:11:13 -0400 Subject: [PATCH] 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); }