From 6d9d32d3472e3a794e362187c9d4f9bc21f87648 Mon Sep 17 00:00:00 2001 From: "Renato \"Lond\" Cerqueira" Date: Sun, 17 Jan 2021 16:41:47 +0100 Subject: [PATCH] Disable google service --- lib/services/google/index.js | 49 +----------------------------------- lib/services/google/url.js | 25 +----------------- 2 files changed, 2 insertions(+), 72 deletions(-) diff --git a/lib/services/google/index.js b/lib/services/google/index.js index 8ce3372..3f84993 100644 --- a/lib/services/google/index.js +++ b/lib/services/google/index.js @@ -101,54 +101,7 @@ function looseMatch(needle, haystack, type) { } export async function search(data, original = {}, cleaned = false) { - await ready; - let query; - let album; - const type = data.type; - - if (type === 'album') { - query = `${data.artist.name} ${data.name}`; - album = data.name; - } else if (type === 'track') { - query = `${data.artist.name} ${data.albumName} ${data.name}`; - album = data.albumName; - } - - const result = await pm.searchAsync(query, 5); - - if (!result.entries) { - if (cleaned) { - return { service: 'google' }; - } - const matches = album.match(/^[^([]+/); - if (matches && matches[0]) { - const cleanedData = JSON.parse(JSON.stringify(data)); - if (type === 'album') { - cleanedData.name = data.name.match(/^[^([]+/)[0].trim(); - } else if (type === 'track') { - cleanedData.albumName = data.albumName.match(/^[^([]+/)[0].trim(); - cleanedData.name = data.name.match(/^[^([]+/)[0].trim(); - } - return await search(cleanedData, data, true); - } - return { service: 'google' }; - } - - const name = original.name || data.name; - - let match = exactMatch(name, result.entries, data.type); - if (!match) { - match = looseMatch(name, result.entries, data.type); - } - - if (!match) { - return { service: 'google' }; - } - if (type === 'album') { - return await lookupId(match.album.albumId, type); - } else if (type === 'track') { - return await lookupId(match.track.storeId, type); - } + // Disable google since it doesn't respond anymore return { service: 'google' }; } diff --git a/lib/services/google/url.js b/lib/services/google/url.js index 30a71b5..0b56423 100644 --- a/lib/services/google/url.js +++ b/lib/services/google/url.js @@ -1,29 +1,6 @@ import { parse } from 'url'; export default function match(url) { - const parsed = parse(url.replace(/\+/g, '%20')); - if (!parsed.host.match(/play\.google\.com$/)) { - return false; - } - - const path = parsed.path; - const hash = parsed.hash; - - if (hash) { - const parts = hash.split('/'); - const id = parts[2]; - const artist = parts[3]; - - if (id.length > 0) { - return true; - } else if (artist.length > 0) { - return true; - } - } else if (path) { - const matches = path.match(/\/music\/m\/([\w]+)/); - if (matches[1]) { - return true; - } - } + // Disable google since it doesn't respond anymore return false; }