Remove support for Amazon because they are banned me for not making money off this.
This commit is contained in:
parent
c32b756aba
commit
fc33d1ea92
12 changed files with 5 additions and 197 deletions
|
@ -1,4 +1,4 @@
|
|||
FROM node:10.0.0-alpine
|
||||
FROM node:10.15.3-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
FROM node:10.0.0-alpine
|
||||
FROM node:10.15.3-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ Install `node` and `postgres` if you don't already have them. Then `npm install`
|
|||
|
||||
Bug reports and feature requests welcome. If you want to contribute code, that is awesome but please issue pull requests early for discussion.
|
||||
|
||||
So there's no surprises for contributors later, I plan on using referral tags wherever it makes sense. Right now that would apply to outgoing links for Amazon, iTunes, Rdio and Spotify. The referral tags themselves will not be baked into the code, just support for using them.
|
||||
So there's no surprises for contributors later, I plan on using referral tags wherever it makes sense. Right now that would apply to outgoing links for iTunes and Spotify. The referral tags themselves will not be baked into the code, just support for using them.
|
||||
|
||||
## Licence
|
||||
|
||||
|
|
|
@ -1,143 +0,0 @@
|
|||
import { parse } from 'url';
|
||||
import { inspect } from 'util';
|
||||
import amazon from 'amazon-product-api';
|
||||
import debuglog from 'debug';
|
||||
import urlMatch from './url';
|
||||
|
||||
const debug = debuglog('combine.fm:youtube');
|
||||
|
||||
|
||||
const client = amazon.createClient({
|
||||
awsId: process.env.AWS_ACCESS_KEY_ID,
|
||||
awsSecret: process.env.AWS_SECRET_ACCESS_KEY,
|
||||
awsTag: process.env.AWS_TAG,
|
||||
});
|
||||
|
||||
export async function lookupId(id, type) {
|
||||
try {
|
||||
const results = await client.itemLookup({
|
||||
itemId: id,
|
||||
responseGroup: 'ItemAttributes,Images,ItemIds',
|
||||
});
|
||||
|
||||
const result = results[0];
|
||||
|
||||
if (!result || result.Error) {
|
||||
return { service: 'amazon' };
|
||||
}
|
||||
|
||||
if (type === 'album') {
|
||||
return {
|
||||
service: 'amazon',
|
||||
type: 'album',
|
||||
id: result.ASIN[0],
|
||||
name: result.ItemAttributes[0].Title[0],
|
||||
streamUrl: result.DetailPageURL[0],
|
||||
purchaseUrl: result.DetailPageURL[0],
|
||||
artwork: {
|
||||
small: result.SmallImage[0].URL[0],
|
||||
large: result.LargeImage[0].URL[0],
|
||||
},
|
||||
artist: {
|
||||
name: result.ItemAttributes[0].Creator[0]._,
|
||||
},
|
||||
};
|
||||
} else if (type === 'track') {
|
||||
return {
|
||||
service: 'amazon',
|
||||
type: 'track',
|
||||
id: result.ASIN[0],
|
||||
name: result.ItemAttributes[0].Title[0],
|
||||
streamUrl: result.DetailPageURL[0],
|
||||
purchaseUrl: result.DetailPageURL[0],
|
||||
artwork: {
|
||||
small: result.SmallImage[0].URL[0],
|
||||
large: result.LargeImage[0].URL[0],
|
||||
},
|
||||
album: {
|
||||
name: result.ItemAttributes[0],
|
||||
},
|
||||
artist: {
|
||||
name: result.ItemAttributes[0].Creator[0]._,
|
||||
},
|
||||
};
|
||||
}
|
||||
} catch (err) {
|
||||
debug(inspect(err, { depth: null }));
|
||||
}
|
||||
return { service: 'amazon' };
|
||||
}
|
||||
|
||||
export async function search(data) {
|
||||
try {
|
||||
const type = data.type;
|
||||
const results = await client.itemSearch({
|
||||
author: data.artist.name.replace(':', ' '),
|
||||
title: data.name.replace(':', ' '),
|
||||
searchIndex: 'MP3Downloads',
|
||||
responseGroup: 'ItemAttributes,Tracks,Images,ItemIds',
|
||||
});
|
||||
|
||||
const result = results[0];
|
||||
|
||||
if (!result || result.Error) {
|
||||
return { service: 'amazon' };
|
||||
}
|
||||
|
||||
if (type === 'album') {
|
||||
return {
|
||||
service: 'amazon',
|
||||
type,
|
||||
id: result.ASIN[0],
|
||||
name: result.ItemAttributes[0].Title[0],
|
||||
streamUrl: result.DetailPageURL[0],
|
||||
purchaseUrl: result.DetailPageURL[0],
|
||||
artwork: {
|
||||
small: result.SmallImage[0].URL[0],
|
||||
large: result.LargeImage[0].URL[0],
|
||||
},
|
||||
artist: {
|
||||
name: result.ItemAttributes[0].Creator[0]._,
|
||||
},
|
||||
};
|
||||
} else if (type === 'track') {
|
||||
return {
|
||||
service: 'amazon',
|
||||
type,
|
||||
id: result.ASIN[0],
|
||||
name: result.ItemAttributes[0].Title[0],
|
||||
streamUrl: result.DetailPageURL[0],
|
||||
purchaseUrl: result.DetailPageURL[0],
|
||||
artwork: {
|
||||
small: result.SmallImage[0].URL[0],
|
||||
large: result.LargeImage[0].URL[0],
|
||||
},
|
||||
artist: {
|
||||
name: result.ItemAttributes[0].Creator[0]._,
|
||||
},
|
||||
album: {
|
||||
name: '',
|
||||
},
|
||||
};
|
||||
}
|
||||
} catch (err) {
|
||||
debug(inspect(err, { depth: 4 }));
|
||||
if (err[0].Error[0].Code[0] === 'RequestThrottled') {
|
||||
debug('Rate Limited');
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
return { service: 'amazon' };
|
||||
}
|
||||
|
||||
export function parseUrl(url) {
|
||||
const matches = parse(url).path.match(/\/(albums|tracks)[/]+([^?]+)/);
|
||||
|
||||
if (matches && matches[2]) {
|
||||
return { type: matches[1].substring(0, 5), id: matches[2] };
|
||||
}
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
export const id = 'amazon';
|
||||
export const match = urlMatch;
|
|
@ -1,11 +0,0 @@
|
|||
import { parse } from 'url';
|
||||
|
||||
export default function match(url) {
|
||||
const parsed = parse(url);
|
||||
if (!parsed.host.match(/\.amazon\.com$/)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const matches = parse(url).path.match(/\/(albums)[/]+([^/]+)/);
|
||||
return (matches && !!matches[2]);
|
||||
}
|
|
@ -3,7 +3,6 @@ export default function (sequelize, DataTypes) {
|
|||
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
||||
externalId: { type: DataTypes.STRING(50), index: true }, // eslint-disable-line new-cap
|
||||
service: DataTypes.ENUM( // eslint-disable-line new-cap
|
||||
'amazon',
|
||||
'deezer',
|
||||
'google',
|
||||
'itunes',
|
||||
|
|
|
@ -5,7 +5,6 @@ export default function (sequelize, DataTypes) {
|
|||
albumId: DataTypes.INTEGER,
|
||||
externalId: { type: DataTypes.STRING(50), index: true }, // eslint-disable-line new-cap
|
||||
service: DataTypes.ENUM( // eslint-disable-line new-cap
|
||||
'amazon',
|
||||
'deezer',
|
||||
'google',
|
||||
'itunes',
|
||||
|
|
|
@ -3,7 +3,6 @@ export default function (sequelize, DataTypes) {
|
|||
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
||||
externalId: { type: DataTypes.STRING(50), index: true }, // eslint-disable-line new-cap
|
||||
service: DataTypes.ENUM( // eslint-disable-line new-cap
|
||||
'amazon',
|
||||
'deezer',
|
||||
'google',
|
||||
'itunes',
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
"@babel/polyfill": "^7.0.0-beta.46",
|
||||
"@babel/preset-env": "^7.0.0-beta.46",
|
||||
"@babel/register": "^7.0.0-beta.46",
|
||||
"amazon-product-api": "^0.4.4",
|
||||
"apple-music-jwt": "^0.2.0",
|
||||
"babel-loader": "^8.0.0-beta.2",
|
||||
"bluebird": "^3.5.1",
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 6 KiB |
|
@ -1,34 +0,0 @@
|
|||
import 'should';
|
||||
import * as amazon from '../../lib/services/amazon';
|
||||
|
||||
describe('Amazon', function () {
|
||||
describe('lookupId', function () {
|
||||
it('should find album by ID', async function () {
|
||||
const result = await amazon.lookupId('B00V8I134A', 'album');
|
||||
result.name.should.equal('In Colour [Explicit]');
|
||||
});
|
||||
|
||||
it('should find track by ID', async function () {
|
||||
const result = await amazon.lookupId('B00V8I1CKU', 'track');
|
||||
result.name.should.equal('Sleep Sound');
|
||||
});
|
||||
});
|
||||
|
||||
describe('search', function(){
|
||||
it('should find album by search', async function () {
|
||||
const result = await amazon.search({type: 'album', artist: {name: 'Jamie xx'}, name: 'In Colour'});
|
||||
result.name.should.equal('In Colour [Explicit]');
|
||||
});
|
||||
|
||||
it('should find track by search', async function () {
|
||||
const result = await amazon.search({type: 'track', artist: {name: 'Jamie xx'}, albumName: 'In Colour', name: 'Loud Places'});
|
||||
result.name.should.equal('Loud Places');
|
||||
});
|
||||
|
||||
it('should find awkward track by search', async function () {
|
||||
const result = await amazon.search({type: 'track', artist: {name: 'Jamie xx'}, albumName: 'In Colour (Remixes)', name: 'Loud Places [Tessela Remix]'});
|
||||
result.name.should.equal('Loud Places [Tessela Remix]');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -4,13 +4,13 @@
|
|||
<title>Combine.fm • <%=head.title%></title>
|
||||
<link rel="stylesheet" href="/dist/<%=manifest['style/main.css']%>" />
|
||||
|
||||
<meta name='description' content='Combine.fm matches album and track links from Youtube, Spotify, Google Music, Apple Music, Amazon Music and Deezer and gives you back one link with matches we find on all of them.' />
|
||||
<meta name='description' content='Combine.fm matches album and track links from Youtube, Spotify, Google Music, Apple Music and Deezer and gives you back one link with matches we find on all of them.' />
|
||||
<meta name='viewport' content='width=device-width, initial-scale=1' />
|
||||
<meta name='theme-color' content='#FE4365' />
|
||||
<meta name='twitter:card' content='<%=typeof share == 'undefined' ? 'summary': 'summary_large_image'%>' />
|
||||
<meta name='twitter:site' content='@Combinefm' />
|
||||
<meta name='twitter:title' property='og:title' content='Combine.fm • <%=head.title%>' />
|
||||
<meta name='twitter:description' property='og:description' content='Combine.fm matches album and track links from Youtube, Spotify, Google Music, Apple Music, Amazon Music and Deezer and gives you back one link with matches we find on all of them.' />
|
||||
<meta name='twitter:description' property='og:description' content='Combine.fm matches album and track links from Youtube, Spotify, Google Music, Apple Music and Deezer and gives you back one link with matches we find on all of them.' />
|
||||
<meta name='twitter:image:src' property='og:image' content='<%=head.image%>' />
|
||||
<meta name="slack-app-id" content="AA9SLSFFC">
|
||||
<meta property='og:url' content='<%=head.shareUrl%>' />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue