diff --git a/docker-compose.yml b/docker-compose.yml index b467425..816bde3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,7 +23,7 @@ services: SLACK_TOKEN: SENTRY_DSN: volumes: - - ./:/app + - ./:/app:z ports: - "3000:3000" command: yarn run watch-server @@ -47,7 +47,7 @@ services: AWS_SECRET_ACCESS_KEY: AWS_TAG: volumes: - - ./:/app + - ./:/app:z command: yarn run watch-worker ports: - "3001:3001" diff --git a/lib/services.js b/lib/services.js index 21f6c1a..194dc3e 100644 --- a/lib/services.js +++ b/lib/services.js @@ -1,5 +1,4 @@ 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'; @@ -7,7 +6,6 @@ import * as ytmusic from './services/ytmusic/index.js'; const services = [ deezer, - google, itunes, spotify, youtube, diff --git a/lib/services/google/index.js b/lib/services/google/index.js deleted file mode 100644 index 3f84993..0000000 --- a/lib/services/google/index.js +++ /dev/null @@ -1,137 +0,0 @@ -import { parse } from 'url'; -import bluebird from 'bluebird'; -import PlayMusic from 'playmusic'; -import debuglog from 'debug'; -import urlMatch from './url.js'; - -const debug = debuglog('combine.fm:google'); - -const pm = bluebird.promisifyAll(new PlayMusic()); - -if (!(process.env.GOOGLE_EMAIL && process.env.GOOGLE_PASSWORD) && !(process.env.GOOGLE_ANDROID_ID && process.env.GOOGLE_MASTER_TOKEN)) { - debug('Required GOOGLE_* environment variables not found, deactivating Google Play Music.'); -} - -const creds = { - androidId: process.env.GOOGLE_ANDROID_ID, - masterToken: process.env.GOOGLE_MASTER_TOKEN, -}; - -let ready = pm.initAsync(creds).catch(function(err) { - debug(err); -}); - -export async function lookupId(id, type) { - await ready; - try { - if (type === 'album') { - const album = await pm.getAlbumAsync(id, false); - return { - service: 'google', - type: 'album', - id: album.albumId, - name: album.name, - streamUrl: `https://play.google.com/music/m/${album.albumId}?signup_if_needed=1`, - purchaseUrl: `https://play.google.com/store/music/album?id=${album.albumId}`, - artwork: { - small: album.albumArtRef.replace('http:', 'https:'), - large: album.albumArtRef.replace('http:', 'https:'), - }, - artist: { - name: album.artist, - }, - }; - } else if (type === 'track') { - const track = await pm.getAllAccessTrackAsync(id); - return { - service: 'google', - type: 'track', - id: track.nid, - name: track.title, - streamUrl: `https://play.google.com/music/m/${track.nid}?signup_if_needed=1`, - purchaseUrl: `https://play.google.com/store/music/album?id=${track.albumId}`, - artwork: { - small: track.albumArtRef[0].url.replace('http:', 'https:'), - large: track.albumArtRef[0].url.replace('http:', 'https:'), - }, - album: { - name: track.album, - }, - artist: { - name: track.artist, - }, - }; - } - } catch(e) { - const error = new Error('Not Found'); - error.status = 404; - return Promise.reject(error); - } - const error = new Error('Not Found'); - error.status = 404; - return Promise.reject(error); -} - -function exactMatch(needle, haystack, type) { - // try to find exact match - return haystack.find((entry) => { - if (!entry[type]) { - return false; - } - const title = entry[type].title; - if (title === needle) { - return entry; - } - return false; - }); -} - -function looseMatch(needle, haystack, type) { - // try to find exact match - return haystack.find((entry) => { - if (!entry[type]) { - return false; - } - const name = entry[type].title || entry[type].name; - if (name.indexOf(needle) >= 0) { - return entry[type]; - } - return false; - }); -} - -export async function search(data, original = {}, cleaned = false) { - // Disable google since it doesn't respond anymore - return { service: 'google' }; -} - -export async function parseUrl(url) { - await ready; - const parsed = parse(url.replace(/\+/g, '%20')); - const path = parsed.path; - const hash = parsed.hash; - if (hash) { - const parts = hash.split('/'); - const type = parts[1]; - const id = parts[2]; - const artist = decodeURIComponent(parts[3]); - const album = decodeURIComponent(parts[4]); - - if (type !== 'album' && type !== 'track') { - return false; - } - - if (id.length > 0) { - return { id, type }; - } - return await search({ type, name: album, artist: { name: artist } }); - } else if (path) { - const matches = path.match(/\/music\/m\/([\w]+)/); - const type = matches[1][0] === 'T' ? 'track' : 'album'; - return await lookupId(matches[1], type); - } - return false; -} - -export const match = urlMatch; -export const id = 'google'; diff --git a/lib/services/google/url.js b/lib/services/google/url.js deleted file mode 100644 index 0b56423..0000000 --- a/lib/services/google/url.js +++ /dev/null @@ -1,6 +0,0 @@ -import { parse } from 'url'; - -export default function match(url) { - // Disable google since it doesn't respond anymore - return false; -} diff --git a/test/services/google.js b/test/services/google.js deleted file mode 100644 index 52d502e..0000000 --- a/test/services/google.js +++ /dev/null @@ -1,50 +0,0 @@ -import 'should'; -import * as google from '../../lib/services/google/index.js'; - -describe('Google Play Music', () => { - describe('lookupId', () => { - it('should find album by ID', async function (){ - const result = await google.lookupId('Byp6lvzimyf74wxi5634ul4tgam', 'album'); - result.name.should.equal('Listen'); - }); - - it('should find track by ID', async function (){ - const result = await google.lookupId('Tjosptub24g2dft37lforqnudpe', 'track'); - result.name.should.equal('Cherub Rock (Remastered 2011)'); - }); - }); - - describe('search', () => { - it('should find album by search', async function (){ - const result = await google.search({type: 'album', artist: {name: 'Jamie xx'}, name: 'In Colour'}); - result.name.should.equal('In Colour'); - }); - - it('should find track by search', async function (){ - const result = await google.search({type: 'track', artist: {name: 'Jamie xx'}, albumName: 'In Colour', name: 'Loud Places'}); - result.name.should.equal('Loud Places (feat. Romy)'); - }); - - it('should find awkward track by search', async function (){ - const result = await google.search({type: 'track', artist: {name: 'Jamie xx'}, albumName: 'Loud Places (Remixes)', name: 'Loud Places [Tessela Remix]'}); - result.name.should.equal('Loud Places [Tessela Remix]'); - }); - }); - - describe('lookupUrl', () => { - it('should parse regular url into album ID', async function (){ - const result = await google.parseUrl('https://play.google.com/music/listen#/album/Byp6lvzimyf74wxi5634ul4tgam/Jamie+xx/In+Colour'); - result.id.should.equal('Byp6lvzimyf74wxi5634ul4tgam'); - }); - - it('should parse url without ID into album ID', async function (){ - const result = await google.parseUrl('https://play.google.com/music/listen#/album//Jamie+xx/In+Colour'); - result.id.should.equal('Bvfmezcj3n42lo4xeuslpclbyrm'); - }); - - it('should parse share url into album ID', async function (){ - const result = await google.parseUrl('https://play.google.com/music/m/Byp6lvzimyf74wxi5634ul4tgam'); - result.id.should.equal('Byp6lvzimyf74wxi5634ul4tgam'); - }); - }); -});