Exemple #1
0
def list():
    show_hint_mobile = libMediathek.getSettingBool('show_hint_mobile')
    if show_hint_mobile:
        libMediathek.setSettingBool('show_hint_mobile', False)
        addon = xbmcaddon.Addon()
        title = addon.getAddonInfo('name')
        text = addon.getLocalizedString(32100)
        xbmcgui.Dialog().ok(title, text)
    use_mobile = libMediathek.getSettingBool('use_mobile')
    use_mobile_prev_value = libMediathek.getSettingBool(
        'use_mobile_prev_value')
    if (use_mobile != use_mobile_prev_value) or show_hint_mobile:
        if 'mode' in params:
            del params['mode']  # force default mode
        if use_mobile != use_mobile_prev_value:
            libMediathek.setSettingBool('use_mobile_prev_value', use_mobile)
            addon = xbmcaddon.Addon()
            title = addon.getAddonInfo('name')
            text = addon.getLocalizedString(32101)
            xbmcgui.Dialog().notification(
                title, text,
                os.path.join(addon.getAddonInfo('path'), 'icon.png'))
            xbmc.executebuiltin('Container.Update(path,replace)')
    if use_mobile:
        return libzdfneu.list()
    else:
        return libMediathek.list(modes, 'libZdfListMain', 'libZdfPlay',
                                 'libZdfPlayById')
def extractBestQuality(streams, fnGetFinalUrl):
	media = []
	for item in streams:
		if isinstance(item,dict) and (item.get('__typename','MediaStreamArray') == 'MediaStreamArray'):
			stream = item.get('_stream',None)
			if stream:
				url = fnGetFinalUrl(stream)
				if url:
					if url.startswith('//'):
						url = 'https:' + url
					quality = item.get('_quality',-1);
					if quality == 'auto':
						media.insert(0,{'url':url, 'type':'video', 'stream':'hls'})
					elif url[-4:].lower() == '.mp4':
						try:
							quality = int(quality)
						except ValueError:
							pass
						else:
							media.append({'url':url, 'type':'video', 'stream':'mp4', 'bitrate':quality})
	ignore_adaptive = libMediathek.getSettingBool('ignore_adaptive')
	while ignore_adaptive and len(media) > 1 and media[0]['stream'] == 'hls':
		del media[0]
	if media: 
		return dict(media = media)
	else: 
		return None
Exemple #3
0
def getVideoUrl(url):
	media = []
	response = getU(url,False)
	j = json.loads(response)
	for item in j['priorityList']:
		if (item['formitaeten'][0].get('type',None) == 'h264_aac_ts_http_m3u8_http'
			or
			item['formitaeten'][0].get('mimeType',None) == 'application/x-mpegURL'
		):
			for streams in item['formitaeten'][0]['qualities']:
				if streams['quality'] == 'auto':
					media.insert(0, {'url':streams['audio']['tracks'][0]['uri'], 'type': 'video', 'stream':'hls'})
		elif (item['formitaeten'][0].get('type',None) == 'h264_aac_mp4_http_na_na'
			or
			item['formitaeten'][0].get('mimeType',None) == 'video/mp4'
		):
			for streams in item['formitaeten'][0]['qualities']:
				try:
					quality = ('low','med','high','veryhigh').index(streams['quality'])
				except ValueError:
					pass
				else:
					media.append({'url':streams['audio']['tracks'][0]['uri'], 'type':'video', 'stream':'mp4', 'bitrate':quality})
	ignore_adaptive = libMediathek.getSettingBool('ignore_adaptive')
	while ignore_adaptive and len(media) > 1 and media[0]['stream'] == 'hls':
		del media[0]
	if media:
		result = dict(media = media)
		for caption in j.get('captions',[]):
			if caption['format'] == 'ebu-tt-d-basic-de':
				result['subtitle'] = [{'url':caption['uri'], 'type':'ttml', 'lang':'de', 'colour':True}]
		return result
	else:
		return None
Exemple #4
0
def fetchJsonVideo(id):
	media = []
	response = libMediathek.getUrl('http://www.ardmediathek.de/play/media/'+id)
	j = json.loads(response)
	for mediaArray in j['_mediaArray']:
		for stream in mediaArray['_mediaStreamArray']:
			if isinstance(stream['_stream'],list):
				url = stream['_stream'][0]
			else:
				url = stream['_stream']
			if url.startswith('//'):
				url = 'https:' + url
			quality = stream.get('_quality',-1);
			if quality == 'auto':
				media.insert(0,{'url':url, 'type':'video', 'stream':'hls'})
			elif url[-4:].lower() == '.mp4':
				try:
					quality = int(quality)
				except ValueError:
					pass
				else:
					media.append({'url':url, 'type':'video', 'stream':'mp4', 'bitrate':quality})
	ignore_adaptive = libMediathek.getSettingBool('ignore_adaptive')
	while ignore_adaptive and len(media) > 1 and media[0]['stream'] == 'hls':
		del media[0]
	if media:
		result = dict(media = media)
		if '_subtitleUrl' in j:
			result['subtitle'] = [{'url':j['_subtitleUrl'], 'type':'ttml', 'lang':'de'}]
		return result
	else:
		return None
def getVideoUrl(uri):
    mediaHLS = []
    mediaMP4 = []
    response = libMediathek.getUrl(baseUrl + uri)
    j = json.loads(response)
    for asset in j.get('hbbtvAssets', []) + j.get('assets', []):
        url = asset['url']
        if url.startswith('//'):
            url = 'https:' + url
        quality = asset.get('quality', None)
        if quality is None:
            continue
        elif isinstance(quality, int):
            pass
        else:
            try:
                quality = quality.split(' ')[0]
                if len(quality) == 1:
                    quality = ('0', '1', '2', '3', '4', '5', '6', '7', '8',
                               '9').index(quality)
                else:
                    quality = ('low', 'med', 'high', 'veryhigh',
                               'auto').index(quality)
            except ValueError:
                continue
        isAdaptive = asset.get('isAdaptive', None)
        if isAdaptive is None:
            isAdaptive = (url[-4:].lower() != '.mp4')
        if isAdaptive:
            mediaHLS.append({
                'url': url,
                'type': 'video',
                'stream': 'hls',
                'bitrate': quality
            })
        else:
            mediaMP4.append({
                'url': url,
                'type': 'video',
                'stream': 'mp4',
                'bitrate': quality
            })
    mediaHLS.sort(key=lambda x: x['bitrate'], reverse=True)
    mediaHLS = mediaHLS[0:1]
    mediaMP4.sort(key=lambda x: x['bitrate'], reverse=True)
    ignore_adaptive = libMediathek.getSettingBool('ignore_adaptive')
    if ignore_adaptive and mediaMP4:
        media = mediaMP4
    else:
        media = mediaHLS + mediaMP4
    if media:
        return dict(media=media)
    else:
        return None
def parseFormitaeten(video, type):
    mediaHLS = []
    mediaMP4 = []
    formitaeten = video.get('formitaeten', None)
    if formitaeten:
        for stream in formitaeten:
            if (stream.get('type', None) == 'h264_aac_ts_http_m3u8_http' or
                    stream.get('mimeType', None) == 'application/x-mpegURL'):
                streamType = 'hls'
                media = mediaHLS
            elif (stream.get('type', None) == 'h264_aac_mp4_http_na_na'
                  or stream.get('mimeType', None) == 'video/mp4'):
                streamType = 'mp4'
                media = mediaMP4
            else:
                continue
            try:
                quality = ('low', 'med', 'high', 'veryhigh',
                           'auto').index(stream['quality'])
            except ValueError:
                pass
            else:
                media.append({
                    'url': stream['url'],
                    'type': type,
                    'stream': streamType,
                    'bitrate': quality
                })
    mediaHLS.sort(key=lambda x: x['bitrate'], reverse=True)
    mediaHLS = mediaHLS[0:1]
    mediaMP4.sort(key=lambda x: x['bitrate'], reverse=True)
    ignore_adaptive = libMediathek.getSettingBool('ignore_adaptive')
    if ignore_adaptive and mediaMP4:
        media = mediaMP4
    else:
        media = mediaHLS + mediaMP4
    if media:
        return dict(media=media)
    else:
        return None