CAG v5.7.4版本的 MD5 值为:bc57ead76a7a30559f0708e9d60d749f
以下内容为反编译后的 YouTubeApi.java 源代码,内容仅作参考
package org.godfootsteps.arch.youtubeApi;
import com.blankj.utilcode.util.NetworkUtils;
import com.google.android.gms.actions.SearchIntents;
import d.c.a.j.s;
import d.c.a.j.v;
import d.c.a.j.z;
import d.c.a.m.b;
import d.c.a.m.c;
import i.c.a.c.m;
import i.j.a.e.t.d;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.regex.Pattern;
import kotlin.Metadata;
import kotlin.coroutines.intrinsics.CoroutineSingletons;
import kotlin.coroutines.jvm.internal.SuspendLambda;
import kotlin.jvm.internal.Ref$ObjectRef;
import kotlin.text.Regex;
import n.e;
import n.f.g;
import n.g.c;
import n.i.a.l;
import n.i.a.p;
import n.i.b.h;
import n.m.t.a.p.m.e1.a;
import o.b.e0;
import o.b.w;
import org.godfootsteps.arch.api.util.BaseRequestProvider;
import org.godfootsteps.arch.api.util.RequestNoResult;
import org.godfootsteps.arch.youtubeApi.model.ItemBean;
import org.godfootsteps.arch.youtubeApi.model.YouTubeVideoModel;
import org.godfootsteps.router.model.PlaylistData;
import org.godfootsteps.router.model.Video;
@Metadata(d1 = {"\u0000P\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\f\n\u0002\u0018\u0002\n\u0002\b\u0003\bÆ\u0002\u0018\u00002\u00020\u0001:\u0001%B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J7\u0010\u0003\u001a\u00020\u0004\"\u0004\b\u0000\u0010\u00052\b\b\u0002\u0010\u0006\u001a\u00020\u00072\u001d\u0010\b\u001a\u0019\u0012\n\u0012\b\u0012\u0004\u0012\u0002H\u00050\n\u0012\u0004\u0012\u00020\u000b0\t¢\u0006\u0002\b\fH\u0002J@\u0010\r\u001a\u00020\u000b2\u0006\u0010\u000e\u001a\u00020\u00072\u0006\u0010\u0006\u001a\u00020\u00072\u0012\u0010\u000f\u001a\u000e\u0012\u0004\u0012\u00020\u0010\u0012\u0004\u0012\u00020\u000b0\t2\u0012\u0010\u0011\u001a\u000e\u0012\u0004\u0012\u00020\u0012\u0012\u0004\u0012\u00020\u000b0\tH\u0002J<\u0010\u0013\u001a\u00020\u000b2\u0006\u0010\u0014\u001a\u00020\u00072\u0018\u0010\u000f\u001a\u0014\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u00160\u0015\u0012\u0004\u0012\u00020\u000b0\t2\u0012\u0010\u0011\u001a\u000e\u0012\u0004\u0012\u00020\u0012\u0012\u0004\u0012\u00020\u000b0\tJ@\u0010\u0017\u001a\u00020\u000b2\u0006\u0010\u000e\u001a\u00020\u00072\b\u0010\u0006\u001a\u0004\u0018\u00010\u00072\u0012\u0010\u000f\u001a\u000e\u0012\u0004\u0012\u00020\u0010\u0012\u0004\u0012\u00020\u000b0\t2\u0012\u0010\u0011\u001a\u000e\u0012\u0004\u0012\u00020\u0012\u0012\u0004\u0012\u00020\u000b0\tJ\u0010\u0010\u0018\u001a\u00020\u00072\b\u0010\u0019\u001a\u0004\u0018\u00010\u0007JF\u0010\u001a\u001a\u00020\u00042\u0006\u0010\u001b\u001a\u00020\u00072\u0006\u0010\u001c\u001a\u00020\u00072\u0006\u0010\u001d\u001a\u00020\u00072\u0012\u0010\u000f\u001a\u000e\u0012\u0004\u0012\u00020\u0010\u0012\u0004\u0012\u00020\u000b0\t2\u0012\u0010\u0011\u001a\u000e\u0012\u0004\u0012\u00020\u0012\u0012\u0004\u0012\u00020\u000b0\tJ6\u0010\u001e\u001a\u00020\u000b2\u0006\u0010\u001f\u001a\u00020\u00072\u0012\u0010\u000f\u001a\u000e\u0012\u0004\u0012\u00020\u0016\u0012\u0004\u0012\u00020\u000b0\t2\u0012\u0010\u0011\u001a\u000e\u0012\u0004\u0012\u00020\u0012\u0012\u0004\u0012\u00020\u000b0\tJ\u001a\u0010 \u001a\u00020\u0010*\b\u0012\u0004\u0012\u00020\u00160\u00152\b\u0010\u0006\u001a\u0004\u0018\u00010\u0007J\f\u0010!\u001a\u00020\u0007*\u00020\u0007H\u0002J\u0012\u0010\"\u001a\b\u0012\u0004\u0012\u00020\u00160\u0015*\u00020#H\u0002J\f\u0010$\u001a\u00020\u0007*\u00020\u0007H\u0002¨\u0006&"}, d2 = {"Lorg/godfootsteps/arch/youtubeApi/YouTubeApi;", "", "()V", "listRequest", "Lkotlinx/coroutines/Job;", "T", "token", "", "buildRequest", "Lkotlin/Function1;", "Lorg/godfootsteps/arch/youtubeApi/YouTubeApi$ListRequest;", "", "Lkotlin/ExtensionFunctionType;", "listRequestByNet", "listId", "onSuccess", "Lorg/godfootsteps/router/model/PlaylistData;", "onError", "", "multipleVideoRequest", "videoIds", "", "Lorg/godfootsteps/router/model/Video;", "playlistRequest", "processDescription", "des", "searchVideo", SearchIntents.EXTRA_QUERY, "nextPageToken", "channelId", "singleVideoRequest", "videoId", "convertToPlaylist", "listCacheKey", "parseYTVideoItem", "Lorg/godfootsteps/arch/youtubeApi/model/YouTubeVideoModel;", "videoCacheKey", "ListRequest", "arch_release"}, k = 1, mv = {1, 5, 1}, xi = 48)
public final class YouTubeApi {
public static final YouTubeApi a = new YouTubeApi();
@Metadata(d1 = {"\u0000 \n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0004\n\u0002\u0010\u0002\n\u0002\b\u0003\b\u0002\u0018\u0000*\u0004\b\u0000\u0010\u00012\u000e\u0012\u0004\u0012\u00020\u0003\u0012\u0004\u0012\u0002H\u00010\u0002B\r\u0012\u0006\u0010\u0004\u001a\u00020\u0005¢\u0006\u0002\u0010\u0006J\u0019\u0010\t\u001a\u00020\n2\u0006\u0010\u000b\u001a\u00028\u0000H\u0094@ø\u0001\u0000¢\u0006\u0002\u0010\fR\u0011\u0010\u0004\u001a\u00020\u0005¢\u0006\b\n\u0000\u001a\u0004\b\u0007\u0010\b\u0082\u0002\u0004\n\u0002\b\u0019¨\u0006\r"}, d2 = {"Lorg/godfootsteps/arch/youtubeApi/YouTubeApi$ListRequest;", "T", "Lorg/godfootsteps/arch/api/util/BaseRequestProvider;", "Lorg/godfootsteps/router/model/PlaylistData;", "token", "", "(Ljava/lang/String;)V", "getToken", "()Ljava/lang/String;", "preResult", "", "result", "(Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "arch_release"}, k = 1, mv = {1, 5, 1}, xi = 48)
public static final class ListRequest<T> extends BaseRequestProvider<PlaylistData, T> {
public final String f15317o;
public ListRequest(String str) {
h.e(str, "token");
this.f15317o = str;
}
@Override
public Object g(T t2, c<? super e> cVar) {
YouTubeApi$ListRequest$preResult$1 youTubeApi$ListRequest$preResult$1;
int i2;
ListRequest<T> listRequest;
Ref$ObjectRef ref$ObjectRef;
l<? super T, e> lVar;
if (cVar instanceof YouTubeApi$ListRequest$preResult$1) {
youTubeApi$ListRequest$preResult$1 = (YouTubeApi$ListRequest$preResult$1) cVar;
int i3 = youTubeApi$ListRequest$preResult$1.label;
if ((i3 & Integer.MIN_VALUE) != 0) {
youTubeApi$ListRequest$preResult$1.label = i3 - Integer.MIN_VALUE;
Object obj = youTubeApi$ListRequest$preResult$1.result;
CoroutineSingletons coroutineSingletons = CoroutineSingletons.COROUTINE_SUSPENDED;
i2 = youTubeApi$ListRequest$preResult$1.label;
if (i2 != 0) {
d.Q4(obj);
Ref$ObjectRef ref$ObjectRef2 = new Ref$ObjectRef();
w wVar = e0.b;
YouTubeApi$ListRequest$preResult$videoModel$1 youTubeApi$ListRequest$preResult$videoModel$1 = new YouTubeApi$ListRequest$preResult$videoModel$1(t2, ref$ObjectRef2, this, null);
youTubeApi$ListRequest$preResult$1.L$0 = this;
youTubeApi$ListRequest$preResult$1.L$1 = ref$ObjectRef2;
youTubeApi$ListRequest$preResult$1.label = 1;
Object R2 = a.R2(wVar, youTubeApi$ListRequest$preResult$videoModel$1, youTubeApi$ListRequest$preResult$1);
if (R2 == coroutineSingletons) {
return coroutineSingletons;
}
listRequest = this;
obj = R2;
ref$ObjectRef = ref$ObjectRef2;
} else if (i2 != 1) {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
} else {
ref$ObjectRef = (Ref$ObjectRef) youTubeApi$ListRequest$preResult$1.L$1;
listRequest = (ListRequest) youTubeApi$ListRequest$preResult$1.L$0;
d.Q4(obj);
}
YouTubeVideoModel youTubeVideoModel = (YouTubeVideoModel) obj;
lVar = listRequest.f15180l;
if (lVar != null) {
YouTubeApi youTubeApi = YouTubeApi.a;
lVar.invoke(youTubeApi.a(youTubeApi.d(youTubeVideoModel), (String) ref$ObjectRef.element));
}
return e.a;
}
}
youTubeApi$ListRequest$preResult$1 = new YouTubeApi$ListRequest$preResult$1(this, cVar);
Object obj2 = youTubeApi$ListRequest$preResult$1.result;
CoroutineSingletons coroutineSingletons2 = CoroutineSingletons.COROUTINE_SUSPENDED;
i2 = youTubeApi$ListRequest$preResult$1.label;
if (i2 != 0) {
}
YouTubeVideoModel youTubeVideoModel2 = (YouTubeVideoModel) obj2;
lVar = listRequest.f15180l;
if (lVar != null) {
}
return e.a;
}
}
public final PlaylistData a(List<? extends Video> list, String str) {
h.e(list, "<this>");
PlaylistData playlistData = new PlaylistData();
playlistData.setNumVideo(list.size());
playlistData.getVideos().addAll(list);
playlistData.setToken(str);
return playlistData;
}
public final String b(String str) {
String str2 = v.j() ? "10" : null;
if (str2 == null) {
str2 = "16";
}
StringBuilder sb = new StringBuilder();
sb.append("0:https://www.googleapis.com/youtube/v3/playlistItems?playlistId=");
sb.append(str);
sb.append("&maxResults=");
sb.append(str2);
sb.append("&part=snippet&fields=items(snippet/resourceId/videoId),pageInfo,nextPageToken&key=");
YouTubeKeyHelper youTubeKeyHelper = YouTubeKeyHelper.a;
sb.append(YouTubeKeyHelper.c);
return sb.toString();
}
public final void c(String str, final l<? super List<? extends Video>, e> lVar, final l<? super Integer, e> lVar2) {
h.e(str, "videoIds");
h.e(lVar, "onSuccess");
h.e(lVar2, "onError");
final List<String> b0 = g.b0(n.o.a.A(str, new String[]{","}, false, 0, 6));
final LinkedHashMap linkedHashMap = new LinkedHashMap();
final ArrayList arrayList = new ArrayList();
if (b0.size() > 1) {
String a2 = b.a.a(e(str));
if (!n.o.a.o(a2)) {
YouTubeVideoModel youTubeVideoModel = (YouTubeVideoModel) m.a(a2, YouTubeVideoModel.class);
h.d(youTubeVideoModel, "videoModel");
Iterator it = ((ArrayList) d(youTubeVideoModel)).iterator();
while (it.hasNext()) {
Video video = (Video) it.next();
String id = video.getId();
h.d(id, "it.id");
linkedHashMap.put(id, video);
}
}
}
for (String str2 : b0) {
b bVar = b.a;
YouTubeApi youTubeApi = a;
String a3 = bVar.a(youTubeApi.e(str2));
if (!n.o.a.o(a3) && (!NetworkUtils.c() || !bVar.b(youTubeApi.e(str2)))) {
Object a4 = m.a(a3, YouTubeVideoModel.class);
h.d(a4, "fromJson(cache, YouTubeVideoModel::class.java)");
linkedHashMap.put(str2, ((ArrayList) youTubeApi.d((YouTubeVideoModel) a4)).get(0));
} else if (linkedHashMap.get(str2) == null) {
arrayList.add(str2);
}
}
if (arrayList.isEmpty()) {
lVar.invoke(g.b0(linkedHashMap.values()));
} else if (!NetworkUtils.c()) {
lVar2.invoke(-997);
} else {
a.g2(new l<RequestNoResult<YouTubeVideoModel, YouTubeVideoModel>, e>() {
@Metadata(d1 = {"\u0000\u0006\n\u0000\n\u0002\u0018\u0002\u0010\u0000\u001a\u00020\u0001H\u008a@"}, d2 = {"<anonymous>", "Lorg/godfootsteps/arch/youtubeApi/model/YouTubeVideoModel;"}, k = 3, mv = {1, 5, 1}, xi = 48)
@n.g.f.a.c(c = "org.godfootsteps.arch.youtubeApi.YouTubeApi$multipleVideoRequest$3$1", f = "YouTubeApi.kt", l = {86}, m = "invokeSuspend")
public static final class AnonymousClass1 extends SuspendLambda implements l<c<? super YouTubeVideoModel>, Object> {
public final List<String> $needRequestList;
public int label;
public AnonymousClass1(List<String> list, c<? super AnonymousClass1> cVar) {
super(1, cVar);
this.$needRequestList = list;
}
@Override
public final c<e> create(c<?> cVar) {
return new AnonymousClass1(this.$needRequestList, cVar);
}
@Override
public final Object invoke(c<? super YouTubeVideoModel> cVar) {
return ((AnonymousClass1) create(cVar)).invokeSuspend(e.a);
}
@Override
public final Object invokeSuspend(Object obj) {
CoroutineSingletons coroutineSingletons = CoroutineSingletons.COROUTINE_SUSPENDED;
int i2 = this.label;
if (i2 == 0) {
d.Q4(obj);
Objects.requireNonNull(d.c.a.m.c.a);
d.c.a.m.c cVar = c.a.b;
String y = g.y(this.$needRequestList, ",", null, null, 0, null, null, 62);
this.label = 1;
obj = d.c.a.m.a.E(cVar, y, null, null, this, 6, null);
if (obj == coroutineSingletons) {
return coroutineSingletons;
}
} else if (i2 != 1) {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
} else {
d.Q4(obj);
}
return obj;
}
}
{
super(1);
}
@Override
public e invoke(RequestNoResult<YouTubeVideoModel, YouTubeVideoModel> requestNoResult) {
invoke2(requestNoResult);
return e.a;
}
public final void invoke2(RequestNoResult<YouTubeVideoModel, YouTubeVideoModel> requestNoResult) {
h.e(requestNoResult, "$this$requestNoResult");
requestNoResult.f(new AnonymousClass1(arrayList, null));
final List<String> list = b0;
final l<List<? extends Video>, e> lVar3 = lVar;
final Map<String, Video> map = linkedHashMap;
requestNoResult.f15180l = new l<YouTubeVideoModel, e>() {
{
super(1);
}
@Override
public e invoke(YouTubeVideoModel youTubeVideoModel2) {
invoke2(youTubeVideoModel2);
return e.a;
}
public final void invoke2(YouTubeVideoModel youTubeVideoModel2) {
h.e(youTubeVideoModel2, "youtubeVideoModel");
for (ItemBean itemBean : youTubeVideoModel2.getItems()) {
b bVar2 = b.a;
StringBuilder P = i.a.b.a.a.P("0:https://www.googleapis.com/youtube/v3/videos?part=snippet,statistics,contentDetails&id=", itemBean.getId(), ",&fields=items(id,statistics/viewCount,snippet/title,snippet/publishedAt,contentDetails/duration)&key=");
YouTubeKeyHelper youTubeKeyHelper = YouTubeKeyHelper.a;
P.append(YouTubeKeyHelper.c);
String sb = P.toString();
String e2 = m.e(new YouTubeVideoModel(d.r3(itemBean)));
h.d(e2, "toJson(YouTubeVideoModel(listOf(video)))");
bVar2.c(sb, e2);
}
List<Video> d2 = YouTubeApi.a.d(youTubeVideoModel2);
ArrayList arrayList2 = new ArrayList();
int B3 = d.B3(d.S(d2, 10));
if (B3 < 16) {
B3 = 16;
}
LinkedHashMap linkedHashMap2 = new LinkedHashMap(B3);
Iterator it2 = ((ArrayList) d2).iterator();
while (it2.hasNext()) {
Object next = it2.next();
linkedHashMap2.put(((Video) next).getId(), next);
}
List<String> list2 = list;
Map<String, Video> map2 = map;
for (String str3 : list2) {
Video video2 = map2.get(str3);
if (video2 == null) {
video2 = (Video) linkedHashMap2.get(str3);
}
if (video2 != null) {
arrayList2.add(video2);
}
}
lVar3.invoke(arrayList2);
}
};
final l<Integer, e> lVar4 = lVar2;
requestNoResult.f15181m = new p<Integer, String, e>() {
{
super(2);
}
@Override
public e invoke(Integer num, String str3) {
invoke(num.intValue(), str3);
return e.a;
}
public final void invoke(int i2, String str3) {
h.e(str3, "s");
lVar4.invoke(Integer.valueOf(i2));
}
};
}
});
}
}
public final List<Video> d(YouTubeVideoModel youTubeVideoModel) {
String str;
String replace;
boolean z;
ArrayList arrayList = new ArrayList();
for (ItemBean itemBean : youTubeVideoModel.getItems()) {
Video video = new Video();
video.setId(itemBean.getId());
video.setTitle(itemBean.getSnippet().getTitle());
String substring = itemBean.getSnippet().getPublishedAt().substring(0, 19);
h.d(substring, "this as java.lang.String…ing(startIndex, endIndex)");
video.setPublishedDate(z.e(substring));
String duration = itemBean.getContentDetails().getDuration();
h.e(duration, "<this>");
HashMap hashMap = new HashMap();
hashMap.put("PT(\\d\\d)S", "00:$1");
hashMap.put("PT(\\d\\d)M", "$1:00");
hashMap.put("PT(\\d\\d)H", "$1:00:00");
hashMap.put("PT(\\d\\d)M(\\d\\d)S", "$1:$2");
hashMap.put("PT(\\d\\d)H(\\d\\d)S", "$1:00:$2");
hashMap.put("PT(\\d\\d)H(\\d\\d)M", "$1:$2:00");
hashMap.put("PT(\\d\\d)H(\\d\\d)M(\\d\\d)S", "$1:$2:$3");
String replace2 = new Regex("(?<=[^\\d])(\\d)(?=[^\\d])").replace(duration, "0$1");
Iterator it = hashMap.keySet().iterator();
while (true) {
if (!it.hasNext()) {
str = null;
break;
}
str = (String) it.next();
if (Pattern.matches(str, replace2)) {
break;
}
}
String str2 = "";
if (str == null) {
replace = "";
} else {
Regex regex = new Regex(str);
String str3 = (String) hashMap.get(str);
if (str3 == null) {
str3 = "";
}
replace = regex.replace(replace2, str3);
if ((n.o.a.C(replace, "0", false, 2) && !n.o.a.C(replace, "00", false, 2)) || n.o.a.C(replace, "00:", false, 2)) {
replace = replace.substring(1);
h.d(replace, "this as java.lang.String).substring(startIndex)");
}
try {
replace = z.d(replace);
} catch (Exception e2) {
e2.printStackTrace();
}
}
video.setDuration(replace);
video.setViewCount(NumberFormat.getIntegerInstance(s.g()).format(itemBean.getStatistics().getViewCount()));
String description = itemBean.getSnippet().getDescription();
if (!(description == null || description.length() == 0)) {
try {
int m2 = n.o.a.m(description, "\n\n", 0, false, 6);
if (m2 >= 0) {
String substring2 = description.substring(0, m2);
h.d(substring2, "this as java.lang.String…ing(startIndex, endIndex)");
if (n.o.a.c(substring2, "http://bit.ly/", false, 2) || n.o.a.c(substring2, "https://bit.ly/", false, 2) || n.o.a.c(substring2, "http://chat.whatsapp.com/", false, 2) || n.o.a.c(substring2, "https://chat.whatsapp.com/", false, 2) || n.o.a.c(substring2, "http://www.messenger.com/", false, 2) || n.o.a.c(substring2, "https://www.messenger.com/", false, 2)) {
String substring3 = description.substring(m2 + 1);
h.d(substring3, "this as java.lang.String).substring(startIndex)");
int length = substring3.length() - 1;
int i2 = 0;
boolean z2 = false;
while (i2 <= length) {
char charAt = substring3.charAt(!z2 ? i2 : length);
if (charAt != '\n' && charAt != ' ') {
z = false;
if (z2) {
if (z) {
i2++;
} else {
z2 = true;
}
} else if (!z) {
break;
} else {
length--;
}
}
z = true;
if (z2) {
}
}
str2 = substring3.subSequence(i2, length + 1).toString();
}
}
} catch (Exception e3) {
e3.printStackTrace();
}
String w2 = n.o.a.w(description, "\n\n", "\n", false, 4);
int length2 = w2.length() - 1;
int i3 = 0;
boolean z3 = false;
while (i3 <= length2) {
char charAt2 = w2.charAt(!z3 ? i3 : length2);
boolean z4 = charAt2 == '\n' || charAt2 == ' ';
if (z3) {
if (!z4) {
break;
}
length2--;
} else if (z4) {
i3++;
} else {
z3 = true;
}
}
str2 = w2.subSequence(i3, length2 + 1).toString();
}
video.setDescription(str2);
video.setThumbnailURL("http://img.youtube.com/vi/" + ((Object) video.getId()) + "/mqdefault.jpg");
video.setHqThumbnailURL("http://img.youtube.com/vi/" + ((Object) video.getId()) + "/hqdefault.jpg");
arrayList.add(video);
}
return arrayList;
}
public final String e(String str) {
StringBuilder P = i.a.b.a.a.P("0:https://www.googleapis.com/youtube/v3/videos?part=snippet,statistics,contentDetails&id=", str, ",&fields=items(id,statistics/viewCount,snippet/title,snippet/publishedAt,contentDetails/duration)&key=");
YouTubeKeyHelper youTubeKeyHelper = YouTubeKeyHelper.a;
P.append(YouTubeKeyHelper.c);
return P.toString();
}
}