def getPlayerType(self): sPlayerType = common.getSetting('playerType') if (sPlayerType == '0'): return xbmc.PLAYER_CORE_AUTO elif (sPlayerType == '1'): return xbmc.PLAYER_CORE_MPLAYER elif (sPlayerType == '2'): return xbmc.PLAYER_CORE_DVDPLAYER # PLAYER_CORE_AMLPLAYER elif (sPlayerType == '3'): return 5 return xbmc.PLAYER_CORE_AUTO
def simpleToken(url): import requests, zlib time = common.getSetting(url + '_time') s = requests.Session() if time: s.headers.update({'If-Modified-Since': time}) s.headers.update({ 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36' }) s.headers.update({'Referer': url}) r = s.get(url) if r.status_code == 304: return common.getSetting(url + '_token') elif r.status_code == 200: content = zlib.decompress(r.content[8:]) if 'tv-msn' in url: token = re.findall(r"lengths.param1.(\w+)", content)[0][:16] else: token = re.findall("TokenResponse (\w+)", content)[0][:16] common.setSetting(url + '_token', token) common.setSetting(url + '_time', r.headers['Last-Modified']) return token
def buildKernel(): os.chdir(getScriptDir()) loadSettings() # Install dependencies (Ubuntu needs u-boot-tools, Debian needs uboot-mkimage) ensureDependencies( ['gcc-arm-linux-gnueabi', 'u-boot-tools', 'device-tree-compiler']) # Clone the linux kernel source tree print('Cloning the Linux kernel source tree') linuxDirName = gitCloneAndEnter( 'git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git', 'master') os.chdir('..') # Clone RCN's git repository print('Building kernel') gitCloneAndEnter('git://github.com/RobertCNelson/stable-kernel.git', '4d82ccd1b2093') # Configure the kernel build script shutil.copyfile('system.sh.sample', 'system.sh') # Overwrites existing file file = open('system.sh', 'a') # Open for appending file.write('LINUX_GIT=' + os.path.join(os.path.realpath('..'), linuxDirName) + '\n') file.write('ZRELADDR=0x80008000' + '\n') # For TI: OMAP3/4/AM35xx (BB is OMAP3) #file.write('BUILD_UIMAGE=1' + '\n') # Do I need to build uImage? file.write('MMC=' + getSetting('mmc') + '\n') # Pull in Torvalds current master tree before applying local patchset # This is very useful during an intial 'rc0' merge. # It is never supported... Enable at your own risk #file.write('LATEST_GIT=1' + '\n') file.write( 'LOCAL_PATCH_DIR=' + os.path.join(os.path.realpath('..'), 'patches', 'stable-kernel') + '\n') file.close() # Adding the CC parameter is a little more complex... we need to seek out # the config line and uncomment it. replaceAll('system.sh', '#CC=arm-linux-gnueabi-', 'CC=arm-linux-gnueabi-') # Build the kernel subprocess.call(['./build_deb.sh']) os.chdir('..')
def playMedia(url, title='', thumb='', description='', playlist_type=xbmc.PLAYLIST_VIDEO): common.log('Play media: ' + url) # start playing file immediately or add to current playlist clear_playlist = common.getSetting('interrupt_media', False) or not mediaPlaying() li = xbmcgui.ListItem(label=title, label2=description, iconImage=thumb, thumbnailImage=thumb) li.setPath(url) li.setInfo('video', {'title': title, 'tagline': description}) pl = xbmc.PlayList(playlist_type) if clear_playlist: pl.clear() pl.add(url, li) if clear_playlist: xbmc.Player().play(pl)
def createCard(): os.chdir(getScriptDir()) loadSettings() fs = 'ext4' # btrfs is waaaaaaaaay too slow on a microSD card # Set swap equal to amount of RAM for kernel compiling, consider disabling # swap for production images swap = 512 # MB, set to zero to disable # Install dependencies ensureDependencies(['uboot-mkimage', 'wget', 'pv', 'dosfstools', 'parted']) # Look for u-boot and MLO useStable = True # as opposed to latest GIT uboot = False mlo = False ubootdir = os.path.join('Bootloader-Builder', 'deploy', 'beagleboard') if os.path.exists(ubootdir): found = useStable for f in sorted(os.listdir(ubootdir), reverse=True): if os.path.isfile(os.path.join(ubootdir, f)) and 'MLO' in f: # Stable will end in -r1. GIT will end in -def (three hex chars) # Therefore, in the real stable image comes last and the latest # GIT will be second-to-last. Simply use "useStable" as a flag # to target the second-to-last. if found: mlo = os.path.realpath(os.path.join(ubootdir, f)) print('Found MLO: ' + mlo) break else: found = True found = useStable for f in sorted(os.listdir(ubootdir), reverse=True): if os.path.isfile(os.path.join(ubootdir, f)) and 'u-boot' in f: if found: uboot = os.path.realpath(os.path.join(ubootdir, f)) print('Found u-boot: ' + uboot) break else: found = True # Build the image deploy = os.path.join('omap-image-builder', 'deploy') if not os.path.exists(deploy): print( 'Error: omap-image-builder directory doesn\'t exist. Try running buildImage()' ) return os.chdir(deploy) for f in sorted(os.listdir('.'), reverse=True): if not os.path.isfile(f): os.chdir(f) break else: print('Error: images not found. Try running buildImage()') return # Enter the only folder for f in os.listdir('.'): if not os.path.isfile(f): os.chdir(f) break else: print('Error: images not found. Try running buildImage()') return cmd = [ 'sudo', './setup_sdcard.sh', '--mmc', getSetting('mmc'), '--uboot', 'beagle_xm', '--rootfs', fs, '--boot_label', 'boot', '--rootfs_label', 'rootfs' ] if uboot and mlo: cmd.extend(['--bootloader', uboot, '--spl', mlo]) if swap: cmd.extend(['--swap_file', str(swap)]) subprocess.call(cmd) os.chdir('..') os.chdir('..') os.chdir('..') os.chdir('..')
def run(self, argv=None): self.addon = Addon('plugin.video.ViendoKodiStreaming', argv) common.log('ViendoKodiStreaming running') base = argv[0] handle = int(argv[1]) parameter = argv[2] self.base = base self.handle = handle paramstring = urllib.unquote_plus(parameter) common.log(paramstring) try: # if addon is started listItemPath = xbmcUtils.getListItemPath() if not listItemPath.startswith(self.base): if not ('mode=' in paramstring and not 'mode=1&' in paramstring): xbmcplugin.setPluginFanart(self.handle, common.Paths.pluginFanart) self.clearCache() #if common.getSetting('autoupdate') == 'true': # self.update() # Main Menu if '98VKS' in paramstring: nametorrent = os.path.normpath(paramstring.split('url=')[1]) if nametorrent == 'quasar': addonTorrent = 'item_info_build=plugin://plugin.video.quasar/play?uri=%s' elif nametorrent == 'pulsar': addonTorrent = 'item_info_build=plugin://plugin.video.pulsar/play?uri=%s' elif nametorrent == 'kmediatorrent': addonTorrent = 'item_info_build=plugin://plugin.video.kmediatorrent/play/%s' elif nametorrent == "torrenter": addonTorrent = 'item_info_build=plugin://plugin.video.torrenter/?action=playSTRM&url=%s¬_download_only=True' elif nametorrent == "yatp": addonTorrent = 'item_info_build=plugin://plugin.video.yatp/?action=play&torrent=%s' else: addonTorrent = 'item_info_build=plugin://plugin.video.xbmctorrent/play/%s' cFichero = common.Paths.catchersDir + '/' + 'torrent.txt' outfile = open(cFichero, 'w') # Indicamos el valor 'w'. outfile.write('item_info_name=url\n' + 'item_info_from=@PARAM1@\n' + addonTorrent + '\n') outfile.close() common.showInfo( '[COLOR red]NO INSTALAR[/COLOR] conjuntamente los addon pulsar y quasar.\nYa que tendremos problemas de compatibilidad y no funcionará ninguno. [COLOR lime] \nPara los torrent se utilizará: [/COLOR] ' + nametorrent) elif len(paramstring) <= 2: mainMenu = ListItem.create() mainMenu['url'] = self.MAIN_MENU_FILE tmpList = self.parseView(mainMenu) if tmpList: self.currentlist = tmpList else: [mode, item] = self._parseParameters() # switch(mode) if mode == Mode.VIEW: tmpList = self.parseView(item) if tmpList: self.currentlist = tmpList count = len(self.currentlist.items) if count == 1: # Autoplay single video autoplayEnabled = common.getSetting( 'autoplay') == 'true' if autoplayEnabled: videos = self.currentlist.getVideos() if len(videos) == 1: self.playVideo(videos[0], True) elif mode == Mode.ADDITEM: tmp = os.path.normpath(paramstring.split('url=')[1]) if tmp: suffix = tmp.split(os.path.sep)[-1] tmp = tmp.replace(suffix, '') + urllib.quote_plus(suffix) if self.favouritesManager.add(tmp): xbmc.executebuiltin('Container.Refresh()') elif mode in [ Mode.ADDTOFAVOURITES, Mode.REMOVEFROMFAVOURITES, Mode.EDITITEM ]: if mode == Mode.ADDTOFAVOURITES: self.favouritesManager.addItem(item) elif mode == Mode.REMOVEFROMFAVOURITES: self.favouritesManager.removeItem(item) xbmc.executebuiltin('Container.Refresh()') elif mode == Mode.EDITITEM: if self.favouritesManager.editItem(item): xbmc.executebuiltin('Container.Refresh()') elif mode == Mode.EXECUTE: self.executeItem(item) elif mode == Mode.PLAY: self.playVideo(item) elif mode == Mode.WEBDRIVER: url = urllib.quote(item['url']) title = item['title'] self.playWebDriver(url, title) elif mode == Mode.QUEUE: self.queueAllVideos(item) elif mode == Mode.CHROME: url = urllib.quote(item['url']) title = item['title'] self.launchChrome(url, title) elif mode == Mode.SAY: #title = item['title'] url = "" elif mode == Mode.INSTALLADDON: success = install(item['url']) if success: xbmc.sleep(100) if xbmcUtils.getCurrentWindowXmlFile( ) == 'DialogAddonSettings.xml': # workaround to update settings dialog common.setSetting('', '') except Exception, e: common.showError('Error running ViendoKodiStreaming') common.log('Error running ViendoKodiStreaming. Reason:' + str(e))
def parseView(self, lItem): def endOfDirectory(succeeded=True): if self.handle > -1: xbmcplugin.endOfDirectory(handle=self.handle, succeeded=succeeded, cacheToDisc=True) else: common.log('Handle -1') if not lItem: endOfDirectory(False) return None if lItem['type'] == 'search': search_phrase = self.getSearchPhrase() if not search_phrase: common.log("search canceled") endOfDirectory(False) return None else: lItem['type'] = 'rss' lItem['url'] = lItem['url'] % ( urllib.quote_plus(search_phrase)) url = lItem['url'] if url == common.Paths.customModulesFile: self.customModulesManager.getCustomModules() tmpList = None result = self.parser.parse(lItem) if result.code == ParsingResult.Code.SUCCESS: tmpList = result.list elif result.code == ParsingResult.Code.CFGFILE_NOT_FOUND: common.showError("No encuentro el fichero Cfg") endOfDirectory(False) return None elif result.code == ParsingResult.Code.CFGSYNTAX_INVALID: common.showError("sintaxis invalida en Cfg") endOfDirectory(False) return None elif result.code == ParsingResult.Code.WEBREQUEST_FAILED: common.showError("Ha fallado la llamada a la Web") if len(result.list.items) > 0: tmpList = result.list else: endOfDirectory(False) return None # if it's the main menu, add folder 'Favourites' and 'Custom Modules if url == self.MAIN_MENU_FILE: tmp = ListItem.create() tmp['title'] = ' [COLOR blue]ViendoKodi[/COLOR] [COLOR red]Streaming[/COLOR]' tmp['type'] = 'say' tmp['url'] = '' tmp['icon'] = os.path.join(common.Paths.imgDir, 'icon.png') tmpList.items.insert(0, tmp) tmp = ListItem.create() tmp['title'] = '[COLOR red][B] [/B][/COLOR]' tmp['type'] = 'say' tmp['url'] = '' tmp['icon'] = os.path.join(common.Paths.imgDir, 'icon.png') tmpList.items.insert(1, tmp) #tmp = ListItem.create() #tmp['title'] = '[COLOR red]Custom Modules[/COLOR]' #tmp['type'] = 'rss' #tmp['url'] = os.path.join(common.Paths.customModulesDir, 'custom.cfg') #tmpList.items.insert(0, tmp) # if it's the favourites menu, add item 'Add item' elif url == common.Paths.favouritesFile or url.startswith( 'favfolders'): if url.startswith('favfolders'): url = os.path.normpath( os.path.join(common.Paths.favouritesFolder, url)) tmp = ListItem.create() tmp['title'] = 'Add item...' tmp['type'] = 'command' tmp['icon'] = os.path.join(common.Paths.imgDir, 'bookmark_add.png') action = 'RunPlugin(%s)' % (self.base + '?mode=' + str(Mode.ADDITEM) + '&url=' + url) tmp['url'] = action tmpList.items.append(tmp) # Create menu or play, if it's a single video and autoplay is enabled count = len(tmpList.items) if (count == 0 and not url.startswith('favfolders')): common.showInfo('No stream available') #Directory with 0 items endOfDirectory(False) elif not (common.getSetting('autoplay') == 'true' and count == 1 and len(tmpList.getVideos()) == 1): # sort methods sortKeys = tmpList.sort.split('|') setSortMethodsForCurrentXBMCList(self.handle, sortKeys) # Add items to XBMC list for m in tmpList.items: self.addListItem(m, len(tmpList.items)) #Directory with >1 items endOfDirectory(True) else: #Directory with 0 items endOfDirectory(False) return tmpList
def run(self, argv=None): self.addon = Addon('plugin.video.SportsDevil', argv) common.log('SportsDevil running') base = argv[0] handle = int(argv[1]) parameter = argv[2] self.base = base self.handle = handle paramstring = urllib.unquote_plus(parameter) common.log(paramstring) try: # if addon is started listItemPath = xbmcUtils.getListItemPath() if not listItemPath.startswith(self.base): if not('mode=' in paramstring and not 'mode=1&' in paramstring): xbmcplugin.setPluginFanart(self.handle, common.Paths.pluginFanart) self.clearCache() # Main Menu if len(paramstring) <= 2: mainMenu = ListItem.create() mainMenu['url'] = self.MAIN_MENU_FILE tmpList = self.parseView(mainMenu) if tmpList: self.currentlist = tmpList else: [mode, item] = self._parseParameters() # switch(mode) if mode == Mode.VIEW: tmpList = self.parseView(item) if tmpList: self.currentlist = tmpList count = len(self.currentlist.items) if count == 1: # Autoplay single video autoplayEnabled = common.getSetting('autoplay') == 'true' if autoplayEnabled: videos = self.currentlist.getVideos() if len(videos) == 1: self.playVideo(videos[0], True) elif mode == Mode.ADDITEM: tmp = os.path.normpath(paramstring.split('url=')[1]) if tmp: suffix = tmp.split(os.path.sep)[-1] tmp = tmp.replace(suffix,'') + urllib.quote_plus(suffix) if self.favouritesManager.add(tmp): xbmc.executebuiltin('Container.Refresh()') elif mode in [Mode.ADDTOFAVOURITES, Mode.REMOVEFROMFAVOURITES, Mode.EDITITEM]: if mode == Mode.ADDTOFAVOURITES: self.favouritesManager.addItem(item) elif mode == Mode.REMOVEFROMFAVOURITES: self.favouritesManager.removeItem(item) xbmc.executebuiltin('Container.Refresh()') elif mode == Mode.EDITITEM: if self.favouritesManager.editItem(item): xbmc.executebuiltin('Container.Refresh()') elif mode == Mode.EXECUTE: self.executeItem(item) elif mode == Mode.PLAY: self.playVideo(item) elif mode == Mode.SLPROXY: self.playSLProxy(item) elif mode == Mode.WEBDRIVER: url = urllib.quote(item['url']) title = item['title'] self.playWebDriver(url, title) elif mode == Mode.QUEUE: self.queueAllVideos(item) elif mode == Mode.CHROME: url = urllib.quote(item['url']) title = item['title'] self.launchChrome(url, title) elif mode == Mode.INSTALLADDON: success = install(item['url']) if success: xbmc.sleep(100) if xbmcUtils.getCurrentWindowXmlFile() == 'DialogAddonSettings.xml': # workaround to update settings dialog common.setSetting('', '') except Exception, e: common.showError('Error running SportsDevil') common.log('Error running SportsDevil. Reason:' + str(e))
def parseView(self, lItem): def endOfDirectory(succeeded=True): xbmcplugin.endOfDirectory(handle=self.handle, succeeded=succeeded, cacheToDisc=True) if not lItem: endOfDirectory(False) return None if lItem['type'] == 'search': search_phrase = self.getSearchPhrase() if not search_phrase: common.log("search canceled") endOfDirectory(False) return None else: lItem['type'] = 'rss' lItem['url'] = lItem['url'] % ( urllib.quote_plus(search_phrase)) url = lItem['url'] if url == common.Paths.customModulesFile: self.customModulesManager.getCustomModules() tmpList = None result = self.parser.parse(lItem) if result.code == ParsingResult.Code.SUCCESS: tmpList = result.list else: if result.code == ParsingResult.Code.CFGFILE_NOT_FOUND: common.showError("Cfg file not found") elif result.code == ParsingResult.Code.CFGSYNTAX_INVALID: common.showError("Cfg syntax invalid") elif result.code == ParsingResult.Code.WEBREQUEST_FAILED: common.showError("Web request failed") endOfDirectory(False) return None # if it's the main menu, add folder 'Favourites' and 'Custom Modules if url == self.MAIN_MENU_FILE: tmp = ListItem.create() tmp['title'] = 'Favourites' tmp['type'] = 'rss' tmp['icon'] = os.path.join(common.Paths.imgDir, 'bookmark.png') tmp['url'] = str(common.Paths.favouritesFile) tmpList.items.insert(0, tmp) tmp = ListItem.create() tmp['title'] = '[COLOR red]Custom Modules[/COLOR]' tmp['type'] = 'rss' tmp['url'] = os.path.join(common.Paths.customModulesDir, 'custom.cfg') tmpList.items.insert(0, tmp) # if it's the favourites menu, add item 'Add item' elif url == common.Paths.favouritesFile or url.startswith( 'favfolders'): if url.startswith('favfolders'): url = os.path.normpath( os.path.join(common.Paths.favouritesFolder, url)) tmp = ListItem.create() tmp['title'] = 'Add item...' tmp['type'] = 'command' tmp['icon'] = os.path.join(common.Paths.imgDir, 'bookmark_add.png') action = 'RunPlugin(%s)' % (self.base + '?mode=' + str(Mode.ADDITEM) + '&url=' + url) tmp['url'] = action tmpList.items.append(tmp) # if it's the custom modules menu, add item 'more...' elif url == common.Paths.customModulesFile: tmp = ListItem.create() tmp['title'] = 'more...' tmp['type'] = 'command' #tmp['icon'] = os.path.join(common.Paths.imgDir, 'bookmark_add.png') action = 'RunPlugin(%s)' % (self.base + '?mode=' + str( Mode.DOWNLOADCUSTOMMODULE) + '&url=') tmp['url'] = action tmpList.items.append(tmp) # Create menu or play, if it's a single video and autoplay is enabled proceed = False count = len(tmpList.items) if count == 0: if url.startswith('favfolders'): proceed = True else: common.showInfo('No stream available') elif count > 0 and not (common.getSetting('autoplay') == 'true' and count == 1 and len(tmpList.getVideos()) == 1): # sort methods sortKeys = tmpList.sort.split('|') setSortMethodsForCurrentXBMCList(self.handle, sortKeys) # Add items to XBMC list for m in tmpList.items: self.addListItem(m, len(tmpList.items)) proceed = True endOfDirectory(proceed) common.log('End of directory') return tmpList
def buildImage(): os.chdir(getScriptDir()) loadSettings() # Look for a kernel image imgpath = False # Discovered image goes here for path in ['images', os.path.join('stable-kernel', 'deploy')]: if not os.path.exists(path): continue files = sorted(os.listdir(path), reverse=True) for f in files: if f.endswith('.deb') and 'image' in f: imgpath = os.path.realpath(os.path.join(path, f)) print('Found kernel image: ' + imgpath) print( 'rootstock will use this local image instead of http://rcn-ee.net' ) break if imgpath: break # Clone RCN's git repository print('Building Ubuntu image') gitCloneAndEnter('git://github.com/RobertCNelson/omap-image-builder.git', '73e92f5cef5d3') #subprocess.call(['git', 'reset', '--hard', 'HEAD']) patches = [ '0001-Only-build-Precise-image.patch', '0002-Include-additional-packages-specified-in-settings.xm.patch', '0003-Force-MAC-address.patch', '0004-Remove-text-from-etc-flash-kernel.conf.patch', '0005-Copy-keys-to-the-new-filesystem.patch' ] if imgpath: patches.append('0006-Primary-kernel-is-on-local-filesystem.patch') if False: patches.append('0007-Run-script-to-install-ros.patch') for p in patches: subprocess.call([ 'git', 'am', os.path.join(getScriptDir(), 'patches', 'omap-image-builder', p) ]) #subprocess.call(['git', 'checkout', 'v2012.4-1', '-b', 'v2012.4-1']) # Configure image builder replaceAll('build_image.sh', 'FQDN="arm"', 'FQDN="' + getSetting('fqdn') + '"') replaceAll('build_image.sh', 'USER_LOGIN="******"', 'USER_LOGIN="******"') replaceAll('build_image.sh', 'USER_PASS="******"', 'USER_PASS="******"') replaceAll('build_image.sh', 'USER_NAME="Demo User"', 'USER_NAME="' + getSetting('name') + '"') replaceAll('var/pkg_list.sh', '__MECANUM_PACKAGES__', ','.join(getSetting('packages'))) if imgpath: # Kernel image, e.g. linux-image-3.2.18-x12_1.0precise_armhf.deb replaceAll('build_image.sh', '__KERNEL_DEB_FILE__', imgpath) replaceAll('tools/fixup.sh', 'DE:AD:BE:EF:CA:FE', getSetting('macaddress')) # Attempt to copy our ssh keys to the new filesystem try: id_rsa = open(getScriptDir() + '../../ssh_keys/id_rsa', 'r') rsa_private = id_rsa.read() id_rsa.close() id_rsa_pub = open(getScriptDir() + '../../ssh_keys/id_rsa.pub', 'r') rsa_public = id_rsa_pub.read() id_rsa_pub.close() if (len(rsa_private) and len(rsa_public)): replaceAll('tools/fixup.sh', '#USER_NAME=__USER_NAME__', 'USER_NAME="' + getSetting('username') + '"') replaceAll('tools/fixup.sh', '__RSA_PRIVATE__', rsa_private) replaceAll('tools/fixup.sh', '__RSA_PUBLIC__', rsa_public) except: pass # Build the image subprocess.call(['./build_image.sh']) os.chdir('..')
def installDependencies(): # Enable ROS packages -- skip this step because there are no armhf packages # sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu precise main" > /etc/apt/sources.list.d/ros-latest.list' # wget http://packages.ros.org/ros.key -O - | sudo apt-key add - ensureDependencies(getSetting('packages'))