From f36a269e2b3408d04cd027133832a03d681381cd Mon Sep 17 00:00:00 2001 From: Jim Mason Date: Sun, 10 Dec 2023 16:09:35 +0000 Subject: [PATCH] strip leading/trailing 'The' from artist name in Discogs search --- controllers/PushServer.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/controllers/PushServer.php b/controllers/PushServer.php index 8ef5a321..97a32d25 100644 --- a/controllers/PushServer.php +++ b/controllers/PushServer.php @@ -228,6 +228,7 @@ public function onOpen(ConnectionInterface $conn) { * @returns false iff communications error, result otherwise (can be empty) */ protected function queryDiscogs($artist, $album = null) { + $artist = preg_replace('/(^The\s)|(,\sThe$)/', '', $artist); $success = true; $retval = new \stdClass(); $retval->imageUrl = $retval->infoUrl = $retval->resourceUrl = null; @@ -331,6 +332,7 @@ protected function queryDiscogsArtistByAlbum($artist, $album) { if($json) { $artists = $json->artists ?? null; + $artist = preg_replace('/(^The\s)|(,\sThe$)/', '', $artist); if($artists && count($artists)) { foreach($artists as $candidate) { if(self::testArtist($candidate->name, $artist)) {