package com.tencent.mm.plugin.topstory.ui.video;

import com.google.android.gms.common.internal.ImagesContract;
import com.google.firebase.analytics.FirebaseAnalytics$b;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.ai.f;
import com.tencent.mm.plugin.topstory.a.b.b;
import com.tencent.mm.plugin.topstory.a.c.j;
import com.tencent.mm.plugin.topstory.a.g;
import com.tencent.mm.plugin.websearch.api.a.a;
import com.tencent.mm.protocal.protobuf.abz;
import com.tencent.mm.protocal.protobuf.bzs;
import com.tencent.mm.protocal.protobuf.chv;
import com.tencent.mm.protocal.protobuf.chw;
import com.tencent.mm.protocal.protobuf.chy;
import com.tencent.mm.protocal.protobuf.tn;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.ah;
import com.tencent.mm.sdk.platformtools.at;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.sqlitelint.config.SharePluginInfo;
import com.tencent.ytcommon.BuildConfig;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONObject;

public final class n {
    f fur = new 3(this);
    public b sDo;
    public boolean sEY;
    public int sEZ;
    j sFa;
    private int sFb;
    private int sFc;

    static /* synthetic */ List b(boolean z, JSONArray jSONArray) {
        AppMethodBeat.i(1775);
        List a = a(z, jSONArray);
        AppMethodBeat.o(1775);
        return a;
    }

    static /* synthetic */ void b(chw chw, String str, String str2) {
        AppMethodBeat.i(1776);
        a(chw, str, str2);
        AppMethodBeat.o(1776);
    }

    public n() {
        AppMethodBeat.i(1762);
        AppMethodBeat.o(1762);
    }

    public final List<chw> cGQ() {
        AppMethodBeat.i(1763);
        LinkedList linkedList = this.sDo.cFT().xgK;
        AppMethodBeat.o(1763);
        return linkedList;
    }

    public final int cGR() {
        AppMethodBeat.i(1764);
        int size = cGQ().size();
        AppMethodBeat.o(1764);
        return size;
    }

    public final void d(chw chw) {
        AppMethodBeat.i(1765);
        synchronized (this) {
            try {
                cGQ().add(chw);
            } finally {
                while (true) {
                }
                AppMethodBeat.o(1765);
            }
        }
    }

    public final void FK(int i) {
        AppMethodBeat.i(1766);
        synchronized (this) {
            if (i >= 0) {
                try {
                    if (i < cGQ().size()) {
                        cGQ().remove(i);
                    }
                } catch (Throwable th) {
                    while (true) {
                        AppMethodBeat.o(1766);
                    }
                }
            }
        }
        AppMethodBeat.o(1766);
    }

    public final chw FL(int i) {
        chw chw;
        AppMethodBeat.i(1767);
        synchronized (this) {
            if (i >= 0) {
                try {
                    if (i < cGQ().size()) {
                        chw = (chw) cGQ().get(i);
                    }
                } finally {
                    while (true) {
                    }
                    AppMethodBeat.o(1767);
                }
            }
            chw = null;
            AppMethodBeat.o(1767);
        }
        return chw;
    }

    public final boolean FM(int i) {
        AppMethodBeat.i(1768);
        if (this.sEY) {
            ab.w("MicroMsg.TopStory.TopStoryVideoDataMgr", "RequestingData");
            AppMethodBeat.o(1768);
            return false;
        }
        tn tnVar;
        boolean z;
        tn tnVar2;
        String stringBuffer;
        ab.i("MicroMsg.TopStory.TopStoryVideoDataMgr", "requestData: %s", new Object[]{Integer.valueOf(i)});
        this.sEY = true;
        chv a = g.a(this.sDo.cFT());
        a.offset = i;
        if (!bo.isNullOrNil(this.sDo.cFT().xgC)) {
            tnVar = new tn();
            tnVar.key = "relevant_vid";
            tnVar.waE = this.sDo.cFT().xgC;
            a.tZG.add(tnVar);
        }
        if (!bo.isNullOrNil(this.sDo.cFT().xgD)) {
            tnVar = new tn();
            tnVar.key = "relevant_expand";
            tnVar.waE = this.sDo.cFT().xgD;
            a.tZG.add(tnVar);
        }
        if (!bo.isNullOrNil(this.sDo.cFT().xgE)) {
            tnVar = new tn();
            tnVar.key = "relevant_pre_searchid";
            tnVar.waE = this.sDo.cFT().xgE;
            a.tZG.add(tnVar);
        }
        if (!bo.isNullOrNil(this.sDo.cFT().xgF)) {
            tnVar = new tn();
            tnVar.key = "relevant_shared_openid";
            tnVar.waE = this.sDo.cFT().xgF;
            a.tZG.add(tnVar);
        }
        if (this.sDo.cFT().xgI != null) {
            tnVar = new tn();
            tnVar.key = "rec_category";
            tnVar.waD = this.sDo.cFT().xgI.wYN;
            a.tZG.add(tnVar);
        } else {
            tnVar = new tn();
            tnVar.key = "rec_category";
            tnVar.waD = this.sDo.cFT().xgG;
            a.tZG.add(tnVar);
        }
        Iterator it = a.tZG.iterator();
        while (it.hasNext()) {
            if ("show_tag_list".equals(((tn) it.next()).key)) {
                z = false;
                break;
            }
        }
        z = true;
        if (this.sDo.cFT().xgI != null && z) {
            tnVar = new tn();
            tnVar.key = "show_tag_list";
            tnVar.waE = this.sDo.cFT().xgI.id;
            a.tZG.add(tnVar);
        }
        tnVar = new tn();
        tnVar.key = "fetch_seed_videoinfo";
        if (this.sDo.cFT().xgI == null || bo.isNullOrNil(this.sDo.cFT().xgI.id)) {
            tnVar.waD = 1;
        } else {
            tnVar.waD = 0;
        }
        a.tZG.add(tnVar);
        if (cGR() == 1) {
            chw FL = FL(0);
            tnVar2 = new tn();
            tnVar2.key = "first_video_tag_list";
            tnVar2.waE = g.dN(FL.wiH).toString();
            a.tZG.add(tnVar2);
        }
        o cFR = this.sDo.cFR();
        if (cFR.sFn.size() > 0) {
            ArrayList<b> arrayList = new ArrayList();
            arrayList.addAll(cFR.sFn.values());
            StringBuffer stringBuffer2 = new StringBuffer(BuildConfig.FLAVOR);
            for (b bVar : arrayList) {
                stringBuffer2.append(bVar.sAY ? 1 : 0);
                stringBuffer2.append("_");
                stringBuffer2.append(bVar.sAX.xgS);
                stringBuffer2.append(";");
            }
            stringBuffer = stringBuffer2.toString();
        } else {
            stringBuffer = null;
        }
        if (!bo.isNullOrNil(stringBuffer)) {
            tnVar2 = new tn();
            tnVar2.key = "client_exposed_info";
            tnVar2.waE = stringBuffer;
            a.tZG.add(tnVar2);
        }
        tnVar = new tn();
        tnVar.key = "is_prefetch";
        tnVar.waD = (long) this.sEZ;
        a.tZG.add(tnVar);
        this.sFa = new j(a);
        com.tencent.mm.kernel.g.Rg().a(this.sFa, 0);
        com.tencent.mm.kernel.g.Rg().a(1943, this.fur);
        a.kT(0);
        AppMethodBeat.o(1768);
        return true;
    }

    /* JADX WARNING: Missing block: B:19:0x0041, code skipped:
            r0 = new com.tencent.mm.plugin.topstory.a.c.e(r6, r2);
            com.tencent.mm.kernel.g.Rg().a(r0, 0);
            com.tencent.mm.kernel.g.Rg().a(r0.getType(), new com.tencent.mm.plugin.topstory.ui.video.n.2(r5, r0));
            com.tencent.matrix.trace.core.AppMethodBeat.o(1769);
     */
    /* JADX WARNING: Missing block: B:30:?, code skipped:
            return;
     */
    public final void a(com.tencent.mm.protocal.protobuf.chv r6, int r7) {
        /*
        r5 = this;
        r4 = 1769; // 0x6e9 float:2.479E-42 double:8.74E-321;
        com.tencent.matrix.trace.core.AppMethodBeat.i(r4);
        r2 = new java.util.ArrayList;
        r2.<init>();
        monitor-enter(r5);
        r3 = r5.cGQ();	 Catch:{ all -> 0x0062 }
        r0 = com.tencent.mm.sdk.platformtools.bo.ek(r3);	 Catch:{ all -> 0x0062 }
        if (r0 != 0) goto L_0x001b;
    L_0x0015:
        r0 = r3.size();	 Catch:{ all -> 0x0062 }
        if (r7 < r0) goto L_0x0020;
    L_0x001b:
        monitor-exit(r5);	 Catch:{ all -> 0x0062 }
        com.tencent.matrix.trace.core.AppMethodBeat.o(r4);
    L_0x001f:
        return;
    L_0x0020:
        if (r7 <= 0) goto L_0x003e;
    L_0x0022:
        r0 = r7 + -1;
    L_0x0024:
        r1 = r0;
    L_0x0025:
        r0 = r3.size();	 Catch:{ all -> 0x0062 }
        if (r1 >= r0) goto L_0x0040;
    L_0x002b:
        r0 = r7 + 10;
        if (r1 >= r0) goto L_0x0040;
    L_0x002f:
        r0 = r3.get(r1);	 Catch:{ all -> 0x0062 }
        r0 = (com.tencent.mm.protocal.protobuf.chw) r0;	 Catch:{ all -> 0x0062 }
        r0 = r0.xgS;	 Catch:{ all -> 0x0062 }
        r2.add(r0);	 Catch:{ all -> 0x0062 }
        r0 = r1 + 1;
        r1 = r0;
        goto L_0x0025;
    L_0x003e:
        r0 = r7;
        goto L_0x0024;
    L_0x0040:
        monitor-exit(r5);	 Catch:{ all -> 0x0062 }
        r0 = new com.tencent.mm.plugin.topstory.a.c.e;
        r0.<init>(r6, r2);
        r1 = com.tencent.mm.kernel.g.Rg();
        r2 = 0;
        r1.a(r0, r2);
        r1 = com.tencent.mm.kernel.g.Rg();
        r2 = r0.getType();
        r3 = new com.tencent.mm.plugin.topstory.ui.video.n$2;
        r3.<init>(r5, r0);
        r1.a(r2, r3);
        com.tencent.matrix.trace.core.AppMethodBeat.o(r4);
        goto L_0x001f;
    L_0x0062:
        r0 = move-exception;
        monitor-exit(r5);	 Catch:{ all -> 0x0062 }
        com.tencent.matrix.trace.core.AppMethodBeat.o(r4);
        throw r0;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tencent.mm.plugin.topstory.ui.video.n.a(com.tencent.mm.protocal.protobuf.chv, int):void");
    }

    public final void aEX() {
        AppMethodBeat.i(1770);
        com.tencent.mm.kernel.g.Rg().b(1943, this.fur);
        AppMethodBeat.o(1770);
    }

    private static List<chw> a(boolean z, JSONArray jSONArray) {
        AppMethodBeat.i(1771);
        ArrayList arrayList = new ArrayList();
        int i = 0;
        while (true) {
            int i2 = i;
            if (i2 < jSONArray.length()) {
                JSONObject jSONObject = (JSONObject) jSONArray.get(i2);
                long optLong = jSONObject.optLong("resultType");
                long optLong2 = jSONObject.optLong("type");
                String optString = jSONObject.optString("expand");
                JSONArray optJSONArray = jSONObject.optJSONArray("items");
                if (optJSONArray != null && optJSONArray.length() > 0) {
                    long yz = bo.yz();
                    i = 0;
                    while (true) {
                        int i3 = i;
                        if (i3 >= optJSONArray.length()) {
                            break;
                        }
                        JSONObject optJSONObject;
                        jSONObject = (JSONObject) optJSONArray.get(i3);
                        String optString2 = jSONObject.optString("videoApi");
                        String optString3 = jSONObject.optString("videoId");
                        String optString4 = jSONObject.optString("videoPlatform");
                        String optString5 = jSONObject.optString("docID");
                        JSONArray optJSONArray2 = jSONObject.optJSONArray("show_tag_list");
                        JSONArray jSONArray2 = null;
                        if (!jSONObject.optBoolean("not_show_feedback", false)) {
                            optJSONObject = jSONObject.optJSONObject("feedbackObj");
                            if (optJSONObject != null) {
                                jSONArray2 = optJSONObject.optJSONArray("feedbackData");
                            }
                        }
                        int optInt = jSONObject.optInt("mediaDuration", 0);
                        JSONObject optJSONObject2 = jSONObject.optJSONObject("videoInfo");
                        optJSONObject = null;
                        if (optJSONObject2 != null) {
                            optJSONObject = optJSONObject2.optJSONObject("videoCdnInfo");
                        }
                        if (!bo.isNullOrNil(optString3)) {
                            Object obj;
                            int i4;
                            chw chw = new chw();
                            chw.xgS = optString3;
                            int i5 = 0;
                            if (optJSONObject != null) {
                                i5 = optJSONObject.optInt("cdnScene", 0);
                            }
                            if (i5 == 1 || i5 == 2) {
                                if (a(i5, chw, optJSONObject)) {
                                    obj = 1;
                                }
                            } else if (!bo.isNullOrNil(optString2)) {
                                a(chw, optString2, optString4);
                                if (bo.ek(chw.xhb)) {
                                    a.kT(29);
                                    ab.i("MicroMsg.TopStory.TopStoryVideoDataMgr", "setVideoInfoByVideoApi retry");
                                    a(chw, optString2, optString4);
                                }
                                obj = null;
                            }
                            chy dM = g.dM(chw.xhb);
                            if (dM != null) {
                                chw.videoUrl = dM.url;
                                chw.xhg = dM.xhg;
                            }
                            if (bo.isNullOrNil(chw.videoUrl)) {
                                a.kT(11);
                            }
                            chw.xgR = optInt;
                            chw.title = jSONObject.optString("title");
                            chw.lvA = jSONObject.optString("shareTitle");
                            chw.qVw = jSONObject.optString("shareDesc");
                            chw.uaf = jSONObject.optString("shareImgUrl");
                            chw.uag = jSONObject.optString("shareString");
                            chw.uah = jSONObject.optString("shareStringUrl");
                            chw.source = jSONObject.optString(FirebaseAnalytics$b.SOURCE);
                            chw.phw = jSONObject.optString("sourceUrl");
                            chw.lvz = jSONObject.optString("shareUrl");
                            chw.xgT = jSONObject.optLong("relevant_category", -1);
                            chw.xgU = jSONObject.optString("shareOpenId");
                            chw.xgV = jSONObject.optString("expand");
                            chw.uai = jSONObject.optString("strPlayCount");
                            chw.uaj = jSONObject.optString("titleUrl");
                            chw.xgW = jSONObject.optInt("itemType");
                            chw.xgY = jSONObject.optString("bizIcon");
                            chw.xhe = jSONObject.optLong("shareChannelId", chw.xgT);
                            chw.timestamp = yz;
                            chw.cui = false;
                            chw.ubA = optString5;
                            chw.xgZ = optLong;
                            chw.ctk = optLong2;
                            chw.xgX = optString;
                            chw.xhd = jSONObject.optInt("switchFlag", 0);
                            boolean z2 = jSONObject.optJSONObject("colikeInfo") != null && jSONObject.optJSONObject("colikeInfo").optBoolean("isSelfThumb");
                            chw.xhh = z2;
                            chw.xhi = jSONObject.optJSONObject("colikeInfo") != null ? jSONObject.optJSONObject("colikeInfo").optString("byPass", BuildConfig.FLAVOR) : BuildConfig.FLAVOR;
                            chw.voe = jSONObject.optInt("insertPos", 0);
                            if (optJSONArray2 != null) {
                                for (i4 = 0; i4 < optJSONArray2.length(); i4++) {
                                    bzs bzs = new bzs();
                                    bzs.id = optJSONArray2.getJSONObject(i4).optString(SharePluginInfo.ISSUE_KEY_ID);
                                    bzs.cEh = optJSONArray2.getJSONObject(i4).optString("wording");
                                    bzs.wYN = optJSONArray2.getJSONObject(i4).optLong("category");
                                    bzs.actionType = optJSONArray2.getJSONObject(i4).optInt("actionType");
                                    bzs.url = optJSONArray2.getJSONObject(i4).optString(ImagesContract.URL);
                                    bzs.title = optJSONArray2.getJSONObject(i4).optString("title");
                                    bzs.jcF = optJSONArray2.getJSONObject(i4).optString("subTitle");
                                    bzs.cIY = optJSONArray2.getJSONObject(i4).optString("icon");
                                    chw.wiH.add(bzs);
                                }
                            }
                            if (jSONArray2 != null) {
                                for (i4 = 0; i4 < jSONArray2.length(); i4++) {
                                    abz abz = new abz();
                                    abz.id = jSONArray2.optJSONObject(i4).optString(SharePluginInfo.ISSUE_KEY_ID, BuildConfig.FLAVOR);
                                    abz.cEh = jSONArray2.optJSONObject(i4).optString("wording", BuildConfig.FLAVOR);
                                    abz.wjP = jSONArray2.optJSONObject(i4).optBoolean("isUseToConfirm", false);
                                    chw.xhc.add(abz);
                                }
                            }
                            if (z) {
                                chw.fgJ = 360;
                                chw.fgI = 640;
                                if (bo.isNullOrNil(chw.xgQ)) {
                                    chw.xgQ = jSONObject.optString("thumbUrl");
                                }
                            } else {
                                if (bo.isNullOrNil(chw.xgQ)) {
                                    chw.xgQ = "http://shp.qpic.cn/qqvideo_ori/0/" + chw.xgS + String.format("_%s_%s/0", new Object[]{Integer.valueOf(496), Integer.valueOf(280)});
                                }
                                chw.fgJ = 496;
                                chw.fgI = 280;
                            }
                            if (obj != null) {
                                ab.i("MicroMsg.TopStory.TopStoryVideoDataMgr", "useCdnData, cdnScene:%s, vid:%s, title:%s, size:%s", new Object[]{Integer.valueOf(i5), chw.xgS, chw.title, Long.valueOf(chw.xha)});
                            }
                            if (bo.isNullOrNil(chw.videoUrl)) {
                                ab.i("MicroMsg.TopStory.TopStoryVideoDataMgr", "Can not add video %s", new Object[]{chw.xgS});
                            } else {
                                ab.i("MicroMsg.TopStory.TopStoryVideoDataMgr", "videoid: %s, videoUrl: %s, videoSize: %s", new Object[]{chw.xgS, chw.videoUrl, Long.valueOf(chw.xha)});
                                arrayList.add(chw);
                            }
                        }
                        i = i3 + 1;
                    }
                }
                i = i2 + 1;
            } else {
                AppMethodBeat.o(1771);
                return arrayList;
            }
        }
    }

    private static boolean a(int i, chw chw, JSONObject jSONObject) {
        JSONObject optJSONObject;
        AppMethodBeat.i(1772);
        if (i == 1) {
            try {
                optJSONObject = jSONObject.optJSONObject("mpInfo");
            } catch (Exception e) {
                ab.e("MicroMsg.TopStory.TopStoryVideoDataMgr", "setVideoInfoByCdn exception: " + e.getMessage());
                AppMethodBeat.o(1772);
                return false;
            }
        }
        optJSONObject = jSONObject.optJSONObject("ctnInfo");
        if (optJSONObject == null || optJSONObject.optJSONArray("urlInfo") == null) {
            AppMethodBeat.o(1772);
            return false;
        }
        JSONArray optJSONArray = optJSONObject.optJSONArray("urlInfo");
        for (int i2 = 0; i2 < optJSONArray.length(); i2++) {
            JSONObject jSONObject2 = (JSONObject) optJSONArray.get(i2);
            if (jSONObject2.has(ImagesContract.URL) && jSONObject2.has("filesize")) {
                chw.xha = (long) jSONObject2.optInt("filesize", 0);
                chy chy = new chy();
                chy.url = jSONObject2.optString(ImagesContract.URL);
                chy.xhg = 0;
                chw.xhb.add(chy);
            }
        }
        chw.xgQ = optJSONObject.optString("coverUrl");
        if (chw.xha <= 0 || bo.ek(chw.xhb)) {
            AppMethodBeat.o(1772);
            return false;
        }
        AppMethodBeat.o(1772);
        return true;
    }

    /* JADX WARNING: Removed duplicated region for block: B:48:0x00c4  */
    /* JADX WARNING: Removed duplicated region for block: B:17:0x004d A:{Catch:{ Throwable -> 0x0074, all -> 0x0236 }} */
    /* JADX WARNING: Removed duplicated region for block: B:111:0x00de A:{SYNTHETIC, EDGE_INSN: B:111:0x00de->B:51:0x00de ?: BREAK  , EDGE_INSN: B:111:0x00de->B:51:0x00de ?: BREAK  } */
    /* JADX WARNING: Removed duplicated region for block: B:21:0x0070 A:{Catch:{ Throwable -> 0x0074, all -> 0x0236 }} */
    /* JADX WARNING: Removed duplicated region for block: B:53:0x00f6 A:{Catch:{ Throwable -> 0x0074, all -> 0x0236 }} */
    /* JADX WARNING: Removed duplicated region for block: B:63:0x0129 A:{Catch:{ Throwable -> 0x0074, all -> 0x0236 }} */
    /* JADX WARNING: Removed duplicated region for block: B:105:0x0252  */
    /* JADX WARNING: Removed duplicated region for block: B:107:0x0259  */
    /* JADX WARNING: Removed duplicated region for block: B:109:0x0260  */
    /* JADX WARNING: Removed duplicated region for block: B:17:0x004d A:{Catch:{ Throwable -> 0x0074, all -> 0x0236 }} */
    /* JADX WARNING: Removed duplicated region for block: B:48:0x00c4  */
    /* JADX WARNING: Removed duplicated region for block: B:21:0x0070 A:{Catch:{ Throwable -> 0x0074, all -> 0x0236 }} */
    /* JADX WARNING: Removed duplicated region for block: B:111:0x00de A:{SYNTHETIC, EDGE_INSN: B:111:0x00de->B:51:0x00de ?: BREAK  , EDGE_INSN: B:111:0x00de->B:51:0x00de ?: BREAK  , EDGE_INSN: B:111:0x00de->B:51:0x00de ?: BREAK  } */
    /* JADX WARNING: Removed duplicated region for block: B:53:0x00f6 A:{Catch:{ Throwable -> 0x0074, all -> 0x0236 }} */
    /* JADX WARNING: Removed duplicated region for block: B:63:0x0129 A:{Catch:{ Throwable -> 0x0074, all -> 0x0236 }} */
    /* JADX WARNING: Removed duplicated region for block: B:105:0x0252  */
    /* JADX WARNING: Removed duplicated region for block: B:107:0x0259  */
    /* JADX WARNING: Removed duplicated region for block: B:109:0x0260  */
    /* JADX WARNING: Removed duplicated region for block: B:48:0x00c4  */
    /* JADX WARNING: Removed duplicated region for block: B:17:0x004d A:{Catch:{ Throwable -> 0x0074, all -> 0x0236 }} */
    /* JADX WARNING: Removed duplicated region for block: B:111:0x00de A:{SYNTHETIC, EDGE_INSN: B:111:0x00de->B:51:0x00de ?: BREAK  , EDGE_INSN: B:111:0x00de->B:51:0x00de ?: BREAK  , EDGE_INSN: B:111:0x00de->B:51:0x00de ?: BREAK  , EDGE_INSN: B:111:0x00de->B:51:0x00de ?: BREAK  } */
    /* JADX WARNING: Removed duplicated region for block: B:21:0x0070 A:{Catch:{ Throwable -> 0x0074, all -> 0x0236 }} */
    /* JADX WARNING: Removed duplicated region for block: B:53:0x00f6 A:{Catch:{ Throwable -> 0x0074, all -> 0x0236 }} */
    /* JADX WARNING: Removed duplicated region for block: B:63:0x0129 A:{Catch:{ Throwable -> 0x0074, all -> 0x0236 }} */
    /* JADX WARNING: Removed duplicated region for block: B:105:0x0252  */
    /* JADX WARNING: Removed duplicated region for block: B:107:0x0259  */
    /* JADX WARNING: Removed duplicated region for block: B:109:0x0260  */
    private static void a(com.tencent.mm.protocal.protobuf.chw r17, java.lang.String r18, java.lang.String r19) {
        /*
        r2 = 1773; // 0x6ed float:2.485E-42 double:8.76E-321;
        com.tencent.matrix.trace.core.AppMethodBeat.i(r2);
        r5 = 0;
        r4 = 0;
        r3 = 0;
        r6 = new java.lang.StringBuilder;
        r2 = "";
        r6.<init>(r2);
        r2 = com.tencent.mm.plugin.topstory.a.g.cFp();	 Catch:{ Throwable -> 0x0074 }
        if (r2 == 0) goto L_0x00a1;
    L_0x0016:
        r2 = 2;
        r8 = r2;
    L_0x0018:
        r9 = Me();	 Catch:{ Throwable -> 0x0074 }
        r2 = com.tencent.mm.sdk.platformtools.ah.getContext();	 Catch:{ Throwable -> 0x0074 }
        r2 = com.tencent.mm.sdk.platformtools.at.getISPCode(r2);	 Catch:{ Throwable -> 0x0074 }
        if (r2 == 0) goto L_0x00c0;
    L_0x0026:
        r7 = r2 / 100;
        r2 = r2 % 100;
        r10 = 460; // 0x1cc float:6.45E-43 double:2.273E-321;
        if (r7 != r10) goto L_0x00c0;
    L_0x002e:
        if (r2 == 0) goto L_0x0036;
    L_0x0030:
        r7 = 2;
        if (r2 == r7) goto L_0x0036;
    L_0x0033:
        r7 = 7;
        if (r2 != r7) goto L_0x00a5;
    L_0x0036:
        r2 = 3;
        r7 = r2;
    L_0x0038:
        r2 = "MicroMsg.TopStory.TopStoryVideoDataMgr";
        r10 = "setVideoInfoByVideoApi, videoapi: %s";
        r11 = 1;
        r11 = new java.lang.Object[r11];	 Catch:{ Throwable -> 0x0074 }
        r12 = 0;
        r11[r12] = r18;	 Catch:{ Throwable -> 0x0074 }
        com.tencent.mm.sdk.platformtools.ab.i(r2, r10, r11);	 Catch:{ Throwable -> 0x0074 }
        r2 = android.webkit.URLUtil.isHttpsUrl(r18);	 Catch:{ Throwable -> 0x0074 }
        if (r2 == 0) goto L_0x00c4;
    L_0x004d:
        r3 = com.tencent.mm.network.b.vb(r18);	 Catch:{ Throwable -> 0x0074 }
        r3.anb();	 Catch:{ Throwable -> 0x0074 }
        r3.amZ();	 Catch:{ Throwable -> 0x0074 }
        r3.ana();	 Catch:{ Throwable -> 0x0074 }
        r2 = r3.gdG;	 Catch:{ Throwable -> 0x0074 }
        r5 = r2.getInputStream();	 Catch:{ Throwable -> 0x0074 }
    L_0x0060:
        r2 = new java.io.InputStreamReader;	 Catch:{ Throwable -> 0x0074 }
        r2.<init>(r5);	 Catch:{ Throwable -> 0x0074 }
        r10 = new java.io.BufferedReader;	 Catch:{ Throwable -> 0x0074 }
        r10.<init>(r2);	 Catch:{ Throwable -> 0x0074 }
    L_0x006a:
        r2 = r10.readLine();	 Catch:{ Throwable -> 0x0074 }
        if (r2 == 0) goto L_0x00de;
    L_0x0070:
        r6.append(r2);	 Catch:{ Throwable -> 0x0074 }
        goto L_0x006a;
    L_0x0074:
        r2 = move-exception;
        r6 = "MicroMsg.TopStory.TopStoryVideoDataMgr";
        r7 = "getVideoUrlByVideoApi error: %s";
        r8 = 1;
        r8 = new java.lang.Object[r8];	 Catch:{ all -> 0x0236 }
        r9 = 0;
        r10 = r2.getMessage();	 Catch:{ all -> 0x0236 }
        r8[r9] = r10;	 Catch:{ all -> 0x0236 }
        com.tencent.mm.sdk.platformtools.ab.printErrStackTrace(r6, r2, r7, r8);	 Catch:{ all -> 0x0236 }
        if (r4 == 0) goto L_0x008f;
    L_0x008a:
        r2 = r4.connection;
        r2.disconnect();
    L_0x008f:
        if (r3 == 0) goto L_0x0096;
    L_0x0091:
        r2 = r3.gdG;
        r2.disconnect();
    L_0x0096:
        if (r5 == 0) goto L_0x026a;
    L_0x0098:
        com.tencent.mm.a.e.p(r5);
        r2 = 1773; // 0x6ed float:2.485E-42 double:8.76E-321;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r2);
    L_0x00a0:
        return;
    L_0x00a1:
        r2 = -1;
        r8 = r2;
        goto L_0x0018;
    L_0x00a5:
        r7 = 1;
        if (r2 == r7) goto L_0x00af;
    L_0x00a8:
        r7 = 6;
        if (r2 == r7) goto L_0x00af;
    L_0x00ab:
        r7 = 9;
        if (r2 != r7) goto L_0x00b2;
    L_0x00af:
        r2 = 2;
        r7 = r2;
        goto L_0x0038;
    L_0x00b2:
        r7 = 3;
        if (r2 == r7) goto L_0x00bc;
    L_0x00b5:
        r7 = 5;
        if (r2 == r7) goto L_0x00bc;
    L_0x00b8:
        r7 = 11;
        if (r2 != r7) goto L_0x00c0;
    L_0x00bc:
        r2 = 1;
        r7 = r2;
        goto L_0x0038;
    L_0x00c0:
        r2 = 0;
        r7 = r2;
        goto L_0x0038;
    L_0x00c4:
        r2 = 0;
        r0 = r18;
        r4 = com.tencent.mm.network.b.a(r0, r2);	 Catch:{ Throwable -> 0x0074 }
        r2 = 1;
        r4.setUseCaches(r2);	 Catch:{ Throwable -> 0x0074 }
        r2 = 3000; // 0xbb8 float:4.204E-42 double:1.482E-320;
        r4.setConnectTimeout(r2);	 Catch:{ Throwable -> 0x0074 }
        r2 = 3000; // 0xbb8 float:4.204E-42 double:1.482E-320;
        r4.setReadTimeout(r2);	 Catch:{ Throwable -> 0x0074 }
        r5 = r4.getInputStream();	 Catch:{ Throwable -> 0x0074 }
        goto L_0x0060;
    L_0x00de:
        r10 = new org.json.JSONObject;	 Catch:{ Throwable -> 0x0074 }
        r2 = r6.toString();	 Catch:{ Throwable -> 0x0074 }
        r6 = 13;
        r2 = r2.substring(r6);	 Catch:{ Throwable -> 0x0074 }
        r10.<init>(r2);	 Catch:{ Throwable -> 0x0074 }
        r2 = "fl";
        r2 = r10.optJSONObject(r2);	 Catch:{ Throwable -> 0x0074 }
        if (r2 == 0) goto L_0x0120;
    L_0x00f6:
        r6 = "fi";
        r6 = r2.optJSONArray(r6);	 Catch:{ Throwable -> 0x0074 }
        if (r6 == 0) goto L_0x0120;
    L_0x00ff:
        r2 = 0;
    L_0x0100:
        r11 = r6.length();	 Catch:{ Throwable -> 0x0074 }
        if (r2 >= r11) goto L_0x0120;
    L_0x0106:
        r11 = r6.getJSONObject(r2);	 Catch:{ Throwable -> 0x0074 }
        r12 = "sl";
        r13 = 0;
        r12 = r11.optInt(r12, r13);	 Catch:{ Throwable -> 0x0074 }
        r13 = 1;
        if (r12 != r13) goto L_0x01ee;
    L_0x0115:
        r2 = "fs";
        r12 = r11.optLong(r2);	 Catch:{ Throwable -> 0x0074 }
        r0 = r17;
        r0.xha = r12;	 Catch:{ Throwable -> 0x0074 }
    L_0x0120:
        r2 = "vl";
        r2 = r10.optJSONObject(r2);	 Catch:{ Throwable -> 0x0074 }
        if (r2 == 0) goto L_0x0250;
    L_0x0129:
        r6 = "vi";
        r2 = r2.optJSONArray(r6);	 Catch:{ Throwable -> 0x0074 }
        if (r2 == 0) goto L_0x0250;
    L_0x0132:
        r6 = r2.length();	 Catch:{ Throwable -> 0x0074 }
        if (r6 <= 0) goto L_0x0250;
    L_0x0138:
        r6 = 0;
        r2 = r2.getJSONObject(r6);	 Catch:{ Throwable -> 0x0074 }
        if (r2 == 0) goto L_0x0250;
    L_0x013f:
        r6 = "fn";
        r10 = r2.optString(r6);	 Catch:{ Throwable -> 0x0074 }
        r6 = "fvkey";
        r11 = r2.optString(r6);	 Catch:{ Throwable -> 0x0074 }
        r6 = "ul";
        r2 = r2.optJSONObject(r6);	 Catch:{ Throwable -> 0x0074 }
        if (r2 == 0) goto L_0x0250;
    L_0x0156:
        r6 = "ui";
        r12 = r2.optJSONArray(r6);	 Catch:{ Throwable -> 0x0074 }
        if (r12 == 0) goto L_0x0250;
    L_0x015f:
        r2 = r12.length();	 Catch:{ Throwable -> 0x0074 }
        if (r2 <= 0) goto L_0x0250;
    L_0x0165:
        r2 = 0;
        r6 = r2;
    L_0x0167:
        r2 = r12.length();	 Catch:{ Throwable -> 0x0074 }
        if (r6 >= r2) goto L_0x0250;
    L_0x016d:
        r2 = r12.getJSONObject(r6);	 Catch:{ Throwable -> 0x0074 }
        if (r2 == 0) goto L_0x01e9;
    L_0x0173:
        r13 = "url";
        r13 = r2.optString(r13);	 Catch:{ Throwable -> 0x0074 }
        r14 = "vt";
        r15 = 0;
        r14 = r2.optInt(r14, r15);	 Catch:{ Throwable -> 0x0074 }
        r2 = com.tencent.mm.sdk.platformtools.bo.isNullOrNil(r13);	 Catch:{ Throwable -> 0x0074 }
        if (r2 != 0) goto L_0x01e9;
    L_0x0188:
        r2 = com.tencent.mm.sdk.platformtools.bo.isNullOrNil(r11);	 Catch:{ Throwable -> 0x0074 }
        if (r2 != 0) goto L_0x01e9;
    L_0x018e:
        r2 = com.tencent.mm.sdk.platformtools.bo.isNullOrNil(r10);	 Catch:{ Throwable -> 0x0074 }
        if (r2 != 0) goto L_0x01e9;
    L_0x0194:
        r2 = new java.lang.StringBuilder;	 Catch:{ Throwable -> 0x0074 }
        r2.<init>();	 Catch:{ Throwable -> 0x0074 }
        r2 = r2.append(r13);	 Catch:{ Throwable -> 0x0074 }
        r2 = r2.append(r10);	 Catch:{ Throwable -> 0x0074 }
        r13 = "?vkey=";
        r2 = r2.append(r13);	 Catch:{ Throwable -> 0x0074 }
        r2 = r2.append(r11);	 Catch:{ Throwable -> 0x0074 }
        r2 = r2.toString();	 Catch:{ Throwable -> 0x0074 }
        r13 = com.tencent.mm.sdk.platformtools.bo.isNullOrNil(r19);	 Catch:{ Throwable -> 0x0074 }
        if (r13 != 0) goto L_0x01d0;
    L_0x01b6:
        r13 = new java.lang.StringBuilder;	 Catch:{ Throwable -> 0x0074 }
        r13.<init>();	 Catch:{ Throwable -> 0x0074 }
        r2 = r13.append(r2);	 Catch:{ Throwable -> 0x0074 }
        r13 = "&platform=";
        r2 = r2.append(r13);	 Catch:{ Throwable -> 0x0074 }
        r0 = r19;
        r2 = r2.append(r0);	 Catch:{ Throwable -> 0x0074 }
        r2 = r2.toString();	 Catch:{ Throwable -> 0x0074 }
    L_0x01d0:
        r13 = "&";
        r15 = com.tencent.mm.sdk.platformtools.bo.isNullOrNil(r2);	 Catch:{ Throwable -> 0x0074 }
        if (r15 == 0) goto L_0x01f2;
    L_0x01d9:
        r13 = new com.tencent.mm.protocal.protobuf.chy;	 Catch:{ Throwable -> 0x0074 }
        r13.<init>();	 Catch:{ Throwable -> 0x0074 }
        r13.url = r2;	 Catch:{ Throwable -> 0x0074 }
        r13.xhg = r14;	 Catch:{ Throwable -> 0x0074 }
        r0 = r17;
        r2 = r0.xhb;	 Catch:{ Throwable -> 0x0074 }
        r2.add(r13);	 Catch:{ Throwable -> 0x0074 }
    L_0x01e9:
        r2 = r6 + 1;
        r6 = r2;
        goto L_0x0167;
    L_0x01ee:
        r2 = r2 + 1;
        goto L_0x0100;
    L_0x01f2:
        r15 = new java.lang.StringBuilder;	 Catch:{ Throwable -> 0x0074 }
        r15.<init>();	 Catch:{ Throwable -> 0x0074 }
        r2 = r15.append(r2);	 Catch:{ Throwable -> 0x0074 }
        r2 = r2.append(r13);	 Catch:{ Throwable -> 0x0074 }
        r13 = "Unicomtype=";
        r2 = r2.append(r13);	 Catch:{ Throwable -> 0x0074 }
        r2 = r2.append(r8);	 Catch:{ Throwable -> 0x0074 }
        r13 = "&newnettype=";
        r2 = r2.append(r13);	 Catch:{ Throwable -> 0x0074 }
        r2 = r2.append(r9);	 Catch:{ Throwable -> 0x0074 }
        r13 = "&Netoperator=";
        r2 = r2.append(r13);	 Catch:{ Throwable -> 0x0074 }
        r2 = r2.append(r7);	 Catch:{ Throwable -> 0x0074 }
        r2 = r2.toString();	 Catch:{ Throwable -> 0x0074 }
        r13 = "MicroMsg.TopStory.TopStoryVideoDataMgr";
        r15 = "joinUrlWithNetInfo: ";
        r16 = java.lang.String.valueOf(r2);	 Catch:{ Throwable -> 0x0074 }
        r15 = r15.concat(r16);	 Catch:{ Throwable -> 0x0074 }
        com.tencent.mm.sdk.platformtools.ab.d(r13, r15);	 Catch:{ Throwable -> 0x0074 }
        goto L_0x01d9;
    L_0x0236:
        r2 = move-exception;
        if (r4 == 0) goto L_0x023e;
    L_0x0239:
        r4 = r4.connection;
        r4.disconnect();
    L_0x023e:
        if (r3 == 0) goto L_0x0245;
    L_0x0240:
        r3 = r3.gdG;
        r3.disconnect();
    L_0x0245:
        if (r5 == 0) goto L_0x024a;
    L_0x0247:
        com.tencent.mm.a.e.p(r5);
    L_0x024a:
        r3 = 1773; // 0x6ed float:2.485E-42 double:8.76E-321;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r3);
        throw r2;
    L_0x0250:
        if (r4 == 0) goto L_0x0257;
    L_0x0252:
        r2 = r4.connection;
        r2.disconnect();
    L_0x0257:
        if (r3 == 0) goto L_0x025e;
    L_0x0259:
        r2 = r3.gdG;
        r2.disconnect();
    L_0x025e:
        if (r5 == 0) goto L_0x026a;
    L_0x0260:
        com.tencent.mm.a.e.p(r5);
        r2 = 1773; // 0x6ed float:2.485E-42 double:8.76E-321;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r2);
        goto L_0x00a0;
    L_0x026a:
        r2 = 1773; // 0x6ed float:2.485E-42 double:8.76E-321;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r2);
        goto L_0x00a0;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tencent.mm.plugin.topstory.ui.video.n.a(com.tencent.mm.protocal.protobuf.chw, java.lang.String, java.lang.String):void");
    }

    public static int Me() {
        AppMethodBeat.i(1774);
        switch (at.getNetType(ah.getContext())) {
            case -1:
                AppMethodBeat.o(1774);
                return 0;
            case 0:
                AppMethodBeat.o(1774);
                return 1;
            default:
                if (at.is2G(ah.getContext())) {
                    AppMethodBeat.o(1774);
                    return 2;
                } else if (at.is3G(ah.getContext())) {
                    AppMethodBeat.o(1774);
                    return 3;
                } else if (at.is4G(ah.getContext())) {
                    AppMethodBeat.o(1774);
                    return 4;
                } else {
                    AppMethodBeat.o(1774);
                    return 0;
                }
        }
    }
}
