The branch, frodo has been updated
       via  991559c5db9f9e13b3e43466bea6d6dca4cc506c (commit)
      from  1d3776f847da7ec9b8b24396556393344a4bca76 (commit)

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

commit 991559c5db9f9e13b3e43466bea6d6dca4cc506c
Author: beenje <[email protected]>
Date:   Tue Jan 22 22:20:57 2013 +0100

    [plugin.video.svtplay] updated to version 3.1.3

diff --git a/plugin.video.svtplay/addon.xml b/plugin.video.svtplay/addon.xml
index 87ca63f..d1d46a3 100644
--- a/plugin.video.svtplay/addon.xml
+++ b/plugin.video.svtplay/addon.xml
@@ -1,11 +1,11 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <addon id="plugin.video.svtplay"
        name="SVT Play"
-       version="3.1.2"
+       version="3.1.3"
        provider-name="nilzen">
   <requires>
     <import addon="script.module.parsedom" version="1.2.0"/>
-    <import addon="xbmc.python" version="2.1"/>
+    <import addon="xbmc.python" version="2.1.0"/>
   </requires>
   <extension point="xbmc.python.pluginsource" library="default.py">
     <provides>video</provides>
diff --git a/plugin.video.svtplay/changelog.txt 
b/plugin.video.svtplay/changelog.txt
index 7322249..f89da98 100644
--- a/plugin.video.svtplay/changelog.txt
+++ b/plugin.video.svtplay/changelog.txt
@@ -1,3 +1,7 @@
+Version 3.1.3
+-------------
+- Added handling of programs with multiple MP4 streams (linqcan)
+
 Version 3.1.2
 -------------
 - Restored playback on Apple TV 2 (by linqcan)
diff --git a/plugin.video.svtplay/default.py b/plugin.video.svtplay/default.py
index 056c074..451f75c 100644
--- a/plugin.video.svtplay/default.py
+++ b/plugin.video.svtplay/default.py
@@ -26,6 +26,7 @@ MODE_SEARCH_EPISODES = "search_episodes"
 MODE_SEARCH_CLIPS = "search_clips"
 
 BASE_URL = "http://www.svtplay.se";
+SWF_URL = "http://www.svtplay.se/public/swf/video/svtplayer-2012.51.swf"; 
 
 URL_A_TO_O = "/program"
 URL_CATEGORIES = "/kategorier"
@@ -527,25 +528,31 @@ def startVideo(url):
   player = xbmc.Player()
   startTime = time.time()
   videoUrl = None
-  hlsvideo = False
+  extension = "None"
 
   for video in jsonObj["video"]["videoReferences"]:
-    if video["url"].find(".m3u8") > 0:
+    """
+    Determine which file extension that will be used
+    m3u8 is preferred, hence the break.
+    Order: m3u8, f4m, mp4, flv
+    """
+    if video["url"].endswith(".m3u8"):
+      extension = "HLS"
       videoUrl = video["url"]
-      hlsvideo = True
       break
-    if video["url"].endswith(".flv"):
+    if video["url"].endswith(".f4m"):
+      extension = "F4M"
       videoUrl = video["url"]
-      break
+      continue
     if video["url"].endswith(".mp4"):
+      extension = "MP4"
       videoUrl = video["url"]
-      break
-    else:
-      if video["url"].endswith("/manifest.f4m"):
-        videoUrl = video["url"].replace("/z/", "/i/").replace("/manifest.f4m", 
"/master.m3u8")
-        hlsvideo = True
-      else:
-        common.log("Skipping unknown filetype: " + video["url"])
+      continue
+    if video["url"].endswith(".flv"):
+      extension = "FLV"
+      videoUrl = video["url"]
+      continue
+    videoUrl = video["url"]
 
   for sub in jsonObj["video"]["subtitleReferences"]:
     if sub["url"].endswith(".wsrt"):
@@ -554,11 +561,25 @@ def startVideo(url):
       if len(sub["url"]) > 0:
         common.log("Skipping unknown subtitle: " + sub["url"])
 
-  if hlsvideo and HLS_STRIP:
-      videoUrl = hlsStrip(videoUrl)
+  if extension == "HLS" and HLS_STRIP:
+    videoUrl = hlsStrip(videoUrl)
+
+  if extension == "F4M":
+    videoUrl = videoUrl.replace("/z/", 
"/i/").replace("manifest.f4m","master.m3u8")
+
+  if extension == "MP4":
+    videoUrl = mp4Handler(jsonObj)
+
+  if extension == "None":
+    # No supported video was found
+    common.log("No supported video extension found for URL: " + videoUrl)
+    videoUrl = None
 
   if videoUrl:
 
+    if extension == "MP4" and videoUrl.startswith("rtmp://"):
+      videoUrl = videoUrl + " swfUrl="+SWF_URL+" swfVfy=1"
+ 
     xbmcplugin.setResolvedUrl(pluginHandle, True, 
xbmcgui.ListItem(path=videoUrl))
 
     if subtitle:
@@ -574,6 +595,40 @@ def startVideo(url):
     dialog = xbmcgui.Dialog()
     dialog.ok("SVT PLAY", localize(30100))
 
+def mp4Handler(jsonObj):
+  """
+  If there are several mp4 streams in the json object:
+  pick the one with the highest bandwidth.
+
+  Some programs are available with multiple mp4 streams
+  for different bitrates. This function ensures that the one
+  with the highest bitrate is chosen.
+
+  Can possibly be extended to support some kind of quality
+  setting in the plugin.
+  """
+  videos = []
+
+  # Find all mp4 videos
+  for video in jsonObj["video"]["videoReferences"]:
+    if video["url"].endswith(".mp4"):
+      videos.append(video)
+  
+  if len(videos) == 1:
+    return videos[0]["url"]
+
+  bitrate = 0
+  url = ""
+
+  # Find the video with the highest bitrate
+  for video in videos:
+    if video["bitrate"] > bitrate:
+      bitrate = video["bitrate"]
+      url = video["url"]          
+
+  common.log("mp4 handler info: bitrate="+str(bitrate)+" url="+url)
+  return url
+
 def hlsStrip(videoUrl):
     """
     Extracts the stream that supports the

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

Summary of changes:
 plugin.video.svtplay/addon.xml     |    4 +-
 plugin.video.svtplay/changelog.txt |    4 ++
 plugin.video.svtplay/default.py    |   83 ++++++++++++++++++++++++++++++------
 3 files changed, 75 insertions(+), 16 deletions(-)


hooks/post-receive
-- 
Plugins

------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons

Reply via email to