Download un-sync fix, playback history
This commit is contained in:
parent
96db2c3753
commit
a77d8437bd
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "client",
|
"name": "client",
|
||||||
"version": "0.1.0",
|
"version": "1.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"serve": "vue-cli-service serve",
|
"serve": "vue-cli-service serve",
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
|
||||||
|
<div v-if='loading'>
|
||||||
|
<v-progress-circular indeterminate class='ma-4'></v-progress-circular>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<v-list v-if='!loading'>
|
||||||
|
<v-lazy v-for='(track, index) in tracks' :key='track.id' max-height='100'>
|
||||||
|
<TrackTile :track='track' @click='play(index)'></TrackTile>
|
||||||
|
</v-lazy>
|
||||||
|
</v-list>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
import TrackTile from '@/components/TrackTile.vue';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'LibraryHistory',
|
||||||
|
components: {
|
||||||
|
TrackTile
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
loading: true,
|
||||||
|
tracks: []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
async load() {
|
||||||
|
this.loading = true;
|
||||||
|
|
||||||
|
//Fetch
|
||||||
|
let res = await this.$axios.get('/history');
|
||||||
|
if (res.data) this.tracks = res.data;
|
||||||
|
|
||||||
|
this.loading = false;
|
||||||
|
},
|
||||||
|
//Load as queue and play
|
||||||
|
play(index) {
|
||||||
|
this.$root.queue.source = {
|
||||||
|
text: 'History',
|
||||||
|
source: 'history',
|
||||||
|
data: null
|
||||||
|
};
|
||||||
|
this.$root.replaceQueue(this.tracks);
|
||||||
|
this.$root.playIndex(index);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
//Load on start
|
||||||
|
this.load();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
|
@ -54,11 +54,11 @@
|
||||||
<v-list-item-title>{{download.track.title}}</v-list-item-title>
|
<v-list-item-title>{{download.track.title}}</v-list-item-title>
|
||||||
<v-list-item-subtitle>{{download.track.artistString}}</v-list-item-subtitle>
|
<v-list-item-subtitle>{{download.track.artistString}}</v-list-item-subtitle>
|
||||||
</v-list-item-content>
|
</v-list-item-content>
|
||||||
<v-liste-item-action>
|
<v-list-item-action>
|
||||||
<v-btn icon @click='deleteDownload(index)'>
|
<v-btn icon @click='deleteDownload(index)'>
|
||||||
<v-icon>mdi-delete</v-icon>
|
<v-icon>mdi-delete</v-icon>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</v-liste-item-action>
|
</v-list-item-action>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
</div>
|
</div>
|
||||||
</v-list>
|
</v-list>
|
||||||
|
@ -79,7 +79,6 @@ export default {
|
||||||
//Remove download from queue
|
//Remove download from queue
|
||||||
async deleteDownload(i) {
|
async deleteDownload(i) {
|
||||||
await this.$axios.delete(`/downloads/${i}`);
|
await this.$axios.delete(`/downloads/${i}`);
|
||||||
this.$root.getDownloads();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,9 @@
|
||||||
<v-tab key='playlists'>
|
<v-tab key='playlists'>
|
||||||
Playlists
|
Playlists
|
||||||
</v-tab>
|
</v-tab>
|
||||||
|
<v-tab key='history'>
|
||||||
|
History
|
||||||
|
</v-tab>
|
||||||
</v-tabs>
|
</v-tabs>
|
||||||
|
|
||||||
<v-tabs-items v-model='tab'>
|
<v-tabs-items v-model='tab'>
|
||||||
|
@ -37,6 +40,11 @@
|
||||||
<v-tab-item key='playlists'>
|
<v-tab-item key='playlists'>
|
||||||
<LibraryPlaylists></LibraryPlaylists>
|
<LibraryPlaylists></LibraryPlaylists>
|
||||||
</v-tab-item>
|
</v-tab-item>
|
||||||
|
|
||||||
|
<!-- History -->
|
||||||
|
<v-tab-item key='history'>
|
||||||
|
<LibraryHistory></LibraryHistory>
|
||||||
|
</v-tab-item>
|
||||||
</v-tabs-items>
|
</v-tabs-items>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -47,11 +55,12 @@ import LibraryTracks from '@/components/LibraryTracks.vue';
|
||||||
import LibraryAlbums from '@/components/LibraryAlbums.vue';
|
import LibraryAlbums from '@/components/LibraryAlbums.vue';
|
||||||
import LibraryArtists from '@/components/LibraryArtists.vue';
|
import LibraryArtists from '@/components/LibraryArtists.vue';
|
||||||
import LibraryPlaylists from '@/components/LibraryPlaylists.vue';
|
import LibraryPlaylists from '@/components/LibraryPlaylists.vue';
|
||||||
|
import LibraryHistory from '@/components/LibraryHistory.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Library',
|
name: 'Library',
|
||||||
components: {
|
components: {
|
||||||
LibraryTracks, LibraryAlbums, LibraryArtists, LibraryPlaylists
|
LibraryTracks, LibraryAlbums, LibraryArtists, LibraryPlaylists, LibraryHistory
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
routeTab: {
|
routeTab: {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "freezer",
|
"name": "freezer",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "1.0.2",
|
"version": "1.0.3",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "background.js",
|
"main": "background.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -163,9 +163,11 @@ class Downloads {
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
this.downloads = [];
|
this.downloads = [];
|
||||||
await new Promise((res, rej) => {
|
await new Promise((res, rej) => {
|
||||||
this.db.remove({state: 0}, {}, (e) => {});
|
this.db.remove({state: 0}, {multi: true}, (e) => {});
|
||||||
res();
|
res();
|
||||||
})
|
});
|
||||||
|
|
||||||
|
if (this.qucb) this.qucb();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,6 +178,8 @@ class Downloads {
|
||||||
res();
|
res();
|
||||||
});
|
});
|
||||||
this.downloads.splice(index, 1);
|
this.downloads.splice(index, 1);
|
||||||
|
|
||||||
|
if (this.qucb) this.qucb();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -193,6 +193,17 @@ app.get('/albums/:id', async (req, res) => {
|
||||||
res.send(albums);
|
res.send(albums);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
//Get tracks from listening history
|
||||||
|
app.get('/history', async (req, res) => {
|
||||||
|
let data = await deezer.callApi('deezer.pageProfile', {
|
||||||
|
nb: 200,
|
||||||
|
tab: "history",
|
||||||
|
user_id: deezer.userId.toString()
|
||||||
|
});
|
||||||
|
let tracks = data.results.TAB.history.data.map((t) => new Track(t));
|
||||||
|
res.send(tracks);
|
||||||
|
});
|
||||||
|
|
||||||
//Search, q as query parameter
|
//Search, q as query parameter
|
||||||
app.get('/search', async (req, res) => {
|
app.get('/search', async (req, res) => {
|
||||||
let data = await deezer.callApi('deezer.pageSearch', {query: req.query.q, nb: 100});
|
let data = await deezer.callApi('deezer.pageSearch', {query: req.query.q, nb: 100});
|
||||||
|
@ -496,27 +507,24 @@ async function createServer(electron = false, ecb) {
|
||||||
downloads: downloads.downloads
|
downloads: downloads.downloads
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
//Emit download progress updates
|
|
||||||
setInterval(() => {
|
|
||||||
sockets.forEach((s) => {
|
|
||||||
if (!downloads.download) {
|
|
||||||
s.emit('download', null);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
s.emit('download', {
|
|
||||||
id: downloads.download.id,
|
|
||||||
size: downloads.download.size,
|
|
||||||
downloaded: downloads.download.downloaded,
|
|
||||||
track: downloads.download.track,
|
|
||||||
path: downloads.download.path
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}, 500);
|
|
||||||
|
|
||||||
});
|
});
|
||||||
await downloads.load();
|
await downloads.load();
|
||||||
|
//Emit download progress updates
|
||||||
|
setInterval(() => {
|
||||||
|
sockets.forEach((s) => {
|
||||||
|
if (!downloads.download) {
|
||||||
|
s.emit('download', null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
s.emit('download', {
|
||||||
|
id: downloads.download.id,
|
||||||
|
size: downloads.download.size,
|
||||||
|
downloaded: downloads.download.downloaded,
|
||||||
|
track: downloads.download.track,
|
||||||
|
path: downloads.download.path
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}, 350);
|
||||||
|
|
||||||
//Start server
|
//Start server
|
||||||
server.on('error', (e) => {
|
server.on('error', (e) => {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "freezer",
|
"name": "freezer",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "1.0.2",
|
"version": "1.0.3",
|
||||||
"description": "",
|
"description": "",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"pack": "electron-builder --dir",
|
"pack": "electron-builder --dir",
|
||||||
|
|
Loading…
Reference in New Issue