summarylogtreecommitdiffstats
path: root/keezmovies.patch
blob: 91bc34540a62c9efacadd011a7529bce7fb1b153 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# update plugin
Index: xvst-2.5.1/resources/services/keezmovies/keezmovies.js
===================================================================
--- xvst-2.5.1.orig/resources/services/keezmovies/keezmovies.js	2014-01-10 20:28:16.225627825 +0100
+++ xvst-2.5.1/resources/services/keezmovies/keezmovies.js	2014-01-10 20:30:28.293623896 +0100
@@ -23,9 +23,8 @@
 *
 */
 
-function RegistVideoService()
-{
-	this.version = "1.0.4a";
+function RegistVideoService() {
+	this.version = "1.0.5";
 	this.minVersion = "2.0.0a";
 	this.author = "Xesc & Technology 2014";
 	this.website = "http://www.keezmovies.com/";
@@ -35,8 +34,7 @@
 	this.musicSite = false;
 }
 
-function getVideoInformation(url)
-{
+function getVideoInformation(url) {
 	// video information
 	var result = new VideoDefinition();
 	// download webpage
@@ -53,8 +51,101 @@
 	return result;
 }
 
-function getVideoServiceIcon()
-{
+function searchVideos(keyWord, pageIndex) {
+	const URL_SEARCH            = "http://www.keezmovies.com/video?search=%1&page=%2";
+	const HTML_SEARCH_START     = '<div class="pag2Block float-left" style="width:804px;">';
+	const HTML_SEARCH_FINISH    = '<div class="gray-border block friend-row">';
+	const HTML_SEARCH_SEPARATOR = "</li>";
+
+	// 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, '<h2 class="title float-left">', '</h2>'); 	
+		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, "</span>", '');
+	summary = strReplace(summary, "<span>", '');
+	summary = strReplace(summary, "<em>", '');
+	summary = strReplace(summary, "</em>", '');
+
+	// remove &quot;
+	summary = strReplace(summary, "&quot;", "");
+
+	// 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, '<img', '/>');
+	title = copyBetween(tmp, 'alt="', '"');
+	imageUrl = copyBetween(tmp, 'src="', '"');
+				
+	// get video description
+	description = "";
+
+	// get video duration
+	tmp = copyBetween(html, '<var class="duration">', '</var>');	
+	duration = convertToSeconds(tmp); 
+
+	// get rating
+	rating = copyBetween(html, '<strong >', '%</strong>')/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,