Skip to content
This repository has been archived by the owner on May 16, 2022. It is now read-only.

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
davipatury committed Aug 26, 2020
1 parent 3867d4e commit 4165b09
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/apis/Youtube.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ class YoutubeAPI {

static getBestThumbnail (thumbnails) {
if (!thumbnails) return {}
const { high, maxres, medium, standard, default: def } = thumbnails
return maxres || high || medium || standard || def
return [ 'maxres', 'high', 'medium', 'standard', 'default' ].find(q => thumbnails[q])
}

// Internal
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const MusicManager = require('./structures/MusicManager')

const manager = new MusicManager()
manager.connect().then(async () => {
const [song] = await manager.songProvider.get('https://open.spotify.com/track/1JYZf5oWWfEVLpl7HjMGiz?si=nl_uSrFHTCKwesCQQhQXpw') // ytsearch:girassol da cor do seu cabelo
const song = await manager.songProvider.get('https://open.spotify.com/track/1JYZf5oWWfEVLpl7HjMGiz?si=nl_uSrFHTCKwesCQQhQXpw') // ytsearch:girassol da cor do seu cabelo
const player = await manager.lavalink.join({
guild: '445203868624748555',
channel: '701928171519344801',
Expand Down
12 changes: 12 additions & 0 deletions src/structures/lavacord/Song.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ class Song {
return this.info.source
}

// Methods
async fetchExtraInfo () {
switch (this.source) {
case 'youtube':
return {} // TODO: YoutubeAPI request
case 'soundcloud':
return {} // TODO: SoundcloudAPI request
default:
return {}
}
}

// Static
static from (track) {
return new this(track, this.decodeTrack(track))
Expand Down
2 changes: 1 addition & 1 deletion src/structures/providers/SongProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class SongProvider {
} catch (e) {
console.error(e)
}
return alternativeLoad || this.loadTracks(identifier)
return alternativeLoad || this.loadTracks(identifier).then(tracks => tracks[0])
}

async alternativeLoad (identifier) {
Expand Down
7 changes: 6 additions & 1 deletion src/structures/providers/spotify/SpotifyProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ class SpotifyProvider {
static async getAlbum (provider, identifier) {
const albumResult = ALBUM_REGEX.map(r => r.exec(identifier)).find(r => r)
if (albumResult) {
const [, id] = albumResult
const album = await SpotifyAPI.getAlbum(id)
if (album) {

}
}
}

Expand All @@ -47,7 +51,8 @@ class SpotifyProvider {
static async fetchTrack (provider, track) {
const video = await YoutubeAPI.getClosestMatch(`${track.artists.map(a => a.name).join(', ')} - ${track.name}`)
if (video) {
return provider.loadTracks(video.id, 1, (code, info) => new SpotifySong(code, info, track, video))
const [song] = await provider.loadTracks(video.id, 1, (code, info) => new SpotifySong(code, info, track, video))
return song
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/structures/providers/spotify/SpotifySong.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ class SpotifySong extends Song {
get source () {
return 'spotify'
}

fetchExtraInfo () {
return this.spotifyTrack
}
}

module.exports = SpotifySong

0 comments on commit 4165b09

Please sign in to comment.