package com.strmr.ps.ui.player;

import android.util.Log;
import com.strmr.ps.data.model.tmdb.TMDBEpisode;
import com.strmr.ps.ui.player.VideoPlayerActivity;
import defpackage.ak1;
import defpackage.ck1;
import defpackage.e6a;
import defpackage.gr3;
import defpackage.hx9;
import defpackage.s38;
import defpackage.vx8;
import kotlin.Metadata;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;

/* JADX INFO: loaded from: classes3.dex */
@Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0002\u001a\u00020\u0001*\u00020\u0000H\n¢\u0006\u0004\b\u0002\u0010\u0003"}, d2 = {"Lak1;", "Le6a;", "<anonymous>", "(Lak1;)V"}, k = 3, mv = {2, 0, 0})
@DebugMetadata(c = "com.strmr.ps.ui.player.VideoPlayerActivity$fetchAndShowNextEpisode$1", f = "VideoPlayerActivity.kt", i = {}, l = {3883}, m = "invokeSuspend", n = {}, s = {})
@vx8
final class p extends SuspendLambda implements gr3<ak1, Continuation<? super e6a>, Object> {
    public int a;
    public final /* synthetic */ VideoPlayerActivity b;
    public final /* synthetic */ int c;
    public final /* synthetic */ int d;
    public final /* synthetic */ int e;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public p(VideoPlayerActivity videoPlayerActivity, int i, int i2, int i3, Continuation continuation) {
        super(2, continuation);
        this.b = videoPlayerActivity;
        this.c = i;
        this.d = i2;
        this.e = i3;
    }

    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    public final Continuation create(Object obj, Continuation continuation) {
        return new p(this.b, this.c, this.d, this.e, continuation);
    }

    @Override // defpackage.gr3
    public final Object invoke(Object obj, Object obj2) {
        return ((p) create((ak1) obj, (Continuation) obj2)).invokeSuspend(e6a.a);
    }

    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    public final Object invokeSuspend(Object obj) {
        String airDate;
        ck1 ck1Var = ck1.a;
        int i = this.a;
        e6a e6aVar = e6a.a;
        VideoPlayerActivity videoPlayerActivity = this.b;
        try {
            if (i == 0) {
                s38.b(obj);
                int i2 = this.c;
                int i3 = this.d;
                int i4 = this.e;
                this.a = 1;
                obj = VideoPlayerActivity.k(videoPlayerActivity, i2, i3, i4, this);
                if (obj == ck1Var) {
                    return ck1Var;
                }
            } else {
                if (i != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                s38.b(obj);
            }
            hx9 hx9Var = (hx9) obj;
            if (hx9Var != null) {
                int iIntValue = ((Number) hx9Var.a).intValue();
                int iIntValue2 = ((Number) hx9Var.b).intValue();
                TMDBEpisode tMDBEpisode = (TMDBEpisode) hx9Var.c;
                Long lP = (tMDBEpisode == null || (airDate = tMDBEpisode.getAirDate()) == null) ? null : VideoPlayerActivity.p(videoPlayerActivity, airDate);
                if (lP == null || lP.longValue() <= System.currentTimeMillis()) {
                    videoPlayerActivity.o0 = new VideoPlayerActivity.d(this.c, iIntValue, iIntValue2, tMDBEpisode != null ? tMDBEpisode.getName() : null, tMDBEpisode != null ? tMDBEpisode.getStillUrl() : null, lP);
                    videoPlayerActivity.bn();
                }
            }
            return e6aVar;
        } catch (Exception e) {
            Log.w("VideoPlayerActivity", "Failed to fetch next episode", e);
            return e6aVar;
        }
    }
}
