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

plugins.nrk: Add support for NRK radio streams. #433

Merged
merged 1 commit into from Jul 6, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 11 additions & 9 deletions src/livestreamer/plugins/nrk.py
Expand Up @@ -4,15 +4,13 @@
from livestreamer.plugin.api import http, validate
from livestreamer.stream import HLSStream

COOKIES = {
"NRK_PLAYER_SETTINGS_TV": (
"devicetype=desktop&"
"preferred-player-odm=hlslink&"
"preferred-player-live=hlslink"
)
}
COOKIE_PARAMS = (
"devicetype=desktop&"
"preferred-player-odm=hlslink&"
"preferred-player-live=hlslink"
)

_url_re = re.compile("http://tv.nrk.no/")
_url_re = re.compile("http://(tv|radio).nrk.no/")
_media_url_re = re.compile("""
<div[^>]*?id="playerelement"[^>]+
data-media="(?P<url>[^"]+)"
Expand All @@ -39,7 +37,11 @@ def can_handle_url(self, url):
return _url_re.match(url)

def _get_streams(self):
playlist_url = http.get(self.url, cookies=COOKIES, schema=_schema)
stream_type = _url_re.match(self.url).group(1).upper()
cookie = {
"NRK_PLAYER_SETTINGS_{0}".format(stream_type): COOKIE_PARAMS
}
playlist_url = http.get(self.url, cookies=cookie, schema=_schema)
if not playlist_url:
return

Expand Down