Skip to content

Commit

Permalink
Genshin Impect Adaptar Error
Browse files Browse the repository at this point in the history
Fixes #17
  • Loading branch information
ale183 committed Feb 6, 2023
1 parent 68ff532 commit e0fbc5b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.kitsunecode</groupId>
<artifactId>moe-moe-secretary</artifactId>
<version>1.2.2</version>
<version>1.2.3</version>
<packaging>jar</packaging>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ public class GenshinImpact extends IWaifuAdapter {

private static final String BASE_URL = "https://genshin-impact.fandom.com";

private static final String IMAGES_SELECTOR = "a[title='Portrait'] img";
private static final String FEMALE_IMAGE_SELECTOR = "a[title='Female Portrait'] img";
private static final String MALE_IMAGE_SELECTOR = "a[title='Male Portrait'] img";
private static final String IMAGES_SELECTOR = "a[title='Wish'] img";
private static final String INGAME_IMAGE_SELECTOR = "a[title='In-Game'] img";
private static final String FEMALE_IMAGE_SELECTOR = "a[title='In-Game (Lumine)'] img";
private static final String MALE_IMAGE_SELECTOR = "a[title='In-Game (Aether)'] img";

public GenshinImpact(String name) {
super(name);
Expand All @@ -45,6 +46,7 @@ public void afterInit() {
private List<String> loadSkinUrls(Document mainDoc, Document outfitsDoc) {
List<String> urls = Stream.of(
Selector.select(IMAGES_SELECTOR, mainDoc).first(),
Selector.select(INGAME_IMAGE_SELECTOR, mainDoc).first(),
Selector.select(MALE_IMAGE_SELECTOR, mainDoc).first(),
Selector.select(FEMALE_IMAGE_SELECTOR, mainDoc).first()
).filter(Objects::nonNull)
Expand All @@ -62,13 +64,13 @@ private List<String> loadSkinUrls(Document mainDoc, Document outfitsDoc) {
String path = row.getElementsByTag("td").first().getElementsByTag("a").first().attr("href");
try {
Document outfitDoc = Jsoup.connect(BASE_URL + path).get();
Element portraitElement = Selector.select("a[title='Portrait']", outfitDoc).first();
Element portraitElement = Selector.select("a[title='Wish']", outfitDoc).first();
if (portraitElement != null) {
urls.add(portraitElement.attr("href").split("/revision")[0]);
}
Element previewElement = Selector.select("a[title='Preview']", outfitDoc).first();
if (previewElement != null) {
urls.add(previewElement.attr("href").split("/revision")[0]);
Element ingameElement = Selector.select("a[title='In-Game']", outfitDoc).first();
if (ingameElement != null) {
urls.add(ingameElement.attr("href").split("/revision")[0]);
}
} catch (IOException e) {
e.printStackTrace();
Expand All @@ -89,11 +91,14 @@ private List<Dialog> loadDialogs(Document document) {
.child(0)
.getElementsByTag("tr")
.stream()
.skip(1)
.skip(2)
.collect(Collectors.toList());

for (Element row : rows) {
Element td = row.getElementsByTag("td").first();
if(td == null) {
continue;
}
Element audioSpan = td.getElementsByTag("span").stream().findAny().orElse(null);
String audioUrl = null;
if (audioSpan != null) {
Expand Down

0 comments on commit e0fbc5b

Please sign in to comment.