1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-12-23 05:16:58 +00:00

fix some string handling

This commit is contained in:
Austin Huang 2021-06-19 17:49:55 -04:00
parent 808c841e65
commit 13dc310c5d
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F

View File

@ -1,12 +1,12 @@
package awais.instagrabber.webservices
import android.util.Log
import awais.instagrabber.models.enums.FollowingType
import awais.instagrabber.repositories.GraphQLService
import awais.instagrabber.repositories.responses.*
import awais.instagrabber.utils.Constants
import awais.instagrabber.utils.ResponseBodyUtils
import awais.instagrabber.utils.extensions.TAG
import com.google.gson.Gson
import org.json.JSONException
import org.json.JSONObject
import java.util.*
@ -181,9 +181,9 @@ class GraphQLRepository(private val service: GraphQLService) {
): User {
val response = service.getUser(username)
val body = JSONObject(response
.split("<script type=\"text/javascript\">window._sharedData = ", false, 2).get(1)
.split("</script>", false, 2).get(0)
.trim().replace(Regex("};$"), "}"))
.split("<script type=\"text/javascript\">window._sharedData = ").get(1)
.split("</script>").get(0)
.trim().replace(Regex("\\};$"), "}"))
val userJson = body
.getJSONObject("entry_data")
.getJSONArray("ProfilePage")
@ -241,9 +241,9 @@ class GraphQLRepository(private val service: GraphQLService) {
): Hashtag {
val response = service.getTag(tag)
val body = JSONObject(response
.split("<script type=\"text/javascript\">window._sharedData = ", false, 2).get(1)
.split("</script>", false, 2).get(0)
.trim().replace(Regex("};$"), "}"))
.split("<script type=\"text/javascript\">window._sharedData = ").get(1)
.split("</script>").get(0)
.trim().replace(Regex("\\};$"), "}"))
.getJSONObject("entry_data")
.getJSONArray("TagPage")
.getJSONObject(0)
@ -265,8 +265,7 @@ class GraphQLRepository(private val service: GraphQLService) {
): Location {
val response = service.getLocation(locationId)
val body = JSONObject(response
.split("<script type=\"text/javascript\">window._sharedData = ", false, 2).get(1)
.split("</script>", false, 2).get(0)
.split("<script type=\"text/javascript\">window._sharedData = ", "</script>").get(1)
.trim().replace(Regex("};$"), "}"))
.getJSONObject("entry_data")
.getJSONArray("LocationsPage")