Skip to content

Commit

Permalink
add YouTube Music and Tidal
Browse files Browse the repository at this point in the history
  • Loading branch information
pendo324 committed Nov 10, 2019
1 parent 7952eb8 commit b62f535
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 18 deletions.
20 changes: 20 additions & 0 deletions src/players/Web/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,23 @@ export class bandcampHandler extends Handler {
});
}
}

export class youtubeMusicHandler extends Handler {
constructor() {
super({
...defaultOptions,
id: 'youtubeMusic',
name: 'YouTube Music'
});
}
}

export class tidalHandler extends Handler {
constructor() {
super({
...defaultOptions,
id: 'tidal',
name: 'Tidal'
});
}
}
38 changes: 20 additions & 18 deletions src/store/modules/now-playing/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,28 @@ const { writeFile } = require('fs').promises;
const actions = {
async setTrack(context, { preview } = { preview: false }) {
const { state, commit, getters } = context;
if (state.player.source === 'Desktop') {
try {
const track = await state.player.getTrack();
commit('SET_TRACK', {
track
});
if (!preview) {
await writeFile(state.saveLocation, getters.nowPlaying, {
encoding: 'utf8'
if (state.player !== null) {
if (state.player.source === 'Desktop') {
try {
const track = await state.player.getTrack();
commit('SET_TRACK', {
track
});
if (!preview) {
await writeFile(state.saveLocation, getters.nowPlaying, {
encoding: 'utf8'
});
}
} catch (e) {
console.log(e);
return commit('SET_TRACK', {
track: ''
});
}
} catch (e) {
console.log(e);
return commit('SET_TRACK', {
track: ''
});
}
} else if (state.player.source === 'Web') {
if (!preview) {
await writeFile(state.saveLocation, getters.nowPlaying);
} else if (state.player.source === 'Web') {
if (!preview) {
await writeFile(state.saveLocation, getters.nowPlaying);
}
}
}
}
Expand Down

0 comments on commit b62f535

Please sign in to comment.