Wei Mingzhi
unread,Mar 3, 2009, 8:25:15 AM3/3/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to benliud downloader [奔流下载]
发到 sourceforge 那边 n 长时间没人理,就发这边来了。
希望能检查一下并且 (如果没问题的话) commit 进去 :)
static inline int GetIndex(const char c)
{
if (c >= 'A' && c <= 'Z')
return c - 'A';
else if (c >= 'a' && c <= 'z')
return c - 'a' + 26;
else if (c >= '0' && c <= '9')
return c - '0' + 52;
else if (c == '+')
return 62;
else if (c == '/')
return 63;
else if (c == '=')
return 64;
return -1;
}
static std::string ConvertXunleiLink(const std::string &xunlei_link)
{
char chr1, chr2, chr3;
int enc1, enc2, enc3, enc4;
int i;
int length = xunlei_link.length();
std::string decoded = "";
if (xunlei_link.compare(0, 10, "thunder://") == 0)
i = 10;
else if (xunlei_link.compare(0, 11, "flashget://") == 0)
i = 11;
else if (xunlei_link.compare(0, 7, "qqdl://") == 0)
i = 7;
else
return xunlei_link;
while (1)
{
enc1 = ((i < length) ? GetIndex(xunlei_link[i++]) : -1);
enc2 = ((i < length) ? GetIndex(xunlei_link[i++]) : -1);
enc3 = ((i < length) ? GetIndex(xunlei_link[i++]) : -1);
enc4 = ((i < length) ? GetIndex(xunlei_link[i++]) : -1);
if (enc1 == -1 || enc2 == -1 || enc3 == -1 || enc4 == -1)
break;
chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4;
decoded += chr1;
if (enc3 != 64)
decoded += chr2;
if (enc4 != 64)
decoded += chr3;
}
if (decoded.compare(0, 2, "AA") == 0)
return decoded.substr(2, decoded.rfind("ZZ") - 2);
else if (decoded.compare(0, 10, "[FLASHGET]") == 0)
return decoded.substr(10, decoded.rfind("[FLASHGET]") - 10);
return decoded;
}
以及:
//返回false是不支持的协议或错误的地址格式
bool CUrlParser::SetUrl( std::string url )
{
Trim( url );
+ url = ConvertXunleiLink( url );