mirror of
https://github.com/KokaKiwi/BarInsta
synced 2026-03-05 20:11:36 +00:00
pt-br init, also discover
This commit is contained in:
parent
e4f8f861be
commit
04d9adbaec
18 changed files with 45 additions and 26 deletions
|
|
@ -92,7 +92,7 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
|||
private final boolean autoloadPosts;
|
||||
private FeedStoryModel[] stories;
|
||||
private boolean hasNextPage = false, feedHasNextPage = false, discoverHasMore = false;
|
||||
private String endCursor = null, feedEndCursor = null, discoverEndMaxId = null, topic = null;
|
||||
private String endCursor = null, feedEndCursor = null, discoverEndMaxId = null, topic = null, rankToken = null;
|
||||
private String[] topicIds = null;
|
||||
private final FetchListener<PostModel[]> postsFetchListener = new FetchListener<PostModel[]>() {
|
||||
@Override
|
||||
|
|
@ -197,6 +197,7 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
|||
public void onResult(final DiscoverTopicModel result) {
|
||||
if (result != null) {
|
||||
topicIds = result.getIds();
|
||||
rankToken = result.getToken();
|
||||
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(
|
||||
main, android.R.layout.simple_spinner_dropdown_item, result.getNames() );
|
||||
main.mainBinding.discoverType.setAdapter(spinnerArrayAdapter);
|
||||
|
|
@ -536,7 +537,7 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
|||
if (discoverLazyLoader != null) discoverLazyLoader.resetState();
|
||||
main.discoverItems.clear();
|
||||
if (discoverAdapter != null) discoverAdapter.notifyDataSetChanged();
|
||||
new DiscoverFetcher(topic, null, discoverFetchListener, false).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
new DiscoverFetcher(topic, null, rankToken, discoverFetchListener, false).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -549,7 +550,7 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
|||
if (discoverLazyLoader != null) discoverLazyLoader.resetState();
|
||||
main.discoverItems.clear();
|
||||
if (discoverAdapter != null) discoverAdapter.notifyDataSetChanged();
|
||||
new DiscoverFetcher(topic, null, discoverFetchListener, false).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
new DiscoverFetcher(topic, null, rankToken, discoverFetchListener, false).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
});
|
||||
|
||||
main.mainBinding.discoverPosts.setAdapter(discoverAdapter = new DiscoverAdapter(main.discoverItems, v -> {
|
||||
|
|
@ -575,12 +576,10 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
|||
main.mainBinding.discoverPosts.addOnScrollListener(discoverLazyLoader = new RecyclerLazyLoader(layoutManager, (page, totalItemsCount) -> {
|
||||
if (discoverHasMore) {
|
||||
main.mainBinding.discoverSwipeRefreshLayout.setRefreshing(true);
|
||||
new DiscoverFetcher(topic, discoverEndMaxId, discoverFetchListener, false).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
new DiscoverFetcher(topic, discoverEndMaxId, rankToken, discoverFetchListener, false).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
discoverEndMaxId = null;
|
||||
}
|
||||
}));
|
||||
|
||||
new DiscoverFetcher(topic, null, discoverFetchListener, true).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
public void onIntent(final Intent intent) {
|
||||
|
|
|
|||
|
|
@ -31,16 +31,17 @@ import static awais.instagrabber.utils.Utils.logCollector;
|
|||
import static awais.instagrabber.utils.Utils.settingsHelper;
|
||||
|
||||
public final class DiscoverFetcher extends AsyncTask<Void, Void, DiscoverItemModel[]> {
|
||||
private final String cluster, maxId;
|
||||
private final String cluster, maxId, rankToken;
|
||||
private final FetchListener<DiscoverItemModel[]> fetchListener;
|
||||
private int lastId = 0;
|
||||
private boolean isFirst, moreAvailable;
|
||||
private String nextMaxId;
|
||||
|
||||
public DiscoverFetcher(final String cluster, final String maxId,
|
||||
public DiscoverFetcher(final String cluster, final String maxId, final String rankToken,
|
||||
final FetchListener<DiscoverItemModel[]> fetchListener, final boolean isFirst) {
|
||||
this.cluster = cluster == null ? "explore_all%3A0" : cluster.replace(":", "%3A");
|
||||
this.maxId = maxId == null ? "" : "&max_id=" + maxId;
|
||||
this.rankToken = rankToken;
|
||||
this.fetchListener = fetchListener;
|
||||
this.isFirst = isFirst;
|
||||
}
|
||||
|
|
@ -66,12 +67,12 @@ public final class DiscoverFetcher extends AsyncTask<Void, Void, DiscoverItemMod
|
|||
private ArrayList<DiscoverItemModel> fetchItems(ArrayList<DiscoverItemModel> discoverItemModels, final String maxId) {
|
||||
try {
|
||||
final String url = "https://www.instagram.com/explore/grid/?is_prefetch=false&omit_cover_media=true&module=explore_popular" +
|
||||
"&use_sectional_payload=false&cluster_id="+cluster+"&include_fixed_destinations=true" + maxId;
|
||||
"&use_sectional_payload=false&cluster_id="+cluster+"&include_fixed_destinations=true&session_id="+rankToken+maxId;
|
||||
|
||||
final HttpURLConnection urlConnection = (HttpURLConnection) new URL(url).openConnection();
|
||||
|
||||
urlConnection.setUseCaches(false);
|
||||
urlConnection.setRequestProperty("User-Agent", Constants.USER_AGENT);
|
||||
urlConnection.setRequestProperty("User-Agent", Constants.I_USER_AGENT);
|
||||
|
||||
if (urlConnection.getResponseCode() == HttpURLConnection.HTTP_OK) {
|
||||
final JSONObject discoverResponse = new JSONObject(Utils.readFromConnection(urlConnection));
|
||||
|
|
|
|||
|
|
@ -103,10 +103,11 @@ public final class iStoryStatusFetcher extends AsyncTask<Void, Void, StoryModel[
|
|||
}
|
||||
if (data.has("story_questions")) {
|
||||
JSONObject tappableObject = data.getJSONArray("story_questions").getJSONObject(0).optJSONObject("question_sticker");
|
||||
if (tappableObject != null) models[i].setQuestion(new QuestionModel(
|
||||
if (tappableObject != null && !tappableObject.getString("question_type").equals("music"))
|
||||
models[i].setQuestion(new QuestionModel(
|
||||
String.valueOf(tappableObject.getLong("question_id")),
|
||||
tappableObject.getString("question")
|
||||
));
|
||||
));
|
||||
}
|
||||
if (data.has("story_quizs")) {
|
||||
JSONObject tappableObject = data.getJSONArray("story_quizs").getJSONObject(0).optJSONObject("quiz_sticker");
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public final class iTopicFetcher extends AsyncTask<Void, Void, DiscoverTopicMode
|
|||
names[i] = mediaNode.getString("title");
|
||||
}
|
||||
|
||||
result = new DiscoverTopicModel(ids, names);
|
||||
result = new DiscoverTopicModel(ids, names, body.getString("rank_token"));
|
||||
}
|
||||
|
||||
conn.disconnect();
|
||||
|
|
|
|||
|
|
@ -4,10 +4,12 @@ import java.io.Serializable;
|
|||
|
||||
public final class DiscoverTopicModel implements Serializable {
|
||||
private final String[] id, name;
|
||||
private final String rankToken;
|
||||
|
||||
public DiscoverTopicModel(final String[] id, final String[] name) {
|
||||
public DiscoverTopicModel(final String[] id, final String[] name, final String rankToken) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.rankToken = rankToken;
|
||||
}
|
||||
|
||||
public String[] getIds() {
|
||||
|
|
@ -17,4 +19,8 @@ public final class DiscoverTopicModel implements Serializable {
|
|||
public String[] getNames() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return rankToken;
|
||||
}
|
||||
}
|
||||
|
|
@ -49,9 +49,9 @@ public final class Constants {
|
|||
// spoof
|
||||
public static final String USER_AGENT = "Mozilla/5.0 (Linux; Android 8.1.0; motorola one Build/OPKS28.63-18-3; wv) " +
|
||||
"AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/70.0.3538.80 Mobile Safari/537.36 " +
|
||||
"Instagram 152.0.0.25.117 Android (27/8.1.0; 320dpi; 720x1362; motorola; motorola one; deen_sprout; qcom; pt_BR; 234847224)";
|
||||
"Instagram 154.0.0.32.123 Android (27/8.1.0; 320dpi; 720x1362; motorola; motorola one; deen_sprout; qcom; pt_BR; 238093938)";
|
||||
public static final String I_USER_AGENT =
|
||||
"Instagram 152.0.0.25.117 Android (27/8.1.0; 320dpi; 720x1362; motorola; motorola one; deen_sprout; qcom; pt_BR; 234847224)";
|
||||
"Instagram 154.0.0.32.123 Android (27/8.1.0; 320dpi; 720x1362; motorola; motorola one; deen_sprout; qcom; pt_BR; 238093938)";
|
||||
public static final String A_USER_AGENT = "https://InstaGrabber.AustinHuang.me / mailto:InstaGrabber@AustinHuang.me";
|
||||
// see https://github.com/dilame/instagram-private-api/blob/master/src/core/constants.ts
|
||||
public static final String SUPPORTED_CAPABILITIES = "[ { \"name\": \"SUPPORTED_SDK_VERSIONS\", \"value\":" +
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ public final class LocaleUtils {
|
|||
if (appLanguageIndex == 7) return "de";
|
||||
if (appLanguageIndex == 8) return "pl";
|
||||
if (appLanguageIndex == 9) return "tr";
|
||||
if (appLanguageIndex == 10) return "pt";
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue