annotate iview.py @ 5:f2e0787f52b8 default tip

Tidy up output to be clearer. - Don't bother the user with XML errors & lack of asset tags. - Print a header for the channel & series lists. - Inform the user how to navigate the menus.
author Daniel O'Connor <darius@dons.net.au>
date Fri, 21 Aug 2009 13:05:59 +0930
parents f914f08d69f5
children
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):
1
f914f08d69f5 Don't re-get series info if we already have it as it's very slow.
Daniel O'Connor <darius@dons.net.au>
parents: 0
diff changeset
79 if len(self.series) > 0:
f914f08d69f5 Don't re-get series info if we already have it as it's very slow.
Daniel O'Connor <darius@dons.net.au>
parents: 0
diff changeset
80 return
0
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
81 # 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
82 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
83 # 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
84 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
85 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
86 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
87 try:
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
88 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
89 except ExpatError:
5
f2e0787f52b8 Tidy up output to be clearer.
Daniel O'Connor <darius@dons.net.au>
parents: 1
diff changeset
90 #print "Unable to parse XML, skipping"
0
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
91 continue
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
92 except NoAsset:
5
f2e0787f52b8 Tidy up output to be clearer.
Daniel O'Connor <darius@dons.net.au>
parents: 1
diff changeset
93 #print "No asset tag, skipping"
0
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
94 continue
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
95
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
96 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
97 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
98 # 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
99 #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
100 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
101 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
102 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
103 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
104
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
105 # 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
106 #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
107 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
108
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
109 # 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
110 #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
111 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
112 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
113 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
114 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
115
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
116 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
117 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
118 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
119 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
120
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
121 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
122 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
123 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
124 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
125 else:
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
126 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
127 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
128
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
129 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
130 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
131 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
132 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
133 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
134 else:
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 += ['-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
136 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
137 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
138 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
139
fa7ca67af8c9 Initial commit of a python program to fetch iview streams using flvstreamer.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
140 # 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
141 #/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
142 # -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
143 # -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
144 # -o ./compass_09_23_28.flv -m 1200