正在查看: MX Player v1.97.8 应用的 b.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: MX Player v1.97.8 应用的 b.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.mxtech.subtitle.service;
import android.annotation.TargetApi;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Base64OutputStream;
import android.util.Log;
import com.microsoft.identity.common.internal.providers.oauth2.ResponseType;
import com.microsoft.identity.common.java.AuthenticationConstants;
import com.microsoft.identity.common.java.authscheme.PopAuthenticationSchemeInternal;
import com.mxtech.SkinViewInflater;
import com.mxtech.io.Files;
import com.mxtech.net.HttpServerException;
import com.mxtech.subtitle.service.SubtitleService;
import com.mxtech.widget.DecorEditText;
import defpackage.akg;
import defpackage.b3d;
import defpackage.b78;
import defpackage.bg;
import defpackage.de2;
import defpackage.e4i;
import defpackage.fab;
import defpackage.rvb;
import defpackage.tjg;
import defpackage.tya;
import defpackage.woa;
import defpackage.xgc;
import defpackage.xwh;
import defpackage.zpc;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.UnknownHostException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.LongBuffer;
import java.nio.channels.FileChannel;
import java.security.KeyManagementException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.zip.GZIPInputStream;
import java.util.zip.ZipException;
import okhttp3.l;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlrpc.android.XMLRPCException;
public class b extends SubtitleService {
public static final int c;
public static final URL d;
public static ScheduledExecutorService e = null;
public static boolean f = false;
public static String g = null;
public static String h = null;
public static long i = 0;
public static int j = -1;
public static int k;
public static c l;
public d a;
public f b;
public class a implements ThreadFactory {
@Override
public final Thread newThread(Runnable runnable) {
return new Thread(runnable, "OpenSubtitles session keeper");
}
}
public class RunnableC0042b implements Runnable {
@Override
public final void run() {
try {
synchronized (b.class) {
try {
b.f = false;
if (b.g != null) {
if (!bg.e() || b.i + 60000 < SystemClock.uptimeMillis()) {
b.j("LogOut", 2, b.g);
b.g = null;
} else {
Object j = b.j("NoOperation", 2, b.g);
if (!(j instanceof Map)) {
b.g = null;
} else if (b.l((Map) j)) {
b.e.schedule(this, 840000L, TimeUnit.MILLISECONDS);
b.f = true;
} else {
b.g = null;
}
}
}
} catch (Throwable th) {
throw th;
}
}
} catch (Throwable th2) {
Log.e("MX.OpenSubtitles", "", th2);
}
}
}
public class c implements b3d.a {
@Override
public final void Q7(b3d b3dVar, String str) {
if (str != null && str.equals(".cr.os")) {
b.h = b.g;
b.g = null;
}
}
}
public class d {
public long a;
public final fab b;
public d(fab fabVar) {
this.b = fabVar;
}
public final void a(HashMap hashMap) {
fab fabVar = this.b;
String f = fabVar.f();
long g = fabVar.g();
hashMap.put("moviefilename", fabVar.c);
if (f != null) {
hashMap.put("moviehash", f);
}
if (g > 0) {
hashMap.put("moviebytesize", Long.toString(g));
}
int i = fabVar.i;
if (i > 0) {
hashMap.put("movietimems", Integer.toString(i));
}
int i2 = fabVar.j;
if (i2 > 0) {
double d = 1.0E9f / i2;
double round = (int) Math.round(d);
if (Math.abs(round - d) < 0.01d) {
d = round;
}
hashMap.put("moviefps", Double.toString(d));
}
}
}
public static class e {
public final fab a;
public final String b;
public e(fab fabVar, String str) {
this.a = fabVar;
this.b = str;
}
}
public class f {
public long a;
public final byte[] b = new byte[SkinViewInflater.FLAG_ANDROID_DRAWABLELEFT];
public final tjg c;
public String d;
public f(tjg tjgVar) throws SubtitleService.SubtitleFileReadException, SubtitleService.SubtitleFileEmptyException, SubtitleService.SubtitleFileTooLargeException {
if (!tjgVar.c()) {
throw new SubtitleService.SubtitleFileReadException();
}
int e = tjgVar.e();
if (e == 0) {
throw new SubtitleService.SubtitleFileEmptyException();
}
if (e > 20971520) {
throw new SubtitleService.SubtitleFileTooLargeException();
}
this.c = tjgVar;
}
public final void a(HashMap hashMap) throws SubtitleService.SubtitleFileReadException, SubtitleService.LocalException {
byte[] bArr = this.b;
String str = this.d;
tjg tjgVar = this.c;
if (str == null) {
try {
InputStream a = tjgVar.a();
try {
MessageDigest messageDigest = MessageDigest.getInstance("MD5");
messageDigest.reset();
int i = 0;
while (true) {
int read = a.read(bArr);
if (read < 0) {
break;
}
i += read;
messageDigest.update(bArr, 0, read);
}
if (i == 0) {
throw new SubtitleService.SubtitleFileReadException("Can't read subtitle " + tjgVar);
}
this.d = de2.a(messageDigest.digest()).toLowerCase(Locale.US);
} finally {
a.close();
}
} catch (IOException e) {
throw new SubtitleService.SubtitleFileReadException(e);
} catch (NoSuchAlgorithmException e2) {
throw new SubtitleService.LocalException(e2);
}
}
hashMap.put("subhash", this.d);
hashMap.put("subfilename", tjgVar.d());
}
}
static {
try {
d = new URL("https://api.opensubtitles.org/xml-rpc");
} catch (MalformedURLException e2) {
Log.e("MX.OpenSubtitles", "", e2);
}
c = 503;
}
public static boolean B() throws KeyManagementException, NoSuchAlgorithmException, IllegalArgumentException, IllegalStateException, IOException, XMLRPCException, XmlPullParserException {
String str;
String str2;
e4i.a a2;
String str3 = h;
if (str3 != null) {
j("LogOut", 2, str3);
h = null;
}
if (g == null) {
String language = Locale.getDefault().getLanguage();
woa.a aVar = woa.a;
language.getClass();
if (language.equals("in")) {
language = "id";
} else if (language.equals("iw")) {
language = "he";
}
String string = tya.o.b.getString(".cr.os", null);
if (string == null || (a2 = e4i.a(string)) == null) {
str = "";
str2 = "";
} else {
str = a2.a;
str2 = a2.b;
}
Object j2 = j("LogIn", 2, str, str2, language, "MX Player v1");
if (!(j2 instanceof Map)) {
return false;
}
Map map = (Map) j2;
if (!l(map)) {
return false;
}
String str4 = (String) map.get(ResponseType.TOKEN);
g = str4;
if (str4 == null) {
return false;
}
if (e == null) {
ScheduledExecutorService newScheduledThreadPool = Executors.newScheduledThreadPool(1, new a());
e = newScheduledThreadPool;
if (newScheduledThreadPool instanceof ThreadPoolExecutor) {
ThreadPoolExecutor threadPoolExecutor = (ThreadPoolExecutor) newScheduledThreadPool;
threadPoolExecutor.setKeepAliveTime(1L, TimeUnit.SECONDS);
threadPoolExecutor.allowCoreThreadTimeOut(true);
}
}
if (!f) {
e.schedule(new RunnableC0042b(), 840000L, TimeUnit.MILLISECONDS);
f = true;
}
if (l == null) {
l = new c();
tya.o.d(l);
}
}
return true;
}
public static Locale C(String str) {
if (TextUtils.isEmpty(str)) {
return null;
}
str.getClass();
switch (str) {
case "chi":
return new Locale("zh", "CN");
case "pob":
return new Locale("pt", "BR");
case "zhe":
break;
case "zht":
return new Locale("zh", "TW");
case "chinese":
Log.w("MX.OpenSubtitles", "Unexpected language code - ".concat(str));
break;
default:
return woa.d(2, str);
}
return new Locale("zh");
}
public static HashMap i() {
if (TextUtils.isEmpty(g)) {
return null;
}
HashMap hashMap = new HashMap();
hashMap.put("Authorization", xgc.a(g));
return hashMap;
}
public static Object j(String str, int i2, Object... objArr) throws KeyManagementException, NoSuchAlgorithmException, IOException, IllegalArgumentException, IllegalStateException, XMLRPCException, XmlPullParserException {
szi sziVar = new szi(d);
HttpURLConnection httpURLConnection = sziVar.d;
httpURLConnection.setRequestProperty("User-Agent", "MX Player v1");
Locale locale = Locale.getDefault();
woa.a aVar = woa.a;
String language = locale.getLanguage();
language.getClass();
if (language.equals("in")) {
language = "id";
} else if (language.equals("iw")) {
language = "he";
}
String country = locale.getCountry();
if (country.length() > 0) {
language = dsb.a('-', language, country);
}
httpURLConnection.setRequestProperty("Accept-Language", language);
sziVar.f = true;
try {
try {
j = -1;
k = 0;
if (s6d.W0) {
Log.d("MX.OpenSubtitles", str + " -->> " + Arrays.toString(objArr));
}
Object a2 = sziVar.a(str, objArr);
if (s6d.W0) {
Log.d("MX.OpenSubtitles", str + " <<-- " + a2 + " (HTTPS response code: " + sziVar.c + ")");
}
k = sziVar.c;
try {
httpURLConnection.disconnect();
} catch (Exception unused) {
}
return a2;
} catch (Throwable th) {
if (sziVar != null) {
try {
sziVar.d.disconnect();
} catch (Exception unused2) {
}
}
throw th;
}
} catch (IOException e2) {
Log.w("MX.OpenSubtitles", "", e2);
int i3 = sziVar.c;
k = i3;
if (i2 <= 0 || i3 < 500) {
throw e2;
}
try {
httpURLConnection.disconnect();
} catch (Exception unused3) {
}
if (s6d.W0) {
Log.w("MX.OpenSubtitles", "Retry RPC call since numRetry is " + i2, e2);
}
return j(str, i2 - 1, objArr);
} catch (XmlPullParserException e3) {
Log.w("MX.OpenSubtitles", "", e3);
if (i2 <= 0) {
throw e3;
}
if (s6d.W0) {
Log.w("MX.OpenSubtitles", "Retry RPC call since numRetry is " + i2, e3);
}
Object j2 = j(str, i2 - 1, objArr);
try {
httpURLConnection.disconnect();
} catch (Exception unused4) {
}
return j2;
}
}
public static boolean k(d dVar, f fVar) throws SubtitleService.SubtitleServiceException {
Object obj;
Object obj2;
eo0 eo0Var = new eo0(1);
HashMap hashMap = new HashMap();
dVar.a(hashMap);
fVar.a(hashMap);
eo0Var.put("cd1", hashMap);
Map r = r("TryUploadSubtitles", 1, eo0Var);
boolean z = w(0L, "alreadyindb", r) == 1;
Object obj3 = r.get("data");
if (obj3 != null && !(obj3 instanceof Boolean)) {
if (obj3 instanceof Map) {
Map map = (Map) obj3;
obj = map.get("IDMovieImdb");
obj2 = map.get("IDSubtitle");
} else {
if (obj3 instanceof Object[]) {
Object[] objArr = (Object[]) obj3;
if (objArr.length > 0) {
Map map2 = (Map) objArr[0];
obj = map2.get("IDMovieImdb");
obj2 = map2.get("IDSubtitle");
}
}
obj = null;
obj2 = null;
}
if (obj != null) {
dVar.a = v(0L, obj);
}
if (obj2 != null) {
fVar.a = v(0L, obj2);
}
}
return z;
}
public static boolean l(Map map) {
String str = (String) map.get("status");
if (str == null) {
return false;
}
zpc.a aVar = zpc.a;
int b = (int) zpc.b(0, str.length(), str);
j = b;
return 200 <= b && b < 300;
}
public static String m(long j2, ByteBuffer byteBuffer, ByteBuffer byteBuffer2) {
long j3 = 0;
long uptimeMillis = s6d.W0 ? SystemClock.uptimeMillis() : 0L;
try {
LongBuffer asLongBuffer = byteBuffer.order(ByteOrder.LITTLE_ENDIAN).asLongBuffer();
long j4 = 0;
while (asLongBuffer.hasRemaining()) {
j4 += asLongBuffer.get();
}
LongBuffer asLongBuffer2 = byteBuffer2.order(ByteOrder.LITTLE_ENDIAN).asLongBuffer();
while (asLongBuffer2.hasRemaining()) {
j3 += asLongBuffer2.get();
}
return String.format("%016x", Long.valueOf(j2 + j4 + j3));
} finally {
if (s6d.W0) {
Log.v("MX.OpenSubtitles", "Hash calculated in " + (SystemClock.uptimeMillis() - uptimeMillis) + "ms.");
}
}
}
public static String n(File file) throws IOException {
FileInputStream fileInputStream = new FileInputStream(file);
try {
return o(fileInputStream, 0L, file.length());
} finally {
fileInputStream.close();
}
}
public static String o(FileInputStream fileInputStream, long j2, long j3) throws IOException {
try {
FileChannel channel = fileInputStream.getChannel();
try {
long min = (int) Math.min(65536L, j3);
FileChannel.MapMode mapMode = FileChannel.MapMode.READ_ONLY;
return m(j3, channel.map(mapMode, j2, min), channel.map(mapMode, (j2 + j3) - min, min));
} finally {
channel.close();
}
} finally {
fileInputStream.close();
}
}
@TargetApi(8)
public static Locale[] q(tjg[] tjgVarArr) throws SubtitleService.SubtitleServiceException {
byte[] bArr = new byte[SkinViewInflater.FLAG_ANDROID_TEXT_COLOR_HINT];
int length = tjgVarArr.length;
ArrayList arrayList = new ArrayList(length);
Locale[] localeArr = new Locale[length];
String[] strArr = new String[length];
try {
MessageDigest messageDigest = MessageDigest.getInstance("MD5");
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(174762);
for (int i2 = 0; i2 < length; i2++) {
try {
messageDigest.reset();
byteArrayOutputStream.reset();
InputStream a2 = tjgVarArr[i2].a();
Base64OutputStream base64OutputStream = new Base64OutputStream(byteArrayOutputStream, 3);
int i3 = 0;
do {
try {
int read = a2.read(bArr);
if (read < 0) {
break;
}
i3 += read;
messageDigest.update(bArr, 0, read);
base64OutputStream.write(bArr, 0, read);
} catch (Throwable th) {
a2.close();
throw th;
}
} while (i3 < 262144);
if (i3 != 0) {
strArr[i2] = de2.a(messageDigest.digest()).toLowerCase(Locale.US);
base64OutputStream.close();
arrayList.add(byteArrayOutputStream.toString(AuthenticationConstants.ENCODING_ASCII_STRING));
if (s6d.W0) {
Log.d("MX.OpenSubtitles", tjgVarArr[i2].a + " ==MD5==> " + strArr[i2]);
}
}
a2.close();
} catch (IOException e2) {
Log.e("MX.OpenSubtitles", "", e2);
}
}
if (arrayList.size() > 0) {
Object obj = r("DetectLanguage", 1, arrayList).get("data");
if (obj instanceof Map) {
for (Map.Entry entry : ((Map) obj).entrySet()) {
String str = (String) entry.getKey();
String str2 = (String) entry.getValue();
for (int i4 = 0; i4 < length; i4++) {
if (strArr[i4].equalsIgnoreCase(str)) {
localeArr[i4] = C(str2);
}
}
}
}
}
return localeArr;
} catch (NoSuchAlgorithmException e3) {
Log.e("MX.OpenSubtitles", "", e3);
throw new SubtitleService.LocalException(e3);
}
}
public static synchronized Map r(String str, int i2, Object... objArr) throws SubtitleService.SubtitleServiceException {
Map s;
synchronized (b.class) {
s = s(2, i2, str, objArr);
}
return s;
}
public static java.util.Map s(int r7, int r8, java.lang.String r9, java.lang.Object... r10) throws com.mxtech.subtitle.service.SubtitleService.SubtitleServiceException {
throw new UnsupportedOperationException("Method not decompiled: com.mxtech.subtitle.service.b.s(int, int, java.lang.String, java.lang.Object[]):java.util.Map");
}
public static void t(File file, String str) throws SubtitleService.SubtitleServiceException {
GZIPInputStream gZIPInputStream;
GZIPInputStream gZIPInputStream2 = null;
try {
try {
str = b78.d().a(str, i(), null, 0, 0);
try {
try {
gZIPInputStream = new GZIPInputStream(str.getInputStream());
} catch (ZipException e2) {
e = e2;
} catch (IOException e3) {
e = e3;
}
try {
OutputStream E = Files.E(file);
try {
q96.s(gZIPInputStream, E, new byte[SkinViewInflater.FLAG_ANDROID_DRAWABLELEFT]);
E.flush();
try {
gZIPInputStream.close();
try {
str.disconnect();
} catch (Exception unused) {
}
} catch (IOException e4) {
Log.e("MX.OpenSubtitles", "", e4);
}
} finally {
E.close();
}
} catch (ZipException e5) {
e = e5;
Log.e("MX.OpenSubtitles", "", e);
throw new SubtitleService.ServerDataFormatException(e);
} catch (IOException e6) {
e = e6;
Log.e("MX.OpenSubtitles", "", e);
throw new SubtitleService.SubtitleFileWriteException(e);
} catch (Throwable th) {
th = th;
gZIPInputStream2 = gZIPInputStream;
if (gZIPInputStream2 != null) {
try {
gZIPInputStream2.close();
} catch (IOException e7) {
Log.e("MX.OpenSubtitles", "", e7);
throw th;
}
}
if (str != 0) {
try {
str.disconnect();
} catch (Exception unused2) {
}
}
throw th;
}
} catch (HttpServerException e8) {
e = e8;
Log.e("MX.OpenSubtitles", "", e);
throw new SubtitleService.ServerException(e);
} catch (MalformedURLException e9) {
e = e9;
Log.e("MX.OpenSubtitles", "", e);
throw new SubtitleService.ServerDataFormatException(e);
} catch (UnknownHostException e10) {
e = e10;
Log.e("MX.OpenSubtitles", "", e);
throw new SubtitleService.NoNetworkException(e);
} catch (IOException e11) {
e = e11;
Log.e("MX.OpenSubtitles", "", e);
throw new SubtitleService.NetworkException(e);
}
} catch (Throwable th2) {
th = th2;
}
} catch (HttpServerException e12) {
e = e12;
} catch (MalformedURLException e13) {
e = e13;
} catch (UnknownHostException e14) {
e = e14;
} catch (IOException e15) {
e = e15;
} catch (Throwable th3) {
th = th3;
str = 0;
}
}
public static double u(Object obj) {
if (obj == null) {
return 0.0d;
}
if (obj instanceof Float) {
return ((Float) obj).floatValue();
}
if (obj instanceof Double) {
return ((Double) obj).doubleValue();
}
if (!(obj instanceof String)) {
if (obj instanceof Long) {
return ((Long) obj).longValue();
}
if (obj instanceof Integer) {
return ((Integer) obj).intValue();
}
if (obj instanceof Short) {
return ((Short) obj).shortValue();
}
return 0.0d;
}
if (((String) obj).length() <= 0) {
return 0.0d;
}
try {
return Double.parseDouble((String) obj);
} catch (NumberFormatException e2) {
if (!s6d.W0) {
return 0.0d;
}
Log.e("MX.OpenSubtitles", "", e2);
return 0.0d;
}
}
public static long v(long j2, Object obj) {
if (obj != null) {
if (obj instanceof Long) {
return ((Long) obj).longValue();
}
if (obj instanceof Integer) {
return ((Integer) obj).intValue();
}
if (obj instanceof Short) {
return ((Short) obj).shortValue();
}
if ((obj instanceof String) && ((String) obj).length() > 0) {
try {
return Long.parseLong((String) obj);
} catch (NumberFormatException e2) {
if (s6d.W0) {
Log.e("MX.OpenSubtitles", "", e2);
}
}
}
}
return j2;
}
public static long w(long j2, String str, Map map) {
return v(j2, map.get(str));
}
public static long x(Object obj) throws SubtitleService.ServerDataFormatException {
if (obj != null) {
if (obj instanceof Long) {
return ((Long) obj).longValue();
}
if (obj instanceof Integer) {
return ((Integer) obj).intValue();
}
if (obj instanceof Short) {
return ((Short) obj).shortValue();
}
if ((obj instanceof String) && ((String) obj).length() > 0) {
try {
return Long.parseLong((String) obj);
} catch (NumberFormatException e2) {
if (s6d.W0) {
Log.e("MX.OpenSubtitles", "", e2);
}
}
}
}
throw new SubtitleService.ServerDataFormatException("Invalid number: " + obj);
}
public static String y(Locale locale) {
if (locale == null) {
return "";
}
String locale2 = locale.toString();
locale2.getClass();
switch (locale2) {
case "pt_BR":
return "pob";
case "zh_CN":
return "chi";
case "zh_TW":
return "zht";
default:
String language = locale.getLanguage();
if (language.length() != 2) {
return null;
}
return language.equals("zh") ? "zht" : woa.c.a(language);
}
}
public final f A(tjg tjgVar) throws SubtitleService.SubtitleFileReadException, SubtitleService.SubtitleFileEmptyException, SubtitleService.SubtitleFileTooLargeException {
f fVar = this.b;
if (fVar != null && tjgVar.equals(fVar.c)) {
return this.b;
}
f fVar2 = new f(tjgVar);
this.b = fVar2;
return fVar2;
}
public defpackage.zjg[] D(defpackage.fab[] r19, java.util.Locale[] r20, java.lang.String r21) throws com.mxtech.subtitle.service.SubtitleService.SubtitleServiceException {
throw new UnsupportedOperationException("Method not decompiled: com.mxtech.subtitle.service.b.D(fab[], java.util.Locale[], java.lang.String):zjg[]");
}
public final void E(DecorEditText decorEditText, DecorEditText decorEditText2) {
decorEditText.setConstraint(2, 20, "^[\\w-]+$", 2131889434);
decorEditText2.setConstraint(1, 64);
}
@Override
public final boolean a(fab fabVar, tjg tjgVar) throws SubtitleService.SubtitleServiceException {
return k(z(fabVar), A(tjgVar));
}
@Override
public final void b(String str, File file, String str2) throws SubtitleService.SubtitleServiceException {
GZIPInputStream gZIPInputStream;
l lVar;
try {
t(file, str);
} catch (Exception unused) {
ByteArrayInputStream byteArrayInputStream = null;
try {
try {
l.a aVar = new l.a();
aVar.f((l) null, "https://subtitle.mxplay.com/subtitle");
lVar = aVar.c();
} catch (IllegalArgumentException unused2) {
lVar = null;
}
l.a f2 = lVar.f();
f2.b(PopAuthenticationSchemeInternal.SerializedNames.URL, str);
t(file, f2.c().i);
} catch (SubtitleService.SubtitleServiceException unused3) {
HashMap hashMap = new HashMap();
hashMap.put("limit", Integer.toString(100));
Object obj = r("DownloadSubtitles", 1, new Object[]{str2}, hashMap).get("data");
if (obj instanceof Object[]) {
for (Object obj2 : (Object[]) obj) {
Map map = (Map) obj2;
String str3 = (String) map.get("idsubtitlefile");
String str4 = (String) map.get("data");
if (str3.equals(str2)) {
try {
ByteArrayInputStream byteArrayInputStream2 = new ByteArrayInputStream(Base64.decode(str4, 0));
try {
try {
gZIPInputStream = new GZIPInputStream(byteArrayInputStream2);
} catch (Throwable th) {
th = th;
gZIPInputStream = null;
}
} catch (ZipException e2) {
e = e2;
} catch (IOException e3) {
e = e3;
} catch (IllegalArgumentException e4) {
e = e4;
}
try {
OutputStream E = Files.E(file);
try {
q96.s(gZIPInputStream, E, new byte[SkinViewInflater.FLAG_ANDROID_DRAWABLELEFT]);
E.flush();
E.close();
try {
byteArrayInputStream2.close();
gZIPInputStream.close();
} catch (IOException e5) {
Log.e("MX.OpenSubtitles", "", e5);
}
} catch (Throwable th2) {
E.close();
throw th2;
}
} catch (IllegalArgumentException e6) {
e = e6;
Log.e("MX.OpenSubtitles", "", e);
throw new SubtitleService.LocalException(e);
} catch (ZipException e7) {
e = e7;
Log.e("MX.OpenSubtitles", "", e);
throw new SubtitleService.ServerDataFormatException(e);
} catch (IOException e8) {
e = e8;
Log.e("MX.OpenSubtitles", "", e);
throw new SubtitleService.SubtitleFileWriteException(e);
} catch (Throwable th3) {
th = th3;
byteArrayInputStream = byteArrayInputStream2;
if (byteArrayInputStream != null) {
try {
byteArrayInputStream.close();
} catch (IOException e9) {
Log.e("MX.OpenSubtitles", "", e9);
throw th;
}
}
if (gZIPInputStream != null) {
gZIPInputStream.close();
}
throw th;
}
} catch (ZipException e10) {
e = e10;
} catch (IOException e11) {
e = e11;
} catch (IllegalArgumentException e12) {
e = e12;
} catch (Throwable th4) {
th = th4;
gZIPInputStream = null;
}
}
}
}
}
}
}
@Override
public final boolean c(String str) {
int h2 = akg.h(str);
return h2 == 0 || h2 == 1 || h2 == 2 || h2 == 3 || h2 == 4 || h2 == 6 || h2 == 7;
}
@Override
public final void d(fab fabVar, tjg tjgVar, int i2, String str) throws SubtitleService.SubtitleServiceException {
d z = z(fabVar);
f A = A(tjgVar);
if (A.a == 0 && (!k(z, A) || A.a == 0)) {
throw new SubtitleService.SubtitleNotFoundException();
}
HashMap hashMap = new HashMap();
hashMap.put("idsubtitle", Long.toString(A.a));
hashMap.put("score", Integer.toString(i2 < 1 ? 1 : i2));
r("SubtitlesVote", 1, hashMap);
if (str == null || str.length() <= 0) {
return;
}
hashMap.clear();
hashMap.put("idsubtitle", Long.toString(A.a));
hashMap.put("comment", str);
if (i2 == 0) {
hashMap.put("badsubtitle", "1");
}
r("AddComment", 1, hashMap);
}
@Override
public final long e(fab fabVar, String str, int i2, int i3, int i4) throws SubtitleService.SubtitleServiceException {
StringBuilder sb;
if (i3 > 0) {
sb = new StringBuilder();
sb.append(str);
sb.append(' ');
sb.append(String.format("S%02d", Integer.valueOf(i3)));
} else {
sb = null;
}
if (i4 >= 0) {
if (sb == null) {
sb = new StringBuilder();
sb.append(str);
sb.append(' ');
}
sb.append(String.format("E%02d", Integer.valueOf(i4)));
}
if (sb != null) {
str = sb.toString();
}
d z = z(fabVar);
z.getClass();
eo0 eo0Var = new eo0(2);
eo0Var.put("moviename", str);
eo0Var.put("movieyear", Integer.toString(i2));
long x = x(r("InsertMovie", 1, eo0Var).get("id"));
z.a = x;
if (x == 0) {
throw new SubtitleService.ServerDataFormatException("New movie id returned 0.");
}
if (x == 0) {
throw new IllegalStateException();
}
HashMap hashMap = new HashMap();
z.a(hashMap);
hashMap.put("imdbid", Long.toString(z.a));
r("InsertMovieHash", 1, new Object[]{hashMap});
return x;
}
@Override
public final List<rvb> f(fab fabVar) throws SubtitleService.SubtitleServiceException {
boolean z;
int i2;
d z2 = z(fabVar);
fab fabVar2 = z2.b;
String f2 = fabVar2.f();
b bVar = b.this;
if (f2 == null) {
return bVar.g(fabVar2.c);
}
LinkedList linkedList = new LinkedList();
boolean z3 = true;
Object obj = r("CheckMovieHash2", 1, new Object[]{f2}).get("data");
if (!(obj instanceof Map)) {
return linkedList;
}
for (Map.Entry entry : ((Map) obj).entrySet()) {
Object key = entry.getKey();
bVar.getClass();
int i3 = 0;
if (key instanceof String) {
z = f2.equalsIgnoreCase((String) key);
} else {
try {
if (Long.parseLong(f2) == v(0L, key)) {
z = z3;
}
} catch (NumberFormatException unused) {
}
z = false;
}
if (z) {
Object value = entry.getValue();
if (value instanceof Object[]) {
Object[] objArr = (Object[]) value;
int length = objArr.length;
while (i3 < length) {
Object obj2 = objArr[i3];
if (obj2 instanceof Map) {
Map map = (Map) obj2;
String str = (String) map.get("MovieName");
long w = w(0L, "MovieImdbID", map);
if (w != 0 && str != null) {
int w2 = (int) w(-1L, "SeriesEpisode", map);
if (w2 == 0) {
w2 = -1;
}
i2 = length;
linkedList.add(new rvb((int) w(0L, "MovieYear", map), (int) w(0L, "SeriesSeason", map), w2, w, str));
i3++;
length = i2;
}
}
i2 = length;
i3++;
length = i2;
}
}
}
z3 = true;
}
return linkedList;
}
@Override
public final List<rvb> g(String str) throws SubtitleService.SubtitleServiceException {
Map r = r("SearchMoviesOnIMDB", 1, str);
xwh xwhVar = new xwh();
Object obj = r.get("data");
if (obj instanceof Object[]) {
for (Object obj2 : (Object[]) obj) {
if (obj2 instanceof Map) {
Map map = (Map) obj2;
Object obj3 = map.get("id");
String str2 = (String) map.get("title");
if (obj3 != null && str2 != null) {
xwhVar.add(new rvb(0, 0, -1, x(obj3), str2));
}
}
}
}
return xwhVar;
}
@Override
public final void h(long j2, fab fabVar, tjg tjgVar, Locale locale) throws SubtitleService.SubtitleServiceException {
String y;
d z = z(fabVar);
f A = A(tjgVar);
z.a = j2;
eo0 eo0Var = new eo0(2);
HashMap hashMap = new HashMap();
eo0Var.put("idmovieimdb", Long.toString(j2));
if (locale != null && (y = y(locale)) != null) {
eo0Var.put("sublanguageid", y);
}
z.a(hashMap);
A.a(hashMap);
byte[] bArr = A.b;
tjg tjgVar2 = A.c;
try {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream((tjgVar2.e() * 2) / 3);
Base64OutputStream base64OutputStream = new Base64OutputStream(byteArrayOutputStream, 3);
InputStream a2 = tjgVar2.a();
int i2 = 0;
while (true) {
try {
int read = a2.read(bArr);
if (read < 0) {
break;
}
i2 += read;
base64OutputStream.write(bArr, 0, read);
} catch (Throwable th) {
a2.close();
throw th;
}
}
if (i2 == 0) {
throw new SubtitleService.SubtitleFileReadException("Can't read subtitle " + tjgVar2);
}
a2.close();
base64OutputStream.close();
hashMap.put("subcontent", byteArrayOutputStream.toString(AuthenticationConstants.ENCODING_ASCII_STRING));
eo0 eo0Var2 = new eo0(2);
eo0Var2.put("baseinfo", eo0Var);
eo0Var2.put("cd1", hashMap);
r("UploadSubtitles", 1, eo0Var2);
} catch (IOException e2) {
throw new SubtitleService.SubtitleFileReadException(e2);
}
}
public final void p(String str, String str2, String str3) throws SubtitleService.SubtitleServiceException {
r("UserRegister", 2, str, str3, str2);
}
public final d z(fab fabVar) {
d dVar = this.a;
if (dVar != null && fabVar.equals(dVar.b)) {
return this.a;
}
d dVar2 = new d(fabVar);
this.a = dVar2;
return dVar2;
}
}