Fix Deezer covers
This commit is contained in:
parent
2c7e4f9dee
commit
2245428465
2 changed files with 12 additions and 12 deletions
5
Makefile
5
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
|
||||
|
|
|
@ -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',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue