summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/unittest/testwebvi.py13
-rw-r--r--templates/video.google.com/search.xsl16
-rw-r--r--templates/video.google.com/searchresults.xsl47
-rw-r--r--templates/video.google.com/videopage.xsl19
4 files changed, 25 insertions, 70 deletions
diff --git a/src/unittest/testwebvi.py b/src/unittest/testwebvi.py
index 8bf15b8..2b53d60 100644
--- a/src/unittest/testwebvi.py
+++ b/src/unittest/testwebvi.py
@@ -153,23 +153,14 @@ class TestServiceModules(unittest.TestCase):
def testGoogleSearch(self):
ref = self.getServiceReference('../../templates/video.google.com')
menuobj = self.downloadMenuPage(ref, 'search')
- self.assertTrue(len(menuobj) == 4, 'Unexpected number of items in Google search menu')
self.assertTrue(isinstance(menuobj[0], menu.MenuItemTextField))
- self.assertTrue(isinstance(menuobj[1], menu.MenuItemList))
- self.assertTrue(len(menuobj[1].items) >= 2)
- self.assertTrue(isinstance(menuobj[2], menu.MenuItemList))
- self.assertTrue(len(menuobj[2].items) >= 4)
- self.assertTrue(isinstance(menuobj[3], menu.MenuItemSubmitButton))
+ self.assertTrue(isinstance(menuobj[-1], menu.MenuItemSubmitButton))
# Query term
menuobj[0].value = 'google'
- # Sort by: date
- menuobj[1].current = 3
- # Duration: Short
- menuobj[2].current = 1
- resultref = menuobj[3].activate()
+ resultref = menuobj[-1].activate()
self.assertNotEqual(resultref, None)
self.downloadAndExtractLinks(resultref, 1, 'search result')
diff --git a/templates/video.google.com/search.xsl b/templates/video.google.com/search.xsl
index 07dbda6..ce68861 100644
--- a/templates/video.google.com/search.xsl
+++ b/templates/video.google.com/search.xsl
@@ -12,23 +12,9 @@
<label>Search terms</label>
</textfield>
- <itemlist name="so">
- <label>Sort by</label>
- <item value="">Relevance</item>
- <item value=",sbd:1">Date</item>
- </itemlist>
-
- <itemlist name="dur">
- <label>Duration</label>
- <item value="">All durations</item>
- <item value=",dur:s">Short (&lt; 4 min)</item>
- <item value=",dur:m">Medium (4-20 min)</item>
- <item value=",dur:l">Long (&gt; 20 min)</item>
- </itemlist>
-
<button>
<label>Search</label>
- <submission>wvt:///video.google.com/searchresults.xsl?srcurl=<xsl:value-of select="str:encode-uri('http://www.google.com/search?q={q}&amp;tbs=vid:1{dur}{so}', true())"/>&amp;HTTP-header=User-Agent,Mozilla/5.0</submission>
+ <submission>wvt:///video.google.com/searchresults.xsl?srcurl=<xsl:value-of select="str:encode-uri('http://video.google.com/videosearch?q={q}+site:video.google.com&amp;start=0&amp;hl=en', true())"/>&amp;HTTP-header=User-Agent,Mozilla/5.0%20(X11;%20Linux%20x86_64;%20rv:5.0.1)%20Gecko/20100101%20Firefox/5.0.1</submission>
</button>
</wvmenu>
</xsl:template>
diff --git a/templates/video.google.com/searchresults.xsl b/templates/video.google.com/searchresults.xsl
index a65b8a6..28230c0 100644
--- a/templates/video.google.com/searchresults.xsl
+++ b/templates/video.google.com/searchresults.xsl
@@ -4,12 +4,19 @@
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:str="http://exslt.org/strings">
+<xsl:template match="a">
+ <link>
+ <label><xsl:value-of select="."/></label>
+ <stream>wvt:///video.google.com/videopage.xsl?srcurl=<xsl:value-of select="str:encode-uri(@href, true())"/></stream>
+ </link>
+</xsl:template>
+
<xsl:template match="/">
<wvmenu>
<title>Search results</title>
<xsl:choose>
- <xsl:when test="not(//li[contains(@class, 'g')]//td/a[not(img)])">
+ <xsl:when test="not(//a[starts-with(@href, 'http://video.google.com/videoplay?')])">
<textarea>
<label>
<xsl:text>Your search did not return any results.</xsl:text>
@@ -18,43 +25,7 @@
</xsl:when>
<xsl:otherwise>
- <xsl:for-each select="//li[@class='g']//td/a[not(img)]">
- <xsl:variable name="url" select="str:decode-uri(substring-after(@href, 'q='))" />
-
- <xsl:choose>
- <xsl:when test="starts-with($url, 'http://www.youtube.com/')">
- <link>
- <label><xsl:value-of select="normalize-space(.)" /></label>
- <stream>wvt:///www.youtube.com/videopage.xsl?srcurl=<xsl:value-of select="str:encode-uri($url, true())"/></stream>
- <ref>wvt:///www.youtube.com/description.xsl?srcurl=<xsl:value-of select="str:encode-uri(concat('http://gdata.youtube.com/feeds/api/videos/', substring-after($url, 'v='), '?v=2'), true())"/></ref>
- </link>
- </xsl:when>
-
- <xsl:when test="starts-with($url, 'http://video.google.com/')">
- <link>
- <label><xsl:value-of select="normalize-space(.)"/></label>
- <stream>wvt:///video.google.com/videopage.xsl?srcurl=<xsl:value-of select="str:encode-uri($url, true())"/></stream>
- <ref>wvt:///video.google.com/description.xsl?srcurl=<xsl:value-of select="str:encode-uri($url, true())"/></ref>
- </link>
- </xsl:when>
-
- <xsl:when test="starts-with($url, 'http://www.metacafe.com/')">
- <link>
- <label><xsl:value-of select="normalize-space(.)"/></label>
- <stream>wvt:///www.metacafe.com/videopage.xsl?srcurl=<xsl:value-of select="str:encode-uri($url, true())"/></stream>
- <ref>wvt:///www.metacafe.com/description.xsl?srcurl=<xsl:value-of select="str:encode-uri($url, true())"/></ref>
- </link>
- </xsl:when>
-
- </xsl:choose>
- </xsl:for-each>
-
- <xsl:for-each select="id('nav')//td[@class='b']/a">
- <link>
- <label><xsl:value-of select="span[2]/text()"/></label>
- <ref>wvt:///video.google.com/searchresults.xsl?srcurl=<xsl:value-of select="str:encode-uri(@href, true())"/></ref>
- </link>
- </xsl:for-each>
+ <xsl:apply-templates select="//a[starts-with(@href, 'http://video.google.com/videoplay?')]"/>
</xsl:otherwise>
</xsl:choose>
diff --git a/templates/video.google.com/videopage.xsl b/templates/video.google.com/videopage.xsl
index 52d6d98..802fc1b 100644
--- a/templates/video.google.com/videopage.xsl
+++ b/templates/video.google.com/videopage.xsl
@@ -4,15 +4,22 @@
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:str="http://exslt.org/strings">
+<xsl:template match="script">
+ <xsl:variable name="videourl">
+ <xsl:value-of select="str:decode-uri(substring-before(substring-after(., 'videoUrl\x3d'), '\x26'))"/>
+ </xsl:variable>
+
+ <xsl:if test="$videourl">
+ <url>
+ <xsl:value-of select="$videourl"/>
+ </url>
+ </xsl:if>
+</xsl:template>
+
<xsl:template match="/">
<mediaurl>
<title><xsl:value-of select="/html/head/title" /></title>
- <xsl:for-each select="/html/body/script">
- <xsl:variable name="videourl" select="str:decode-uri(substring-before(substring-after(., 'videoUrl\x3d'), '\x26'))"/>
- <xsl:if test="$videourl">
- <url><xsl:value-of select="$videourl"/></url>
- </xsl:if>
- </xsl:for-each>
+ <xsl:apply-templates select="//script[contains(., 'videoUrl\x3d')]"/>
</mediaurl>
</xsl:template>