diff --git a/resources/lib/channels/jp/ntvnews24.py b/resources/lib/channels/jp/ntvnews24.py index a39d2f57f..24d7f4c38 100644 --- a/resources/lib/channels/jp/ntvnews24.py +++ b/resources/lib/channels/jp/ntvnews24.py @@ -9,17 +9,30 @@ # noinspection PyUnresolvedReferences from codequick import Resolver +import urlquick +import json + from resources.lib import resolver_proxy, web_utils # TODO # Add Videos, Replays ? -# URL_ROOT = 'http://www.news24.jp' -# URL_LIVE = URL_ROOT + '/livestream/' -URL_LIVE = 'https://news.ntv.co.jp/live' -video_url = 'https://n24-cdn-live.ntv.co.jp/ch01/index.m3u8' +URL_ROOT = 'https://news.ntv.co.jp' +URL_LIVE = URL_ROOT + '/live' +URL_TOKEN = URL_ROOT + '/api/generate-pta' +VIDEO_LIVE = 'https://n24-cdn-live-x.ntv.co.jp/ch01/index.m3u8' @Resolver.register def get_live_url(plugin, item_id, **kwargs): - return resolver_proxy.get_stream_with_quality(plugin, video_url, manifest_type="hls") + headers = { + 'referer': URL_LIVE, + 'User-Agent': web_utils.get_random_ua() + } + + resp = urlquick.get(URL_TOKEN, headers=headers, max_age=-1) + json_parser = json.loads(resp.text) + pta = json_parser['pta'] + video_url = VIDEO_LIVE + '?pta=%s' % pta + + return resolver_proxy.get_stream_with_quality(plugin, video_url)