Merge pull request #1268 from arispoloway/dev
Handle links with time specified (ex. &t=xxx)
This commit is contained in:
commit
88268ae569
5 changed files with 15 additions and 34 deletions
|
@ -54,7 +54,7 @@ dependencies {
|
||||||
exclude module: 'support-annotations'
|
exclude module: 'support-annotations'
|
||||||
}
|
}
|
||||||
|
|
||||||
implementation 'com.github.TeamNewPipe:NewPipeExtractor:a6b6235644474'
|
implementation 'com.github.TeamNewPipe:NewPipeExtractor:77a74b8'
|
||||||
|
|
||||||
|
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.12'
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,6 @@ import org.schabi.newpipe.player.helper.PlayerHelper;
|
||||||
import org.schabi.newpipe.player.old.PlayVideoActivity;
|
import org.schabi.newpipe.player.old.PlayVideoActivity;
|
||||||
import org.schabi.newpipe.playlist.PlayQueue;
|
import org.schabi.newpipe.playlist.PlayQueue;
|
||||||
import org.schabi.newpipe.playlist.SinglePlayQueue;
|
import org.schabi.newpipe.playlist.SinglePlayQueue;
|
||||||
import org.schabi.newpipe.report.ErrorActivity;
|
|
||||||
import org.schabi.newpipe.report.UserAction;
|
import org.schabi.newpipe.report.UserAction;
|
||||||
import org.schabi.newpipe.util.Constants;
|
import org.schabi.newpipe.util.Constants;
|
||||||
import org.schabi.newpipe.util.ExtractorHelper;
|
import org.schabi.newpipe.util.ExtractorHelper;
|
||||||
|
@ -205,7 +204,7 @@ public class VideoDetailFragment
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
return inflater.inflate(R.layout.fragment_video_detail, container, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -682,14 +681,14 @@ public class VideoDetailFragment
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case R.id.menu_item_share: {
|
case R.id.menu_item_share: {
|
||||||
if (currentInfo != null) {
|
if (currentInfo != null) {
|
||||||
shareUrl(currentInfo.getName(), url);
|
shareUrl(currentInfo.getName(), currentInfo.getUrl());
|
||||||
} else {
|
|
||||||
shareUrl(url, url);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case R.id.menu_item_openInBrowser: {
|
case R.id.menu_item_openInBrowser: {
|
||||||
openUrlInBrowser(url);
|
if (currentInfo != null) {
|
||||||
|
openUrlInBrowser(currentInfo.getUrl());
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case R.id.action_play_with_kodi:
|
case R.id.action_play_with_kodi:
|
||||||
|
@ -818,7 +817,7 @@ public class VideoDetailFragment
|
||||||
public void prepareAndHandleInfo(final StreamInfo info, boolean scrollToTop) {
|
public void prepareAndHandleInfo(final StreamInfo info, boolean scrollToTop) {
|
||||||
if (DEBUG) Log.d(TAG, "prepareAndHandleInfo() called with: info = [" + info + "], scrollToTop = [" + 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);
|
pushToStack(serviceId, url, name);
|
||||||
showLoading();
|
showLoading();
|
||||||
|
|
||||||
|
@ -1112,7 +1111,7 @@ public class VideoDetailFragment
|
||||||
public void handleResult(@NonNull StreamInfo info) {
|
public void handleResult(@NonNull StreamInfo info) {
|
||||||
super.handleResult(info);
|
super.handleResult(info);
|
||||||
|
|
||||||
setInitialData(info.getServiceId(), info.getUrl(), info.getName());
|
setInitialData(info.getServiceId(), info.getOriginalUrl(), info.getName());
|
||||||
pushToStack(serviceId, url, name);
|
pushToStack(serviceId, url, name);
|
||||||
|
|
||||||
animateView(thumbnailPlayButton, true, 200);
|
animateView(thumbnailPlayButton, true, 200);
|
||||||
|
@ -1192,7 +1191,9 @@ public class VideoDetailFragment
|
||||||
toggleExpandRelatedVideos(currentInfo);
|
toggleExpandRelatedVideos(currentInfo);
|
||||||
wasRelatedStreamsExpanded = false;
|
wasRelatedStreamsExpanded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
setTitleToUrl(info.getServiceId(), info.getUrl(), info.getName());
|
setTitleToUrl(info.getServiceId(), info.getUrl(), info.getName());
|
||||||
|
setTitleToUrl(info.getServiceId(), info.getOriginalUrl(), info.getName());
|
||||||
|
|
||||||
if (!info.getErrors().isEmpty()) {
|
if (!info.getErrors().isEmpty()) {
|
||||||
showSnackBarError(info.getErrors(),
|
showSnackBarError(info.getErrors(),
|
||||||
|
|
|
@ -28,12 +28,12 @@ public class PlayQueueItem implements Serializable {
|
||||||
private long recoveryPosition;
|
private long recoveryPosition;
|
||||||
private Throwable error;
|
private Throwable error;
|
||||||
|
|
||||||
private transient Single<StreamInfo> stream;
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
if (info.getStartPosition() > 0)
|
||||||
|
setRecoveryPosition(info.getStartPosition() * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayQueueItem(@NonNull final StreamInfoItem item) {
|
PlayQueueItem(@NonNull final StreamInfoItem item) {
|
||||||
|
@ -100,11 +100,6 @@ public class PlayQueueItem implements Serializable {
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public Single<StreamInfo> getStream() {
|
public Single<StreamInfo> getStream() {
|
||||||
return stream == null ? stream = getInfo() : stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
private Single<StreamInfo> getInfo() {
|
|
||||||
return ExtractorHelper.getStreamInfo(this.serviceId, this.url, false)
|
return ExtractorHelper.getStreamInfo(this.serviceId, this.url, false)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.doOnError(throwable -> error = throwable);
|
.doOnError(throwable -> error = throwable);
|
||||||
|
|
|
@ -475,7 +475,6 @@ public class NavigationHelper {
|
||||||
throw new ExtractionException("Url not known to service. service=" + service + " url=" + url);
|
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);
|
Intent rIntent = getOpenIntent(context, url, service.getServiceId(), linkType);
|
||||||
|
|
||||||
switch (linkType) {
|
switch (linkType) {
|
||||||
|
@ -488,20 +487,6 @@ public class NavigationHelper {
|
||||||
return rIntent;
|
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) {
|
private static Uri openMarketUrl(String packageName) {
|
||||||
return Uri.parse("market://details")
|
return Uri.parse("market://details")
|
||||||
.buildUpon()
|
.buildUpon()
|
||||||
|
|
Loading…
Reference in a new issue