make php script to extract mpd url from this python script: #…
- User
make php script to extract mpd url from this python script: # ----------------------------------------------------------------------------------------------------------------------
Copyright (c) 2022-2023 Dimitri Kroon.
This file is part of plugin.video.viwx.
SPDX-License-Identifier: GPL-2.0-or-later
See LICENSE.txt
----------------------------------------------------------------------------------------------------------------------
import os import logging
from datetime import datetime, timedelta import pytz import xbmc
from codequick import Script from codequick.support import logger_id
from . import utils from . import fetch from . import kodi_utils
logger = logging.getLogger(logger_id + '.itv')
def get_live_schedule(hours=4, local_tz=None): """Get the schedule of the live channels from now up to the specified number of hours.
""" if local_tz is None: local_tz = pytz.timezone('Europe/London') btz = pytz.timezone('Europe/London') british_now = datetime.now(pytz.utc).astimezone(btz) # Request TV schedules for the specified number of hours from now, in british time from_date = british_now.strftime('%Y%m%d%H%M') to_date = (british_now + timedelta(hours=hours)).strftime('%Y%m%d%H%M') # Note: platformTag=ctv is exactly what a webbrowser sends url = 'https://scheduled.oasvc.itv.com/scheduled/itvonline/schedules?from={}&platformTag=ctv&to={}'.format( from_date, to_date) data = fetch.get_json(url) schedules_list = data.get('_embedded', {}).get('schedule', []) schedule = [element['_embedded'] for element in schedules_list] # Convert British start time to local time and format in the user's regional format # Use local time format without seconds. Fix weird kodi formatting for 12-hour clock. time_format = xbmc.getRegion('time').replace(':%S', '').replace('%I%I:', '%I:') strptime = utils.strptime for channel in schedule: for program in channel['slot']: time_str = program['startTime'][:16] brit_time = btz.localize(strptime(time_str, '%Y-%m-%dT%H:%M')) program['startTime'] = brit_time.astimezone(local_tz).strftime(time_format) program['orig_start'] = program['onAirTimeUTC'][:19] return schedulestream_req_data = { 'client': { 'id': 'browser', 'service': 'itv.x', 'supportsAdPods': False, 'version': '4.1' }, 'device': { 'manufacturer': 'Firefox', 'model': '110', 'os': { 'name': 'Linux', 'type': 'desktop', } }, 'user': { 'entitlements': [], 'itvUserId': '', 'token': '' }, 'variantAvailability': { 'featureset': { 'max': ['mpeg-dash', 'widevine', 'outband-webvtt', 'hd', 'single-track'], 'min': ['mpeg-dash', 'widevine', 'outband-webvtt', 'hd', 'single-track'] }, 'platformTag': 'dotcom', 'player': 'dash' } }
def _request_stream_data(url, stream_type='live'): from .itv_account import itv_session, fetch_authenticated session = itv_session()
stream_req_data['user']['token'] = session.access_token stream_req_data['client']['supportsAdPods'] = stream_type != 'live' if stream_type == 'live': accept_type = 'application/vnd.itv.online.playlist.sim.v3+json' # Live MUST have a featureset containing an item without outband-webvtt, or a bad request is returned. min_features = ['mpeg-dash', 'widevine'] else: accept_type = 'application/vnd.itv.vod.playlist.v2+json' # ITV appears now to use the min feature for catchup streams, causing subtitles # to go missing if not specified here. Min and max both specifying webvtt appears to # be no problem for catchup streams that don't have subtitles. min_features = ['mpeg-dash', 'widevine', 'outband-webvtt', 'hd', 'single-track'] stream_req_data['variantAvailability']['featureset']['min'] = min_features stream_data = fetch_authenticated( fetch.post_json, url, data=stream_req_data, headers={'Accept': accept_type}, cookies=session.cookie) return stream_data - Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.