From 7a7a90bf79a613dad94fac4eea1af3747ccbb725 Mon Sep 17 00:00:00 2001 From: bopol Date: Sun, 20 Dec 2020 00:03:19 +0100 Subject: [PATCH] remove timestamp from share url for all services except youtube It produces not found error for PeerTube, media.ccc.de, SoundCloud --- .../org/schabi/newpipe/player/VideoPlayerImpl.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java b/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java index 3cbcb87a3..a304b4430 100644 --- a/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java +++ b/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java @@ -103,6 +103,7 @@ import org.schabi.newpipe.util.ShareUtils; import java.util.List; +import static org.schabi.newpipe.extractor.ServiceList.YouTube; import static org.schabi.newpipe.player.MainPlayer.ACTION_CLOSE; import static org.schabi.newpipe.player.MainPlayer.ACTION_FAST_FORWARD; import static org.schabi.newpipe.player.MainPlayer.ACTION_FAST_REWIND; @@ -889,10 +890,17 @@ public class VideoPlayerImpl extends VideoPlayer private void onShareClicked() { // share video at the current time (youtube.com/watch?v=ID&t=SECONDS) // Timestamp doesn't make sense in a live stream so drop it - final String ts = isLive() ? "" : ("&t=" + (getPlaybackSeekBar().getProgress() / 1000)); + + final int ts = getPlaybackSeekBar().getProgress() / 1000; + final MediaSourceTag metadata = getCurrentMetadata(); + String videoUrl = getVideoUrl(); + if (!isLive() && ts >= 0 && metadata != null + && metadata.getMetadata().getServiceId() == YouTube.getServiceId()) { + videoUrl += ("&t=" + ts); + } ShareUtils.shareUrl(service, getVideoTitle(), - getVideoUrl() + ts); + videoUrl); } private void onPlayWithKodiClicked() {