2018-08-12

2018-08-12  本文已影响23人  _小老虎_
package cn.vcinema.terminal.cache;

import cn.vcinema.terminal.basic.Base64;
import com.google.devtools.build.android.desugar.runtime.ThrowableExtension;
import java.net.URLEncoder;
import java.security.MessageDigest;
import java.util.HashMap;
import java.util.Map;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;

public class Play
{
  private static final byte[] a = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
  private static final char[] b = "0123456789ABCDEF".toCharArray();
  private static final int c = 3600;
  private static final int d = 15;
  
  private static String a(String paramString)
  {
    try
    {
      Object localObject = MessageDigest.getInstance("MD5");
      paramString = paramString.toCharArray();
      int j = 0;
      byte[] arrayOfByte = new byte[paramString.length];
      int i = 0;
      while (i < paramString.length)
      {
        arrayOfByte[i] = ((byte)paramString[i]);
        i += 1;
      }
      paramString = ((MessageDigest)localObject).digest(arrayOfByte);
      localObject = new StringBuilder();
      int k = paramString.length;
      i = j;
      while (i < k)
      {
        j = paramString[i] & 0xFF;
        if (j < 16) {
          ((StringBuilder)localObject).append("0");
        }
        ((StringBuilder)localObject).append(Long.toHexString(j));
        i += 1;
      }
      return ((StringBuilder)localObject).toString();
    }
    catch (Exception paramString)
    {
      ThrowableExtension.printStackTrace(paramString);
    }
    return null;
  }
  
  private static String a(String paramString1, String paramString2)
  {
    if (paramString2 == null) {
      return null;
    }
    try
    {
      if (paramString2.length() != 16) {
        return null;
      }
      paramString2 = new SecretKeySpec(paramString2.getBytes("ASCII"), "AES");
      Cipher localCipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
      localCipher.init(2, paramString2, new IvParameterSpec(a));
      new Base64();
      paramString1 = new String(localCipher.doFinal(Base64.decode(paramString1)));
      return paramString1;
    }
    catch (Exception paramString1)
    {
      ThrowableExtension.printStackTrace(paramString1);
    }
    return null;
  }
  
  private static String b(String paramString)
  {
    StringBuilder localStringBuilder = new StringBuilder();
    paramString = paramString.getBytes();
    int i = 0;
    while (i < paramString.length)
    {
      localStringBuilder.append(b[((paramString[i] & 0xFF) >> 4)]);
      localStringBuilder.append(b[(paramString[i] & 0xF)]);
      i += 1;
    }
    return localStringBuilder.toString().trim();
  }
  
  public static Map getPlayUrl(String paramString, long paramLong1, long paramLong2, boolean paramBoolean1, boolean paramBoolean2)
    throws Exception
  {
    if ((paramString != null) && (!"".equalsIgnoreCase(paramString)))
    {
      if (paramLong2 == 0L) {
        return null;
      }
      HashMap localHashMap = new HashMap();
      Object localObject = paramString.substring(paramString.indexOf("vcinema.com.cn/") + 14, paramString.indexOf("?"));
      String str = a(paramString.substring(paramString.indexOf("?auth_key=") + 10), "bREd2Yr2Pv4Rr4PT");
      if ((!paramString.startsWith("http://s1.cdn.")) && (!paramString.startsWith("https://s1.cdn.")) && (!paramString.startsWith("http://dev.s1.cdn.")) && (!paramString.startsWith("https://dev.s1.cdn.")))
      {
        if ((!paramString.startsWith("http://s2.cdn.")) && (!paramString.startsWith("https://s2.cdn.")) && (!paramString.startsWith("http://dev.s2.cdn.")) && (!paramString.startsWith("https://dev.s2.cdn.")))
        {
          if ((!paramString.startsWith("http://s7.cdn.")) && (!paramString.startsWith("https://s7.cdn.")) && (!paramString.startsWith("http://dev.s7.cdn.")) && (!paramString.startsWith("https://dev.s7.cdn.")))
          {
            if ((!paramString.startsWith("http://s9.cdn.")) && (!paramString.startsWith("https://s9.cdn.")) && (!paramString.startsWith("http://dev.s9.cdn.")) && (!paramString.startsWith("https://dev.s9.cdn.")))
            {
              if ((!paramString.startsWith("http://s3.cdn.")) && (!paramString.startsWith("https://s3.cdn.")) && (!paramString.startsWith("http://dev.s3.cdn.")) && (!paramString.startsWith("https://dev.s3.cdn.")))
              {
                if ((!paramString.startsWith("http://s5.cdn.")) && (!paramString.startsWith("https://s5.cdn.")) && (!paramString.startsWith("http://dev.s5.cdn.")) && (!paramString.startsWith("https://dev.s5.cdn.")))
                {
                  if ((!paramString.startsWith("http://s6.cdn.")) && (!paramString.startsWith("https://s6.cdn.")) && (!paramString.startsWith("http://dev.s6.cdn.")) && (!paramString.startsWith("https://dev.s6.cdn."))) {
                    return null;
                  }
                  paramLong1 = paramLong2 / 1000L + 3600L + paramLong1;
                  localHashMap.put("invalid_time", Long.valueOf(paramLong1));
                  localStringBuilder = new StringBuilder();
                  localStringBuilder.append(paramString.substring(0, paramString.indexOf("vcinema.com.cn") + 14));
                  localStringBuilder.append((String)localObject);
                  localStringBuilder.append("?f3tm=");
                  localStringBuilder.append(paramLong1);
                  localStringBuilder.append("&f3key=");
                  paramString = new StringBuilder();
                  paramString.append(str);
                  paramString.append((String)localObject);
                  paramString.append(paramLong1);
                  localStringBuilder.append(a(paramString.toString()));
                  localHashMap.put("play_url", localStringBuilder.toString());
                  localHashMap.put("play_type", PlayType.CDN);
                  return localHashMap;
                }
                paramLong1 = paramLong2 / 1000L + 3600L + paramLong1;
                localHashMap.put("invalid_time", Long.valueOf(paramLong1));
                localStringBuilder = new StringBuilder();
                localStringBuilder.append(paramString.substring(0, paramString.indexOf("vcinema.com.cn") + 14));
                localStringBuilder.append((String)localObject);
                localStringBuilder.append("?token=");
                paramString = new StringBuilder();
                paramString.append((String)localObject);
                localObject = new StringBuilder();
                ((StringBuilder)localObject).append(paramLong1);
                ((StringBuilder)localObject).append("");
                paramString.append(b(((StringBuilder)localObject).toString()));
                paramString.append(str);
                localStringBuilder.append(a(paramString.toString()));
                localStringBuilder.append("&txTime=");
                paramString = new StringBuilder();
                paramString.append(paramLong1);
                paramString.append("");
                localStringBuilder.append(b(paramString.toString()));
                localHashMap.put("play_url", localStringBuilder.toString());
                if (paramBoolean2)
                {
                  localHashMap.put("play_type", PlayType.QCLOUD_P2P);
                  return localHashMap;
                }
                localHashMap.put("play_type", PlayType.CDN);
                return localHashMap;
              }
              paramLong1 = paramLong2 / 1000L + 3600L + paramLong1;
              localHashMap.put("invalid_time", Long.valueOf(paramLong1));
              localStringBuilder = new StringBuilder();
              localStringBuilder.append(paramString.substring(0, paramString.indexOf("vcinema.com.cn") + 14));
              localStringBuilder.append((String)localObject);
              localStringBuilder.append("?k=");
              paramString = new StringBuilder();
              paramString.append(str);
              paramString.append((String)localObject);
              paramString.append(paramLong1);
              localStringBuilder.append(a(paramString.toString()));
              localStringBuilder.append("&t=");
              localStringBuilder.append(paramLong1);
              localHashMap.put("play_url", localStringBuilder.toString());
              localHashMap.put("play_type", PlayType.CDN);
              return localHashMap;
            }
            paramLong1 = paramLong2 / 1000L + 15L;
            localHashMap.put("invalid_time", Long.valueOf(paramLong1));
            localStringBuilder = new StringBuilder();
            localStringBuilder.append(paramString.substring(0, paramString.indexOf("vcinema.com.cn") + 14));
            localStringBuilder.append((String)localObject);
            localStringBuilder.append("?_upt=");
            paramString = new StringBuilder();
            paramString.append(str);
            paramString.append("&");
            paramString.append(paramLong1);
            paramString.append("&");
            paramString.append((String)localObject);
            localStringBuilder.append(a(paramString.toString()).substring(12, 20));
            localStringBuilder.append(paramLong1);
            localHashMap.put("play_url", localStringBuilder.toString());
            localHashMap.put("play_type", PlayType.CDN);
            return localHashMap;
          }
          paramLong1 = paramLong2 / 1000L + 15L;
          localHashMap.put("invalid_time", Long.valueOf(paramLong1));
          localStringBuilder = new StringBuilder();
          localStringBuilder.append(paramString.substring(0, paramString.indexOf("vcinema.com.cn") + 14));
          localStringBuilder.append((String)localObject);
          localStringBuilder.append("?auth_key=");
          localStringBuilder.append(paramLong1);
          localStringBuilder.append("-0-0-");
          paramString = new StringBuilder();
          paramString.append((String)localObject);
          paramString.append("-");
          paramString.append(paramLong1);
          paramString.append("-0-0-");
          paramString.append(str);
          localStringBuilder.append(a(paramString.toString()));
          localHashMap.put("play_url", localStringBuilder.toString());
          localHashMap.put("play_type", PlayType.CDN);
          return localHashMap;
        }
        paramLong1 = paramLong2 / 1000L + 15L;
        localHashMap.put("invalid_time", Long.valueOf(paramLong1));
        localStringBuilder = new StringBuilder();
        localStringBuilder.append(paramString.substring(0, paramString.indexOf("vcinema.com.cn") + 14));
        localStringBuilder.append((String)localObject);
        localStringBuilder.append("?sign=");
        paramString = new StringBuilder();
        paramString.append(str);
        paramString.append(URLEncoder.encode((String)localObject));
        paramString.append(paramLong1);
        localStringBuilder.append(a(paramString.toString().replace("%2F", "/")));
        localStringBuilder.append("&t=");
        localStringBuilder.append(paramLong1);
        localHashMap.put("play_url", localStringBuilder.toString());
        localHashMap.put("play_type", PlayType.CDN);
        return localHashMap;
      }
      paramLong1 = paramLong2 / 1000L + 3600L + paramLong1;
      StringBuilder localStringBuilder = new StringBuilder();
      localStringBuilder.append(paramString.substring(0, paramString.indexOf("vcinema.com.cn") + 14));
      localStringBuilder.append((String)localObject);
      localStringBuilder.append("?auth_key=");
      localStringBuilder.append(paramLong1);
      localStringBuilder.append("-0-0-");
      paramString = new StringBuilder();
      paramString.append((String)localObject);
      paramString.append("-");
      paramString.append(paramLong1);
      paramString.append("-0-0-");
      paramString.append(str);
      localStringBuilder.append(a(paramString.toString()));
      localHashMap.put("play_url", localStringBuilder.toString());
      if (paramBoolean1) {
        localHashMap.put("play_type", PlayType.ALI_PCDN);
      } else {
        localHashMap.put("play_type", PlayType.CDN);
      }
      localHashMap.put("invalid_time", Long.valueOf(paramLong1));
      return localHashMap;
    }
    return null;
  }
}
上一篇下一篇

猜你喜欢

热点阅读