Added spotify playlists in the playlist tab
This commit is contained in:
parent
45375e2f4a
commit
147ecba9cb
@ -376,7 +376,7 @@ <h1>Favorites</h1>
|
|||||||
<div v-if="playlists.length == 0">
|
<div v-if="playlists.length == 0">
|
||||||
<h1>No Playlists found</h1>
|
<h1>No Playlists found</h1>
|
||||||
</div>
|
</div>
|
||||||
<div class="release_grid" v-if="playlists.length > 0">
|
<div class="release_grid" v-if="playlists.length > 0 || spotifyPlaylists > 0">
|
||||||
<div v-for="release in playlists" class="release clickable" @click="playlistView"
|
<div v-for="release in playlists" class="release clickable" @click="playlistView"
|
||||||
:data-id="release.id">
|
:data-id="release.id">
|
||||||
<div class="cover_container">
|
<div class="cover_container">
|
||||||
@ -388,6 +388,17 @@ <h1>No Playlists found</h1>
|
|||||||
<p class="primary-text">{{ release.title }}</p>
|
<p class="primary-text">{{ release.title }}</p>
|
||||||
<p class="secondary-text">{{ 'by '+release.creator.name+' - '+release.nb_tracks+' tracks' }}</p>
|
<p class="secondary-text">{{ 'by '+release.creator.name+' - '+release.nb_tracks+' tracks' }}</p>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-for="release in spotifyPlaylists" class="release clickable" @click="spotifyPlaylistView"
|
||||||
|
:data-id="release.id">
|
||||||
|
<div class="cover_container">
|
||||||
|
<img class="rounded coverart" :src="release.picture_medium">
|
||||||
|
<div role="button" aria-label="download" @contextmenu.prevent="openQualityModal"
|
||||||
|
@click.stop="addToQueue" :data-link="release.link" class="download_overlay"><i
|
||||||
|
class="material-icons">get_app</i></div>
|
||||||
|
</div>
|
||||||
|
<p class="primary-text">{{ release.title }}</p>
|
||||||
|
<p class="secondary-text">{{ 'by '+release.creator.name+' - '+release.nb_tracks+' tracks' }}</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="album_favorites" class="favorites_tabcontent">
|
<div id="album_favorites" class="favorites_tabcontent">
|
||||||
@ -783,6 +794,10 @@ <h3>Album covers</h3>
|
|||||||
<p>Spotify Client Secret</p>
|
<p>Spotify Client Secret</p>
|
||||||
<input type="password" v-model="spotifyFeatures.clientSecret">
|
<input type="password" v-model="spotifyFeatures.clientSecret">
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<p>Spotify username</p>
|
||||||
|
<input type="text" v-model="spotifyUser">
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<footer>
|
<footer>
|
||||||
<button @click="resetSettings">Reset to Default</button>
|
<button @click="resetSettings">Reset to Default</button>
|
||||||
@ -859,6 +874,7 @@ <h2 class="inline-flex"><span v-if="metadata">{{ metadata }}</span><span class="
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
<template v-if="type!='Spotify Playlist'">
|
||||||
<template v-for="track in body">
|
<template v-for="track in body">
|
||||||
<tr v-if="track.type == 'track'">
|
<tr v-if="track.type == 'track'">
|
||||||
<td><i @click=playPausePreview
|
<td><i @click=playPausePreview
|
||||||
@ -879,7 +895,22 @@ <h2 class="inline-flex"><span v-if="metadata">{{ metadata }}</span><span class="
|
|||||||
<td colspan="6" style="opacity: 0.54;"><i class="material-icons">album</i>{{ track.number }}</td>
|
<td colspan="6" style="opacity: 0.54;"><i class="material-icons">album</i>{{ track.number }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</template>
|
</template>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<tr v-for="(track, i) in body">
|
||||||
|
<td><i @click=playPausePreview
|
||||||
|
:class="'material-icons' + (track.preview_url ? ' preview_playlist_controls' : '')"
|
||||||
|
:data-preview="track.preview_url">play_arrow</i></td>
|
||||||
|
<td>{{ i+1 }}</td>
|
||||||
|
<td class="inline-flex"><i v-if="track.explicit"
|
||||||
|
class="material-icons">explicit</i>{{ track.name }}
|
||||||
|
</td>
|
||||||
|
<td>{{ track.artists[0].name }}</td>
|
||||||
|
<td>{{ track.album.name }}</td>
|
||||||
|
<td>{{ convertDuration(Math.floor(track.duration_ms/1000)) }}</td>
|
||||||
|
<td><input class="trackCheckbox" type="checkbox" v-model="track.selected"></td>
|
||||||
|
</tr>
|
||||||
|
</template>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<span v-if="label"
|
<span v-if="label"
|
||||||
|
@ -99,7 +99,10 @@ function startApp() {
|
|||||||
if ('true' === localStorage.getItem('slimDownloads')) {
|
if ('true' === localStorage.getItem('slimDownloads')) {
|
||||||
document.getElementById("download_list").classList.add("slim")
|
document.getElementById("download_list").classList.add("slim")
|
||||||
}
|
}
|
||||||
|
let spotifyUser = localStorage.getItem('spotifyUser')
|
||||||
|
if (spotifyUser != ''){
|
||||||
|
socket.emit('update_userSpotifyPlaylists', spotifyUser)
|
||||||
|
}
|
||||||
// Open default tab
|
// Open default tab
|
||||||
document.getElementById('main_home_tablink').click()
|
document.getElementById('main_home_tablink').click()
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { socket } from '../socket.js'
|
import { socket } from '../socket.js'
|
||||||
import { playlistView, artistView, albumView } from '../tabs.js'
|
import { playlistView, artistView, albumView, spotifyPlaylistView } from '../tabs.js'
|
||||||
import Downloads from '../downloads.js'
|
import Downloads from '../downloads.js'
|
||||||
import QualityModal from '../quality-modal.js'
|
import QualityModal from '../quality-modal.js'
|
||||||
import TrackPreview from '../track-preview.js'
|
import TrackPreview from '../track-preview.js'
|
||||||
@ -11,13 +11,15 @@ const FavoritesTab = new Vue({
|
|||||||
tracks: [],
|
tracks: [],
|
||||||
albums: [],
|
albums: [],
|
||||||
artists: [],
|
artists: [],
|
||||||
playlists: []
|
playlists: [],
|
||||||
|
spotifyPlaylists: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
playlistView,
|
playlistView,
|
||||||
artistView,
|
artistView,
|
||||||
albumView,
|
albumView,
|
||||||
|
spotifyPlaylistView,
|
||||||
playPausePreview: TrackPreview.playPausePreview,
|
playPausePreview: TrackPreview.playPausePreview,
|
||||||
previewMouseEnter: TrackPreview.previewMouseEnter,
|
previewMouseEnter: TrackPreview.previewMouseEnter,
|
||||||
previewMouseLeave: TrackPreview.previewMouseLeave,
|
previewMouseLeave: TrackPreview.previewMouseLeave,
|
||||||
@ -29,6 +31,11 @@ const FavoritesTab = new Vue({
|
|||||||
openQualityModal(e) {
|
openQualityModal(e) {
|
||||||
QualityModal.open(e.currentTarget.dataset.link)
|
QualityModal.open(e.currentTarget.dataset.link)
|
||||||
},
|
},
|
||||||
|
updated_userSpotifyPlaylists(data){this.spotifyPlaylists = data},
|
||||||
|
updated_userPlaylists(data){this.playlists = data},
|
||||||
|
updated_userAlbums(data){this.albums = data},
|
||||||
|
updated_userArtist(data){this.artists = data},
|
||||||
|
updated_userTracks(data){this.tracks = data},
|
||||||
initFavorites(data) {
|
initFavorites(data) {
|
||||||
this.tracks = data.tracks
|
this.tracks = data.tracks
|
||||||
this.albums = data.albums
|
this.albums = data.albums
|
||||||
@ -39,6 +46,11 @@ const FavoritesTab = new Vue({
|
|||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
socket.on('init_favorites', this.initFavorites)
|
socket.on('init_favorites', this.initFavorites)
|
||||||
|
socket.on('updated_userSpotifyPlaylists', this.updated_userSpotifyPlaylists)
|
||||||
|
socket.on('updated_userPlaylists', this.updated_userPlaylists)
|
||||||
|
socket.on('updated_userAlbums', this.updated_userAlbums)
|
||||||
|
socket.on('updated_userArtist', this.updated_userArtist)
|
||||||
|
socket.on('updated_userTracks', this.updated_userTracks)
|
||||||
}
|
}
|
||||||
}).$mount('#favorites_tab')
|
}).$mount('#favorites_tab')
|
||||||
|
|
||||||
|
@ -5,9 +5,11 @@ const SettingsTab = new Vue({
|
|||||||
data: () => ({
|
data: () => ({
|
||||||
settings: { tags: {} },
|
settings: { tags: {} },
|
||||||
lastSettings: {},
|
lastSettings: {},
|
||||||
lastCredentials: {},
|
|
||||||
spotifyFeatures: {},
|
spotifyFeatures: {},
|
||||||
defaultSettings: {}
|
lastCredentials: {},
|
||||||
|
defaultSettings: {},
|
||||||
|
lastUser: '',
|
||||||
|
spotifyUser: ''
|
||||||
}),
|
}),
|
||||||
computed: {
|
computed: {
|
||||||
darkMode: {
|
darkMode: {
|
||||||
@ -47,7 +49,14 @@ const SettingsTab = new Vue({
|
|||||||
saveSettings() {
|
saveSettings() {
|
||||||
this.lastSettings = { ...SettingsTab.settings }
|
this.lastSettings = { ...SettingsTab.settings }
|
||||||
this.lastCredentials = { ...SettingsTab.spotifyFeatures }
|
this.lastCredentials = { ...SettingsTab.spotifyFeatures }
|
||||||
socket.emit('saveSettings', this.lastSettings, this.lastCredentials)
|
let changed = false
|
||||||
|
if (this.lastUser != this.spotifyUser){
|
||||||
|
// force cloning without linking
|
||||||
|
this.lastUser = (' ' + this.spotifyUser).slice(1)
|
||||||
|
localStorage.setItem('spotifyUser', this.lastUser)
|
||||||
|
changed = true
|
||||||
|
}
|
||||||
|
socket.emit('saveSettings', this.lastSettings, this.lastCredentials, changed ? this.lastUser : false)
|
||||||
},
|
},
|
||||||
loadSettings(settings, spotifyCredentials, defaults = null) {
|
loadSettings(settings, spotifyCredentials, defaults = null) {
|
||||||
if (defaults) this.defaultSettings = { ...defaults }
|
if (defaults) this.defaultSettings = { ...defaults }
|
||||||
@ -80,6 +89,11 @@ const SettingsTab = new Vue({
|
|||||||
mounted() {
|
mounted() {
|
||||||
socket.on('init_settings', this.initSettings)
|
socket.on('init_settings', this.initSettings)
|
||||||
socket.on('updateSettings', this.updateSettings)
|
socket.on('updateSettings', this.updateSettings)
|
||||||
|
let spotyUser = localStorage.getItem('spotifyUser')
|
||||||
|
if (spotyUser){
|
||||||
|
this.lastUser = spotyUser
|
||||||
|
this.spotifyUser = spotyUser
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}).$mount('#settings_tab')
|
}).$mount('#settings_tab')
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ const TracklistTab = new Vue({
|
|||||||
var selected = []
|
var selected = []
|
||||||
if (this.body) {
|
if (this.body) {
|
||||||
this.body.forEach(item => {
|
this.body.forEach(item => {
|
||||||
if (item.type == 'track' && item.selected) selected.push(item.link)
|
if (item.type == 'track' && item.selected) selected.push(this.type == "Spotify Playlist" ? item.uri : item.link)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return selected.join(';')
|
return selected.join(';')
|
||||||
@ -110,11 +110,33 @@ const TracklistTab = new Vue({
|
|||||||
} else {
|
} else {
|
||||||
this.body = data.tracks
|
this.body = data.tracks
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
showSpotifyPlaylist(data) {
|
||||||
|
this.type = 'Spotify Playlist'
|
||||||
|
this.link = data.uri
|
||||||
|
this.title = data.name
|
||||||
|
this.image = data.images.length ? data.images[0].url : "https://e-cdns-images.dzcdn.net/images/cover/d41d8cd98f00b204e9800998ecf8427e/1000x1000-000000-80-0-0.jpg"
|
||||||
|
this.release_date = ""
|
||||||
|
this.metadata = `by ${data.owner.display_name} • ${data.tracks.length} songs`
|
||||||
|
this.head = [
|
||||||
|
{ title: '<i class="material-icons">music_note</i>', width: '24px' },
|
||||||
|
{ title: '#' },
|
||||||
|
{ title: 'Song' },
|
||||||
|
{ title: 'Artist' },
|
||||||
|
{ title: 'Album' },
|
||||||
|
{ title: '<i class="material-icons">timer</i>', width: '40px' }
|
||||||
|
]
|
||||||
|
if (_.isEmpty(data.tracks)) {
|
||||||
|
this.body = null
|
||||||
|
} else {
|
||||||
|
this.body = data.tracks
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
socket.on('show_album', this.showAlbum)
|
socket.on('show_album', this.showAlbum)
|
||||||
socket.on('show_playlist', this.showPlaylist)
|
socket.on('show_playlist', this.showPlaylist)
|
||||||
|
socket.on('show_spotifyplaylist', this.showSpotifyPlaylist)
|
||||||
}
|
}
|
||||||
}).$mount('#tracklist_tab')
|
}).$mount('#tracklist_tab')
|
||||||
|
|
||||||
|
@ -47,6 +47,13 @@ export function playlistView(ev) {
|
|||||||
showTab('playlist', id)
|
showTab('playlist', id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function spotifyPlaylistView(ev) {
|
||||||
|
let id = ev.currentTarget.dataset.id
|
||||||
|
TracklistTab.reset()
|
||||||
|
socket.emit('getTracklist', { type: 'spotifyplaylist', id: id })
|
||||||
|
showTab('spotifyplaylist', id)
|
||||||
|
}
|
||||||
|
|
||||||
function analyzeLink(link) {
|
function analyzeLink(link) {
|
||||||
console.log('Analyzing: ' + link)
|
console.log('Analyzing: ' + link)
|
||||||
LinkAnalyzerTab.reset()
|
LinkAnalyzerTab.reset()
|
||||||
@ -169,6 +176,8 @@ function changeTab(sidebarEl, section, tabName) {
|
|||||||
}
|
}
|
||||||
if (tabName == 'settings_tab' && main_selected != 'settings_tab') {
|
if (tabName == 'settings_tab' && main_selected != 'settings_tab') {
|
||||||
SettingsTab.settings = { ...SettingsTab.lastSettings }
|
SettingsTab.settings = { ...SettingsTab.lastSettings }
|
||||||
|
SettingsTab.spotifyCredentials = { ...SettingsTab.lastCredentials }
|
||||||
|
SettingsTab.spotifyUser = (' ' + SettingsTab.lastUser).slice(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById(tabName).style.display = 'block'
|
document.getElementById(tabName).style.display = 'block'
|
||||||
|
Loading…
Reference in New Issue
Block a user