Skip to content

Commit

Permalink
Merge pull request #468 from chhe/gaming-live
Browse files Browse the repository at this point in the history
Added plugin for gaminglive.tv.
  • Loading branch information
chrippa committed Aug 2, 2014
2 parents c2f8451 + 0c44cba commit 5c92af1
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 1 deletion.
8 changes: 8 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,18 @@ N: Agustín Carrasco
G: asermax
D: Crunchyroll plugin.

N: Che
G: chhe
D: Added plugin for gaminglive.tv.

N: Sam Edwards
G: dotsam
D: ilive.to plugin fixes.

N: Vitaly Evtushenko
G: eltiren
D: Added plugin for goodgame.ru.

N: Gaspard Jankowiak
G: gapato
D: Added a DailyMotion plugin.
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ CLI:

Plugins:
- Added plugin for GoodGame.ru (goodgame), patch by @eltiren. (#466)
- Added plugin for gaminglive.tv (gaminglive), patch by @chhe. (#468)
- hitbox: Added support for HLS videos.

API:
Expand Down
1 change: 1 addition & 0 deletions docs/plugin_matrix.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ euronews euronews.com Yes No
filmon filmon.com Yes Yes Only SD quality streams.
filmon_us filmon.us Yes Yes
furstream furstre.am Yes No
gaminglive gamlinglive.tv Yes No
gomexp gomexp.com Yes No
goodgame goodgame.ru Yes No Only HLS streams are available.
hitbox hitbox.tv Yes Yes
Expand Down
2 changes: 1 addition & 1 deletion src/livestreamer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"Martin Panter", "t0mm0", "Agustin Carrasco", "Andy Mikhailenko",
"unintended", "Moritz Blanke", "Jon Bergli Heier", "Stefan Breunig",
"papplampe", "Brian Callahan", "Eric J", "Jan Tore Morken", "JOKer",
"Max Nordlund", "yeeeargh"
"Max Nordlund", "yeeeargh", "Vitaly Evtushenko", "Che"
]


Expand Down
75 changes: 75 additions & 0 deletions src/livestreamer/plugins/gaminglive.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import re

from livestreamer.plugin import Plugin
from livestreamer.plugin.api import http, validate
from livestreamer.stream import RTMPStream

CHANNELS_API_URL = "http://api.gaminglive.tv/channels/{0}"
QUALITY_WEIGHTS = {
"live": 3,
"medium": 2,
"low": 1,
}

_url_re = re.compile("""
http(s)?://(staging|alpha)\.gaminglive\.tv
/\#/channels/(?P<channel>[^/]+)
""", re.VERBOSE)
_quality_re = re.compile("[^/]+-(?P<quality>[^/]+)")

_channel_schema = validate.Schema(
{
validate.optional("state"): {
"stream": {
"qualities": [validate.text],
"rootUrl": validate.url(scheme="rtmp")
}
}
},
validate.get("state")
)


class GamingLive(Plugin):
@classmethod
def can_handle_url(self, url):
return _url_re.match(url)

@classmethod
def stream_weight(cls, key):
weight = QUALITY_WEIGHTS.get(key)
if weight:
return weight, "gaminglive"

return Plugin.stream_weight(key)

def _get_quality(self, label):
match = _quality_re.match(label)
if match:
return match.group("quality")

return "live"

def _get_streams(self):
match = _url_re.match(self.url)
channel = match.group("channel")

res = http.get(CHANNELS_API_URL.format(channel))
json = http.json(res, schema=_channel_schema)
if not json:
return

streams = {}
for quality in json["stream"]["qualities"]:
stream_name = self._get_quality(quality)
stream = RTMPStream(self.session, {
"rtmp": json["stream"]["rootUrl"],
"playpath": quality,
"pageUrl": self.url
})
streams[stream_name] = stream

return streams


__plugin__ = GamingLive

0 comments on commit 5c92af1

Please sign in to comment.