';
+ const HTML_SEARCH_SEPARATOR = "";
+
+ // replace all spaces for "+"
+ keyWord = strReplace(keyWord, " ", "+");
+
+ // init search results object
+ var searchResults = new SearchResults();
+
+ // init http object
+ var http = new Http();
+ var html = http.downloadWebpage(strFormat(URL_SEARCH, keyWord, pageIndex));
+
+ var noResIx = strIndexOf(html, "did not match any videos");
+ if (noResIx == -1) {
+
+ // get the search summary
+ var summary = copyBetween(html, '
', '
');
+ searchResults.setSummary(summary);
+
+ // get results html block
+ var htmlResults = copyBetween(html, HTML_SEARCH_START, HTML_SEARCH_FINISH);
+
+ // if we found some results then...
+ if (htmlResults != "") {
+ var blocks = splitString(htmlResults, HTML_SEARCH_SEPARATOR);
+ for (n = 0; n < blocks.length-1; n++)
+ parseResultItem(searchResults, blocks[n]);
+ }
+ }
+
+ // return search results
+ return searchResults;
+}
+
+function cleanSummary(summary) {
+ // remove all "\n"
+ summary = strReplace(summary, "\n", "");
+
+ // remove unused tags
+ summary = strReplace(summary, "", '');
+ summary = strReplace(summary, "
", '');
+ summary = strReplace(summary, "", '');
+ summary = strReplace(summary, "", '');
+
+ // remove "
+ summary = strReplace(summary, """, "");
+
+ // return cleanned summary
+ return summary;
+}
+
+function parseResultItem(searchResults, html) {
+ // vars
+ var tmp, videoUrl, imageUrl, title, description, duration, rating;
+
+ // get video url
+ videoUrl = copyBetween(html, 'href="', '"');
+
+ // get title and image url
+ tmp= copyBetween(html, '');
+ title = copyBetween(tmp, 'alt="', '"');
+ imageUrl = copyBetween(tmp, 'src="', '"');
+
+ // get video description
+ description = "";
+
+ // get video duration
+ tmp = copyBetween(html, '', '');
+ duration = convertToSeconds(tmp);
+
+ // get rating
+ rating = copyBetween(html, '', '%')/10;
+
+ // add to results list
+ searchResults.addSearchResult(videoUrl, imageUrl, title, description, duration, rating);
+}
+
+function convertToSeconds(text) {
+ // how many ":" exists?
+ var count = getTokenCount(text, ":");
+
+ // get mins and seconds
+ var h = new Number(h = count == 3 ? getToken(tmp2, ":", 0) * 3600 : 0);
+ var m = new Number(getToken(text, ":", count - 2) * 60);
+ var s = new Number(getToken(text, ":", count - 1));
+
+ // convert h:m:s to seconds
+ return h + m + s;
+}
+
+function getVideoServiceIcon() {
return new Array(
0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52,
0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x10,0x08,0x03,0x00,0x00,0x00,0x28,0x2d,0x0f,