diff --git a/Makefile b/Makefile index 2c7c39d..9fa6866 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,10 @@ help: .PHONY: start start: docker-compose-up watch-frontend ## Start containers and watch frontend +.PHONY: test +test: ## Run tests + docker-compose run --rm app yarn test + .PHONY: logs logs: ## Tail the app and worker logs docker-compose logs -f app worker @@ -23,7 +27,6 @@ migrate: ## Migrate database schema watch-frontend: ## Build and watch frontend for changes docker-compose run --rm app yarn watch-js - .PHONY: docker-compose-up docker-compose-up: ## Start (and create) docker containers docker-compose up -d diff --git a/lib/services/deezer/index.js b/lib/services/deezer/index.js index 2c058ac..6c49193 100644 --- a/lib/services/deezer/index.js +++ b/lib/services/deezer/index.js @@ -1,8 +1,11 @@ import { parse } from 'url'; import request from 'superagent'; import 'superagent-bluebird-promise'; +import debuglog from 'debug'; import urlMatch from './url'; +const debug = debuglog('combine.fm:deezer'); + const apiRoot = 'https://api.deezer.com'; export function parseUrl(url) { @@ -44,7 +47,7 @@ function looseMatch(needle, haystack, type, various) { export function* lookupId(id, type) { - const path = `/${type}/${id}`; + const path = `/${type}/${id}?size=xl`; const { body } = yield request.get(apiRoot + path).promise(); if (!body || body.error) { @@ -53,18 +56,12 @@ export function* lookupId(id, type) { return Promise.reject(error); } const item = body; - const coverUrl = item.cover || item.album.cover; - let cover = 'test'; - // nasty hacks for superagent-bluebird-promise - try { - cover = yield request.get(coverUrl).redirects(0); - } catch (err) { - cover = err.originalError.response; - } + const artwork = { - small: cover.headers.location.replace('120x120', '200x200'), - large: cover.headers.location.replace('120x120', '800x800'), + small: item.cover_medium || item.artist.picture_medium, + large: item.cover_xl || item.artist.picture_xl, }; + if (type === 'album') { return Promise.resolve({ service: 'deezer',