mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-29 04:17:12 +01:00
Fix gfycat and redgifs API.
This commit is contained in:
parent
0402a47090
commit
96a8230d39
@ -1,6 +1,7 @@
|
||||
package ml.docilealligator.infinityforreddit;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
@ -34,6 +35,7 @@ public class FetchGfycatOrRedgifsVideoLinks {
|
||||
gfycatRetrofit.create(GfycatAPI.class).getGfycatData(gfycatId).enqueue(new Callback<String>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||
Log.i("asdfasf", "s " + response.body());
|
||||
if (response.isSuccessful()) {
|
||||
new ParseGfycatVideoLinksAsyncTask(response.body(), fetchGfycatOrRedgifsVideoLinksListener).execute();
|
||||
} else {
|
||||
@ -100,16 +102,22 @@ public class FetchGfycatOrRedgifsVideoLinks {
|
||||
protected Void doInBackground(Void... voids) {
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(response);
|
||||
webm = jsonObject.getJSONObject(JSONUtils.GFY_ITEM_KEY)
|
||||
.getJSONObject(JSONUtils.CONTENT_URLS_KEY)
|
||||
.getJSONObject(JSONUtils.WEBM_KEY)
|
||||
.getString(JSONUtils.URL_KEY);
|
||||
mp4 = jsonObject.getJSONObject(JSONUtils.GFY_ITEM_KEY).has(JSONUtils.MP4_URL_KEY) ?
|
||||
jsonObject.getJSONObject(JSONUtils.GFY_ITEM_KEY).getString(JSONUtils.MP4_URL_KEY)
|
||||
: jsonObject.getJSONObject(JSONUtils.GFY_ITEM_KEY)
|
||||
.getJSONObject(JSONUtils.CONTENT_URLS_KEY)
|
||||
.getJSONObject(JSONUtils.MP4_KEY)
|
||||
.getString(JSONUtils.URL_KEY);
|
||||
if (jsonObject.getJSONObject(JSONUtils.GFY_ITEM_KEY).has(JSONUtils.WEBM_URL_KEY)) {
|
||||
webm = jsonObject.getJSONObject(JSONUtils.GFY_ITEM_KEY).getString(JSONUtils.WEBM_URL_KEY);
|
||||
} else if (jsonObject.getJSONObject(JSONUtils.GFY_ITEM_KEY).getJSONObject(JSONUtils.CONTENT_URLS_KEY).has(JSONUtils.WEBM_KEY)) {
|
||||
webm = jsonObject.getJSONObject(JSONUtils.GFY_ITEM_KEY)
|
||||
.getJSONObject(JSONUtils.CONTENT_URLS_KEY)
|
||||
.getJSONObject(JSONUtils.WEBM_KEY)
|
||||
.getString(JSONUtils.URL_KEY);
|
||||
} else {
|
||||
webm = mp4;
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
parseFailed = true;
|
||||
|
@ -131,4 +131,5 @@ public class JSONUtils {
|
||||
public static final String AWARDEE_KARMA_KEY = "awardee_karma";
|
||||
public static final String CONTENT_URLS_KEY = "content_urls";;
|
||||
public static final String WEBM_KEY = "webm";
|
||||
public static final String WEBM_URL_KEY = "webmUrl";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user