fix go to channel or playlist

This commit is contained in:
gmnsii 2022-11-28 18:02:16 -08:00
parent 47f53bb238
commit 65d01f870a
No known key found for this signature in database
GPG key ID: 13B5ECF7DDFDA0DC
4 changed files with 30 additions and 16 deletions

View file

@ -35,7 +35,7 @@
<font-awesome-icon icon="rss" />
</a>
<WatchOnYouTubeButton :link="`https://youtube.com/channel/${this.channel.id}`" />
<WatchOnYouTubeButton :id="`${this.channel.id}`" :type="'channel'" />
<div class="flex mt-4 mb-2">
<button

View file

@ -23,7 +23,7 @@
<a class="btn mr-1" :href="getRssUrl">
<font-awesome-icon icon="rss" />
</a>
<WatchOnYouTubeButton :link="`https://www.youtube.com/playlist?list=${this.$route.query.list}`" />
<WatchOnYouTubeButton :id="`${this.$route.query.list}`" :type="'playlist'" />
</div>
</div>

View file

@ -1,21 +1,34 @@
<script>
export default {
props: {
videoId: String,
currentTime: Number,
playlistId: String,
playlistIndex: String,
id: String, // The id of the content.
type: String, // The type of the content (video, channel, playlist).
// The below parameters are only evaluated if `type` is video.
videoTimestamp: Number,
videoPlaylistId: String,
videoPlaylistIndex: Number,
},
computed: {
generatedLink() {
let url = `https://youtu.be/watch?v=${this.videoId}`;
if (this.playlistId != undefined) {
// If this.playlistId is defined then this.playlistIndex is too.
url += `&list=${this.playlistId}&index=${this.playlistIndex}`;
switch (String(this.type)) {
case "video": {
let url = `https://youtu.be/watch?v=${this.id}`;
if (this.videoPlaylistId != undefined) {
// If the playlist id is defined then the playlist index is too.
url += `&list=${this.videoPlaylistId}&index=${this.videoPlaylistIndex}`;
}
url += `&t=${parseInt(this.currentTime)}`;
url += `&t=${parseInt(this.videoTimestamp)}`;
return url;
}
case "playlist":
return `https://youtu.be/playlist?list=${this.id}`;
case "channel":
return `https://youtu.be/channel/${this.id}`;
default:
return `https://youtu.be/${this.id}`;
}
},
},
};

View file

@ -109,10 +109,11 @@
<font-awesome-icon icon="rss" />
</a>
<WatchOnYouTubeButton
:video-id="getVideoId()"
:current-time="currentTime"
:playlist-id="playlistId"
:playlist-index="index"
:id="getVideoId()"
:type="'video'"
:videoTimestamp="currentTime"
:videoPlaylistId="playlistId"
:videoPlaylistIndex="index"
/>
<!-- Share Dialog -->
<button class="btn" @click="showShareModal = !showShareModal">