因为我有时候下H片是迅雷的地址而我又不是迅雷会员,无法离线下载。我QQ旋风又可以离线下载,于是乎在网上搜了一下参考代码,写了一个转换器。以后下H片就不怕不怕拉。
using System;
using System.Collections.Generic;
using System.Text;
namespace DownloadConvert
{
public class ConvertClass
{
public ConvertClass()
{
}
/// <summary>
/// 下载地址转换方法
/// </summary>
/// <param name="ZHLX">转换类型</param>
/// <param name="In_Address">输入地址</param>
/// <returns></returns>
public static string ConvertStr(string ZHLX,string In_Address)
{
string Out_Address = "";//存储输出地址
int index = In_Address.Trim().ToLower().LastIndexOf("/");
string StrTo = In_Address.ToLower();
if(StrTo.StartsWith("thunder://"))//如果当前输入下载地址是迅雷下载地址
{
byte[] output = { };
output = Convert.FromBase64String(In_Address.Substring(index +1));
string str = Encoding.Default.GetString(output);
string strSub = str.Substring(2,str.Length - 4);
switch(ZHLX)
{
case "普通HTTP":
Out_Address = strSub;
break;
case "迅雷地址":
Out_Address = In_Address;
break;
case "旋风地址":
byte[] byte_XF = Encoding.Default.GetBytes(strSub);
Out_Address = "qqdl://" + Convert.ToBase64String(byte_XF);
break;
case "快车地址":
string App = "[FLASHGET]" + strSub + "[FLASHGET]";
byte[] byte_KC = Encoding.Default.GetBytes(App);
Out_Address = "flashget://" + Convert.ToBase64String(byte_KC) + "&JiangZheng711";
break;
}
}
else if (StrTo.StartsWith("qqdl://"))
{
byte[] output = { };
output = Convert.FromBase64String(In_Address.Substring(index + 1));
string str = Encoding.Default.GetString(output);
switch (ZHLX)
{
case "普通HTTP":
Out_Address = str;
break;
case "迅雷地址":
string App = "AA" + str + "ZZ";
byte[] bytes_XL = Encoding.Default.GetBytes(App);
Out_Address = "thunder://" + Convert.ToBase64String(bytes_XL);
break;
case "旋风地址":
Out_Address = In_Address;
break;
case "快车地址":
string AppStr = "[FLASHGET]" + str + "[FLASHGET]";
byte[] byte_KC = Encoding.Default.GetBytes(AppStr);
Out_Address = "flashget://" + Convert.ToBase64String(byte_KC) + "&JiangZheng711";
break;
}
}
else if (StrTo.StartsWith("flashget://"))
{
byte[] outputb = { };
int FlashSpe = In_Address.Trim().IndexOf("&");
outputb = Convert.FromBase64String(In_Address.Trim().Substring(index + 1, FlashSpe - "flashget://".Length));
string str = Encoding.Default.GetString(outputb);
int indexS = str.IndexOf("]");
int indexE = str.LastIndexOf("[");
string strSub = str.Substring(indexS + 1, indexE - indexS - 1);
switch (ZHLX)
{
case "普通HTTP":
Out_Address = strSub;
break;
case "迅雷地址":
string App = "AA" + str + "ZZ";
byte[] bytes_XL = Encoding.Default.GetBytes(App);
Out_Address = "thunder://" + Convert.ToBase64String(bytes_XL);
break;
case "快车地址":
Out_Address = In_Address;
break;
case "旋风地址":
byte[] byte_XF = Encoding.Default.GetBytes(strSub);
Out_Address = "qqdl://" + Convert.ToBase64String(byte_XF);
break;
}
}
else
{
switch (ZHLX)
{
case "普通HTTP":
Out_Address = In_Address;
break;
case "迅雷地址":
string App = "AA" + In_Address + "ZZ";
byte[] bytes_XL = Encoding.Default.GetBytes(App);
Out_Address = "thunder://" + Convert.ToBase64String(bytes_XL);
break;
case "快车地址":
string AppS = "[FLASHGET]" + In_Address + "[FLASHGET]";
byte[] byte_KC = Encoding.Default.GetBytes(AppS);
Out_Address = "flashget://" + Convert.ToBase64String(byte_KC) + "&JiangZheng711";
break;
case "旋风地址":
byte[] byte_XF = Encoding.Default.GetBytes(In_Address);
Out_Address = "qqdl://" + Convert.ToBase64String(byte_XF);
break;
}
}
return Out_Address;
}
}
}