def get_track_url(self, track_id, quality=None, cut_id=None, fallback=True):
oldSessionId = self.session_id
self.session_id = self.stream_session_id
soundQuality = quality if quality else self._config.quality
#if soundQuality == Quality.lossless and self._config.codec == 'MQA' and not cut_id:
# soundQuality = Quality.hi_res
media = Session.get_track_url(self, track_id, quality=soundQuality, cut_id=cut_id)
if fallback and soundQuality == Quality.lossless and (media == None or media.isEncrypted):
log(media.url, level=xbmc.LOGWARNING)
if media:
log('Got encryptionKey "%s" for track %s, trying HIGH Quality ...' % (media.encryptionKey, track_id), level=xbmc.LOGWARNING)
else:
log('No Lossless stream for track %s, trying HIGH Quality ...' % track_id, level=xbmc.LOGWARNING)
media = self.get_track_url(track_id, quality=Quality.high, cut_id=cut_id, fallback=False)
if media:
if quality == Quality.lossless and media.codec not in ['FLAC', 'ALAC', 'MQA']:
xbmcgui.Dialog().notification(plugin.name, _T(30504) , icon=xbmcgui.NOTIFICATION_WARNING)
log('Got stream with soundQuality:%s, codec:%s' % (media.soundQuality, media.codec))
self.session_id = oldSessionId
return media
python类NOTIFICATION_WARNING的实例源码
def getTMDBId(mediatype, id):
if isTMDBId(mediatype, id):
return id
else:
if mediatype == 'movie':
url = "https://api.themoviedb.org/3/find/%s?api_key=%s&language=en-US&external_source=%s" % (id, api_key, 'imdb_id')
elif mediatype == 'show':
url = "https://api.themoviedb.org/3/find/%s?api_key=%s&language=en-US&external_source=%s" % (id, api_key, 'tvdb_id')
response = getJSON(url)
if 'status_code' in response:
xbmcgui.Dialog().notification(ADDON.getLocalizedString(32007), ADDON.getLocalizedString(32008), xbmcgui.NOTIFICATION_WARNING, 3000)
return None
if response['movie_results']:
return response['movie_results'][0]['id']
elif response['tv_results']:
return response['tv_results'][0]['id']
elif response['tv_episode_results']:
return response['tv_episode_results'][0]['id']
else:
return None
def infoDialog(message, heading=addonInfo('name'), icon='', time=3000, sound=False):
if icon == '': icon = addonIcon()
elif icon == 'INFO': icon = xbmcgui.NOTIFICATION_INFO
elif icon == 'WARNING': icon = xbmcgui.NOTIFICATION_WARNING
elif icon == 'ERROR': icon = xbmcgui.NOTIFICATION_ERROR
dialog.notification(heading, message, icon, time, sound=sound)
def infoDialog(message, heading=addonInfo('name'), icon='', time=3000, sound=False):
if icon == '': icon = addonIcon()
elif icon == 'INFO': icon = xbmcgui.NOTIFICATION_INFO
elif icon == 'WARNING': icon = xbmcgui.NOTIFICATION_WARNING
elif icon == 'ERROR': icon = xbmcgui.NOTIFICATION_ERROR
dialog.notification(heading, message, icon, time, sound=sound)
def infoDialog(message, heading=addonInfo('name'), icon='', time=3000, sound=False):
if icon == '': icon = addonIcon()
elif icon == 'INFO': icon = xbmcgui.NOTIFICATION_INFO
elif icon == 'WARNING': icon = xbmcgui.NOTIFICATION_WARNING
elif icon == 'ERROR': icon = xbmcgui.NOTIFICATION_ERROR
dialog.notification(heading, message, icon, time, sound=sound)
def infoDialog(message, heading=addonInfo('name'), icon='', time=3000, sound=False):
if icon == '':
icon = addonIcon()
elif icon == 'INFO':
icon = xbmcgui.NOTIFICATION_INFO
elif icon == 'WARNING':
icon = xbmcgui.NOTIFICATION_WARNING
elif icon == 'ERROR':
icon = xbmcgui.NOTIFICATION_ERROR
dialog.notification(heading=heading, message=message, icon=icon, time=time, sound=sound)
def notify(self,title, msg):
dialog = xbmcgui.Dialog()
dialog.notification(title, msg,
xbmcgui.NOTIFICATION_WARNING, 3000)
def infoDialog(message, heading=addonInfo('name'), icon='', time=3000, sound=False):
if icon == '': icon = icon=__addon__.getAddonInfo('icon')
elif icon == 'INFO': icon = xbmcgui.NOTIFICATION_INFO
elif icon == 'WARNING': icon = xbmcgui.NOTIFICATION_WARNING
elif icon == 'ERROR': icon = xbmcgui.NOTIFICATION_ERROR
dialog.notification(heading, message, icon, time, sound=sound)
def dialog_notification(heading, message, icon=0, time=5000, sound=True):
dialog = xbmcgui.Dialog()
try:
l_icono = xbmcgui.NOTIFICATION_INFO, xbmcgui.NOTIFICATION_WARNING, xbmcgui.NOTIFICATION_ERROR
dialog.notification(heading, message, l_icono[icon], time, sound)
except:
dialog_ok(heading, message)
def configureTMDB():
global api_key
api_key = ADDON.getSetting('tmdb_api_key')
if not api_key:
# Temporarily use predefined key
api_key = "29a551a65eef108dd01b46e27eb0554a"
return True
# xbmcgui.Dialog().notification(ADDON.getLocalizedString(32005),
# ADDON.getLocalizedString(32006), xbmcgui.NOTIFICATION_WARNING, 3000)
# return False
return True
platformtools.py 文件源码
项目:plugin.video.streamondemand-pureita
作者: orione7
项目源码
文件源码
阅读 17
收藏 0
点赞 0
评论 0
def dialog_notification(heading, message, icon=0, time=5000, sound=True):
dialog = xbmcgui.Dialog()
l_icono = xbmcgui.NOTIFICATION_INFO, xbmcgui.NOTIFICATION_WARNING, xbmcgui.NOTIFICATION_ERROR
dialog.notification(heading, message, l_icono[icon], time, sound)
def dialog_notification(heading, message, icon=0, time=5000, sound=True):
dialog = xbmcgui.Dialog()
try:
l_icono = xbmcgui.NOTIFICATION_INFO, xbmcgui.NOTIFICATION_WARNING, xbmcgui.NOTIFICATION_ERROR
dialog.notification(heading, message, l_icono[icon], time, sound)
except:
dialog_ok(heading, message)
def play_live_tv(epg_channel_id):
# Get Current running event on channel
current_event = skygo.getCurrentEvent(epg_channel_id)
# If there is a running event play it
if current_event is not False:
event_id = current_event['id']
playInfo = skygo.getEventPlayInfo(event_id, epg_channel_id)
apix_id = playInfo['apixId']
manifest_url = playInfo['manifestUrl']
# Login to get session
login = skygo.login()
session_id = skygo.sessionId
# create init data for licence acquiring
init_data = skygo.get_init_data(session_id, apix_id)
# Create list item with inputstream addon
li = xbmcgui.ListItem(path=manifest_url)
info = {
'mediatype': 'movie',
}
li.setInfo('video', info)
li.setProperty('inputstream.adaptive.license_type', skygo.license_type)
li.setProperty('inputstream.adaptive.manifest_type', 'ism')
if init_data:
li.setProperty('inputstream.adaptive.license_key', skygo.licence_url)
li.setProperty('inputstream.adaptive.license_data', init_data)
li.setProperty('inputstreamaddon', 'inputstream.adaptive')
xbmcplugin.setResolvedUrl(addon_handle, True, listitem=li)
else:
xbmcgui.Dialog().notification('Kein laufendes Event', 'Auf diesem Kanal ist kein laufendes Event vorhanden.', icon=xbmcgui.NOTIFICATION_WARNING)
def get_video_url(self, video_id, maxHeight=-1):
oldSessionId = self.session_id
self.session_id = self.http_video_session_id
maxVideoHeight = maxHeight if maxHeight > 0 else self._config.maxVideoHeight
media = None
try:
if self._config.forceHttpVideo:
quality = 'LOW' if self._config.maxVideoHeight < 480 else 'MEDIUM' if self._config.maxVideoHeight < 720 else 'HIGH'
media = Session.get_video_url(self, video_id, quality=quality)
except requests.HTTPError as e:
r = e.response
msg = _T(30505)
try:
msg = r.reason
msg = r.json().get('userMessage')
except:
pass
log('HTTP-Error: ' + msg, xbmc.LOGERROR)
log('Got no HTTP Stream for Video ID %s, using HLS Stream ...' % video_id, xbmc.LOGERROR)
xbmcgui.Dialog().notification(plugin.name, _T(30510), xbmcgui.NOTIFICATION_WARNING)
if not media:
# Using HLS-Stream
self.session_id = self.stream_session_id
media = Session.get_video_url(self, video_id, quality=None)
if maxVideoHeight <> 9999 and media.url.lower().find('.m3u8') > 0:
log('Parsing M3U8 Playlist: %s' % media.url)
m3u8obj = m3u8_load(media.url)
if m3u8obj.is_variant and not m3u8obj.cookies:
# Variant Streams with Cookies have to be played without stream selection.
# You can change the Bandwidth Limit in Kodi Settings to select other streams !
# Select stream with highest resolution <= maxVideoHeight
selected_height = 0
selected_bandwidth = -1
for playlist in m3u8obj.playlists:
try:
width, height = playlist.stream_info.resolution
bandwidth = playlist.stream_info.average_bandwidth
if not bandwidth:
bandwidth = playlist.stream_info.bandwidth
if not bandwidth:
bandwidth = 0
if (height > selected_height or (height == selected_height and bandwidth > selected_bandwidth)) and height <= maxVideoHeight:
if re.match(r'https?://', playlist.uri):
media.url = playlist.uri
else:
media.url = m3u8obj.base_uri + playlist.uri
if height == selected_height and bandwidth > selected_bandwidth:
log('Bandwidth %s > %s' % (bandwidth, selected_bandwidth))
log('Selected %sx%s %s: %s' % (width, height, bandwidth, playlist.uri.split('?')[0].split('/')[-1]))
selected_height = height
selected_bandwidth = bandwidth
media.width = width
media.height = height
media.bandwidth = bandwidth
elif height > maxVideoHeight:
log('Skipped %sx%s %s: %s' % (width, height, bandwidth, playlist.uri.split('?')[0].split('/')[-1]))
except:
pass
self.session_id = oldSessionId
return media