Almost working spotify protocol support
This commit is contained in:
parent
672a6591be
commit
02ce37f40a
2 changed files with 24 additions and 1 deletions
|
@ -159,7 +159,7 @@ export class AppEvents {
|
||||||
|
|
||||||
// Spotify Protocols
|
// Spotify Protocols
|
||||||
else if (arg.startsWith("spotify://")) {
|
else if (arg.startsWith("spotify://")) {
|
||||||
|
app.spotifyConvert
|
||||||
}
|
}
|
||||||
|
|
||||||
// Play
|
// Play
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import {utils} from "../main/base/utils";
|
||||||
|
|
||||||
Vue.use(VueHorizontal);
|
Vue.use(VueHorizontal);
|
||||||
Vue.use(VueObserveVisibility);
|
Vue.use(VueObserveVisibility);
|
||||||
var notyf = new Notyf();
|
var notyf = new Notyf();
|
||||||
|
@ -313,6 +315,27 @@ const app = new Vue({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
spotifyConvert(spotURL) {
|
||||||
|
notyf.open({ type: "info", message: app.getLz('term.spotify.coverting') })
|
||||||
|
let self = this
|
||||||
|
let httpRequest = new XMLHttpRequest();
|
||||||
|
let newURL = "https://open.spotify.com/" + spotURL.split("spotify://")[1]
|
||||||
|
console.log(newURL)
|
||||||
|
httpRequest.open('GET', `https://api.song.link/v1-alpha.1/links?url=${newURL}&userCountry=US`, true);
|
||||||
|
httpRequest.send();
|
||||||
|
httpRequest.onreadystatechange = function () {
|
||||||
|
if (httpRequest.readyState === 4) {
|
||||||
|
if (httpRequest.status === 200) {
|
||||||
|
let response = JSON.parse(httpRequest.responseText);
|
||||||
|
console.log(response);
|
||||||
|
utils.getWindow().webContents.send('play', 'url', response.linksByPlatform.appleMusic.url)
|
||||||
|
} else {
|
||||||
|
console.log('There was a problem with the request.');
|
||||||
|
notyf.error(app.getLz('term.requestError'))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
mainMenuVisibility(val) {
|
mainMenuVisibility(val) {
|
||||||
if (val) {
|
if (val) {
|
||||||
(this.mk.isAuthorized) ? this.chrome.menuOpened = !this.chrome.menuOpened : false;
|
(this.mk.isAuthorized) ? this.chrome.menuOpened = !this.chrome.menuOpened : false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue