Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring and update for the VOD support #1450

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions src/livestreamer/plugins/livecodingtv.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import re

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


_vod_re = re.compile('\"(http(s)?://.*\.mp4\?t=.*)\"')
_rtmp_re = re.compile('rtmp://[^"]+/(?P<channel>\w+)+[^/"]+')
_url_re = re.compile("http(s)?://(?:\w+.)?\livecoding\.tv")
_url_re = re.compile('http(s)?://(?:\w+.)?\livecoding\.tv')


class LivecodingTV(Plugin):
Expand All @@ -16,19 +16,18 @@ def can_handle_url(cls, url):

def _get_streams(self):
res = http.get(self.url)
match = _rtmp_re.search(res.text)
rtmp_url = match.group(0)

if not match:
match = _rtmp_re.search(res.content)
if match:
params = {
"rtmp": match.group(0),
"pageUrl": self.url,
"live": True,
}
yield 'live', RTMPStream(self.session, params)
return

stream = RTMPStream(self.session, {
"rtmp": rtmp_url,
"pageUrl": self.url,
"live": True,
})

return dict(live=stream)

match = _vod_re.search(res.content)
if match:
yield 'vod', HTTPStream(self.session, match.group(1))

__plugin__ = LivecodingTV