multiget 支持专用链的补丁

14 views
Skip to first unread message

Wei Mingzhi

unread,
Mar 3, 2009, 8:25:15 AM3/3/09
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 );

Reply all
Reply to author
Forward
0 new messages