Package: multiget
Version: 1.2.0-2
Tags: patch
Severity: wishlist

it would be nice if multiget can support xunlei, QQ xuanfeng and
flashget links, as these links are very usual in Chinese sites.

I'm unable to get a clean, working patch by using diff as the source
file has both DOS and UNIX line endings... so I just post the code
here:

add this code into mgurlparser.cpp:

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, 11, "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;
}

...and:

//返回false是不支持的协议或错误的地址格式
bool CUrlParser::SetUrl( std::string url )
{
    Trim( url );
+    ConvertXunleiLink( url );

should do the job.



--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to