1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-22 22:57:29 +00:00

byebye storiesig

This commit is contained in:
Austin Huang 2020-09-20 22:36:23 -04:00
parent 03bd549016
commit 6425fc3975
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F
21 changed files with 17 additions and 62 deletions

View File

@ -19,25 +19,23 @@ import awais.instagrabber.utils.NetworkUtils;
public final class HighlightsFetcher extends AsyncTask<Void, Void, List<HighlightModel>> { public final class HighlightsFetcher extends AsyncTask<Void, Void, List<HighlightModel>> {
private final String id; private final String id;
private final boolean storiesig;
private final FetchListener<List<HighlightModel>> fetchListener; private final FetchListener<List<HighlightModel>> fetchListener;
public HighlightsFetcher(final String id, final boolean storiesig, final FetchListener<List<HighlightModel>> fetchListener) { public HighlightsFetcher(final String id, final FetchListener<List<HighlightModel>> fetchListener) {
this.id = id; this.id = id;
this.storiesig = storiesig;
this.fetchListener = fetchListener; this.fetchListener = fetchListener;
} }
@Override @Override
protected List<HighlightModel> doInBackground(final Void... voids) { protected List<HighlightModel> doInBackground(final Void... voids) {
List<HighlightModel> result = null; List<HighlightModel> result = null;
String url = "https://" + (storiesig ? "storiesig" : "i.instagram") + ".com/api/v1/highlights/" + id + "/highlights_tray/"; String url = "https://i.instagram.com/api/v1/highlights/" + id + "/highlights_tray/";
try { try {
HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection(); HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
conn.setInstanceFollowRedirects(false); conn.setInstanceFollowRedirects(false);
conn.setUseCaches(false); conn.setUseCaches(false);
conn.setRequestProperty("User-Agent", storiesig ? Constants.A_USER_AGENT : Constants.I_USER_AGENT); conn.setRequestProperty("User-Agent", Constants.I_USER_AGENT);
conn.connect(); conn.connect();
if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) { if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {

View File

@ -30,7 +30,6 @@ public final class iStoryStatusFetcher extends AsyncTask<Void, Void, StoryModel[
private String username; private String username;
private final boolean isLoc; private final boolean isLoc;
private final boolean isHashtag; private final boolean isHashtag;
private final boolean storiesig;
private final boolean highlight; private final boolean highlight;
private final FetchListener<StoryModel[]> fetchListener; private final FetchListener<StoryModel[]> fetchListener;
@ -38,14 +37,12 @@ public final class iStoryStatusFetcher extends AsyncTask<Void, Void, StoryModel[
final String username, final String username,
final boolean isLoc, final boolean isLoc,
final boolean isHashtag, final boolean isHashtag,
final boolean storiesig,
final boolean highlight, final boolean highlight,
final FetchListener<StoryModel[]> fetchListener) { final FetchListener<StoryModel[]> fetchListener) {
this.id = id; this.id = id;
this.username = username; this.username = username;
this.isLoc = isLoc; this.isLoc = isLoc;
this.isHashtag = isHashtag; this.isHashtag = isHashtag;
this.storiesig = storiesig;
this.highlight = highlight; this.highlight = highlight;
this.fetchListener = fetchListener; this.fetchListener = fetchListener;
} }
@ -55,13 +52,7 @@ public final class iStoryStatusFetcher extends AsyncTask<Void, Void, StoryModel[
StoryModel[] result = null; StoryModel[] result = null;
final String userId = id.replace(":", "%3A"); final String userId = id.replace(":", "%3A");
final StringBuilder builder = new StringBuilder(); final StringBuilder builder = new StringBuilder();
builder.append("https://"); builder.append("https://i.instagram.com/api/v1/");
if (storiesig) {
builder.append("storiesig");
} else {
builder.append("i.instagram");
}
builder.append(".com/api/v1/");
if (isLoc) { if (isLoc) {
builder.append("locations/"); builder.append("locations/");
} }
@ -75,24 +66,20 @@ public final class iStoryStatusFetcher extends AsyncTask<Void, Void, StoryModel[
} }
builder.append(userId); builder.append(userId);
if (!highlight) { if (!highlight) {
if (storiesig) {
builder.append("/reel_media/");
} else {
builder.append("/story/"); builder.append("/story/");
} }
}
final String url = builder.toString(); final String url = builder.toString();
try { try {
final HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection(); final HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
conn.setInstanceFollowRedirects(true); conn.setInstanceFollowRedirects(true);
conn.setUseCaches(false); conn.setUseCaches(false);
conn.setRequestProperty("User-Agent", storiesig ? Constants.A_USER_AGENT : Constants.I_USER_AGENT); conn.setRequestProperty("User-Agent", Constants.I_USER_AGENT);
conn.setRequestProperty("Accept-Language", LocaleUtils.getCurrentLocale().getLanguage() + ",en-US;q=0.8"); conn.setRequestProperty("Accept-Language", LocaleUtils.getCurrentLocale().getLanguage() + ",en-US;q=0.8");
conn.connect(); conn.connect();
if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) { if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
JSONObject data = new JSONObject(NetworkUtils.readFromConnection(conn)); JSONObject data = new JSONObject(NetworkUtils.readFromConnection(conn));
if (!storiesig && !highlight) if (!highlight)
data = data.optJSONObject((isLoc || isHashtag) ? "story" : "reel"); data = data.optJSONObject((isLoc || isHashtag) ? "story" : "reel");
else if (highlight) data = data.getJSONObject("reels").optJSONObject(id); else if (highlight) data = data.getJSONObject("reels").optJSONObject(id);

View File

@ -286,7 +286,7 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
final Context context = getContext(); final Context context = getContext();
if (context == null) return; if (context == null) return;
if (isLoggedIn) { if (isLoggedIn) {
new iStoryStatusFetcher(hashtagModel.getName(), null, false, true, false, false, stories -> { new iStoryStatusFetcher(hashtagModel.getName(), null, false, true, false, stories -> {
if (stories != null && stories.length > 0) { if (stories != null && stories.length > 0) {
binding.mainHashtagImage.setStoriesBorder(); binding.mainHashtagImage.setStoriesBorder();
} }

View File

@ -293,7 +293,6 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR
true, true,
false, false,
false, false,
false,
stories -> { stories -> {
if (stories != null && stories.length > 0) { if (stories != null && stories.length > 0) {
binding.mainLocationImage.setStoriesBorder(); binding.mainLocationImage.setStoriesBorder();

View File

@ -544,7 +544,6 @@ public class StoryViewerFragment extends Fragment {
}; };
storiesService.getUserStory(currentStoryMediaId, storiesService.getUserStory(currentStoryMediaId,
username, username,
!isLoggedIn && settingsHelper.getString(Constants.STORY_VIEWER) == StoryViewerChoice.STORIESIG.getValue(),
false, false,
false, false,
isHighlight, isHighlight,

View File

@ -441,12 +441,11 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
} }
binding.isVerified.setVisibility(profileModel.isVerified() ? View.VISIBLE : View.GONE); binding.isVerified.setVisibility(profileModel.isVerified() ? View.VISIBLE : View.GONE);
final String profileId = profileModel.getId(); final String profileId = profileModel.getId();
if (settingsHelper.getString(Constants.STORY_VIEWER).equals(StoryViewerChoice.STORIESIG.getValue()) || isLoggedIn) { if (isLoggedIn) {
new iStoryStatusFetcher(profileId, new iStoryStatusFetcher(profileId,
profileModel.getUsername(), profileModel.getUsername(),
false, false,
false, false,
!isLoggedIn && settingsHelper.getString(Constants.STORY_VIEWER).equals(StoryViewerChoice.STORIESIG.getValue()),
false, false,
result -> { result -> {
storyModels = result; storyModels = result;
@ -455,7 +454,6 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
} }
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new HighlightsFetcher(profileId, new HighlightsFetcher(profileId,
!isLoggedIn && settingsHelper.getString(Constants.STORY_VIEWER).equals(StoryViewerChoice.STORIESIG.getValue()),
result -> { result -> {
if (result != null) { if (result != null) {
binding.highlightsList.setVisibility(View.VISIBLE); binding.highlightsList.setVisibility(View.VISIBLE);

View File

@ -4,9 +4,8 @@ import java.io.Serializable;
public enum StoryViewerChoice implements Serializable { public enum StoryViewerChoice implements Serializable {
NONE(0), NONE(0),
STORIESIG(1), ALOINSTAGRAM(1),
ALOINSTAGRAM(2), INSTADP(2);
INSTADP(3);
private int value; private int value;

View File

@ -98,14 +98,12 @@ public class StoriesService extends BaseService {
public void getUserStory(final String id, public void getUserStory(final String id,
final String username, final String username,
final boolean storiesig,
final boolean isLoc, final boolean isLoc,
final boolean isHashtag, final boolean isHashtag,
final boolean highlight, final boolean highlight,
final ServiceCallback<List<StoryModel>> callback) { final ServiceCallback<List<StoryModel>> callback) {
final String url = buildUrl(id, storiesig, isLoc, isHashtag, highlight); final String url = buildUrl(id, isLoc, isHashtag, highlight);
final String userAgent = storiesig ? Constants.A_USER_AGENT : Constants.I_USER_AGENT; final Call<String> userStoryCall = repository.getUserStory(Constants.I_USER_AGENT, url);
final Call<String> userStoryCall = repository.getUserStory(userAgent, url);
userStoryCall.enqueue(new Callback<String>() { userStoryCall.enqueue(new Callback<String>() {
@Override @Override
public void onResponse(@NonNull final Call<String> call, @NonNull final Response<String> response) { public void onResponse(@NonNull final Call<String> call, @NonNull final Response<String> response) {
@ -119,7 +117,7 @@ public class StoriesService extends BaseService {
} }
data = new JSONObject(body); data = new JSONObject(body);
if (!storiesig && !highlight) if (!highlight)
data = data.optJSONObject((isLoc || isHashtag) ? "story" : "reel"); data = data.optJSONObject((isLoc || isHashtag) ? "story" : "reel");
else if (highlight) data = data.getJSONObject("reels").optJSONObject(id); else if (highlight) data = data.getJSONObject("reels").optJSONObject(id);
@ -243,16 +241,10 @@ public class StoriesService extends BaseService {
}); });
} }
private String buildUrl(final String id, final boolean storiesig, final boolean isLoc, final boolean isHashtag, final boolean highlight) { private String buildUrl(final String id, final boolean isLoc, final boolean isHashtag, final boolean highlight) {
final String userId = id.replace(":", "%3A"); final String userId = id.replace(":", "%3A");
final StringBuilder builder = new StringBuilder(); final StringBuilder builder = new StringBuilder();
builder.append("https://"); builder.append("https://i.instagram.com/api/v1/");
if (storiesig) {
builder.append("storiesig");
} else {
builder.append("i.instagram");
}
builder.append(".com/api/v1/");
if (isLoc) { if (isLoc) {
builder.append("locations/"); builder.append("locations/");
} }
@ -266,12 +258,8 @@ public class StoriesService extends BaseService {
} }
builder.append(userId); builder.append(userId);
if (!highlight) { if (!highlight) {
if (storiesig) {
builder.append("/reel_media/");
} else {
builder.append("/story/"); builder.append("/story/");
} }
}
return builder.toString(); return builder.toString();
} }
} }

View File

@ -42,7 +42,6 @@
</string-array> </string-array>
<string-array name="anonymous_story_viewer"> <string-array name="anonymous_story_viewer">
<item>Deaktivieren</item> <item>Deaktivieren</item>
<item>storiesig</item>
<item>Aloinstagram</item> <item>Aloinstagram</item>
<item>Instadp</item> <item>Instadp</item>
</string-array> </string-array>

View File

@ -42,7 +42,6 @@
</string-array> </string-array>
<string-array name="anonymous_story_viewer"> <string-array name="anonymous_story_viewer">
<item>Disable</item> <item>Disable</item>
<item>storiesig</item>
<item>Aloinstagram</item> <item>Aloinstagram</item>
<item>Instadp</item> <item>Instadp</item>
</string-array> </string-array>

View File

@ -42,7 +42,6 @@
</string-array> </string-array>
<string-array name="anonymous_story_viewer"> <string-array name="anonymous_story_viewer">
<item>غیرفعال</item> <item>غیرفعال</item>
<item>استوری های ig</item>
<item>Aloinstagram</item> <item>Aloinstagram</item>
<item>Instadp</item> <item>Instadp</item>
</string-array> </string-array>

View File

@ -42,7 +42,6 @@
</string-array> </string-array>
<string-array name="anonymous_story_viewer"> <string-array name="anonymous_story_viewer">
<item>Disable</item> <item>Disable</item>
<item>storiesig</item>
<item>Aloinstagram</item> <item>Aloinstagram</item>
<item>Instadp</item> <item>Instadp</item>
</string-array> </string-array>

View File

@ -42,7 +42,6 @@
</string-array> </string-array>
<string-array name="anonymous_story_viewer"> <string-array name="anonymous_story_viewer">
<item>Nonaktifkan</item> <item>Nonaktifkan</item>
<item>storiesig</item>
<item>Aloinstagram</item> <item>Aloinstagram</item>
<item>Instadp</item> <item>Instadp</item>
</string-array> </string-array>

View File

@ -42,7 +42,6 @@
</string-array> </string-array>
<string-array name="anonymous_story_viewer"> <string-array name="anonymous_story_viewer">
<item>Disattiva</item> <item>Disattiva</item>
<item>storiesig</item>
<item>Aloinstagram</item> <item>Aloinstagram</item>
<item>Instadp</item> <item>Instadp</item>
</string-array> </string-array>

View File

@ -42,7 +42,6 @@
</string-array> </string-array>
<string-array name="anonymous_story_viewer"> <string-array name="anonymous_story_viewer">
<item>Disable</item> <item>Disable</item>
<item>storiesig</item>
<item>Aloinstagram</item> <item>Aloinstagram</item>
<item>Instadp</item> <item>Instadp</item>
</string-array> </string-array>

View File

@ -42,7 +42,6 @@
</string-array> </string-array>
<string-array name="anonymous_story_viewer"> <string-array name="anonymous_story_viewer">
<item>Disable</item> <item>Disable</item>
<item>storiesig</item>
<item>Aloinstagram</item> <item>Aloinstagram</item>
<item>Instadp</item> <item>Instadp</item>
</string-array> </string-array>

View File

@ -42,7 +42,6 @@
</string-array> </string-array>
<string-array name="anonymous_story_viewer"> <string-array name="anonymous_story_viewer">
<item>Disable</item> <item>Disable</item>
<item>storiesig</item>
<item>Aloinstagram</item> <item>Aloinstagram</item>
<item>Instadp</item> <item>Instadp</item>
</string-array> </string-array>

View File

@ -42,7 +42,6 @@
</string-array> </string-array>
<string-array name="anonymous_story_viewer"> <string-array name="anonymous_story_viewer">
<item>Disable</item> <item>Disable</item>
<item>storiesig</item>
<item>Aloinstagram</item> <item>Aloinstagram</item>
<item>Instadp</item> <item>Instadp</item>
</string-array> </string-array>

View File

@ -42,7 +42,6 @@
</string-array> </string-array>
<string-array name="anonymous_story_viewer"> <string-array name="anonymous_story_viewer">
<item>Devredışı Bırak</item> <item>Devredışı Bırak</item>
<item>storiesig</item>
<item>Aloinstagram</item> <item>Aloinstagram</item>
<item>Instadp</item> <item>Instadp</item>
</string-array> </string-array>

View File

@ -42,7 +42,6 @@
</string-array> </string-array>
<string-array name="anonymous_story_viewer"> <string-array name="anonymous_story_viewer">
<item>禁用</item> <item>禁用</item>
<item>storiesig</item>
<item>Aloinstagram</item> <item>Aloinstagram</item>
<item>Instadp</item> <item>Instadp</item>
</string-array> </string-array>

View File

@ -42,7 +42,6 @@
</string-array> </string-array>
<string-array name="anonymous_story_viewer"> <string-array name="anonymous_story_viewer">
<item>Disable</item> <item>Disable</item>
<item>storiesig</item>
<item>Aloinstagram</item> <item>Aloinstagram</item>
<item>Instadp</item> <item>Instadp</item>
</string-array> </string-array>