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

View file

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

View file

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

View file

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