aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Dominik Dabrowski <dominik@silberrock.com>2012-04-19 18:25:55 +0200
committerGravatar Dominik Dabrowski <dominik@silberrock.com>2012-04-19 18:25:55 +0200
commit28d0110d44a9a78233dfc829d5510a2c02c264d1 (patch)
tree241c6d46dca964d82af0de9378b7e47f744bc928 /src
parent9b9fcb92fe5d51d0b5f487f669bba34dcf8cb247 (diff)
Putting some organizational logic into the Plugin base class to automatically choose a 'best' quality
Diffstat (limited to 'src')
-rw-r--r--src/livestreamer/plugins/__init__.py10
-rw-r--r--src/livestreamer/plugins/justintv.py2
-rw-r--r--src/livestreamer/plugins/ownedtv.py2
-rw-r--r--src/livestreamer/plugins/ustreamtv.py2
4 files changed, 13 insertions, 3 deletions
diff --git a/src/livestreamer/plugins/__init__.py b/src/livestreamer/plugins/__init__.py
index cf6954b..a4e39cc 100644
--- a/src/livestreamer/plugins/__init__.py
+++ b/src/livestreamer/plugins/__init__.py
@@ -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):
diff --git a/src/livestreamer/plugins/justintv.py b/src/livestreamer/plugins/justintv.py
index b21f9a4..16c522c 100644
--- a/src/livestreamer/plugins/justintv.py
+++ b/src/livestreamer/plugins/justintv.py
@@ -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:]
diff --git a/src/livestreamer/plugins/ownedtv.py b/src/livestreamer/plugins/ownedtv.py
index ab9c479..e2ccf94 100644
--- a/src/livestreamer/plugins/ownedtv.py
+++ b/src/livestreamer/plugins/ownedtv.py
@@ -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:
diff --git a/src/livestreamer/plugins/ustreamtv.py b/src/livestreamer/plugins/ustreamtv.py
index 5f120f5..a30e695 100644
--- a/src/livestreamer/plugins/ustreamtv.py
+++ b/src/livestreamer/plugins/ustreamtv.py
@@ -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)