[senat.pl] support for live videos
This commit is contained in:
parent
12a935cf42
commit
a0986f874d
|
@ -1113,7 +1113,7 @@ from .sejmpl import (
|
||||||
SejmPlVideoIE,
|
SejmPlVideoIE,
|
||||||
)
|
)
|
||||||
from .senateisvp import SenateISVPIE
|
from .senateisvp import SenateISVPIE
|
||||||
from .senatpl import SenatPlArchivalIE
|
from .senatpl import SenatPlIE
|
||||||
from .sendtonews import SendtoNewsIE
|
from .sendtonews import SendtoNewsIE
|
||||||
from .servus import ServusIE
|
from .servus import ServusIE
|
||||||
from .sevenplus import SevenPlusIE
|
from .sevenplus import SevenPlusIE
|
||||||
|
|
|
@ -5,9 +5,9 @@ from .common import InfoExtractor
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
|
||||||
class SenatPlArchivalIE(InfoExtractor):
|
class SenatPlIE(InfoExtractor):
|
||||||
_VALID_URL = r'https://av8\.senat\.pl/(?P<id>\d+[a-zA-Z\d]+)'
|
_VALID_URL = r'https://av8\.senat\.pl/(?P<id>\d+[a-zA-Z\d]+)'
|
||||||
IE_NAME = 'senat.pl:archival'
|
IE_NAME = 'senat.gov.pl'
|
||||||
|
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'https://av8.senat.pl/10Sen221',
|
'url': 'https://av8.senat.pl/10Sen221',
|
||||||
|
@ -20,11 +20,15 @@ class SenatPlArchivalIE(InfoExtractor):
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
|
webpage = self._download_webpage(url, video_id)
|
||||||
|
res_type = self._search_regex(
|
||||||
|
r'<script [^>]+ src="/senat-console/static/js/generated/(vod|live)\.item\.js">',
|
||||||
|
webpage, 'resource type')
|
||||||
vod = self._download_json(
|
vod = self._download_json(
|
||||||
'https://av8.senat.pl/senat-console/side-menu/transmissions/%s/vod' % video_id,
|
'https://av8.senat.pl/senat-console/side-menu/transmissions/%s/%s' % (video_id, res_type),
|
||||||
video_id, 'Downloading transmission metadata')
|
video_id, 'Downloading transmission metadata')
|
||||||
conf = self._download_json(
|
conf = self._download_json(
|
||||||
'https://av8.senat.pl/senat-console/side-menu/transmissions/%s/vod/player-configuration' % video_id,
|
'https://av8.senat.pl/senat-console/side-menu/transmissions/%s/%s/player-configuration' % (video_id, res_type),
|
||||||
video_id, 'Downloading player configuration')
|
video_id, 'Downloading player configuration')
|
||||||
|
|
||||||
def unix_milliseconds_to_wtf_atende_wants(date):
|
def unix_milliseconds_to_wtf_atende_wants(date):
|
||||||
|
@ -35,17 +39,32 @@ class SenatPlArchivalIE(InfoExtractor):
|
||||||
return int(date.timestamp() * 1000)
|
return int(date.timestamp() * 1000)
|
||||||
|
|
||||||
start_time = unix_milliseconds_to_wtf_atende_wants(vod['since'])
|
start_time = unix_milliseconds_to_wtf_atende_wants(vod['since'])
|
||||||
stop_time = unix_milliseconds_to_wtf_atende_wants(vod['till'])
|
if res_type == 'vod':
|
||||||
|
stop_time = unix_milliseconds_to_wtf_atende_wants(vod['till'])
|
||||||
|
else:
|
||||||
|
stop_time = None
|
||||||
|
|
||||||
duration = (stop_time - start_time) // 1000
|
if stop_time:
|
||||||
|
duration = (stop_time - start_time) // 1000
|
||||||
|
else:
|
||||||
|
duration = None
|
||||||
|
|
||||||
entries = []
|
entries = []
|
||||||
|
|
||||||
def add_entry(player):
|
def add_entry(player):
|
||||||
|
trans_url = f"https:{player['playlist']['flv']}?startTime={start_time}"
|
||||||
|
if stop_time:
|
||||||
|
trans_url += f"&stopTime={stop_time}"
|
||||||
|
stream_id = self._search_regex(
|
||||||
|
r'/o2/senat/([^/]+)/[^./]+\.livx', trans_url, 'stream id')
|
||||||
entries.append({
|
entries.append({
|
||||||
'_type': 'url_transparent',
|
'_type': 'url_transparent',
|
||||||
'url': f"https:{player['playlist']['flv']}?startTime={start_time}&stopTime={stop_time}",
|
'url': trans_url,
|
||||||
'ie_key': 'SejmPlVideo',
|
'ie_key': 'SejmPlVideo',
|
||||||
|
'id': stream_id,
|
||||||
|
'title': stream_id,
|
||||||
|
'duration': duration,
|
||||||
|
'is_live': res_type == 'live',
|
||||||
})
|
})
|
||||||
|
|
||||||
add_entry(conf['player'])
|
add_entry(conf['player'])
|
||||||
|
@ -60,4 +79,5 @@ class SenatPlArchivalIE(InfoExtractor):
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': vod['title'],
|
'title': vod['title'],
|
||||||
'duration': duration,
|
'duration': duration,
|
||||||
|
'is_live': res_type == 'live',
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue