package com.strmr.ps.data.repository;

import android.util.Log;
import com.strmr.ps.data.model.tmdb.TMDBShowListResponse;
import com.strmr.ps.data.remote.api.TMDBApiService;
import defpackage.ak1;
import defpackage.ck1;
import defpackage.e6a;
import defpackage.gr3;
import defpackage.s38;
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\u0004\u0018\u00010\u0001*\u00020\u0000H\n¢\u0006\u0004\b\u0002\u0010\u0003"}, d2 = {"Lak1;", "Lcom/strmr/ps/data/model/tmdb/TMDBShowListResponse;", "<anonymous>", "(Lak1;)Lcom/strmr/ps/data/model/tmdb/TMDBShowListResponse;"}, k = 3, mv = {2, 0, 0})
@DebugMetadata(c = "com.strmr.ps.data.repository.ContentRepository$fetchShowsByGenreFromApis$2$discoverPages$1$1", f = "ContentRepository.kt", i = {}, l = {590}, m = "invokeSuspend", n = {}, s = {})
public final class ContentRepository$fetchShowsByGenreFromApis$2$discoverPages$1$1 extends SuspendLambda implements gr3<ak1, Continuation<? super TMDBShowListResponse>, Object> {
    final /* synthetic */ int $firstTmdbPage;
    final /* synthetic */ int $offset;
    final /* synthetic */ String $sortToken;
    final /* synthetic */ Integer $tmdbGenreId;
    int label;
    final /* synthetic */ ContentRepository this$0;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public ContentRepository$fetchShowsByGenreFromApis$2$discoverPages$1$1(ContentRepository contentRepository, Integer num, int i, int i2, String str, Continuation<? super ContentRepository$fetchShowsByGenreFromApis$2$discoverPages$1$1> continuation) {
        super(2, continuation);
        this.this$0 = contentRepository;
        this.$tmdbGenreId = num;
        this.$firstTmdbPage = i;
        this.$offset = i2;
        this.$sortToken = str;
    }

    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    public final Continuation<e6a> create(Object obj, Continuation<?> continuation) {
        return new ContentRepository$fetchShowsByGenreFromApis$2$discoverPages$1$1(this.this$0, this.$tmdbGenreId, this.$firstTmdbPage, this.$offset, this.$sortToken, continuation);
    }

    @Override // defpackage.gr3
    public final Object invoke(ak1 ak1Var, Continuation<? super TMDBShowListResponse> continuation) {
        return ((ContentRepository$fetchShowsByGenreFromApis$2$discoverPages$1$1) create(ak1Var, continuation)).invokeSuspend(e6a.a);
    }

    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    public final Object invokeSuspend(Object obj) {
        ContentRepository$fetchShowsByGenreFromApis$2$discoverPages$1$1 contentRepository$fetchShowsByGenreFromApis$2$discoverPages$1$1;
        TMDBApiService tMDBApiService;
        String string;
        int i;
        String str;
        Exception exc;
        ck1 ck1Var = ck1.a;
        int i2 = this.label;
        if (i2 == 0) {
            s38.b(obj);
            try {
                tMDBApiService = this.this$0.tmdbApiService;
                string = this.$tmdbGenreId.toString();
                i = this.$firstTmdbPage + this.$offset;
                str = this.$sortToken;
                this.label = 1;
                contentRepository$fetchShowsByGenreFromApis$2$discoverPages$1$1 = this;
            } catch (Exception e) {
                e = e;
                contentRepository$fetchShowsByGenreFromApis$2$discoverPages$1$1 = this;
                exc = e;
                Log.e("ContentRepository", "Discover shows failed (page " + (contentRepository$fetchShowsByGenreFromApis$2$discoverPages$1$1.$firstTmdbPage + contentRepository$fetchShowsByGenreFromApis$2$discoverPages$1$1.$offset) + ", sort=" + contentRepository$fetchShowsByGenreFromApis$2$discoverPages$1$1.$sortToken + ")", exc);
                return null;
            }
            try {
                obj = TMDBApiService.DefaultImpls.discoverTvShows$default(tMDBApiService, string, str, i, 50, false, contentRepository$fetchShowsByGenreFromApis$2$discoverPages$1$1, 16, null);
                if (obj == ck1Var) {
                    return ck1Var;
                }
            } catch (Exception e2) {
                e = e2;
                exc = e;
                Log.e("ContentRepository", "Discover shows failed (page " + (contentRepository$fetchShowsByGenreFromApis$2$discoverPages$1$1.$firstTmdbPage + contentRepository$fetchShowsByGenreFromApis$2$discoverPages$1$1.$offset) + ", sort=" + contentRepository$fetchShowsByGenreFromApis$2$discoverPages$1$1.$sortToken + ")", exc);
                return null;
            }
        } else {
            if (i2 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            try {
                s38.b(obj);
                contentRepository$fetchShowsByGenreFromApis$2$discoverPages$1$1 = this;
            } catch (Exception e3) {
                exc = e3;
                contentRepository$fetchShowsByGenreFromApis$2$discoverPages$1$1 = this;
                Log.e("ContentRepository", "Discover shows failed (page " + (contentRepository$fetchShowsByGenreFromApis$2$discoverPages$1$1.$firstTmdbPage + contentRepository$fetchShowsByGenreFromApis$2$discoverPages$1$1.$offset) + ", sort=" + contentRepository$fetchShowsByGenreFromApis$2$discoverPages$1$1.$sortToken + ")", exc);
                return null;
            }
        }
        return (TMDBShowListResponse) obj;
    }
}
