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

pt-br init, also discover

This commit is contained in:
Austin Huang 2020-08-12 14:38:07 -04:00
parent e4f8f861be
commit 04d9adbaec
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F
18 changed files with 45 additions and 26 deletions

View File

@ -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) {

View File

@ -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));

View File

@ -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");

View File

@ -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();

View File

@ -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;
}
}

View File

@ -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\":" +

View File

@ -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;
}

View File

@ -11,6 +11,7 @@
<item>Deutsch [Danke an @peterge1998 (GitHub)]</item>
<item>Polnisch [Danke an @Lego8486 (GitHub)]</item>
<item>Türkisch [Danke an @faydin90 (Telegram)]</item>
<item>BR Portugiesisch [Danke an @wagnim (GitHub)]</item>
</string-array>
<string-array name="theme_presets">
<item>Auto / Folge System</item>

View File

@ -11,6 +11,7 @@
<item>Alemán [Gracias a @peterge1998 (GitHub)]</item>
<item>Polaco [Gracias a @Lego8486 (GitHub)]</item>
<item>Turco [Gracias a @faydin90 (Telegram)]</item>
<item>Portugués brasileño [Gracias a @wagnim (GitHub)]</item>
</string-array>
<string-array name="theme_presets">
<item>Auto / Seguir Sistema</item>

View File

@ -11,6 +11,7 @@
<item>Allemand [Merci à @peterge1998 (GitHub)]</item>
<item>Polonais [Merci à @Lego8486 (GitHub)]</item>
<item>Turc [Merci à @faydin90 (Telegram)]</item>
<item>Portugais brésilien [Merci à @wagnim (GitHub)]</item>
</string-array>
<string-array name="theme_presets">
<item>Automatique (Système)</item>

View File

@ -11,6 +11,7 @@
<item>Jerman [Terima kasih @peterge1998 (GitHub)]</item>
<item>Polandia [Terima kasih @Lego8486 (GitHub)]</item>
<item>Turki [Terima kasih @faydin90 (Telegram)]</item>
<item>Portugis Brasil [Terima kasih @wagnim (GitHub)]</item>
</string-array>
<string-array name="theme_presets">
<item>Otomatis / Ikuti Sistem</item>

View File

@ -11,6 +11,7 @@
<item>Tedesco [Grazie a @peterge1998 (GitHub)]</item>
<item>Polacco [Grazie a @Lego8486 (GitHub)]</item>
<item>Turco [Grazie a @faydin90 (Telegram)]</item>
<item>Portoghese [Grazie a @wagnim (Telegram)]</item>
</string-array>
<string-array name="theme_presets">
<item>Automatico / In base al sistema</item>

View File

@ -10,7 +10,8 @@
<item>Włoski [Podziękowania dla @RAR_Ramar (Telegram)]</item>
<item>Niemiecki [Podziękowania dla @peterge1998 (GitHub)]</item>
<item>Polski [Podziękowania dla @Lego8486 (GitHub)]</item>
<item>Turkish [Thanks to @faydin90 (Telegram)]</item>
<item>Turecki [Podziękowania dla @faydin90 (Telegram)]</item>
<item>Portugalski [Podziękowania dla @wagnim (GitHub)]</item>
</string-array>
<string-array name="theme_presets">
<item>Auto / Ustawienia systemu</item>

View File

@ -3,14 +3,15 @@
<string-array name="languages">
<item>Padrão do sistema</item>
<item>Inglês</item>
<item>Francês Agradecimentos a @kernoeb (Telegram)]</item>
<item>Espanhol Agradecimentos a @sguinetti (GitLab)]</item>
<item>Francês [Agradecimentos a @kernoeb (Telegram)]</item>
<item>Espanhol [Agradecimentos a @sguinetti (GitLab)]</item>
<item>Chinês (Simplificado)</item>
<item>Indonésio [Agradecimentos a @ Galang23 (GitLab)]</item>
<item>Indonésio [Agradecimentos a @Galang23 (GitLab)]</item>
<item>Italiano [Agradecimentos a @RAR_Ramar (Telegram)]</item>
<item>Alemão [Agradecimentos a @ peterge1998 (GitHub)]</item>
<item>Polonês [Agradecimentos a @ Lego8486 (GitHub)]</item>
<item>Turco [Agradecimentos a @ faydin90 (Telegram)]</item>
<item>Alemão [Agradecimentos a @peterge1998 (GitHub)]</item>
<item>Polonês [Agradecimentos a @Lego8486 (GitHub)]</item>
<item>Turco [Agradecimentos a @faydin90 (Telegram)]</item>
<item>Português (BR) [Agradecimentos a @wagnim (GitHub)]</item>
</string-array>
<string-array name="theme_presets">
<item>Auto / Seguir o sistema</item>

View File

@ -11,6 +11,7 @@
<item>German [Thanks to @peterge1998 (GitHub)]</item>
<item>Polish [Thanks to @Lego8486 (GitHub)]</item>
<item>Turkish [Thanks to @faydin90 (Telegram)]</item>
<item>Portuguese (BR) [Thanks to @wagnim (GitHub)]</item>
</string-array>
<string-array name="theme_presets">
<item>Auto / Follow System</item>

View File

@ -11,6 +11,7 @@
<item>Almanca [@peterge1998 (GitHub) sayesinde]</item>
<item>Lehçe [@Lego8486 (GitHub) sayesinde]</item>
<item>Türkçe [@faydin90 (Telegram) sayesinde]</item>
<item>Portekizce [@wagnim (GitHub) sayesinde]</item>
</string-array>
<string-array name="theme_presets">
<item>Otomatik / Sistemi Takip Et</item>

View File

@ -10,13 +10,14 @@
<item>意大利文 [感谢 @RAR_Ramar (Telegram)]</item>
<item>德文 [感谢 @peterge1998 (GitHub)]</item>
<item>波兰文 [感谢 @Lego8486 (GitHub)]</item>
<item>土耳其语 [感谢 @faydin90 (Telegram)]</item>
<item>土耳其文 [感谢 @faydin90 (Telegram)]</item>
<item>巴西葡文 [感谢 @wagnim (GitHub)]</item>
</string-array>
<string-array name="theme_presets">
<item>自动 / 跟随系统</item>
<item>自动 / 跟随电池</item>
<item>暗黑</item>
<item>明亮</item>
<item>夜间模式</item>
<item>明亮模式</item>
</string-array>
<string-array name="separator_presets">
<item></item>

View File

@ -11,6 +11,7 @@
<item>German [Thanks to @peterge1998 (GitHub)]</item>
<item>Polish [Thanks to @Lego8486 (GitHub)]</item>
<item>Turkish [Thanks to @faydin90 (Telegram)]</item>
<item>Brazilian Portuguese [Thanks to @wagnim (GitHub)]</item>
</string-array>
<string-array name="theme_presets">
<item>Auto / Follow System</item>