Skip to content

Commit

Permalink
strip leading/trailing 'The' from artist name in Discogs search
Browse files Browse the repository at this point in the history
  • Loading branch information
RocketMan committed Dec 10, 2023
1 parent 1e7c20a commit f36a269
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions controllers/PushServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit f36a269

Please sign in to comment.