fix: nullpointer when scraping musician from Moby games in some situations

This commit is contained in:
lantzelot-swe 2024-01-09 10:37:52 +01:00
parent fc99e08ae6
commit 39427e21fc
1 changed files with 11 additions and 3 deletions

View File

@ -314,8 +314,17 @@ public class MobyGamesScraper implements Scraper
{
Element musicElement = musicElements.get(0);
Element musicParent = musicElement.parent();
value = musicParent.getElementsByTag("a").first().text();
if (musicParent.getElementsByTag("a").first() != null)
{
value = musicParent.getElementsByTag("a").first().text();
}
else
{
Element commaListElement = musicParent.getElementsByClass("commaList").first();
final List<String> musicList = new ArrayList<>();
commaListElement.getElementsByTag("li").forEach(liElement -> musicList.add(liElement.text()));
value = String.join(",", musicList);
}
}
}
}
@ -323,7 +332,6 @@ public class MobyGamesScraper implements Scraper
{
ExceptionHandler.handleException(e, "Could not scrape composer");
}
return value;
}