-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathliri.js
90 lines (71 loc) · 2.49 KB
/
liri.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
require("dotenv").config();
var axios = require("axios");
var moment = require("moment");
var keys = require("./keys.js");
var Spotify = require('node-spotify-api');
var spotify = new Spotify(keys.spotify);
var userinput1 = process.argv[2];
var userinput2 = process.argv[3];
switch (userinput1) {
case ("concert-this"):
concertThis();
break;
case ("spotify-this-song"):
spotifyThis();
break;
case ("movie-this"):
movieThis();
break;
default:
console.log("Please enter something else.")
};
function concertThis() {
axios.get("https://rest.bandsintown.com/artists/" + userinput2 + "/events?app_id=codingbootcamp").then(
function (response) {
for (let i = 0; i < response.data.length; i++) {
var convDate = moment(response.data[0].datetime).format('MM/DD/YYYY')
console.log("Venue: " + response.data[i].venue.name + "\nCity: " + response.data[i].venue.city);
console.log("Date: " + convDate)
console.log("===============================")
}
}
);
}
function spotifyThis() {
spotify.search({type: 'track', query: userinput2, limit: 10}, function(error, data) {
if (error) {
console.log("Something went wrong.")
console.log(error)
} else {
for (let i = 0; i < data.tracks.items.length; i++) {
console.log(
"Artist: " + data.tracks.items[i].artists[0].name +
"\nSong: " + data.tracks.items[i].name +
"\nPreview URL: " + data.tracks.items[i].preview_url +
"\nAlbum: " + data.tracks.items[i].album.name)
console.log("===============================")
}
}
})
}
function movieThis() {
axios.get("http://www.omdbapi.com/?apikey=trilogy&" + "t=" + userinput2).then(
function (response) {
console.log("==================")
console.log("Title: " + response.data.Title +
"\nYear Released: " + response.data.Year +
"\nIMDB Rating: " + response.data.imdbRating +
"\nRotten Tomatoes Rating: " + response.data.Ratings[1].Value +
"\nCountry of Production: " + response.data.Country +
"\nLanguage: " + response.data.Language +
"\nPlot: " + response.data.Plot +
"\nActors: " + response.data.Actors)
console.log("==================")
}
);
if (userinput2 === "Mr.Nobody") {
console.log("==================")
console.log("If you haven't watched 'Mr. Nobody,' then you should: http://www.imdb.com/title/tt0485947/");
console.log("It's on Netflix!");
}
}