From fc33d1ea92dc46be995ef7553cefad8bcb69b84e Mon Sep 17 00:00:00 2001 From: Jonathan Cremin Date: Mon, 11 Mar 2019 20:13:10 +0000 Subject: [PATCH] Remove support for Amazon because they are banned me for not making money off this. --- Dockerfile | 2 +- Dockerfile.dev | 2 +- README.md | 2 +- lib/services/amazon/index.js | 143 -------------------------------- lib/services/amazon/url.js | 11 --- models/album.js | 1 - models/match.js | 1 - models/track.js | 1 - package.json | 1 - public/assets/images/amazon.png | Bin 6138 -> 0 bytes test/services/amazon.js | 34 -------- views/index.html | 4 +- 12 files changed, 5 insertions(+), 197 deletions(-) delete mode 100644 lib/services/amazon/index.js delete mode 100644 lib/services/amazon/url.js delete mode 100644 public/assets/images/amazon.png delete mode 100644 test/services/amazon.js 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 b718af3871176ead60080e3f56d601f6e9fac766..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6138 zcmVX8gt6=#7cdF;4E}=H$+u zWK41$&5h%jjE;_G^x`WH21FczAoxNB4F*)6;tLQCoLBeWyJ}s|?&fq$9}e9L#(4YB zsb8JL+11sxzgnwmRn_i;Pl+m3s#K{`rAn15RjO2}Qf20%T_?|6+OTp@dS}LxotM|C z3O;27hlZ-SPw$*UPZp9q2I~5mAbrn@#r5C&oCsV+p;s_Sb#ZY7bq?w*D42yhmCu2| zRTS``3RUDFpJe(pbA=d7wYKn`Jl>-MLVa?_+7*8GnVeY z>)gd3&cdfhl`2)L^s8IZY2;07x{kYJg^vnoy?*4KYr2m8w^g0-CqSL5Or5i}%cRHF zbe%P4b$~w_N>m6@%&a-)3uF2o4M-=5QAp#P?|ko!50PiY&sOw`B0Ei?XFxDUpoatW zNH#*uYC<1;tMP=9r`2JMtt5&ZN`v5Do&gi-=fI-luR$9NW9s{I_G@=%{hW z-MQvu5wE|sA&l{&FsNDb+NFbbq9c-Ksd?LOJcX3rfCa(O#_^)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xtbefpUxzVc(Mql{r6T9^gpwW(kOEK=!6^ceXnQ@?5Q1HV z?k1!jz=tZ_LAc#YX)r(o$tHD(X(S>MJE#+iA=CpT1*2(#odI?ywL8Hc5cW)RqC0_Z zG@eh-N83{d>XJkSKm|)YRq4-3Zp_}#z;qOOO0C}V$`vD?0H`Q~2@kCMM+ws3&KZt- zn}{bTGv^NAq5VYoxt&_-g9}t}C7_e&2PQWTxe}4{UjX+bd?7Eg41yFulDzo)!Zn50 zPGE7_d`f7$Mw7&%htvoyd0&Nc1X*ga#Xr;d5YLB;!v>Q7A;LRe{>za|Q2~>Gy{Six z@Kp(F`V%e-s~0T0Xz+X-0Df9eAM~gnKLMWksw&PG&p$lBfVxk3m4__D%1bQ<*w62P z16mjXpv0Y)j+uo{xc~Y|f|9pZ7Xzw)pvVJocwp6)quxN}V9z71e`Pv#xf4-j;lgh$ zzj*ksK9gs%dfo73Kj-uu1!fbR1TW~!{OlX5#g<&5m6s!KsVJrHwS6&BhUj7p=mmSn zi9z@BT@is_cH_{K3ZgQvf|3xwY3};-@?ifLg#Q2v;KV$Ls)=Te1i!k`L=l z{>)Uo3*_&GW-)0O1rc9bdF^ra)nl_AlRU zp?mc!$C5jq^)fG{6wTb#0XB@Fe2>Dlgsu>pXN}QStG{)^=IXiVPkyG<95$qPU-9gb zLXK3YqX-#6!2m#e0j#A+O$p8QV M07*qoM6N<$f<=7ATL1t6 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 @@ Combine.fm • <%=head.title%> - + ' /> - +