def download_token(tokenUrl): try: DownloadHeaders = {} DownloadRequest = hybrid.urllib_request(tokenUrl, headers=DownloadHeaders) DownloadDataHttp = hybrid.urllib_urlopen(DownloadRequest) DownloadString = hybrid.string_decode_utf8(DownloadDataHttp.read()) return DownloadString except: notificationIcon = path.addon( 'resources/skins/default/media/common/close.png') xbmcgui.Dialog().notification(var.addonname, 'Token download failure.', notificationIcon, 2500, False) return None
def reset_thumbnails(): try: dialogAnswers = ["Alle zender logo's vernieuwen"] dialogHeader = "Alle zender logo's vernieuwen" dialogSummary = "Weet u zeker dat u alle zender logo's wilt vernieuwen? dit zal alle ingeladen afbeeldingen verwijderen zodat de logo's opnieuw gedownload worden." dialogFooter = '' dialogResult = dialog.show_dialog(dialogHeader, dialogSummary, dialogFooter, dialogAnswers) if dialogResult == "Alle zender logo's vernieuwen": textureFolder = hybrid.string_decode_utf8(hybrid.xbmc_translate_path('special://home/userdata/Thumbnails')) files.removeDirectory(textureFolder) xbmc.sleep(100) files.createDirectory(textureFolder) xbmcgui.Dialog().notification(var.addonname, "Zender logo's zijn verwijderd.", var.addonicon, 2500, False) except: pass
def download_streams(): try: DownloadHeaders = {} DownloadRequest = hybrid.urllib_request( 'https://raw.githubusercontent.com/dumbie/kodirepo/master/plugin.video.vogelspot/streams/streams.js', headers=DownloadHeaders) DownloadDataHttp = hybrid.urllib_urlopen(DownloadRequest) DownloadString = hybrid.string_decode_utf8(DownloadDataHttp.read()) return DownloadString except: notificationIcon = path.addon( 'resources/skins/default/media/common/close.png') xbmcgui.Dialog().notification(var.addonname, 'Streams download failure.', notificationIcon, 2500, False) return None
guiHelp = None windowHome = xbmcgui.Window(10000) WINDOW_DIALOG_VIDEO_OSD_SETTINGS = 10123 WINDOW_DIALOG_AUDIO_OSD_SETTINGS = 10124 WINDOW_FULLSCREEN_VIDEO = 12005 WINDOW_VISUALISATION = 12006 WINDOW_ADDON = 13000 #Add-on variables addon = xbmcaddon.Addon() addonmonitor = xbmc.Monitor() addonid = addon.getAddonInfo('id') addonname = addon.getAddonInfo('name') addonicon = addon.getAddonInfo('icon') addonversion = addon.getAddonInfo('version') addonpath = hybrid.string_decode_utf8(addon.getAddonInfo('path')) addonstorage = os.path.join( hybrid.string_decode_utf8( hybrid.xbmc_translate_path('special://profile/addon_data/')), addonid) kodiversion = xbmc.getInfoLabel('System.BuildVersion').split(' ')[0].split( '-')[0] #Launch variables LaunchArgument = '' #Dialog variables DialogResult = None #Thread variables thread_check_requirements = None thread_zap_wait_timer = None
def enable_widevine_support(forceUpdate=False): #Check if Widevine is already updating if var.WidevineUpdating == True: return var.WidevineUpdating = True #Get InputStream adaptive Widevine path input_addon = xbmcaddon.Addon('inputstream.adaptive') decrypter_path = input_addon.getSetting('DECRYPTERPATH') if func.string_isnullorempty(decrypter_path): widevine_path = hybrid.string_decode_utf8( hybrid.xbmc_translate_path('special://home/cdm')) input_addon.setSetting('DECRYPTERPATH', 'special://home/cdm') else: widevine_path = hybrid.string_decode_utf8( hybrid.xbmc_translate_path(decrypter_path)) #Set the download headers DownloadHeaders = {"User-Agent": var.addon.getSetting('CustomUserAgent')} #Check if newer Widevine version is available RequestUrl = str(path.requirements()) + 'version.txt' DownloadRequest = hybrid.urllib_request(RequestUrl, headers=DownloadHeaders) DownloadDataHttp = hybrid.urllib_urlopen(DownloadRequest) DownloadDataString = DownloadDataHttp.read().decode() if DownloadDataString != var.addon.getSetting('WidevineVersion'): var.addon.setSetting('WidevineVersion', DownloadDataString) forceUpdate = True #Check if Widevine support is installed if forceUpdate == False: for aRoot, aDirs, aFiles in os.walk(widevine_path): for fileName in aFiles: if 'widevinecdm' in fileName: var.WidevineUpdating = False return #Check the system processor architecture downloadArchitecture = '' systemArchitecture = platform.machine().lower() systemBits = platform.architecture()[0].lower() if 'arm' in systemArchitecture: downloadArchitecture = 'armv7' elif systemBits == '32bit': downloadArchitecture = 'ia32' elif systemBits == '64bit': downloadArchitecture = 'x64' #Check if operating system is supported downloadOperatingSystem = '' if xbmc.getCondVisibility('System.Platform.Android'): var.WidevineUpdating = False return elif xbmc.getCondVisibility('System.Platform.IOS'): var.WidevineUpdating = False return elif xbmc.getCondVisibility('System.Platform.Linux'): downloadOperatingSystem = 'linux' elif xbmc.getCondVisibility('System.Platform.OSX'): downloadOperatingSystem = 'mac' elif xbmc.getCondVisibility('System.Platform.Windows'): downloadOperatingSystem = 'win' else: var.WidevineUpdating = False xbmcgui.Dialog().notification( var.addonname, 'Besturing systeem wordt niet ondersteund.', var.addonicon, 2500, False) return #Notify the user Widevine is installing xbmcgui.Dialog().notification(var.addonname, 'Widevine wordt geinstalleerd.', var.addonicon, 2500, False) #Stop the current playback of any media if xbmc.Player().isPlaying(): xbmc.Player().stop() xbmc.sleep(1000) #Create the Widevine decrypter directory if os.path.exists(widevine_path) == False: os.mkdir(widevine_path) try: #Download the required Widevine files RequestUrl = str(path.requirements()) + 'widevine-' + str( downloadOperatingSystem) + '-' + str(downloadArchitecture) + '.zip' DownloadRequest = hybrid.urllib_request(RequestUrl, headers=DownloadHeaders) DownloadDataHttp = hybrid.urllib_urlopen(DownloadRequest) DownloadDataBytes = DownloadDataHttp.read() #Write the downloaded Widevine zip file download_filename = widevine_path + '/widevine.zip' filewrite = open(download_filename, 'wb') filewrite.write(DownloadDataBytes) filewrite.close() except: var.WidevineUpdating = False notificationIcon = path.resources( 'resources/skins/default/media/common/error.png') xbmcgui.Dialog().notification(var.addonname, 'Mislukt om Widevine te downloaden.', notificationIcon, 2500, False) return try: #Extract the downloaded Widevine zip file downloadZip = ZipFile(download_filename) downloadZip.extractall(widevine_path) downloadZip.close() except: var.WidevineUpdating = False notificationIcon = path.resources( 'resources/skins/default/media/common/error.png') xbmcgui.Dialog().notification(var.addonname, 'Mislukt om Widevine te installeren.', notificationIcon, 2500, False) return #Remove the downloaded Widevine zip file os.remove(download_filename) var.WidevineUpdating = False xbmcgui.Dialog().notification(var.addonname, 'Widevine is succesvol geinstalleerd.', var.addonicon, 2500, False)