Some service api fixes
This commit is contained in:
parent
2225712d5f
commit
3ea715de39
6 changed files with 425 additions and 249 deletions
|
@ -1,45 +1,62 @@
|
|||
import 'should';
|
||||
import * as deezer from '../../lib/services/deezer/index.js';
|
||||
import "should";
|
||||
import * as deezer from "../../lib/services/deezer/index.js";
|
||||
|
||||
describe('Deezer', () => {
|
||||
describe('lookupId', () => {
|
||||
it('should find album by ID', async function test() {
|
||||
const result = await deezer.lookupId('302127', 'album');
|
||||
result.name.should.equal('Discovery');
|
||||
describe("Deezer", () => {
|
||||
describe("lookupId", () => {
|
||||
it("should find album by ID", async function test() {
|
||||
const result = await deezer.lookupId("302127", "album");
|
||||
result.name.should.equal("Discovery");
|
||||
});
|
||||
|
||||
it('should find track by ID', async function (){
|
||||
const result = await deezer.lookupId('3135554', 'track');
|
||||
result.name.should.equal('Aerodynamic');
|
||||
it("should find track by ID", async function() {
|
||||
const result = await deezer.lookupId("3135554", "track");
|
||||
result.name.should.equal("Aerodynamic");
|
||||
});
|
||||
});
|
||||
|
||||
describe('search', () => {
|
||||
it('should find album by search', async function (){
|
||||
const result = await deezer.search({type: 'album', artist: {name: 'Jamie xx'}, name: 'In Colour'});
|
||||
result.name.should.startWith('In Colour');
|
||||
describe("search", () => {
|
||||
it("should find album by search", async function() {
|
||||
const result = await deezer.search({
|
||||
type: "album",
|
||||
artist: { name: "Jamie xx" },
|
||||
name: "In Colour"
|
||||
});
|
||||
result.name.should.startWith("In Colour");
|
||||
});
|
||||
|
||||
it('should find album with various artists by search', async function (){
|
||||
const result = await deezer.search({type: 'album', artist: {name: 'Various Artists'}, name: 'The Trevor Nelson Collection'});
|
||||
result.name.should.equal('The Trevor Nelson Collection');
|
||||
it("should find album with various artists by search", async function() {
|
||||
const result = await deezer.search({
|
||||
type: "album",
|
||||
artist: { name: "Various Artists" },
|
||||
name: "Rocket League x Monstercat Vol. 6"
|
||||
});
|
||||
result.name.should.equal("Rocket League x Monstercat Vol. 6");
|
||||
});
|
||||
|
||||
it('should find track by search', async function (){
|
||||
const result = await deezer.search({type: 'track', artist: {name: 'Deftones'}, albumName: 'Deftones', name: 'Hexagram'});
|
||||
result.name.should.equal('Hexagram');
|
||||
it("should find track by search", async function() {
|
||||
const result = await deezer.search({
|
||||
type: "track",
|
||||
artist: { name: "Deftones" },
|
||||
albumName: "Deftones",
|
||||
name: "Hexagram"
|
||||
});
|
||||
result.name.should.equal("Hexagram");
|
||||
});
|
||||
});
|
||||
|
||||
describe('lookupUrl', () => {
|
||||
describe('parseUrl', () => {
|
||||
it('should parse album url into ID', async function (){
|
||||
const result = await deezer.parseUrl('http://www.deezer.com/album/302127');
|
||||
describe("lookupUrl", () => {
|
||||
describe("parseUrl", () => {
|
||||
it("should parse album url into ID", async function() {
|
||||
const result = await deezer.parseUrl(
|
||||
"http://www.deezer.com/album/302127"
|
||||
);
|
||||
result.id.should.equal(302127);
|
||||
});
|
||||
|
||||
it('should parse track url into ID', async function (){
|
||||
const result = await deezer.parseUrl('http://www.deezer.com/track/3135554');
|
||||
it("should parse track url into ID", async function() {
|
||||
const result = await deezer.parseUrl(
|
||||
"http://www.deezer.com/track/3135554"
|
||||
);
|
||||
result.id.should.equal(3135554);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,46 +1,54 @@
|
|||
import 'should';
|
||||
import * as itunes from '../../lib/services/itunes/index.js';
|
||||
import "should";
|
||||
import * as itunes from "../../lib/services/itunes/index.js";
|
||||
|
||||
describe('iTunes Music', function(){
|
||||
describe('lookupId', function(){
|
||||
it('should find album by ID', async function (){
|
||||
const result = await itunes.lookupId('1445991287', 'album');
|
||||
result.name.should.equal('Peace Orchestra');
|
||||
describe("iTunes Music", function() {
|
||||
describe("lookupId", function() {
|
||||
it("should find album by ID", async function() {
|
||||
const result = await itunes.lookupId("1445991287", "album");
|
||||
result.name.should.equal("Peace Orchestra");
|
||||
});
|
||||
|
||||
it('should find track by ID', async function (){
|
||||
const result = await itunes.lookupId('1445927701', 'track');
|
||||
result.name.should.equal('Double Drums');
|
||||
it("should find track by ID", async function() {
|
||||
const result = await itunes.lookupId("1440718994", "track");
|
||||
result.name.should.equal("Zombie");
|
||||
});
|
||||
});
|
||||
|
||||
describe('search', function(){
|
||||
it('should find album by search', async function (){
|
||||
const result = await itunes.search({type: 'album', artist: {name: 'Deftones'}, name: 'White Pony'});
|
||||
result.name.should.equal('White Pony');
|
||||
describe("search", function() {
|
||||
it("should find album by search", async function() {
|
||||
const result = await itunes.search({
|
||||
type: "album",
|
||||
artist: { name: "Deftones" },
|
||||
name: "White Pony"
|
||||
});
|
||||
result.name.should.equal("White Pony");
|
||||
});
|
||||
|
||||
it('should find awkward album by search', async function (){
|
||||
const result = await itunes.search({type: 'album', artist: {name: 'Anavitória'}, name: 'Fica'});
|
||||
result.name.should.equal('Fica (feat. Matheus & Kauan) - Single');
|
||||
});
|
||||
|
||||
it('should find track by search', async function (){
|
||||
const result = await itunes.search({type: 'track', artist: {name: 'Deftones'}, albumName: 'Deftones', name: 'Hexagram'});
|
||||
result.name.should.equal('Hexagram');
|
||||
it("should find track by search", async function() {
|
||||
const result = await itunes.search({
|
||||
type: "track",
|
||||
artist: { name: "Deftones" },
|
||||
albumName: "Deftones",
|
||||
name: "Hexagram"
|
||||
});
|
||||
result.name.should.equal("Hexagram");
|
||||
});
|
||||
});
|
||||
|
||||
describe('lookupUrl', function(){
|
||||
describe('parseUrl', function(){
|
||||
it('should parse album url into ID', async function (){
|
||||
const result = await itunes.parseUrl('https://itunes.apple.com/us/album/peace-orchestra/1445991287');
|
||||
result.id.should.equal('us1445991287');
|
||||
describe("lookupUrl", function() {
|
||||
describe("parseUrl", function() {
|
||||
it("should parse album url into ID", async function() {
|
||||
const result = await itunes.parseUrl(
|
||||
"https://itunes.apple.com/us/album/peace-orchestra/1445991287"
|
||||
);
|
||||
result.id.should.equal("us1445991287");
|
||||
});
|
||||
|
||||
it('should parse track url into ID', async function (){
|
||||
const result = await itunes.parseUrl('https://itunes.apple.com/us/album/double-drums-dj-dsl-mix/1445927689?i=1445927701');
|
||||
result.id.should.equal('us1445927689');
|
||||
it("should parse track url into ID", async function() {
|
||||
const result = await itunes.parseUrl(
|
||||
"https://itunes.apple.com/us/album/double-drums-dj-dsl-mix/1445927689?i=1445927701"
|
||||
);
|
||||
result.id.should.equal("us1445927689");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,79 +1,111 @@
|
|||
import 'should';
|
||||
import * as ytmusic from '../../lib/services/ytmusic/index.js';
|
||||
import "should";
|
||||
import * as ytmusic from "../../lib/services/ytmusic/index.js";
|
||||
|
||||
describe('ytmusic', function(){
|
||||
describe('lookupId', () => {
|
||||
it('should find album by ID', async function testV() {
|
||||
const result = await ytmusic.lookupId('MPREb_nlOKEssnatr', 'album');
|
||||
result.name.should.equal('Carne de Pescoço');
|
||||
describe("ytmusic", function() {
|
||||
describe("lookupId", () => {
|
||||
it("should find album by ID", async function testV() {
|
||||
const result = await ytmusic.lookupId(
|
||||
"OLAK5uy_kalBoqyqQmbtZKCBV43Qipcoe2O2Hg_to",
|
||||
"album"
|
||||
);
|
||||
result.name.should.equal("Carne de Pescoço");
|
||||
});
|
||||
|
||||
it('should find track by ID', async function (){
|
||||
const result = await ytmusic.lookupId('9zrYXvUXiQk', 'track');
|
||||
result.name.should.equal('One Vision');
|
||||
result.artist.name.should.equal('Queen');
|
||||
result.album.name.should.equal('A Kind Of Magic')
|
||||
it("should find track by ID", async function() {
|
||||
const result = await ytmusic.lookupId("9zrYXvUXiQk", "track");
|
||||
result.name.should.equal("One Vision");
|
||||
result.artist.name.should.equal("Queen");
|
||||
result.album.name.should.equal("A Kind Of Magic");
|
||||
});
|
||||
it('should find track by ID', async function (){
|
||||
const result = await ytmusic.lookupId('rAzfNuU1f8E', 'track');
|
||||
result.name.should.equal('Erre (Live)');
|
||||
result.artist.name.should.equal('Boogarins');
|
||||
it("should find track by ID", async function() {
|
||||
const result = await ytmusic.lookupId("rAzfNuU1f8E", "track");
|
||||
result.name.should.equal("Erre (Live)");
|
||||
result.artist.name.should.equal("Boogarins");
|
||||
// The copyright notice is too long and is the only place where the album name is.
|
||||
result.album.name.should.equal('')
|
||||
result.album.name.should.equal("");
|
||||
});
|
||||
it('should find track by ID', async function (){
|
||||
const result = await ytmusic.lookupId('Wst0la_TgTY', 'track');
|
||||
result.name.should.equal('Às Vezes Bate Uma Saudade');
|
||||
it("should find track by ID", async function() {
|
||||
const result = await ytmusic.lookupId("Wst0la_TgTY", "track");
|
||||
result.name.should.equal("Às Vezes Bate Uma Saudade");
|
||||
// XXX: This is very odd. Sometimes, google will return the first artist "Rodrigo Alarcon", sometimes "Rodrigo Alarcon, Ana Muller & Mariana Froes" and sometimes
|
||||
// "Rodrigo Alarcon, Ana Muller, Mariana Froes". Same API call, same everything. Go figure.
|
||||
// result.artist.name.should.equal('Rodrigo Alarcon, Ana Muller, Mariana Froes');
|
||||
result.artist.name.should.startWith('Rodrigo Alarcon');
|
||||
result.album.name.should.equal('Taquetá Vol.1')
|
||||
result.artist.name.should.startWith("Rodrigo Alarcon");
|
||||
result.album.name.should.equal("Taquetá Vol.1");
|
||||
});
|
||||
});
|
||||
describe('search', () => {
|
||||
it('should find album by search', async function (){
|
||||
const result = await ytmusic.search({type: 'album', artist: {name: 'Jamie xx'}, name: 'In Colour'});
|
||||
result.name.should.startWith('In Colour');
|
||||
describe("search", () => {
|
||||
it("should find album by search", async function() {
|
||||
const result = await ytmusic.search({
|
||||
type: "album",
|
||||
artist: { name: "Jamie xx" },
|
||||
name: "In Colour"
|
||||
});
|
||||
result.name.should.startWith("In Colour");
|
||||
result.id.should.equal("MPREb_IbDz5pAZFvJ");
|
||||
});
|
||||
|
||||
it('should find album with various artists by search', async function (){
|
||||
const result = await ytmusic.search({type: 'album', artist: {name: 'Various Artists'}, name: 'Sambabook João Nogueira'});
|
||||
result.name.should.equal('Sambabook João Nogueira');
|
||||
result.id.should.equal('MPREb_iZt1VjORlv7');
|
||||
it("should find album with various artists by search", async function() {
|
||||
const result = await ytmusic.search({
|
||||
type: "album",
|
||||
artist: { name: "Various Artists" },
|
||||
name: "Sambabook João Nogueira"
|
||||
});
|
||||
result.name.should.equal("Sambabook João Nogueira");
|
||||
result.id.should.equal("MPREb_iZt1VjORlv7");
|
||||
});
|
||||
|
||||
it('should find album and make sure it makes sense by search', async function(){
|
||||
const result = await ytmusic.search({type: 'album', artist: {name: 'The Beatles'}, name: 'The Beatles'});
|
||||
result.name.should.equal('The Beatles');
|
||||
result.id.should.equal('MPREb_S5TiUIYvI78');
|
||||
it("should find album and make sure it makes sense by search", async function() {
|
||||
const result = await ytmusic.search({
|
||||
type: "album",
|
||||
artist: { name: "The Beatles" },
|
||||
name: "The Beatles"
|
||||
});
|
||||
result.name.should.equal("The Beatles");
|
||||
result.id.should.equal("MPREb_S5TiUIYvI78");
|
||||
});
|
||||
|
||||
it('should find track by search', async function (){
|
||||
const result = await ytmusic.search({type: 'track', artist: {name: 'Oasis'}, albumName: 'Stop The Clocks', name: 'Wonderwall'});
|
||||
result.name.should.equal('Wonderwall');
|
||||
result.id.should.equal('Gvfgut8nAgw');
|
||||
it("should find track by search", async function() {
|
||||
const result = await ytmusic.search({
|
||||
type: "track",
|
||||
artist: { name: "Oasis" },
|
||||
albumName: "Stop The Clocks",
|
||||
name: "Wonderwall"
|
||||
});
|
||||
result.name.should.equal("Wonderwall");
|
||||
result.id.should.equal("Gvfgut8nAgw");
|
||||
});
|
||||
});
|
||||
describe('lookupUrl', () => {
|
||||
describe('parseUrl', () => {
|
||||
it('should parse track url into ID', async function (){
|
||||
const result = await ytmusic.parseUrl('https://music.youtube.com/watch?v=YLp2cW7ICCU&feature=share');
|
||||
describe("lookupUrl", () => {
|
||||
describe("parseUrl", () => {
|
||||
it("should parse track url into ID", async function() {
|
||||
const result = await ytmusic.parseUrl(
|
||||
"https://music.youtube.com/watch?v=YLp2cW7ICCU&feature=share"
|
||||
);
|
||||
result.id.should.equal("YLp2cW7ICCU");
|
||||
result.streamUrl.should.equal("https://music.youtube.com/watch?v=YLp2cW7ICCU");
|
||||
result.streamUrl.should.equal(
|
||||
"https://music.youtube.com/watch?v=YLp2cW7ICCU"
|
||||
);
|
||||
});
|
||||
it('should parse album url into ID', async function (){
|
||||
const result = await ytmusic.parseUrl('https://music.youtube.com/browse/MPREb_9C36yscfgmJ');
|
||||
it("should parse album url into ID", async function() {
|
||||
const result = await ytmusic.parseUrl(
|
||||
"https://music.youtube.com/browse/MPREb_9C36yscfgmJ"
|
||||
);
|
||||
result.id.should.equal("MPREb_9C36yscfgmJ");
|
||||
result.streamUrl.should.equal("https://music.youtube.com/browse/MPREb_9C36yscfgmJ");
|
||||
result.streamUrl.should.equal(
|
||||
"https://music.youtube.com/browse/MPREb_9C36yscfgmJ"
|
||||
);
|
||||
});
|
||||
it('should parse alternative album url into ID', async function (){
|
||||
const result = await ytmusic.parseUrl('https://music.youtube.com/playlist?list=OLAK5uy_lx9K5RpiBEwd3E4C1GKqY7e06qTlwydvs');
|
||||
it("should parse alternative album url into ID", async function() {
|
||||
const result = await ytmusic.parseUrl(
|
||||
"https://music.youtube.com/playlist?list=OLAK5uy_lx9K5RpiBEwd3E4C1GKqY7e06qTlwydvs"
|
||||
);
|
||||
result.id.should.equal("MPREb_9C36yscfgmJ");
|
||||
});
|
||||
it('should parse alternative album url into ID, regression', async function (){
|
||||
const result = await ytmusic.parseUrl('https://music.youtube.com/playlist?list=OLAK5uy_kxepMtCUKFek54-bgWICIsmglK86HD0TM');
|
||||
it("should parse alternative album url into ID, regression", async function() {
|
||||
const result = await ytmusic.parseUrl(
|
||||
"https://music.youtube.com/playlist?list=OLAK5uy_kxepMtCUKFek54-bgWICIsmglK86HD0TM"
|
||||
);
|
||||
result.id.should.equal("MPREb_XmlDLpyWvMt");
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue