package xyz.stream.api;

import android.os.Handler;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import tv.danmaku.ijk.media.player.IjkMediaPlayer;
import xyz.stream.api.entity.BaseEntity;
import xyz.stream.api.entity.SubtitleEntity;

/* JADX INFO: loaded from: classes3.dex */
public final class s implements e {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final /* synthetic */ t f35934a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final /* synthetic */ int f35935b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final /* synthetic */ u f35936c;

    public s(int i10, t tVar, u uVar) {
        this.f35936c = uVar;
        this.f35934a = tVar;
        this.f35935b = i10;
    }

    @Override // xyz.stream.api.e
    public final void a(String str) {
        new Handler(xyz.stream.utils.e.d().f36112a.getMainLooper()).postDelayed(new androidx.activity.n(this, this.f35935b, this.f35934a, 20), 1000L);
    }

    @Override // xyz.stream.api.e
    public final void onSuccess(Object obj) {
        BaseEntity baseEntity = (BaseEntity) obj;
        int i10 = this.f35935b;
        t tVar = this.f35934a;
        if (baseEntity == null || baseEntity.getData() == null) {
            if (tVar != null) {
                tVar.onSubtitleFetched(new ArrayList());
                return;
            }
            return;
        }
        try {
            List<Map> list = (List) xyz.stream.utils.m.f36162a.fromJson(baseEntity.getData(), new SubtitleLoader$1$1().getType());
            ArrayList arrayList = new ArrayList();
            for (Map map : list) {
                String str = (String) map.get("name");
                String str2 = (String) map.get(IjkMediaPlayer.OnNativeInvokeListener.ARG_URL);
                String str3 = (String) map.get("type");
                if (str != null && str2 != null && str3 != null) {
                    arrayList.add(new SubtitleEntity(null, Integer.valueOf(i10), str, str2, str3, null, null, null));
                }
            }
            if (arrayList.isEmpty()) {
                if (tVar != null) {
                    tVar.onSubtitleFetched(new ArrayList());
                }
            } else if (tVar != null) {
                tVar.onSubtitleFetched(arrayList);
            }
        } catch (Exception e10) {
            xyz.stream.utils.h.c("parse subtitles error: " + e10 + ", videoId: " + i10);
            xyz.stream.utils.h.c(e10.getMessage());
            if (tVar != null) {
                tVar.onSubtitleFetched(new ArrayList());
            }
        }
    }
}
