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

Added plugin: Disney and Disney Channel Germany #698

Merged
merged 1 commit into from
Jan 25, 2015
Merged
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
43 changes: 43 additions & 0 deletions src/livestreamer/plugins/disney_de.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""Plugin for Disney (Channel) Germany

Supports:
- http://video.disney.de/sehen/*
- http://disneychannel.de/sehen/*
- http://disneychannel.de/livestream
"""

import re
import json

from livestreamer.plugin import Plugin
from livestreamer.plugin.api import http
from livestreamer.stream import HLSStream

_url_re = re.compile("http(s)?://(\w+\.)?disney(channel)?.de/")
HTTP_HEADERS = {
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1944.9 Safari/537.36"
}

# stream urls are in `Grill.burger`->stack->data->externals->data
_stream_hls_re = re.compile("\"hlsStreamUrl\":\s*(\"[^\"]+\")")
_stream_data_re = re.compile("\"dataUrl\":\s*(\"[^\"]+\")")


class DisneyDE(Plugin):
@classmethod
def can_handle_url(cls, url):
return _url_re.match(url)

def _get_streams(self):
html = http.get(self.url, headers=HTTP_HEADERS).content

url_match = _stream_hls_re.search(html)
if url_match is None:
url_match = _stream_data_re.search(html)

stream_url = json.loads(url_match.group(1))

return HLSStream.parse_variant_playlist(self.session, stream_url)


__plugin__ = DisneyDE