-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
32 lines (26 loc) 路 741 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const GoogleHomeNotifier = require('@shooontan/google-home-notifier');
require("dotenv").config();
var keys = require("./keys.js");
var Spotify = require('node-spotify-api');
var spotify = new Spotify(keys.spotify);
process.argv.forEach((val) => {
getArgs = (`${val} `);
});
spotify
.search({ type: 'track', query: `${getArgs}` })
.then(function(response) {
var data = response.tracks.items[0].preview_url
return data;
})
.then(function (data) {
console.log(data);
(async () => {
const notifier = GoogleHomeNotifier();
await notifier.create();
const mp3Url = data;
await notifier.play(mp3Url)
})();
})
.catch(function(err) {
console.log(err);
});