-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
"Capture More" now works properly Pumbility Page
- Loading branch information
Showing
23 changed files
with
272 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
app/src/main/java/dev/kr3st1k/piucompanion/core/network/data/Pumbility.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package dev.kr3st1k.piucompanion.core.network.data | ||
|
||
data class Pumbility( | ||
val user: User, | ||
val scores: List<PumbilityScore> | ||
) |
10 changes: 10 additions & 0 deletions
10
app/src/main/java/dev/kr3st1k/piucompanion/core/network/data/PumbilityScore.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package dev.kr3st1k.piucompanion.core.network.data | ||
|
||
data class PumbilityScore( | ||
override val songName: String, | ||
override val songBackgroundUri: String, | ||
override val difficulty: String, | ||
override val score: String, | ||
override val rank: String, | ||
val datetime: String, | ||
) : Score(songName, songBackgroundUri, difficulty, score, rank) |
80 changes: 80 additions & 0 deletions
80
app/src/main/java/dev/kr3st1k/piucompanion/core/network/parsers/PumbilityParser.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package dev.kr3st1k.piucompanion.core.network.parsers | ||
|
||
import dev.kr3st1k.piucompanion.core.helpers.Utils | ||
import dev.kr3st1k.piucompanion.core.helpers.Utils.getBackgroundImg | ||
import dev.kr3st1k.piucompanion.core.helpers.Utils.parseTypeDifficultyFromUri | ||
import dev.kr3st1k.piucompanion.core.network.data.Pumbility | ||
import dev.kr3st1k.piucompanion.core.network.data.PumbilityScore | ||
import org.jsoup.nodes.Document | ||
import org.jsoup.nodes.Element | ||
import java.util.Locale | ||
|
||
object PumbilityParser : Parser<Pumbility>() { | ||
|
||
private fun parsePumbilityScore(element: Element): PumbilityScore { | ||
|
||
val score = element | ||
.select("div.score") | ||
.first()!! | ||
.select("i.tt.en") | ||
.first()!! | ||
.text() | ||
|
||
val songName = element.select("div.profile_name").first()!!.select("p.t1").first()!!.text() | ||
|
||
val typeDiffImgUri = element.select("div.tw").select("img").attr("src") | ||
|
||
val typeDiff = parseTypeDifficultyFromUri(typeDiffImgUri)!! | ||
|
||
val bg = getBackgroundImg(element.select("div.re.bgfix").first()!!, false) | ||
|
||
val diffElems = element.select("div.imG") | ||
|
||
var diff = "" | ||
|
||
for (i in diffElems) { | ||
diff += Utils.parseDifficultyFromUri(i.select("img").attr("src")) | ||
} | ||
|
||
diff = typeDiff.uppercase(Locale.ENGLISH) + diff | ||
|
||
|
||
val rankImg = element.select("div.grade_wrap").first()!!.select("img").attr("src") | ||
var rank = Utils.parseRankFromUri(rankImg).toString() | ||
rank = rank.uppercase(Locale.ENGLISH).replace("_p", "+").replace("_P", "+") | ||
.replace("X_", "Broken ") | ||
|
||
val datePlay = element.select("div.date").first()!!.select("i.tt").text() | ||
|
||
|
||
return PumbilityScore( | ||
songName, | ||
bg, | ||
diff, | ||
score, | ||
rank, | ||
Utils.convertDateFromSite(datePlay) | ||
) | ||
} | ||
|
||
|
||
override fun parse(document: Document): Pumbility { | ||
val res: MutableList<PumbilityScore> = mutableListOf() | ||
|
||
val user = UserParser.parse(document) | ||
|
||
val scoreTable = document | ||
.select("div.rating_rangking_list_w.top_songSt.pumblitiySt.mgT1") | ||
.first()!! | ||
.select("ul.list") | ||
.first()!! | ||
val scores = scoreTable.select("li").filter { element -> | ||
element.select("div.in.flex.vc.wrap").count() == 1 | ||
} | ||
for (element in scores) { | ||
res.add(parsePumbilityScore(element)) | ||
} | ||
return Pumbility(user, res) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../piucompanion/ui/screens/home/newsPage.kt → ...1k/piucompanion/ui/pages/home/newsPage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.