正在查看: MX Player v1.97.8 应用的 YoutubeWebViewManager.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: MX Player v1.97.8 应用的 YoutubeWebViewManager.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.mxtech.videoplayer.ad.online.features.search.youtube;
import android.text.TextUtils;
import android.util.Base64;
import android.webkit.JavascriptInterface;
import android.webkit.ValueCallback;
import com.google.gson.JsonSyntaxException;
import com.microsoft.identity.client.internal.MsalUtils;
import com.microsoft.identity.common.adal.internal.AuthenticationConstants;
import com.microsoft.identity.common.java.authscheme.TokenAuthenticationScheme;
import com.mxtech.videoplayer.ad.online.features.search.youtube.YoutubeVideoResourceFlow;
import com.mxtech.videoplayer.ad.online.model.bean.next.ResourceType;
import com.mxtech.videoplayer.ad.utils.GsonUtil;
import defpackage.jn;
import defpackage.v0j;
import defpackage.xe0;
import java.lang.ref.WeakReference;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public final class YoutubeWebViewManager {
public YoutubeWebView a;
public String b;
public HashMap d;
public HashMap e;
public boolean f;
public b g;
public String k;
public Integer c = 0;
public boolean h = true;
public Integer i = 0;
public final String j = "javascript:function getYoutubeList(startIndex, isCallback) {\n var elements = document.getElementsByTagName(\"ytm-video-with-context-renderer\");\n var object = {};\n var params = [];\n\n if (elements == undefined || startIndex > elements.length) {\n object['youtubeVideos'] = params;\n\n } else {\n var reg = new RegExp('\"', \"g\");\n for (var i = startIndex; i < elements.length; i++) {\n if (elements[i] == undefined) {\n continue;\n }\n var timeTag = elements[i].getElementsByTagName(\"ytm-thumbnail-overlay-time-status-renderer\")[0];\n var time = \"\";\n if (timeTag != undefined) {\n time = timeTag.innerText;\n }\n var imgSrcTag = elements[i].getElementsByTagName(\"img\")[0];\n var imgSrc = \"\";\n if (imgSrcTag != undefined && imgSrcTag.hasAttribute(\"src\")) {\n imgSrc = imgSrcTag.getAttribute(\"src\");\n }\n\n var watchIdTag = elements[i].getElementsByTagName(\"a\")[0];\n var watchId = \"\";\n if (watchIdTag != undefined && watchIdTag.hasAttribute(\"href\")) {\n watchId = watchIdTag.getAttribute(\"href\").substring(9);\n }else{\n continue;\n }\n\n var nameTag = elements[i].getElementsByTagName(\"h4\")[0];\n var name = \"\";\n if (nameTag != undefined) {\n name = nameTag.innerText;\n }\n var publisherTag = elements[i].getElementsByTagName(\"div\")[6];\n var publisher = \"\";\n if (publisherTag != undefined) {\n publisher = publisherTag.innerText;\n }\n var totalNumberOfWatchTag = elements[i].getElementsByTagName(\"div\")[7];\n var totalNumberOfWatch = \"\";\n if (totalNumberOfWatchTag != undefined) {\n totalNumberOfWatch = totalNumberOfWatchTag.innerText;\n }\n var publishTimeTag = elements[i].getElementsByTagName(\"div\")[8];\n var publishTime = \"\";\n if (publishTimeTag != undefined) {\n publishTime = publishTimeTag.innerText;\n }\n var item = {};\n item['youtubeWatchId'] = watchId;\n if (imgSrc == \"\") {\n imgSrc = \"https://i.ytimg.com/vi/\" + watchId + \"/hqdefault.jpg\";\n }\n item['youtubeImageUrl'] = imgSrc;\n item['youtubeName'] = name.replace(reg, \"\");\n item['youtubeDurationString'] = time;\n item['youtubeType'] = \"youtube\";\n item['youtubePublisher'] = publisher;\n item['totalNumberOfWatch'] = totalNumberOfWatch;\n item['youtubePublishTime'] = publishTime;\n params.push(item);\n }\n object['youtubeVideos'] = params;\n }\n\n object['nextStartIndex'] = startIndex + params.length;\n if (isCallback) {\n AndroidNative.postJsonData(JSON.stringify(object));\n } else {\n return JSON.stringify(object);\n }\n}";
public String l = "";
public boolean m = false;
public boolean n = false;
public boolean o = false;
public boolean p = false;
public boolean q = false;
public int r = 0;
public final jn s = new jn(this, 8);
public static class JavascriptPerformException extends RuntimeException {
public JavascriptPerformException() {
super("The injected javascript method failed to execute, or the injection did not complete, or the injection failed. ");
}
}
public static class WebViewLoadDataException extends RuntimeException {
public WebViewLoadDataException() {
super("The webView loading of YouTube data is not complete or failed.");
}
}
public static class a {
public WeakReference<YoutubeWebViewManager> a;
public YoutubeWebView b;
@JavascriptInterface
public void postJsonData(String str) {
this.a.get().e(str);
}
@JavascriptInterface
public String scrollVertical() {
YoutubeWebView youtubeWebView = this.b;
int verticalScrollRange = youtubeWebView.getVerticalScrollRange();
youtubeWebView.scrollTo(0, verticalScrollRange);
return "" + verticalScrollRange;
}
}
public interface b {
void J6(YoutubeVideoResourceFlow youtubeVideoResourceFlow, boolean z, boolean z2);
void g3(YoutubeVideoResourceFlow youtubeVideoResourceFlow, RuntimeException runtimeException);
}
public YoutubeWebViewManager(YoutubeWebView youtubeWebView) {
this.a = youtubeWebView;
xe0.c cVar = new xe0.c();
cVar.b = "GET";
cVar.a = "https://androidapi.mxplay.com/v1/youtube-search-js";
new xe0(cVar).d(new v0j(this));
}
public static String f(String str) {
if (TextUtils.isEmpty(str)) {
return "";
}
try {
return URLEncoder.encode(str, "utf-8");
} catch (Exception unused) {
return str.replace("%", "%25").replace("+", "%20").replace(TokenAuthenticationScheme.SCHEME_DELIMITER, "%20").replace("/", "%2F").replace(MsalUtils.QUERY_STRING_SYMBOL, "%3F").replace("#", "%23").replace(MsalUtils.QUERY_STRING_DELIMITER, "%26");
}
}
public final void a(YoutubeVideoResourceFlow youtubeVideoResourceFlow, boolean z, RuntimeException runtimeException) {
this.f = false;
b bVar = this.g;
if (bVar != null) {
if (z) {
bVar.J6(youtubeVideoResourceFlow, this.m, this.h);
} else {
bVar.g3(youtubeVideoResourceFlow, runtimeException);
}
}
}
public final YoutubeVideoResourceFlow b() {
YoutubeVideoResourceFlow youtubeVideoResourceFlow = new YoutubeVideoResourceFlow();
youtubeVideoResourceFlow.setYoutubeVideos(new ArrayList());
h(youtubeVideoResourceFlow);
return youtubeVideoResourceFlow;
}
public final void c(Integer num, b bVar) {
this.f = true;
this.i = num;
this.g = bVar;
if (num.intValue() > 0) {
this.m = false;
} else {
this.m = true;
}
HashMap hashMap = this.d;
if (hashMap == null || !hashMap.containsKey(num)) {
d(num);
return;
}
YoutubeVideoResourceFlow youtubeVideoResourceFlow = (YoutubeVideoResourceFlow) this.d.get(num);
if (youtubeVideoResourceFlow == null || youtubeVideoResourceFlow.getYoutubeVideos() == null || youtubeVideoResourceFlow.getYoutubeVideos().size() == 0) {
this.d.remove(num);
d(num);
} else {
this.e.put(this.g, this.i);
a(youtubeVideoResourceFlow, true, null);
}
}
public final void d(Integer num) {
if (num.intValue() < 0) {
num = 0;
}
this.i = num;
YoutubeWebView youtubeWebView = this.a;
if (youtubeWebView == null) {
a(b(), false, new WebViewLoadDataException());
return;
}
youtubeWebView.evaluateJavascript("javascript:getYoutubeList(" + this.c + ", false)", new ValueCallback() {
@Override
public final void onReceiveValue(java.lang.Object r8) {
throw new UnsupportedOperationException("Method not decompiled: defpackage.u0j.onReceiveValue(java.lang.Object):void");
}
});
}
public final void e(String str) {
YoutubeVideoResourceFlow youtubeVideoResourceFlow;
if (TextUtils.isEmpty(str) || "null".equals(str)) {
a(b(), false, new JavascriptPerformException());
return;
}
try {
youtubeVideoResourceFlow = (YoutubeVideoResourceFlow) GsonUtil.a().fromJson(str.substring(1, str.length() - 1).replace("\\", ""), YoutubeVideoResourceFlow.class);
} catch (JsonSyntaxException unused) {
a(b(), false, new JavascriptPerformException());
youtubeVideoResourceFlow = null;
}
if (youtubeVideoResourceFlow == null || youtubeVideoResourceFlow.getYoutubeVideos() == null || youtubeVideoResourceFlow.getYoutubeVideos().size() <= 0) {
this.h = false;
a(b(), false, new WebViewLoadDataException());
return;
}
this.h = true;
h(youtubeVideoResourceFlow);
a(youtubeVideoResourceFlow, true, null);
this.d.put(this.i, youtubeVideoResourceFlow);
this.e.put(this.g, this.i);
this.c = Integer.valueOf(youtubeVideoResourceFlow.getNextStartIndex());
YoutubeWebView youtubeWebView = this.a;
if (youtubeWebView != null) {
this.a.scrollTo(0, youtubeWebView.getVerticalScrollRange());
}
}
public final void g() {
this.c = 0;
HashMap hashMap = this.d;
if (hashMap != null) {
hashMap.clear();
} else {
this.d = new HashMap();
}
HashMap hashMap2 = this.e;
if (hashMap2 != null) {
hashMap2.clear();
} else {
this.e = new HashMap();
}
this.r = 0;
this.q = false;
}
public final void h(YoutubeVideoResourceFlow youtubeVideoResourceFlow) {
youtubeVideoResourceFlow.setName("YOUTUBE");
youtubeVideoResourceFlow.setType(ResourceType.FeedType.YOUTUBE_VIDEO);
youtubeVideoResourceFlow.setHasMore(this.h);
youtubeVideoResourceFlow.setPageNo(this.i.intValue());
youtubeVideoResourceFlow.setNextToken(AuthenticationConstants.Broker.REDIRECT_SSL_PREFIX);
youtubeVideoResourceFlow.setId("search_youtube");
List<YoutubeVideoResourceFlow.YoutubeVideo> youtubeVideos = youtubeVideoResourceFlow.getYoutubeVideos();
if (youtubeVideos == null || youtubeVideos.size() <= 0) {
return;
}
long currentTimeMillis = System.currentTimeMillis();
for (int i = 0; i < youtubeVideos.size(); i++) {
YoutubeVideoResourceFlow.YoutubeVideo youtubeVideo = youtubeVideos.get(i);
if (youtubeVideo != null) {
youtubeVideo.setQuery(this.b);
youtubeVideo.setId(youtubeVideo.getYoutubeWatchId());
youtubeVideo.setName(youtubeVideo.getYoutubeName());
youtubeVideo.setType(ResourceType.FeedType.YOUTUBE_VIDEO);
String str = youtubeVideo.getYoutubeWatchId() + youtubeVideo.getYoutubeName() + youtubeVideo.getType().typeName() + System.currentTimeMillis();
youtubeVideo.setRequestId(TextUtils.isEmpty(str) ? null : Base64.encodeToString(str.getBytes(), 0));
youtubeVideo.setRequestId(u54.h(String.valueOf(currentTimeMillis)));
}
}
}
}