]> code.delx.au - webdl/commitdiff
Fixed Channel 9
authorJames Bunton <jamesbunton@delx.net.au>
Sun, 24 May 2015 06:54:18 +0000 (16:54 +1000)
committerJames Bunton <jamesbunton@delx.net.au>
Sun, 24 May 2015 06:54:18 +0000 (16:54 +1000)
brightcove.py
common.py

index 9d054d62a141bc3e3b5a4977164e0bae3535741a..863410b3b8569ebf259739909eadb4393ece0528 100644 (file)
@@ -1,7 +1,7 @@
 import re
 import sys
 
-from common import grab_json, download_rtmp, Node, append_to_qs
+from common import grab_json, download_hls, Node, append_to_qs
 
 CH9_TOKEN = "ogxhPgSphIVa2hhxbi9oqtYwtg032io4B4-ImwddYliFWHqS0UfMEw.."
 CH10_TOKEN = "lWCaZyhokufjqe7H4TLpXwHSTnNXtqHxyMvoNOsmYA_GRaZ4zcwysw.."
@@ -21,28 +21,14 @@ class BrightcoveVideoNode(Node):
         desc_url = append_to_qs(BRIGHTCOVE_API, {
             "token": self.token,
             "command": "find_video_by_id",
-            "video_fields": "renditions",
+            "video_fields": "HLSURL",
             "video_id": self.video_id,
         })
-        print "video desc_url", desc_url
-
         doc = grab_json(desc_url, 3600)
+        video_url = doc["HLSURL"]
 
-        best_encoding_rate = 0
-        best_url = None
-        for item in doc['renditions']:
-            encoding_rate = item['encodingRate']
-            if encoding_rate > best_encoding_rate:
-                best_encoding_rate = encoding_rate
-                best_url = item['url']
-
-        if best_url is None:
-            raise Exception("Could not find video URL: " + desc_url)
-
-        vbase, vpath = best_url.split("&")
-        filename = self.title + ".mp4"
-        return download_rtmp(filename, vbase, vpath, HASH_URL)
-
+        filename = self.title + ".ts"
+        return download_hls(filename, video_url)
 
 class BrightcoveRootNode(Node):
     def __init__(self, title, parent, token):
index c2badff307d177f75cc8fa74398eb158a51b03ff..470769042263f0c29cb54907bf595d799a3daca0 100644 (file)
--- a/common.py
+++ b/common.py
@@ -234,12 +234,18 @@ def convert_to_mp4(filename):
 
 def download_hds(filename, video_url, pvswf=None):
     filename = sanify_filename(filename)
-    video_url = video_url.replace("http://", "hds://")
     print "Downloading: %s" % filename
+
+    video_url = video_url.replace("http://", "hds://")
+    if pvswf:
+        param = "%s pvswf=%s" % (video_url, pvswf)
+    else:
+        param = video_url
+
     cmd = [
         "livestreamer",
         "-o", filename,
-        "%s pvswf=%s" % (video_url, pvswf),
+        param,
         "best",
     ]
     if exec_subprocess(cmd):