The branch, frodo has been updated
       via  1090a4f6fa3ae114932014fe7d19575ef683389c (commit)
      from  0301f5e24a280b9387090e534ffcc7a0894d2088 (commit)

- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/plugins;a=commit;h=1090a4f6fa3ae114932014fe7d19575ef683389c

commit 1090a4f6fa3ae114932014fe7d19575ef683389c
Author: kibje <[email protected]>
Date:   Thu Jun 20 14:02:53 2013 +0200

    [plugin.video.oppetarkiv] updated to version 0.2.3

diff --git a/plugin.video.oppetarkiv/README.md 
b/plugin.video.oppetarkiv/README.md
index 23cedd0..9fa2f4e 100755
--- a/plugin.video.oppetarkiv/README.md
+++ b/plugin.video.oppetarkiv/README.md
@@ -1,5 +1,5 @@
 # XBMC Öppet Arkiv addon
-# 0.2.1
+# 0.2.3
 Forked from nielzen/xbmc-svtplay
 
 This addon is used to stream videos from www.oppetarkiv.se
diff --git a/plugin.video.oppetarkiv/addon.xml 
b/plugin.video.oppetarkiv/addon.xml
index 887691b..2bc0406 100755
--- a/plugin.video.oppetarkiv/addon.xml
+++ b/plugin.video.oppetarkiv/addon.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <addon id="plugin.video.oppetarkiv"
        name="Öppet Arkiv"
-       version="0.2.2"
+       version="0.2.3"
        provider-name="khoda">
   <requires>
     <import addon="script.module.parsedom" version="1.2.0"/>
diff --git a/plugin.video.oppetarkiv/changelog.txt 
b/plugin.video.oppetarkiv/changelog.txt
index 03e97a9..65d8e2d 100755
--- a/plugin.video.oppetarkiv/changelog.txt
+++ b/plugin.video.oppetarkiv/changelog.txt
@@ -1,3 +1,7 @@
+Version 0.2.3
+-------------
+- Added search functionality (linqan)
+
 Version 0.2.2
 -------------
 - Added fanart (linqan)
diff --git a/plugin.video.oppetarkiv/default.py 
b/plugin.video.oppetarkiv/default.py
index 49ed0d6..9f62797 100755
--- a/plugin.video.oppetarkiv/default.py
+++ b/plugin.video.oppetarkiv/default.py
@@ -77,7 +77,7 @@ LOW_BANDWIDH   = LOW_BANDWIDTH
 def viewStart():
 
   addDirectoryItem(localize(30000), { "mode": MODE_A_TO_O })
-
+  addDirectoryItem(localize(30006), { "mode": MODE_SEARCH })
   
 def viewAtoO():
   programs = svt.getAtoO()
@@ -96,20 +96,36 @@ def viewProgram(url,page,index):
 
 
 def viewSearch():
-
-  keyword = common.getUserInput(localize(30102))
-  if keyword == "" or not keyword:
+  query = common.getUserInput(localize(30102))
+  if query == "" or not query:
     viewStart()
     return
-  keyword = urllib.quote(keyword)
-  common.log("Search string: " + keyword)
+  query = urllib.quote(query)
+  common.log("Search string: " + query)
 
-  keyword = re.sub(r" ","+",keyword) 
+  query = re.sub(r" ", "+", query)
+  page = 1
+  results = True
 
-  url = svt.URL_TO_SEARCH + keyword
-  
-  createTabIndex(url)
+  while results:
+    results = viewSearchPageResult(query, page)
+    if not results:
+      break
 
+    if svt.hasMoreResults(query, page):
+      page = page + 1
+    else:
+      results = False 
+
+def viewSearchPageResult(query, page):
+  programs = svt.getSearchResult(query, page)
+
+  if not programs:
+    return False  
+
+  for program in programs:
+    addDirectoryItem(program["title"], { "mode": MODE_VIDEO, "url": 
program["url"] }, False, False, program["info"])
+  return True
 
 
 def viewPageResults(url,mode,page,index):
diff --git a/plugin.video.oppetarkiv/resources/lib/svt.py 
b/plugin.video.oppetarkiv/resources/lib/svt.py
index cb18f93..c97af17 100755
--- a/plugin.video.oppetarkiv/resources/lib/svt.py
+++ b/plugin.video.oppetarkiv/resources/lib/svt.py
@@ -16,7 +16,8 @@ URL_CATEGORIES = "/kategori/titel"
 URL_TO_LATEST = "?tab=episodes&sida=1"
 URL_TO_LATEST_NEWS = "?tab=news&sida=1"
 URL_TO_RECOMMENDED = "?tab=recommended&sida=1"
-URL_TO_SEARCH = "/sok?q="
+URL_TO_SEARCH = "/sok/?q="
+URL_TO_SEARCH_PAGE = "&sida="
 
 JSON_SUFFIX = "?output=json"
 
@@ -157,6 +158,53 @@ def getArticles(url,page,tabname=None):
  
   return newarticles
 
+def getSearchResult(query, page):
+  """
+  Returns the search results from a search query.
+
+  Return result is a list of article objects.
+  """
+  page = getPage(URL_TO_SEARCH + query + URL_TO_SEARCH_PAGE + str(page))
+
+  container = common.parseDOM(page, "div", attrs = { "class": 
"[^\"']*svtoa-js-searchlist[^\"']*" })
+  if not container:
+    common.log("Could not find svtjs-toogle-group!")
+    return None
+
+  articles = common.parseDOM(container, "article")
+  if not articles:
+    common.log("No articles could be found!")
+    return None
+  
+  newarticles = []
+  for article in articles:
+    newarticle = {}
+    newarticle["url"] = common.parseDOM(article, "a", ret = "href")[0]
+    thumbnail = common.parseDOM(article, "img", ret = "src")[0]
+    thumbnail = helper.prepareThumb(thumbnail)
+    newarticle["thumbnail"] = thumbnail
+    title = common.parseDOM(article, "h2")[0]
+    title = common.parseDOM(title, "a")[0]
+    title = common.replaceHTMLCodes(title)
+    newarticle["title"] = title
+    newarticle["info"] = { "title": title }
+    newarticles.append(newarticle)
+
+  return newarticles
+
+def hasMoreResults(query, page):
+    """
+    Checks if more search results exists for a search result page.
+    Check for the "Visa fler" link in the bottom of the page.
+    """
+    page = getPage(URL_TO_SEARCH + query + URL_TO_SEARCH_PAGE + str(page))
+
+    link = common.parseDOM(page, "a", attrs = { "class": 
"[^\"']*svtoa-js-search-step-button[^\"']*" })
+
+    if link:
+        return True
+    else:
+        return False
 
 def getPage(url):
   """

-----------------------------------------------------------------------

Summary of changes:
 plugin.video.oppetarkiv/README.md                  |    2 +-
 plugin.video.oppetarkiv/addon.xml                  |    2 +-
 plugin.video.oppetarkiv/changelog.txt              |    4 ++
 plugin.video.oppetarkiv/default.py                 |   36 ++++++++++----
 .../resources/language/.DS_Store                   |  Bin 0 -> 6148 bytes
 plugin.video.oppetarkiv/resources/lib/svt.py       |   50 +++++++++++++++++++-
 6 files changed, 81 insertions(+), 13 deletions(-)
 create mode 100644 plugin.video.oppetarkiv/resources/language/.DS_Store


hooks/post-receive
-- 
Plugins

------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons

Reply via email to