Don't preemptively clean url and save StreamInfo with PlayQueueItem

This commit is contained in:
Aris Poloway 2018-04-04 20:11:13 -04:00
parent 183f9701fd
commit f3a280dcb6
2 changed files with 12 additions and 3 deletions

View file

@ -122,7 +122,7 @@ public class RouterActivity extends AppCompatActivity {
currentService = NewPipe.getServiceByUrl(url); currentService = NewPipe.getServiceByUrl(url);
currentServiceId = currentService.getServiceId(); currentServiceId = currentService.getServiceId();
currentLinkType = currentService.getLinkTypeByUrl(url); currentLinkType = currentService.getLinkTypeByUrl(url);
currentUrl = NavigationHelper.getCleanUrl(currentService, url, currentLinkType); currentUrl = url;
} else { } else {
currentService = NewPipe.getService(currentServiceId); currentService = NewPipe.getService(currentServiceId);
} }
@ -307,7 +307,8 @@ public class RouterActivity extends AppCompatActivity {
// StreamDetailFragment can fetch data itself // StreamDetailFragment can fetch data itself
if(playerChoiceKey.equals(getString(R.string.show_info_key))) { if(playerChoiceKey.equals(getString(R.string.show_info_key))) {
disposables.add(Observable disposables.add(Observable
.fromCallable(() -> NavigationHelper.getIntentByLink(this, currentUrl)) .fromCallable(() -> NavigationHelper.getIntentByLink(this,
NavigationHelper.getCleanUrl(currentService, currentUrl, currentLinkType)))
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(intent -> { .subscribe(intent -> {

View file

@ -29,11 +29,13 @@ public class PlayQueueItem implements Serializable {
private Throwable error; private Throwable error;
private transient Single<StreamInfo> stream; private transient Single<StreamInfo> stream;
private StreamInfo info;
PlayQueueItem(@NonNull final StreamInfo info) { PlayQueueItem(@NonNull final StreamInfo info) {
this(info.getName(), info.getUrl(), info.getServiceId(), info.getDuration(), this(info.getName(), info.getUrl(), info.getServiceId(), info.getDuration(),
info.getThumbnailUrl(), info.getUploaderName(), info.getStreamType()); info.getThumbnailUrl(), info.getUploaderName(), info.getStreamType());
this.stream = Single.just(info); this.stream = Single.just(info);
this.info = info;
} }
PlayQueueItem(@NonNull final StreamInfoItem item) { PlayQueueItem(@NonNull final StreamInfoItem item) {
@ -105,7 +107,13 @@ public class PlayQueueItem implements Serializable {
@NonNull @NonNull
private Single<StreamInfo> getInfo() { private Single<StreamInfo> getInfo() {
return ExtractorHelper.getStreamInfo(this.serviceId, this.url, false) Single<StreamInfo> single;
if (this.info != null){
single = Single.just(info);
} else {
single = ExtractorHelper.getStreamInfo(this.serviceId, this.url, false);
}
return single
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.doOnError(throwable -> error = throwable); .doOnError(throwable -> error = throwable);
} }