Use native esm
This commit is contained in:
parent
c4354a6600
commit
70bd12a4d6
37 changed files with 379 additions and 119 deletions
|
@ -1,14 +1,4 @@
|
|||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
|
||||
var services = [];
|
||||
|
||||
fs.readdirSync(path.join(__dirname, 'services')).forEach(function(file) {
|
||||
const service = require(path.join(__dirname, 'services', file));
|
||||
if (service.search) {
|
||||
services.push(service);
|
||||
}
|
||||
});
|
||||
import services from './services.js';
|
||||
|
||||
export default async function (url) {
|
||||
let matchedService;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import fs from 'fs';
|
||||
import { createBundleRenderer } from 'vue-server-renderer';
|
||||
import vueServerRenderer from 'vue-server-renderer';
|
||||
|
||||
const createBundleRenderer = vueServerRenderer.createBundleRenderer;
|
||||
|
||||
const app = fs.readFileSync('./public/dist/js/main-server.js', 'utf8');
|
||||
const renderer = createBundleRenderer(app);
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import * as deezer from './services/deezer/index.js';
|
||||
import * as google from './services/google/index.js';
|
||||
import * as itunes from './services/itunes/index.js';
|
||||
import * as spotify from './services/spotify/index.js';
|
||||
import * as youtube from './services/youtube/index.js';
|
||||
|
||||
const services = [];
|
||||
|
||||
fs.readdirSync(path.join(__dirname, 'services')).forEach((file) => {
|
||||
const service = require(path.join(__dirname, 'services', file));
|
||||
if (service.search) {
|
||||
services.push(service);
|
||||
}
|
||||
});
|
||||
const services = [
|
||||
deezer,
|
||||
google,
|
||||
itunes,
|
||||
spotify,
|
||||
youtube,
|
||||
]
|
||||
|
||||
export default services;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { parse } from 'url';
|
||||
import request from 'superagent';
|
||||
import debuglog from 'debug';
|
||||
import urlMatch from './url';
|
||||
import urlMatch from './url.js';
|
||||
|
||||
const debug = debuglog('combine.fm:deezer');
|
||||
|
||||
|
@ -11,7 +11,7 @@ export function parseUrl(url) {
|
|||
const matches = parse(url).path.match(/\/(album|track)[/]+([^/]+)/);
|
||||
|
||||
if (matches && matches[2]) {
|
||||
return module.exports.lookupId(matches[2], matches[1]);
|
||||
return lookupId(matches[2], matches[1]);
|
||||
}
|
||||
throw new Error();
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ export async function search(data, original = {}) {
|
|||
match = looseMatch(name, response.body.data, data.type, various);
|
||||
}
|
||||
|
||||
return await module.exports.lookupId(response.body.data[0].id, type);
|
||||
return await lookupId(response.body.data[0].id, type);
|
||||
}
|
||||
const matches = album.match(/^[^([]+/);
|
||||
if (matches && matches[0] && matches[0] !== album) {
|
||||
|
@ -141,7 +141,7 @@ export async function search(data, original = {}) {
|
|||
} else if (type === 'track') {
|
||||
cleanedData.albumName = matches[0].trim();
|
||||
}
|
||||
return await module.exports.search(cleanedData, data);
|
||||
return await search(cleanedData, data);
|
||||
}
|
||||
return Promise.resolve({ service: 'deezer' });
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ import { parse } from 'url';
|
|||
import bluebird from 'bluebird';
|
||||
import PlayMusic from 'playmusic';
|
||||
import debuglog from 'debug';
|
||||
import urlMatch from './url';
|
||||
import urlMatch from './url.js';
|
||||
|
||||
const debug = debuglog('combine.fm:google');
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { parse } from 'url';
|
||||
import querystring from 'querystring';
|
||||
import request from 'superagent';
|
||||
import urlMatch from './url';
|
||||
import urlMatch from './url.js';
|
||||
|
||||
const apiRoot = 'https://itunes.apple.com';
|
||||
|
||||
|
@ -22,7 +22,7 @@ export async function parseUrl(url) {
|
|||
}
|
||||
}
|
||||
|
||||
return await module.exports.lookupId(itunesId, type, matches[1] || 'us');
|
||||
return await lookupId(itunesId, type, matches[1] || 'us');
|
||||
}
|
||||
throw new Error();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { parse } from 'url';
|
||||
import SpotifyWebApi from 'spotify-web-api-node';
|
||||
import urlMatch from './url';
|
||||
import urlMatch from './url.js';
|
||||
|
||||
const spotify = new SpotifyWebApi({
|
||||
clientId: process.env.SPOTIFY_CLIENT_ID,
|
||||
|
|
|
@ -2,9 +2,9 @@ import { parse } from 'url';
|
|||
import querystring from 'querystring';
|
||||
import request from 'superagent';
|
||||
import Nodebrainz from 'nodebrainz';
|
||||
import { toSeconds, parse as ptParse } from 'iso8601-duration';
|
||||
import iso8601 from 'iso8601-duration';
|
||||
import debuglog from 'debug';
|
||||
import urlMatch from './url';
|
||||
import urlMatch from './url.js';
|
||||
|
||||
const debug = debuglog('combine.fm:youtube');
|
||||
|
||||
|
@ -32,7 +32,7 @@ export async function lookupId(id) {
|
|||
const result = await request.get(apiRoot + path);
|
||||
const item = result.body.items[0].snippet;
|
||||
|
||||
const duration = toSeconds(ptParse(result.body.items[0].contentDetails.duration));
|
||||
const duration = iso8601.toSeconds(iso8601.parse(result.body.items[0].contentDetails.duration));
|
||||
|
||||
const split = item.title.match(/([^-]+)-(.*)/);
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import co from 'co';
|
||||
import debuglog from 'debug';
|
||||
|
||||
import models from '../models';
|
||||
import services from '../lib/services';
|
||||
import models from '../models/index.cjs';
|
||||
|
||||
const debug = debuglog('combine.fm:share');
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue