cody-music
Advanced tools
Comparing version 2.4.5 to 2.4.6
@@ -101,3 +101,2 @@ import { PlayerName, Track, PlayerDevice, SpotifyAudioFeature, PlaylistItem, CodyResponse, CodyConfig, PlayerContext } from "./models"; | ||
export declare function getUserProfile(): Promise<SpotifyUser>; | ||
export declare function isSpotifyUserLoggedIn(): Promise<boolean>; | ||
/** | ||
@@ -104,0 +103,0 @@ * Initiate the play command for a specific player |
@@ -339,6 +339,2 @@ "use strict"; | ||
exports.getUserProfile = getUserProfile; | ||
function isSpotifyUserLoggedIn() { | ||
return userProfile.isSpotifyUserLoggedIn(); | ||
} | ||
exports.isSpotifyUserLoggedIn = isSpotifyUserLoggedIn; | ||
/** | ||
@@ -345,0 +341,0 @@ * Initiate the play command for a specific player |
@@ -25,3 +25,2 @@ import { CodyResponse } from "./models"; | ||
spotifyApiDelete(api: string, qsOptions?: any, payload?: any): Promise<CodyResponse>; | ||
getSpotifyFeatureSiteResponse(): Promise<CodyResponse>; | ||
addQueryStringToApi(api: string, qsOptions?: any): string; | ||
@@ -28,0 +27,0 @@ buildSuccessResponse(resp: any): CodyResponse; |
@@ -21,5 +21,2 @@ "use strict"; | ||
}); | ||
const spotifyFeatureSiteClient = axios_1.default.create({ | ||
baseURL: "https://open.spotify.com/browse/featured" | ||
}); | ||
/** | ||
@@ -216,12 +213,2 @@ * Spotify Error Cases | ||
} | ||
getSpotifyFeatureSiteResponse() { | ||
return spotifyFeatureSiteClient | ||
.get("") | ||
.then((resp) => { | ||
return this.buildSuccessResponse(resp); | ||
}) | ||
.catch(async (err) => { | ||
return this.buildErrorResponse(err); | ||
}); | ||
} | ||
addQueryStringToApi(api, qsOptions = {}) { | ||
@@ -228,0 +215,0 @@ const qs = querystring.stringify(qsOptions); |
@@ -224,9 +224,12 @@ "use strict"; | ||
if (options.album_id) { | ||
return musicUtil.launchWebUrl(`https://open.spotify.com/album/${options.album_id}`); | ||
const albumId = musicUtil.createSpotifyIdFromUri(options.album_id); | ||
return musicUtil.launchWebUrl(`https://open.spotify.com/album/${albumId}`); | ||
} | ||
else if (options.track_id) { | ||
return musicUtil.launchWebUrl(`https://open.spotify.com/track/${options.track_id}`); | ||
const trackId = musicUtil.createSpotifyIdFromUri(options.track_id); | ||
return musicUtil.launchWebUrl(`https://open.spotify.com/track/${trackId}`); | ||
} | ||
else if (options.playlist_id) { | ||
return musicUtil.launchWebUrl(`https://open.spotify.com/playlist/${options.playlist_id}`); | ||
const playlistId = musicUtil.createSpotifyIdFromUri(options.playlist_id); | ||
return musicUtil.launchWebUrl(`https://open.spotify.com/playlist/${playlistId}`); | ||
} | ||
@@ -233,0 +236,0 @@ return musicUtil.launchWebUrl("https://open.spotify.com/browse"); |
@@ -16,3 +16,2 @@ export declare class SpotifyUser { | ||
getUserProfile(): Promise<SpotifyUser>; | ||
isSpotifyUserLoggedIn(): Promise<boolean>; | ||
} |
@@ -53,13 +53,3 @@ "use strict"; | ||
} | ||
async isSpotifyUserLoggedIn() { | ||
let response = await musicClient.getSpotifyFeatureSiteResponse(); | ||
if (response && response.data) { | ||
let body = response.data; | ||
if (body.includes("login") || body.includes("Log in")) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
} | ||
exports.UserProfile = UserProfile; |
@@ -15,4 +15,5 @@ import { PlayerName } from "./models"; | ||
formatString(source: string, params: any): string; | ||
createSpotifyIdFromUri(uri: string): string; | ||
extractAristFromSpotifyTrack(track: any): void; | ||
launchWebUrl(url: string): Promise<any>; | ||
} |
@@ -94,2 +94,8 @@ "use strict"; | ||
} | ||
createSpotifyIdFromUri(uri) { | ||
if (uri.indexOf("spotify:") === 0) { | ||
return uri.substring(uri.lastIndexOf(":") + 1); | ||
} | ||
return uri; | ||
} | ||
extractAristFromSpotifyTrack(track) { | ||
@@ -96,0 +102,0 @@ if (!track) { |
@@ -14,3 +14,2 @@ "use strict"; | ||
const util_1 = require("../util"); | ||
const models_1 = require("../../lib/models"); | ||
const userProfile = profile_1.UserProfile.getInstance(); | ||
@@ -47,26 +46,2 @@ const testUtil = new util_1.TestUtil(); | ||
}); | ||
// | ||
it("test user logon", done => { | ||
CodyMusic.getSpotifyRecentlyPlayedTracks(1).then(result => { | ||
let uri = result[0].uri; | ||
uri = uri.substring(uri.lastIndexOf(":") + 1); | ||
CodyMusic.pause(models_1.PlayerName.SpotifyWeb).then(result => { | ||
CodyMusic.getSpotifyDevices().then(result => { | ||
console.log("devices: ", result); | ||
done(); | ||
}); | ||
}); | ||
// CodyMusic.launchPlayer(PlayerName.SpotifyWeb, { | ||
// track_id: uri | ||
// }).then(result => { | ||
// CodyMusic.isSpotifyUserLoggedIn().then(result => { | ||
// console.log("spotify user logged on: ", result); | ||
// CodyMusic.getSpotifyDevices().then(result => { | ||
// console.log("devices: ", result); | ||
// done(); | ||
// }); | ||
// }); | ||
// }); | ||
}); | ||
}); | ||
it("fetch recently played tracks", done => { | ||
@@ -73,0 +48,0 @@ CodyMusic.getSpotifyRecentlyPlayedTracks(1).then(result => { |
@@ -253,12 +253,17 @@ import { MusicUtil } from "./util"; | ||
if (options.album_id) { | ||
const albumId = musicUtil.createSpotifyIdFromUri(options.album_id); | ||
return musicUtil.launchWebUrl( | ||
`https://open.spotify.com/album/${options.album_id}` | ||
`https://open.spotify.com/album/${albumId}` | ||
); | ||
} else if (options.track_id) { | ||
const trackId = musicUtil.createSpotifyIdFromUri(options.track_id); | ||
return musicUtil.launchWebUrl( | ||
`https://open.spotify.com/track/${options.track_id}` | ||
`https://open.spotify.com/track/${trackId}` | ||
); | ||
} else if (options.playlist_id) { | ||
const playlistId = musicUtil.createSpotifyIdFromUri( | ||
options.playlist_id | ||
); | ||
return musicUtil.launchWebUrl( | ||
`https://open.spotify.com/playlist/${options.playlist_id}` | ||
`https://open.spotify.com/playlist/${playlistId}` | ||
); | ||
@@ -265,0 +270,0 @@ } |
@@ -111,2 +111,9 @@ import { MusicStore } from "./store"; | ||
createSpotifyIdFromUri(uri: string) { | ||
if (uri.indexOf("spotify:") === 0) { | ||
return uri.substring(uri.lastIndexOf(":") + 1); | ||
} | ||
return uri; | ||
} | ||
extractAristFromSpotifyTrack(track: any) { | ||
@@ -113,0 +120,0 @@ if (!track) { |
{ | ||
"name": "cody-music", | ||
"version": "2.4.5", | ||
"version": "2.4.6", | ||
"description": "mac osx spotify and itunes music player controller, spotify audio features, itunes and spotify genre, and playlist control", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
358897
8735