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);
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 -> {

View File

@ -29,11 +29,13 @@ public class PlayQueueItem implements Serializable {
private Throwable error;
private transient Single<StreamInfo> 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<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())
.doOnError(throwable -> error = throwable);
}