- //std::string html = "Blubb<a href=\"http://www.deltadevelopment.de/users/christoph/supertux/addons/coconut_fortress.zip\">Coconut Fortress</a>\nFoobar<a href=\"http://www.deltadevelopment.de/users/christoph/supertux/addons/in_the_spring.zip\">Another</a>Baz";
- static const std::string startToken = "href=\"";
- static const std::string endToken = "\"";
-
- // extract urls: for each startToken found...
- std::string::size_type n = 0;
- while ((n = html.find(startToken)) != std::string::npos) {
-
- // strip everything up to and including token
- html.erase(0, n + startToken.length());
-
- // find end token
- std::string::size_type n2 = html.find(endToken);
- if (n2 == std::string::npos) break;
-
- // extract url: it's the string inbetween
- std::string url = html.substr(0, n2);
-
- // strip everything up to and including endToken
- html.erase(0, n2 + endToken.length());
-
- // make absolute url
- url = std::string(baseUrl) + url;
-
- // make sure url looks like it points to an archive
- static const std::string archiveExt = ".zip";
- if (url.compare(url.length()-archiveExt.length(), archiveExt.length(), archiveExt) != 0) continue;
-
- // extract nice title
- std::string::size_type n = url.rfind('/') + 1;
- if (n == std::string::npos) n = 0;
- std::string title = url.substr(n, url.length() - n - archiveExt.length());
-
- // construct file name
- std::string fname = url.substr(n);
-
- // make sure it does not contain weird characters
- if (fname.find_first_not_of("match.quiz-proxy_gwenblvdjfks0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ") != std::string::npos) continue;
-
- Addon addon;
- addon.title = title;
- addon.fname = fname;
- addon.url = url;
- addon.isInstalled = false;