From 911e572cfe5495bffd9e96573e0ddaeae94de9af Mon Sep 17 00:00:00 2001 From: Pavlos Touboulidis Date: Wed, 30 Nov 2016 21:42:19 +0200 Subject: [PATCH] Fix the antenna plugin to work with the updated site --- src/livestreamer/plugins/antenna.py | 33 ++++++++++------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/src/livestreamer/plugins/antenna.py b/src/livestreamer/plugins/antenna.py index bca7470a..2555227d 100644 --- a/src/livestreamer/plugins/antenna.py +++ b/src/livestreamer/plugins/antenna.py @@ -3,12 +3,10 @@ from livestreamer.plugin import Plugin from livestreamer.plugin.api import http, validate -from livestreamer.stream import HDSStream +from livestreamer.stream import HLSStream -_url_re = re.compile("(http(s)?://(\w+\.)?antenna.gr)/webtv/watch\?cid=.+") -_playlist_re = re.compile("playlist:\s*\"(/templates/data/jplayer\?cid=[^\"]+)") -_manifest_re = re.compile("jwplayer:source\s+file=\"([^\"]+)\"") -_swf_re = re.compile("(http[^<]+)") +_url_re = re.compile("(http(s)?://(\w+\.)?antenna.gr)/minisites/[^/]+/watch/.+") +_playlist_re = re.compile("/Services/jwplayer/getplaylistJson.ashx\?mid=[^&]+&show=[^&]+") class Antenna(Plugin): @classmethod @@ -17,33 +15,24 @@ def can_handle_url(self, url): def _get_streams(self): - # Discover root + # Discover site root match = _url_re.search(self.url) root = match.group(1) # Download main URL res = http.get(self.url) - # Find playlist + # Find URL of JSON playlist match = _playlist_re.search(res.text) - playlist_url = root + match.group(1) + "d" + playlist_url = root + match.group(0) - # Download playlist + # Download JSON playlist res = http.get(playlist_url) - # Find manifest - match = _manifest_re.search(res.text) - manifest_url = match.group(1) + # Get URL of m3u8 playlist + res = json.loads(res.text) + res = res['url'] - # Find SWF - match = _swf_re.search(res.text) - swf_url = match.group(1); - - streams = {} - streams.update( - HDSStream.parse_manifest(self.session, manifest_url, pvswf=swf_url) - ) - - return streams + return HLSStream.parse_variant_playlist(self.session, res) __plugin__ = Antenna