Fix Spotify matching with their new urls

This commit is contained in:
Jonathan Cremin 2018-04-10 23:55:24 +01:00
parent f1d7faf02d
commit 9e4626daa4
2 changed files with 3 additions and 2 deletions

View file

@ -38,6 +38,7 @@ function looseMatch(needle, haystack, type) {
} }
export function* lookupId(id, type) { export function* lookupId(id, type) {
console.log(id);
const token = yield spotify.clientCredentialsGrant(); const token = yield spotify.clientCredentialsGrant();
spotify.setAccessToken(token.body['access_token']); spotify.setAccessToken(token.body['access_token']);
let data = yield spotify[`get${type.charAt(0).toUpperCase()}${type.slice(1)}s`]([id]); let data = yield spotify[`get${type.charAt(0).toUpperCase()}${type.slice(1)}s`]([id]);
@ -132,7 +133,7 @@ export function* search(data, original = {}) {
} }
export function* parseUrl(url) { export function* parseUrl(url) {
const matches = parse(url).path.match(/\/(album|track)[/]+([^/]+)/); const matches = parse(url).path.match(/\/(album|track)[/]+([A-Za-z0-9]+)/);
if (matches && matches[2]) { if (matches && matches[2]) {
return yield lookupId(matches[2], matches[1]); return yield lookupId(matches[2], matches[1]);

View file

@ -6,6 +6,6 @@ export default function match(url) {
return false; return false;
} }
const matches = parse(url).path.match(/\/(album|track)[/]+([^/]+)/); const matches = parse(url).path.match(/\/(album|track)[/]+([A-Za-z0-9]+)/);
return matches && !!matches[2]; return matches && !!matches[2];
} }