Putting some organizational logic into the Plugin base class to automatically choose a 'best' quality

This commit is contained in:
Dominik Dabrowski 2012-04-19 18:25:55 +02:00
parent 9b9fcb92fe
commit 28d0110d44
4 changed files with 13 additions and 3 deletions

View File

@ -23,6 +23,16 @@ class Plugin(object):
self.args = args
def get_streams(self):
ranking = ['iphonelow', 'iphonehigh', '240p', '360p', '480p', '720p',
'hd', '1080p', 'live']
streams = self._get_streams()
for rank in reversed(ranking):
if rank in streams:
streams['best'] = streams[rank]
break
return streams
def _get_streams(self):
raise NotImplementedError
def load_plugins(plugins):

View File

@ -69,7 +69,7 @@ class JustinTV(Plugin):
res.append(node.data)
return "".join(res)
def get_streams(self):
def _get_streams(self):
def clean_tag(tag):
if tag[0] == "_":
return tag[1:]

View File

@ -46,7 +46,7 @@ class OwnedTV(Plugin):
if match:
return int(match.group(1))
def get_streams(self):
def _get_streams(self):
channelid = self._get_channel_id(self.url)
if not channelid:

View File

@ -23,7 +23,7 @@ class UStreamTV(Plugin):
if match:
return int(match.group(1))
def get_streams(self):
def _get_streams(self):
def get_amf_value(data, key):
pattern = ("{0}\W\W\W(.+?)\x00").format(key)
match = re.search(bytes(pattern, "ascii"), data)