Added GSU's cover
This commit is contained in:
parent
8b64b70be4
commit
420374ea58
2 changed files with 25 additions and 9 deletions
|
@ -6,6 +6,7 @@ module.exports = {
|
||||||
discogsToken: process.env.discogsToken,
|
discogsToken: process.env.discogsToken,
|
||||||
delay: process.env.delay || 4000,
|
delay: process.env.delay || 4000,
|
||||||
rx3List: ['Rx3', 'REAL REBEL RADIO', 'REAL REBEL RADIO homemade'],
|
rx3List: ['Rx3', 'REAL REBEL RADIO', 'REAL REBEL RADIO homemade'],
|
||||||
|
rx3CoverBaseUrl: process.env.rx3CoverBaseUrl,
|
||||||
colors: {
|
colors: {
|
||||||
Reset: '\x1b[0m',
|
Reset: '\x1b[0m',
|
||||||
Bright: '\x1b[1m',
|
Bright: '\x1b[1m',
|
||||||
|
|
33
libs.js
33
libs.js
|
@ -60,12 +60,35 @@ const getLastSong = (callback) => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fonction permettant de retrouver la cover d'un titre Rx3
|
||||||
|
* @param {Object} song
|
||||||
|
* @param {Function} callback
|
||||||
|
*/
|
||||||
|
const getRx3Cover = (song, callback) => {
|
||||||
|
let cover = null
|
||||||
|
// Cas des GSU
|
||||||
|
if (song.title.indexOf('GSU') === 0) {
|
||||||
|
const year = song.title.split(' ')[1]
|
||||||
|
|
||||||
|
if (!isNaN(parseInt(year))) {
|
||||||
|
cover = `${config.rx3CoverBaseUrl}gsu${year}.jpg`
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(null, cover)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fonction permettant de chercher sur Discogs la pochette d'un album
|
* Fonction permettant de chercher sur Discogs la pochette d'un album
|
||||||
* @param {Object} song
|
* @param {Object} song
|
||||||
* @param {Function} callback
|
* @param {Function} callback
|
||||||
*/
|
*/
|
||||||
const getRemoteCover = (song, callback) => {
|
const getRemoteCover = (song, callback) => {
|
||||||
|
if (config.rx3List.indexOf(song.artist) !== -1) {
|
||||||
|
getRx3Cover(song, callback)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// Si c'est KOЯN on remplace par KORN (merci discogs)
|
// Si c'est KOЯN on remplace par KORN (merci discogs)
|
||||||
if (song.artist === 'KOЯN') {
|
if (song.artist === 'KOЯN') {
|
||||||
song.artist = 'KORN'
|
song.artist = 'KORN'
|
||||||
|
@ -94,14 +117,6 @@ const getRemoteCover = (song, callback) => {
|
||||||
* @param {Function} callback
|
* @param {Function} callback
|
||||||
*/
|
*/
|
||||||
const findCover = (song, callback) => {
|
const findCover = (song, callback) => {
|
||||||
// Si c'est Rx3 on ne met pas de cover
|
|
||||||
if (config.rx3List.indexOf(song.artist) !== -1) {
|
|
||||||
const metadata = new mongo.Metadata(song)
|
|
||||||
metadata.save()
|
|
||||||
callback(null, null)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
mongo.Metadata.findOne({
|
mongo.Metadata.findOne({
|
||||||
id: song.id
|
id: song.id
|
||||||
})
|
})
|
||||||
|
@ -121,7 +136,7 @@ const findCover = (song, callback) => {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Aucune pochette trouvée, on interroge Discogs
|
// Aucune pochette trouvée, on interroge Discogs (peut être que cette fois ils auront une cover...)
|
||||||
getRemoteCover(song, (err, coverUrl) => {
|
getRemoteCover(song, (err, coverUrl) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
callback(err)
|
callback(err)
|
||||||
|
|
Loading…
Reference in a new issue