mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-22 06:37:30 +00:00
possible anonymous fix?
This commit is contained in:
parent
dcd00ce60b
commit
808c841e65
@ -8,15 +8,15 @@ interface GraphQLService {
|
|||||||
@GET("/graphql/query/")
|
@GET("/graphql/query/")
|
||||||
suspend fun fetch(@QueryMap(encoded = true) queryParams: Map<String, String>): String
|
suspend fun fetch(@QueryMap(encoded = true) queryParams: Map<String, String>): String
|
||||||
|
|
||||||
@GET("/{username}/?__a=1")
|
@GET("/{username}/")
|
||||||
suspend fun getUser(@Path("username") username: String): String
|
suspend fun getUser(@Path("username") username: String): String
|
||||||
|
|
||||||
@GET("/p/{shortcode}/?__a=1")
|
@GET("/p/{shortcode}/?__a=1")
|
||||||
suspend fun getPost(@Path("shortcode") shortcode: String): String
|
suspend fun getPost(@Path("shortcode") shortcode: String): String
|
||||||
|
|
||||||
@GET("/explore/tags/{tag}/?__a=1")
|
@GET("/explore/tags/{tag}/")
|
||||||
suspend fun getTag(@Path("tag") tag: String): String
|
suspend fun getTag(@Path("tag") tag: String): String
|
||||||
|
|
||||||
@GET("/explore/locations/{locationId}/?__a=1")
|
@GET("/explore/locations/{locationId}/")
|
||||||
suspend fun getLocation(@Path("locationId") locationId: Long): String
|
suspend fun getLocation(@Path("locationId") locationId: Long): String
|
||||||
}
|
}
|
@ -1,16 +1,17 @@
|
|||||||
package awais.instagrabber.webservices
|
package awais.instagrabber.webservices
|
||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import awais.instagrabber.models.enums.FollowingType
|
|
||||||
import awais.instagrabber.repositories.GraphQLService
|
import awais.instagrabber.repositories.GraphQLService
|
||||||
import awais.instagrabber.repositories.responses.*
|
import awais.instagrabber.repositories.responses.*
|
||||||
import awais.instagrabber.utils.Constants
|
import awais.instagrabber.utils.Constants
|
||||||
import awais.instagrabber.utils.ResponseBodyUtils
|
import awais.instagrabber.utils.ResponseBodyUtils
|
||||||
import awais.instagrabber.utils.extensions.TAG
|
import awais.instagrabber.utils.extensions.TAG
|
||||||
|
import com.google.gson.Gson
|
||||||
import org.json.JSONException
|
import org.json.JSONException
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
|
||||||
class GraphQLRepository(private val service: GraphQLService) {
|
class GraphQLRepository(private val service: GraphQLService) {
|
||||||
|
|
||||||
// TODO convert string response to a response class
|
// TODO convert string response to a response class
|
||||||
@ -179,8 +180,16 @@ class GraphQLRepository(private val service: GraphQLService) {
|
|||||||
username: String,
|
username: String,
|
||||||
): User {
|
): User {
|
||||||
val response = service.getUser(username)
|
val response = service.getUser(username)
|
||||||
val body = JSONObject(response)
|
val body = JSONObject(response
|
||||||
val userJson = body.getJSONObject("graphql").getJSONObject(Constants.EXTRAS_USER)
|
.split("<script type=\"text/javascript\">window._sharedData = ", false, 2).get(1)
|
||||||
|
.split("</script>", false, 2).get(0)
|
||||||
|
.trim().replace(Regex("};$"), "}"))
|
||||||
|
val userJson = body
|
||||||
|
.getJSONObject("entry_data")
|
||||||
|
.getJSONArray("ProfilePage")
|
||||||
|
.getJSONObject(0)
|
||||||
|
.getJSONObject("graphql")
|
||||||
|
.getJSONObject(Constants.EXTRAS_USER)
|
||||||
val isPrivate = userJson.getBoolean("is_private")
|
val isPrivate = userJson.getBoolean("is_private")
|
||||||
val id = userJson.optLong(Constants.EXTRAS_ID, 0)
|
val id = userJson.optLong(Constants.EXTRAS_ID, 0)
|
||||||
val timelineMedia = userJson.getJSONObject("edge_owner_to_timeline_media")
|
val timelineMedia = userJson.getJSONObject("edge_owner_to_timeline_media")
|
||||||
@ -231,7 +240,13 @@ class GraphQLRepository(private val service: GraphQLService) {
|
|||||||
tag: String,
|
tag: String,
|
||||||
): Hashtag {
|
): Hashtag {
|
||||||
val response = service.getTag(tag)
|
val response = service.getTag(tag)
|
||||||
val body = JSONObject(response)
|
val body = JSONObject(response
|
||||||
|
.split("<script type=\"text/javascript\">window._sharedData = ", false, 2).get(1)
|
||||||
|
.split("</script>", false, 2).get(0)
|
||||||
|
.trim().replace(Regex("};$"), "}"))
|
||||||
|
.getJSONObject("entry_data")
|
||||||
|
.getJSONArray("TagPage")
|
||||||
|
.getJSONObject(0)
|
||||||
.getJSONObject("graphql")
|
.getJSONObject("graphql")
|
||||||
.getJSONObject(Constants.EXTRAS_HASHTAG)
|
.getJSONObject(Constants.EXTRAS_HASHTAG)
|
||||||
val timelineMedia = body.getJSONObject("edge_hashtag_to_media")
|
val timelineMedia = body.getJSONObject("edge_hashtag_to_media")
|
||||||
@ -249,7 +264,13 @@ class GraphQLRepository(private val service: GraphQLService) {
|
|||||||
locationId: Long,
|
locationId: Long,
|
||||||
): Location {
|
): Location {
|
||||||
val response = service.getLocation(locationId)
|
val response = service.getLocation(locationId)
|
||||||
val body = JSONObject(response)
|
val body = JSONObject(response
|
||||||
|
.split("<script type=\"text/javascript\">window._sharedData = ", false, 2).get(1)
|
||||||
|
.split("</script>", false, 2).get(0)
|
||||||
|
.trim().replace(Regex("};$"), "}"))
|
||||||
|
.getJSONObject("entry_data")
|
||||||
|
.getJSONArray("LocationsPage")
|
||||||
|
.getJSONObject(0)
|
||||||
.getJSONObject("graphql")
|
.getJSONObject("graphql")
|
||||||
.getJSONObject(Constants.EXTRAS_LOCATION)
|
.getJSONObject(Constants.EXTRAS_LOCATION)
|
||||||
// val timelineMedia = body.getJSONObject("edge_location_to_media")
|
// val timelineMedia = body.getJSONObject("edge_location_to_media")
|
||||||
|
Loading…
Reference in New Issue
Block a user