Merge pull request #1236 from Bnyro/master

clone playlist from youtube
This commit is contained in:
Kavin 2022-07-22 18:58:31 +05:30 committed by GitHub
commit a4588b643f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 5 deletions

View File

@ -2,7 +2,7 @@
<ErrorHandler v-if="playlist && playlist.error" :message="playlist.message" :error="playlist.error" /> <ErrorHandler v-if="playlist && playlist.error" :message="playlist.message" :error="playlist.error" />
<div v-if="playlist" v-show="!playlist.error"> <div v-if="playlist" v-show="!playlist.error">
<h1 class="text-center" v-text="playlist.name" /> <h1 class="text-center my-4" v-text="playlist.name" />
<div class="grid grid-cols-2"> <div class="grid grid-cols-2">
<div> <div>
@ -15,7 +15,10 @@
<div class="right-2vw absolute"> <div class="right-2vw absolute">
<strong v-text="`${playlist.videos} ${$t('video.videos')}`" /> <strong v-text="`${playlist.videos} ${$t('video.videos')}`" />
<br /> <br />
<a :href="getRssUrl"> <button class="btn mr-1" v-if="authenticated && !isPipedPlaylist" @click="clonePlaylist">
{{ $t("actions.clone_playlist") }}<font-awesome-icon class="ml-3" icon="clone" />
</button>
<a class="btn" :href="getRssUrl">
<font-awesome-icon icon="rss" /> <font-awesome-icon icon="rss" />
</a> </a>
</div> </div>
@ -59,6 +62,12 @@ export default {
getRssUrl: _this => { getRssUrl: _this => {
return _this.authApiUrl() + "/rss/playlists/" + _this.$route.query.list; return _this.authApiUrl() + "/rss/playlists/" + _this.$route.query.list;
}, },
isPipedPlaylist: _this => {
// regex to determine whether it's a Piped plalylist
return /[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}/.test(
_this.$route.query.list,
);
},
}, },
mounted() { mounted() {
this.getPlaylistData(); this.getPlaylistData();
@ -109,6 +118,21 @@ export default {
removeVideo(index) { removeVideo(index) {
this.playlist.relatedStreams.splice(index, 1); this.playlist.relatedStreams.splice(index, 1);
}, },
async clonePlaylist() {
this.fetchJson(this.authApiUrl() + "/import/playlist", null, {
method: "POST",
headers: {
Authorization: this.getAuthToken(),
},
body: JSON.stringify({
playlistId: this.$route.query.list,
}),
}).then(resp => {
if (!resp.error) {
alert(this.$t("actions.clone_playlist_success"));
} else alert(resp.error);
});
},
}, },
}; };
</script> </script>

View File

@ -244,7 +244,7 @@
class="input w-auto" class="input w-auto"
type="password" type="password"
/> />
<a class="btn w-auto" style="margin-left: 0.5em" @click="deleteAccount" v-t="'actions.delete_account'" /> <a class="btn w-auto ml-2" @click="deleteAccount" v-t="'actions.delete_account'" />
<br /> <br />
</div> </div>
<br /> <br />

View File

@ -1,5 +1,5 @@
<template> <template>
<h1 class="text-center" v-text="$route.query.search_query" /> <h1 class="text-center my-2" v-text="$route.query.search_query" />
<label for="ddlSearchFilters"> <label for="ddlSearchFilters">
<strong v-text="`${$t('actions.filter')}:`" /> <strong v-text="`${$t('actions.filter')}:`" />

View File

@ -86,7 +86,9 @@
"minimize_recommendations_default": "Minimize Recommendations by default", "minimize_recommendations_default": "Minimize Recommendations by default",
"invalidate_session": "Logout all devices", "invalidate_session": "Logout all devices",
"different_auth_instance": "Use a different instance for authentication", "different_auth_instance": "Use a different instance for authentication",
"instance_auth_selection": "Autentication Instance Selection" "instance_auth_selection": "Autentication Instance Selection",
"clone_playlist": "Clone Playlist",
"clone_playlist_success": "Successfully cloned!"
}, },
"comment": { "comment": {
"pinned_by": "Pinned by", "pinned_by": "Pinned by",

View File

@ -17,6 +17,7 @@ import {
faCirclePlus, faCirclePlus,
faCircleMinus, faCircleMinus,
faXmark, faXmark,
faClone,
} from "@fortawesome/free-solid-svg-icons"; } from "@fortawesome/free-solid-svg-icons";
import { faGithub, faBitcoin, faYoutube } from "@fortawesome/free-brands-svg-icons"; import { faGithub, faBitcoin, faYoutube } from "@fortawesome/free-brands-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
@ -40,6 +41,7 @@ library.add(
faCirclePlus, faCirclePlus,
faCircleMinus, faCircleMinus,
faXmark, faXmark,
faClone,
); );
import router from "@/router/router.js"; import router from "@/router/router.js";