annotate iview.py @ 0:fa7ca67af8c9

Initial commit of a python program to fetch iview streams using flvstreamer.
author Daniel O'Connor <darius@dons.net.au>
date Thu, 20 Aug 2009 16:48:16 +0930
parents
children f914f08d69f5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
1 #!/usr/bin/env python
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
2
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
3 import exceptions
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
4 import htmlentitydefs
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
5 import re
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
6 import sys
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
7 import time
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
8 import urllib2
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
9 import xml.dom.minidom as minidom
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
10 from xml.parsers.expat import ExpatError
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
11
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
12 confurl = 'http://www.abc.net.au/iview/iview_231_config.xml'
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
13
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
14 pattern = re.compile("&(\w+?);")
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
15
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
16 def descape_entity(m, defs=htmlentitydefs.entitydefs):
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
17 try:
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
18 return defs[m.group(1)]
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
19 except KeyError:
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
20 return m.group(0) # use as is
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
21 def descape(string):
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
22 return pattern.sub(descape_entity, string)
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
23
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
24 def toBool(s):
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
25 if type(s) is bool:
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
26 return s
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
27 s = str(s).strip().lower()
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
28 return not s[0] in ['f','n','0']
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
29
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
30 class NoAsset(exceptions.Exception):
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
31 pass
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
32
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
33 class Series(object):
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
34 def __init__(self, seriesElem):
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
35 self.id = seriesElem.getAttribute("id")
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
36 self.url = seriesElem.getAttribute("href")
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
37
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
38 # Fetch titles and so on
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
39 #print "Fetching series URL " + self.url
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
40 xmlp = minidom.parse(urllib2.urlopen(self.url))
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
41 self.title = self.gatherChildren(xmlp.getElementsByTagName("title"))
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
42 self.descr = self.gatherChildren(xmlp.getElementsByTagName("description"))
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
43
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
44 # No asset means unpublished?
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
45 assets = xmlp.getElementsByTagName("abc:videoAsset")
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
46 if len(assets) == 0:
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
47 raise NoAsset
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
48
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
49 self.asset = assets[0].childNodes[0].data.rstrip('.flv')
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
50
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
51 rating = xmlp.getElementsByTagName("abc:rating")[0].childNodes
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
52 if len(rating) > 0:
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
53 self.rating = descape(rating[0].data)
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
54 else:
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
55 self.rating = "unrated"
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
56
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
57 self.imgurl = xmlp.getElementsByTagName("image")[0].getElementsByTagName("url")[0].childNodes[0].data
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
58 self.expiry = time.strptime(xmlp.getElementsByTagName("abc:expireDate")[0].childNodes[0].data ,
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
59 '%d/%m/%Y %H:%M:%S')
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
60
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
61 def gatherChildren(self, elemList):
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
62 rtn = []
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
63 for e in elemList:
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
64 if len(e.childNodes) > 0:
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
65 rtn.append(descape(e.childNodes[0].data.strip()))
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
66 return rtn
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
67
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
68 class Channel(object):
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
69 def __init__(self, chanElem):
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
70 self.id = chanElem.getAttribute("id")
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
71 self.sort = chanElem.getAttribute("sort")
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
72 self.path = chanElem.getAttribute("path")
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
73 self.thumb = chanElem.getAttribute("thumb")
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
74 self.name = descape(chanElem.getElementsByTagName("name")[0].childNodes[0].data)
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
75 self.descr = descape(chanElem.getElementsByTagName("description")[0].childNodes[0].data)
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
76 self.series = []
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
77
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
78 def getSeries(self):
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
79 # This can take ages
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
80 print "Fetching series for channel " + self.name
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
81 # Series is nested for some reason
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
82 xmlp = minidom.parse(urllib2.urlopen(self.path))
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
83 nl = xmlp.getElementsByTagName("series")[0]
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
84 for s in nl.getElementsByTagName("series"):
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
85 try:
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
86 self.series.append(Series(s))
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
87 except ExpatError:
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
88 print "Unable to parse XML, skipping"
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
89 continue
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
90 except NoAsset:
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
91 print "No asset tag, skipping"
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
92 continue
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
93
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
94 class IView(object):
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
95 def __init__(self):
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
96 # Fetch and parse config URL
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
97 #print "Fetching configuration URL"
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
98 xmlp = minidom.parse(urllib2.urlopen(confurl))
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
99 self.params = {}
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
100 for param in xmlp.getElementsByTagName("param"):
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
101 self.params[param.getAttribute("name")] = param.getAttribute("value")
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
102
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
103 # Get token & metered status from auth_path URL
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
104 #print "Fetching authorisation information"
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
105 self.getAuth()
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
106
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
107 # Build channel list
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
108 #print "Fetching channel list"
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
109 xmlp = minidom.parse(urllib2.urlopen(self.params['base_url'] + '/' + self.params['xml_channels']))
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
110 self.channels = []
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
111 for chan in xmlp.getElementsByTagName("channel"):
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
112 self.channels.append(Channel(chan))
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
113
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
114 def getAuth(self):
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
115 xmlp = minidom.parse(urllib2.urlopen(self.params['auth_path']))
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
116 self.token = xmlp.getElementsByTagName("token")[0].childNodes[0].data
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
117 self.metered = not toBool(xmlp.getElementsByTagName("free")[0].childNodes[0].data)
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
118
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
119 server = xmlp.getElementsByTagName("server")[0].childNodes
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
120 if len(server) == 0:
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
121 self.rtmp = self.params['server_streaming'].rstrip('/ondemand') + '////' + self.params['media_path']
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
122 self.tcurl = self.params['server_streaming']
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
123 else:
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
124 self.rtmp = xmlp.getElementsByTagName("server")[0].childNodes[0].data
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
125 self.tcurl = None
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
126
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
127 def genFetchCmd(self, series, outfile):
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
128 cmd = ['-m', '1200']
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
129 if self.tcurl == None:
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
130 cmd += ['-r', self.rtmp + '?auth=' + self.token]
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
131 cmd += ['-y', series.asset]
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
132 else:
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
133 cmd += ['-r', self.rtmp + series.asset]
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
134 cmd += ['-t', self.tcurl + '?auth=' + self.token]
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
135 cmd += ['-o', outfile]
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
136 return cmd
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
137
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
138 # Non-metered:
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
139 #/home/darius/projects/flvstreamer/flvstreamer_x86
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
140 # -r rtmp://cp53909.edgefcs.net////flash/playback/_definst_/catch_up/compass_09_23_28
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
141 # -t rtmp://cp53909.edgefcs.net/ondemand?auth=daEbFbibab6d4c0cwdjcwcya4dTb9cucucw-bkJnTd-8-klt_rFzqL&aifp=v001
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
142 # -o ./compass_09_23_28.flv -m 1200