Finally finished giant ES6 refactor
This commit is contained in:
parent
c6d48cc424
commit
03e2666958
39 changed files with 553 additions and 635 deletions
|
@ -1,14 +1,15 @@
|
|||
import {parse} from 'url';
|
||||
import { parse } from 'url';
|
||||
import request from 'superagent';
|
||||
import 'superagent-bluebird-promise';
|
||||
import { match as urlMatch } from './url';
|
||||
|
||||
module.exports.id = 'deezer';
|
||||
export let id = 'deezer';
|
||||
|
||||
const apiRoot = 'https://api.deezer.com';
|
||||
|
||||
module.exports.match = require('./url').match;
|
||||
export const match = urlMatch;
|
||||
|
||||
module.exports.parseUrl = function(url) {
|
||||
export function parseUrl(url) {
|
||||
let matches = parse(url).path.match(/\/(album|track)[\/]+([^\/]+)/);
|
||||
|
||||
if (matches && matches[2]) {
|
||||
|
@ -18,7 +19,7 @@ module.exports.parseUrl = function(url) {
|
|||
}
|
||||
};
|
||||
|
||||
module.exports.lookupId = function* (id, type) {
|
||||
export function* lookupId(id, type) {
|
||||
let path = '/' + type + '/' + id;
|
||||
|
||||
let {body} = yield request.get(apiRoot + path).promise();
|
||||
|
@ -74,7 +75,7 @@ module.exports.lookupId = function* (id, type) {
|
|||
}
|
||||
};
|
||||
|
||||
module.exports.search = function* (data) {
|
||||
export function* search(data) {
|
||||
let cleanParam = function(str) {
|
||||
return str.replace(/[\:\?\&]+/, '');
|
||||
};
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
"use strict";
|
||||
var parse = require('url').parse;
|
||||
import { parse } from 'url';
|
||||
|
||||
module.exports.match = function(url) {
|
||||
var parsed = parse(url);
|
||||
export function* match(url) {
|
||||
const parsed = parse(url);
|
||||
if (!parsed.host.match(/deezer\.com$/)) {
|
||||
return false;
|
||||
}
|
||||
var matches = parsed.path.match(/\/(album|track)[\/]+([^\/]+)/);
|
||||
const matches = parsed.path.match(/\/(album|track)[\/]+([^\/]+)/);
|
||||
return matches.length > 1;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue