diff --git a/Dockerfile b/Dockerfile index 11e142a..589463f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:10.0.0-alpine +FROM node:10.15.3-alpine WORKDIR /app diff --git a/Dockerfile.dev b/Dockerfile.dev index 2185adf..1124596 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -1,4 +1,4 @@ -FROM node:10.0.0-alpine +FROM node:10.15.3-alpine WORKDIR /app diff --git a/README.md b/README.md index bfb8c67..e675efb 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/lib/services/amazon/index.js b/lib/services/amazon/index.js deleted file mode 100644 index 3804e97..0000000 --- a/lib/services/amazon/index.js +++ /dev/null @@ -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; diff --git a/lib/services/amazon/url.js b/lib/services/amazon/url.js deleted file mode 100644 index e31f5f7..0000000 --- a/lib/services/amazon/url.js +++ /dev/null @@ -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]); -} diff --git a/models/album.js b/models/album.js index 03af8ae..e369eb9 100644 --- a/models/album.js +++ b/models/album.js @@ -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', diff --git a/models/match.js b/models/match.js index 46359bb..89f7017 100644 --- a/models/match.js +++ b/models/match.js @@ -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', diff --git a/models/track.js b/models/track.js index f75a162..c85536b 100644 --- a/models/track.js +++ b/models/track.js @@ -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', diff --git a/package.json b/package.json index f3c07c9..5000c4a 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/public/assets/images/amazon.png b/public/assets/images/amazon.png deleted file mode 100644 index b718af3..0000000 Binary files a/public/assets/images/amazon.png and /dev/null differ diff --git a/test/services/amazon.js b/test/services/amazon.js deleted file mode 100644 index 1d484f7..0000000 --- a/test/services/amazon.js +++ /dev/null @@ -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]'); - }); - }); -}); - diff --git a/views/index.html b/views/index.html index 8fd34b9..6a62309 100644 --- a/views/index.html +++ b/views/index.html @@ -4,13 +4,13 @@