小爽音 v1.3版本的 MD5 值为:448355de843c720d712f30c7cdfbd99b

以下内容为反编译后的 i.java 源代码,内容仅作参考


package h.n.a.a.m;

import com.alibaba.fastjson.JSON;
import com.jbzd.media.xsy.bean.event.EventDownload;
import com.jbzd.media.xsy.bean.response.DownloadVideoInfo;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.util.List;
import java.util.Objects;
import kotlin.Metadata;
import kotlin.ResultKt;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsKt;
import kotlin.coroutines.jvm.internal.Boxing;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;
import kotlin.io.TextStreamsKt;
import kotlin.jvm.functions.Function2;
import kotlin.jvm.internal.Intrinsics;
import kotlin.text.StringsKt__StringsJVMKt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@Metadata(d1 = {"\u0000\n\n\u0000\n\u0002\u0010\u0002\n\u0002\u0018\u0002\u0010\u0000\u001a\u00020\u0001*\u00020\u0002H\u008a@"}, d2 = {"<anonymous>", "", "Lkotlinx/coroutines/CoroutineScope;"}, k = 3, mv = {1, 5, 1}, xi = 48)
@DebugMetadata(c = "com.jbzd.media.xsy.utils.DownloadRunnable$downLoadWork$1", f = "VideoDownloadController.kt", i = {}, l = {}, m = "invokeSuspend", n = {}, s = {})
public final class i extends SuspendLambda implements Function2<d.a.c0, Continuation<? super Unit>, Object> {
    public final DownloadVideoInfo c;
    public final j f6061d;

    public i(DownloadVideoInfo downloadVideoInfo, j jVar, Continuation<? super i> continuation) {
        super(2, continuation);
        this.c = downloadVideoInfo;
        this.f6061d = jVar;
    }

    @Override
    @NotNull
    public final Continuation<Unit> create(@Nullable Object obj, @NotNull Continuation<?> continuation) {
        return new i(this.c, this.f6061d, continuation);
    }

    @Override
    public Object invoke(d.a.c0 c0Var, Continuation<? super Unit> continuation) {
        return new i(this.c, this.f6061d, continuation).invokeSuspend(Unit.INSTANCE);
    }

    @Override
    @Nullable
    public final Object invokeSuspend(@NotNull Object obj) {
        File file;
        String str;
        File file2;
        boolean z;
        String str2;
        File file3;
        InputStream inputStream;
        FileOutputStream fileOutputStream;
        URLConnection openConnection;
        InputStream inputStream2;
        FileOutputStream fileOutputStream2;
        String str3 = "doing";
        String str4 = "completed";
        IntrinsicsKt__IntrinsicsKt.getCOROUTINE_SUSPENDED();
        ResultKt.throwOnFailure(obj);
        DownloadVideoInfo downloadVideoInfo = this.c;
        try {
            try {
                StringBuilder sb = new StringBuilder();
                sb.append((Object) h.u.a.a.a);
                sb.append((Object) File.separator);
                sb.append((Object) downloadVideoInfo.getTask_id());
                file = new File(sb.toString());
                if (!file.exists()) {
                    file.mkdirs();
                }
                file2 = new File(((Object) file.getPath()) + ((Object) str) + "info.json");
                if (file2.exists()) {
                    Objects.requireNonNull(this.f6061d);
                    BufferedReader bufferedReader = new BufferedReader(new FileReader(file2));
                    String readText = TextStreamsKt.readText(bufferedReader);
                    bufferedReader.close();
                    Object parseObject = JSON.parseObject(readText, DownloadVideoInfo.class);
                    Intrinsics.checkNotNullExpressionValue(parseObject, "parseObject(readFileToString(infoFile), DownloadVideoInfo::class.java)");
                    downloadVideoInfo = (DownloadVideoInfo) parseObject;
                }
            } catch (Exception e2) {
                e2.printStackTrace();
            }
            if (Intrinsics.areEqual(downloadVideoInfo.getStatus(), "completed")) {
                return Unit.INSTANCE;
            }
            int successCount = downloadVideoInfo.getSuccessIndex() > 0 ? downloadVideoInfo.getSuccessCount() + 1 : 0;
            List<String> files = downloadVideoInfo.getFiles();
            if (files != null && !files.isEmpty()) {
                z = false;
                if (!z) {
                    downloadVideoInfo.setStatus("doing");
                    j jVar = this.f6061d;
                    String jSONString = JSON.toJSONString(downloadVideoInfo);
                    Intrinsics.checkNotNullExpressionValue(jSONString, "toJSONString(currentDownloadVideoInfo)");
                    j.b(jVar, jSONString, file2);
                    p.b.a.c.b().g(new EventDownload(downloadVideoInfo));
                    File file4 = new File(((Object) file.getPath()) + ((Object) str) + "index.m3u8");
                    if (!file4.exists()) {
                        j jVar2 = this.f6061d;
                        String content = downloadVideoInfo.getContent();
                        Intrinsics.checkNotNullExpressionValue(content, "currentDownloadVideoInfo.content");
                        j.b(jVar2, content, file4);
                    }
                    int size = downloadVideoInfo.getFiles().size();
                    if (successCount < size) {
                        while (true) {
                            int i2 = successCount + 1;
                            if (Intrinsics.areEqual(downloadVideoInfo.getStatus(), "error")) {
                                break;
                            }
                            String fileUrl = downloadVideoInfo.getFiles().get(successCount);
                            StringBuilder sb2 = new StringBuilder();
                            sb2.append(file.getPath());
                            sb2.append((Object) File.separator);
                            j jVar3 = this.f6061d;
                            String str5 = str3;
                            Intrinsics.checkNotNullExpressionValue(fileUrl, "fileUrl");
                            sb2.append(j.a(jVar3, fileUrl));
                            File file5 = new File(sb2.toString());
                            if (file5.exists()) {
                                file5.delete();
                            }
                            file5.createNewFile();
                            try {
                                openConnection = new URL(fileUrl).openConnection();
                            } catch (Exception e3) {
                                e = e3;
                                str2 = str4;
                                file3 = file;
                            }
                            if (openConnection != null) {
                                HttpURLConnection httpURLConnection = (HttpURLConnection) openConnection;
                                httpURLConnection.setRequestProperty("referer", (String) this.f6061d.f6069e.getValue());
                                httpURLConnection.setConnectTimeout(10000);
                                httpURLConnection.setReadTimeout(10000);
                                if (httpURLConnection.getResponseCode() == 200) {
                                    try {
                                        inputStream = httpURLConnection.getInputStream();
                                        try {
                                            fileOutputStream = new FileOutputStream(file5);
                                            try {
                                                byte[] bArr = new byte[8388608];
                                                while (true) {
                                                    Integer boxInt = Boxing.boxInt(inputStream.read(bArr));
                                                    str2 = str4;
                                                    try {
                                                        int intValue = boxInt.intValue();
                                                        file3 = file;
                                                        if (boxInt.intValue() == -1) {
                                                            break;
                                                        }
                                                        try {
                                                            fileOutputStream.write(bArr, 0, intValue);
                                                            str4 = str2;
                                                            file = file3;
                                                        } catch (Exception e4) {
                                                            e = e4;
                                                            Intrinsics.stringPlus("downLoadWork: ", e);
                                                            if (inputStream != null) {
                                                            }
                                                            if (fileOutputStream != null) {
                                                            }
                                                            downloadVideoInfo.setStatus("error");
                                                            j jVar4 = this.f6061d;
                                                            String jSONString2 = JSON.toJSONString(downloadVideoInfo);
                                                            Intrinsics.checkNotNullExpressionValue(jSONString2, "toJSONString(currentDownloadVideoInfo)");
                                                            j.b(jVar4, jSONString2, file2);
                                                            p.b.a.c.b().g(new EventDownload(downloadVideoInfo));
                                                            if (i2 < size) {
                                                            }
                                                        }
                                                    } catch (Exception e5) {
                                                        e = e5;
                                                        file3 = file;
                                                        Intrinsics.stringPlus("downLoadWork: ", e);
                                                        if (inputStream != null) {
                                                        }
                                                        if (fileOutputStream != null) {
                                                        }
                                                        downloadVideoInfo.setStatus("error");
                                                        j jVar42 = this.f6061d;
                                                        String jSONString22 = JSON.toJSONString(downloadVideoInfo);
                                                        Intrinsics.checkNotNullExpressionValue(jSONString22, "toJSONString(currentDownloadVideoInfo)");
                                                        j.b(jVar42, jSONString22, file2);
                                                        p.b.a.c.b().g(new EventDownload(downloadVideoInfo));
                                                        if (i2 < size) {
                                                        }
                                                    }
                                                }
                                                inputStream.close();
                                                fileOutputStream.close();
                                                inputStream2 = inputStream;
                                                fileOutputStream2 = fileOutputStream;
                                            } catch (Exception e6) {
                                                e = e6;
                                                str2 = str4;
                                            }
                                        } catch (Exception e7) {
                                            e = e7;
                                            str2 = str4;
                                            file3 = file;
                                            fileOutputStream = null;
                                            Intrinsics.stringPlus("downLoadWork: ", e);
                                            if (inputStream != null) {
                                                inputStream.close();
                                            }
                                            if (fileOutputStream != null) {
                                                fileOutputStream.close();
                                            }
                                            downloadVideoInfo.setStatus("error");
                                            j jVar422 = this.f6061d;
                                            String jSONString222 = JSON.toJSONString(downloadVideoInfo);
                                            Intrinsics.checkNotNullExpressionValue(jSONString222, "toJSONString(currentDownloadVideoInfo)");
                                            j.b(jVar422, jSONString222, file2);
                                            p.b.a.c.b().g(new EventDownload(downloadVideoInfo));
                                            if (i2 < size) {
                                            }
                                        }
                                    } catch (Exception e8) {
                                        e = e8;
                                        str2 = str4;
                                        file3 = file;
                                        inputStream = null;
                                    }
                                } else {
                                    str2 = str4;
                                    file3 = file;
                                    fileOutputStream2 = null;
                                    inputStream2 = null;
                                }
                                try {
                                    Objects.requireNonNull(this.f6061d);
                                    BufferedReader bufferedReader2 = new BufferedReader(new FileReader(file4));
                                    String readText2 = TextStreamsKt.readText(bufferedReader2);
                                    bufferedReader2.close();
                                    j.b(this.f6061d, StringsKt__StringsJVMKt.replace$default(readText2, fileUrl, "http://127.0.0.1:" + i0.f6062e.a() + ((Object) File.separator) + "videos?taskId=" + ((Object) downloadVideoInfo.getTask_id()) + "&fileName=" + j.a(this.f6061d, fileUrl), false, 4, (Object) null), file4);
                                    downloadVideoInfo.setSuccessCount(downloadVideoInfo.getSuccessCount() + 1);
                                    downloadVideoInfo.setSuccessIndex(successCount);
                                } catch (Exception e9) {
                                    e = e9;
                                }
                                try {
                                    downloadVideoInfo.setStatus(successCount == downloadVideoInfo.getFiles().size() - 1 ? str2 : str5);
                                    j jVar5 = this.f6061d;
                                    String jSONString3 = JSON.toJSONString(downloadVideoInfo);
                                    Intrinsics.checkNotNullExpressionValue(jSONString3, "toJSONString(currentDownloadVideoInfo)");
                                    j.b(jVar5, jSONString3, file2);
                                    p.b.a.c.b().g(new EventDownload(downloadVideoInfo));
                                } catch (Exception e10) {
                                    e = e10;
                                    InputStream inputStream3 = inputStream2;
                                    fileOutputStream = fileOutputStream2;
                                    inputStream = inputStream3;
                                    Intrinsics.stringPlus("downLoadWork: ", e);
                                    if (inputStream != null) {
                                    }
                                    if (fileOutputStream != null) {
                                    }
                                    downloadVideoInfo.setStatus("error");
                                    j jVar4222 = this.f6061d;
                                    String jSONString2222 = JSON.toJSONString(downloadVideoInfo);
                                    Intrinsics.checkNotNullExpressionValue(jSONString2222, "toJSONString(currentDownloadVideoInfo)");
                                    j.b(jVar4222, jSONString2222, file2);
                                    p.b.a.c.b().g(new EventDownload(downloadVideoInfo));
                                    if (i2 < size) {
                                    }
                                }
                                if (i2 < size) {
                                    break;
                                }
                                successCount = i2;
                                str3 = str5;
                                str4 = str2;
                                file = file3;
                            } else {
                                str2 = str4;
                                file3 = file;
                                try {
                                    throw new NullPointerException("null cannot be cast to non-null type java.net.HttpURLConnection");
                                    break;
                                } catch (Exception e11) {
                                    e = e11;
                                    inputStream = null;
                                    fileOutputStream = null;
                                    Intrinsics.stringPlus("downLoadWork: ", e);
                                    if (inputStream != null) {
                                    }
                                    if (fileOutputStream != null) {
                                    }
                                    downloadVideoInfo.setStatus("error");
                                    j jVar42222 = this.f6061d;
                                    String jSONString22222 = JSON.toJSONString(downloadVideoInfo);
                                    Intrinsics.checkNotNullExpressionValue(jSONString22222, "toJSONString(currentDownloadVideoInfo)");
                                    j.b(jVar42222, jSONString22222, file2);
                                    p.b.a.c.b().g(new EventDownload(downloadVideoInfo));
                                    if (i2 < size) {
                                    }
                                }
                            }
                        }
                    }
                }
                j jVar6 = this.f6061d;
                String str6 = jVar6.f6070f;
                jVar6.f6068d.invoke(downloadVideoInfo);
                return Unit.INSTANCE;
            }
            z = true;
            if (!z) {
            }
            j jVar62 = this.f6061d;
            String str62 = jVar62.f6070f;
            jVar62.f6068d.invoke(downloadVideoInfo);
            return Unit.INSTANCE;
        } finally {
            j jVar7 = this.f6061d;
            String str7 = jVar7.f6070f;
            jVar7.f6068d.invoke(downloadVideoInfo);
        }
    }
}