change to library-songs retrieval method
This commit is contained in:
parent
f6bce2019d
commit
082137ed9d
4 changed files with 13283 additions and 166 deletions
|
@ -1,17 +1,32 @@
|
|||
const MusicKitTools = {
|
||||
async v3Continuous (href, options = {}, reqOptions = {}) {
|
||||
async v3Continuous ({
|
||||
href,
|
||||
options = {},
|
||||
reqOptions = {},
|
||||
onProgress = () => {},
|
||||
onError = () => {},
|
||||
onSuccess = () => {}
|
||||
} = {}) {
|
||||
let returnData = []
|
||||
async function sendReq(href, options) {
|
||||
const response = await app.mk.api.v3.music(href, options)
|
||||
const response = await app.mk.api.v3.music(href, options).catch(error => onError)
|
||||
|
||||
returnData = returnData.concat(response.data.data)
|
||||
if(response.data.next) {
|
||||
onProgress({
|
||||
response: response,
|
||||
total: returnData.length
|
||||
})
|
||||
try {
|
||||
await sendReq(response.data.next, options)
|
||||
}catch(e){
|
||||
await sendReq(response.data.next, options)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await sendReq(href, options)
|
||||
|
||||
onSuccess(returnData)
|
||||
return returnData
|
||||
},
|
||||
getHeader() {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {store} from './vuex-store.js';
|
||||
import { store } from './vuex-store.js';
|
||||
|
||||
Vue.use(VueHorizontal);
|
||||
Vue.use(VueObserveVisibility);
|
||||
|
@ -1017,7 +1017,7 @@ const app = new Vue({
|
|||
console.log("playlist has no cache")
|
||||
}
|
||||
|
||||
if(cachedTrackMapping) {
|
||||
if (cachedTrackMapping) {
|
||||
console.log("using cached track mapping")
|
||||
this.playlists.trackMapping = cachedTrackMapping
|
||||
}
|
||||
|
@ -1033,7 +1033,7 @@ const app = new Vue({
|
|||
const playlistData = await app.mk.api.v3.music(`/v1/me/library/playlist-folders/${parent}/children/`)
|
||||
await asyncForEach(playlistData.data.data, async (playlist) => {
|
||||
playlist.parent = parent
|
||||
if(
|
||||
if (
|
||||
playlist.type != "library-playlist-folders" &&
|
||||
typeof playlist.attributes.playParams["versionHash"] != "undefined"
|
||||
) {
|
||||
|
@ -1401,7 +1401,7 @@ const app = new Vue({
|
|||
*/
|
||||
convertTime(time = 0, format = 'short') {
|
||||
|
||||
if(isNaN(time)) {
|
||||
if (isNaN(time)) {
|
||||
time = 0
|
||||
}
|
||||
if (typeof time !== "number") {
|
||||
|
@ -1516,9 +1516,9 @@ const app = new Vue({
|
|||
document.querySelector("#app-content").scrollTop = 0
|
||||
} else if (kind == "editorial-elements") {
|
||||
console.log(item)
|
||||
if (item.relationships?.contents?.data != null && item.relationships?.contents?.data.length > 0){
|
||||
if (item.relationships?.contents?.data != null && item.relationships?.contents?.data.length > 0) {
|
||||
this.routeView(item.relationships.contents.data[0])
|
||||
} else if (item.attributes?.link?.url != null){
|
||||
} else if (item.attributes?.link?.url != null) {
|
||||
window.open(item.attributes.link.url)
|
||||
}
|
||||
|
||||
|
@ -2048,7 +2048,7 @@ const app = new Vue({
|
|||
}
|
||||
let librarySongs = await CiderCache.getCache(cacheId)
|
||||
if (librarySongs) {
|
||||
this.library.songs.listing = librarySongs
|
||||
this.library.songs.listing.data = librarySongs
|
||||
this.searchLibrarySongs()
|
||||
}
|
||||
if (this.songstest) {
|
||||
|
@ -2058,8 +2058,9 @@ const app = new Vue({
|
|||
this.library.backgroundNotification.show = true
|
||||
this.library.backgroundNotification.message = app.getLz('notification.updatingLibrarySongs')
|
||||
|
||||
function downloadChunk() {
|
||||
const params = {
|
||||
library = await MusicKitTools.v3Continuous({
|
||||
href: `/v1/me/library/songs/`,
|
||||
options: {
|
||||
"include[library-songs]": "catalog,artists,albums",
|
||||
"fields[artists]": "name,url,id",
|
||||
"fields[albums]": "name,url,id",
|
||||
|
@ -2067,80 +2068,28 @@ const app = new Vue({
|
|||
"fields[catalog]": "artistUrl,albumUrl",
|
||||
"fields[songs]": "artistName,artistUrl,artwork,contentRating,editorialArtwork,name,playParams,releaseDate,url",
|
||||
limit: 100,
|
||||
l: self.mklang
|
||||
}
|
||||
const safeparams = {
|
||||
"platform": "web",
|
||||
"limit": 80
|
||||
}
|
||||
self.library.songs.downloadState = 1
|
||||
if (downloaded == null) {
|
||||
app.mk.api.v3.music(`/v1/me/library/songs/`, params).then((response) => {
|
||||
processChunk(response.data)
|
||||
}).catch((error) => {
|
||||
console.log('safe loading');
|
||||
app.mk.api.v3.music(`/v1/me/library/songs/`, safeparams).then((response) => {
|
||||
processChunk(response.data)
|
||||
}).catch((error) => {
|
||||
console.log('safe loading failed', error)
|
||||
app.library.songs.downloadState = 2
|
||||
app.library.backgroundNotification.show = false
|
||||
})
|
||||
})
|
||||
} else {
|
||||
if (downloaded.next != null) {
|
||||
app.mk.api.v3.music(downloaded.next, params).then((response) => {
|
||||
processChunk(response.data)
|
||||
}).catch((error) => {
|
||||
console.log('safe loading');
|
||||
app.mk.api.v3.music(downloaded.next, safeparams).then((response) => {
|
||||
processChunk(response.data)
|
||||
}).catch((error) => {
|
||||
console.log('safe loading failed', error)
|
||||
app.library.songs.downloadState = 2
|
||||
app.library.backgroundNotification.show = false
|
||||
})
|
||||
})
|
||||
} else {
|
||||
console.log("Download next", downloaded.next)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function processChunk(response) {
|
||||
downloaded = response
|
||||
library = library.concat(downloaded.data)
|
||||
l: app.mklang,
|
||||
},
|
||||
onProgress: (data) => {
|
||||
console.log(`${data.total}/${data.response.data.meta.total}`)
|
||||
self.library.backgroundNotification.show = true
|
||||
self.library.backgroundNotification.message = app.getLz('notification.updatingLibrarySongs')
|
||||
self.library.backgroundNotification.total = downloaded.meta.total
|
||||
self.library.backgroundNotification.progress = library.length
|
||||
self.library.backgroundNotification.total = data.response.data.meta.total
|
||||
self.library.backgroundNotification.progress = data.total
|
||||
},
|
||||
onSuccess: () => {
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
self.library.songs.listing = library
|
||||
self.library.songs.downloadState = 2
|
||||
self.library.backgroundNotification.show = false
|
||||
self.searchLibrarySongs()
|
||||
CiderCache.putCache(cacheId, library)
|
||||
console.log("Done!")
|
||||
|
||||
if (downloaded.meta.total == 0) {
|
||||
self.library.songs.downloadState = 3
|
||||
return
|
||||
}
|
||||
if (typeof downloaded.next == "undefined") {
|
||||
console.log("downloaded.next is undefined")
|
||||
self.library.songs.listing = library
|
||||
self.library.songs.downloadState = 2
|
||||
self.library.backgroundNotification.show = false
|
||||
self.searchLibrarySongs()
|
||||
CiderCache.putCache(cacheId, library)
|
||||
}
|
||||
if (downloaded.meta.total > library.length || typeof downloaded.meta.next != "undefined") {
|
||||
console.log(`downloading next chunk - ${library.length} songs so far`)
|
||||
downloadChunk()
|
||||
} else {
|
||||
self.library.songs.listing = library
|
||||
self.library.songs.downloadState = 2
|
||||
self.library.backgroundNotification.show = false
|
||||
self.searchLibrarySongs()
|
||||
CiderCache.putCache(cacheId, library)
|
||||
// console.log(library)
|
||||
}
|
||||
}
|
||||
|
||||
downloadChunk()
|
||||
},
|
||||
// copy the getLibrarySongsFull function except change Songs to Albums
|
||||
async getLibraryAlbumsFull(force = false, index) {
|
||||
|
@ -3868,14 +3817,15 @@ const app = new Vue({
|
|||
}
|
||||
},
|
||||
pinMiniPlayer(status = false) {
|
||||
if (!status){
|
||||
if (!status) {
|
||||
if (!this.cfg.visual.miniplayer_top_toggle) {
|
||||
ipcRenderer.send('windowontop', true)
|
||||
this.cfg.visual.miniplayer_top_toggle = true;
|
||||
} else {
|
||||
ipcRenderer.send('windowontop', false)
|
||||
this.cfg.visual.miniplayer_top_toggle = false;
|
||||
}} else {
|
||||
}
|
||||
} else {
|
||||
ipcRenderer.send('windowontop', this.cfg.visual.miniplayer_top_toggle ?? false)
|
||||
}
|
||||
},
|
||||
|
|
13152
src/renderer/style.css
Normal file
13152
src/renderer/style.css
Normal file
File diff suppressed because it is too large
Load diff
|
@ -558,14 +558,14 @@ input[type=range].web-slider::-webkit-slider-runnable-track {
|
|||
.app-sidebar-notification {
|
||||
text-align: center;
|
||||
font-size: 12px;
|
||||
min-height: 60px;
|
||||
min-height: 36px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
border-top: 1px solid rgb(200 200 200 / 15%);
|
||||
background: rgb(0 0 0 / 15%);
|
||||
flex-direction: column;
|
||||
padding: 20px 0px;
|
||||
padding: 10px 0px;
|
||||
|
||||
&.libraryNotification {
|
||||
flex-direction: row;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue