How to use activatewindow method in pyatom

Best Python code snippet using pyatom_python

__init__.py

Source:__init__.py Github

copy

Full Screen

1# Copyright (C) 2008 Chris Longo <cal@chrislongo.net> and Tobias Arrskog (topfs2)2#3# This file is a plugin for EventGhost.4#5# EventGhost is free software; you can redistribute it and/or modify6# it under the terms of the GNU General Public License as published by7# the Free Software Foundation; either version 2 of the License, or8# (at your option) any later version.9#10# EventGhost is distributed in the hope that it will be useful,11# but WITHOUT ANY WARRANTY; without even the implied warranty of12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13# GNU General Public License for more details.14#15# You should have received a copy of the GNU General Public License16# along with EventGhost; if not, write to the Free Software17# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA1819from xbmcclient import *20import urllib21import json22import ast23import xml.dom.minidom24from xml.dom.minidom import Node2526# expose some information about the plugin through an eg.PluginInfo subclass2728eg.RegisterPlugin(29 name = "XBMC2",30 author = "Joni Boren",31 version = "0.6.0",32 kind = "program",33 guid = "{2DD98E35-F060-4444-9F11-168CD8131A6B}",34 canMultiLoad = True,35 createMacrosOnAdd = True,36 url = "http://www.eventghost.net/forum/viewtopic.php?f=10&t=1562",37 description = "Adds actions buttons to control <a href='http://www.xbmc.org/'>XBMC</a>.",38 icon = (39 "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsRAAALEQF/ZF+RAAAA"40 "BGdBTUEAALGeYUxB9wAAACBjSFJNAAB6fAAAfosAAPoBAACHPAAAbUoAAPFDAAA2IAAAHlNX4WK7"41 "AAACYElEQVR42tTTPW8ScQDH8d/9n44HESgFKQjFWku1rUYdTEAT0sGHSU10cHZz0piYjqYxbia6"42 "+hB3Y0w3kzq0scaojdZqYiMp1dQWAlLg4A7ugbvzRXTy8wK+21dyXRe7QbBLuw6wG3ceJnJnLuTL"43 "279DrutySBIhEnUopSbjtMsYVzkXLSFEU5Y9dY/XW5Nlr207DpRWE+zzp6VHxWLpstpWKaEA5RT9"44 "XgCcC/jDDihjOpWI6vF4WkLweigULgdD4R/p4ZH30X1Dr6XhbK4i/OH43qSKVikJLhhGz26AEo61"45 "+Qz0roWR8RDWixtIJKP4/mUVA5EgkvvjOHEy/1FKj+XnwpHMxdipIhJH29C2o0hMVmH1KJQyxWTw"46 "FuKhKYCbaDUVOI4LwzKxOD8PAvkrMazOW1uSUH43ilCqgUYphvJyBitzKUyfLiCVBe7PPkVzp4l7"47 "dx9g+lwB5T9bePPqJTIjB4v0uqmVi4cHbx67UkFteRjRAx30mgEcym9iZz2NpRcyfAM6Om0Nruui"48 "sr2F8SNZuIQjEhl6Lj0LAY8Hcwtq6nwhStuQJB8sWOh3fTClBgIDOhj1wDAtcEFRq/5FW+shPRRF"49 "diyTYJNe4Kr1bfaJHiv0qAtBKTgX4D6CAJXAbQIhaYhyG16iIxvpwEfW0BITM75YrsJm3Ah6SnfB"50 "kCtzWmLikmabYLYAIRxO34Zp6nAs9VdX6xSVRn2lb7QWe2b3w9RxplwLy2AL8AOMIa5s3vb6gzUm"51 "+5mh1XXL0Lq2pVRVQ2z66J6fpLdaMqu6KjwUXo8XnFH0+w6k/3+mfwMAzwT87LI0qNEAAAAASUVO"52 "RK5CYII="53 ),54)5556# from threading import Event, Thread5758# Windows availible in XBMC. For a list of all actions see: http://xbmc.org/wiki/?title=Window_IDs59"""60"""6162WINDOWS = (63(eg.ActionGroup, "Windows", "Windows", None, (64 ("MyMovies", "Show Movies Screen", "Show Movies screen.", "ActivateWindow(MyVideoLibrary,movietitles,return)"),65 ("MyTVShows", "Show TV Shows Screen", "Show TV Shows screen.", "ActivateWindow(MyVideoLibrary,tvshowtitles,return)"),66 ("ShutdownMenu", "Show Shutdown Menu", "Show the shutdown Menu.", "ActivateWindow(ShutdownMenu)"),67 ("Home", "Home", "Home", "Activatewindow(Home)"),68 ("Programs", "Programs", "Programs", "Activatewindow(Programs)"),69 ("Pictures", "Pictures", "Pictures", "Activatewindow(Pictures)"),70 ("Files", "Files", "Files", "Activatewindow(Files)"),71 ("Settings", "Settings", "Settings", "Activatewindow(Settings)"),72 ("Music", "Music", "Music", "Activatewindow(Music)"),73 ("Musicfiles", "Musicfiles", "Musicfiles", "Activatewindow(Musicfiles)"),74 ("Musiclibrary", "Musiclibrary", "Musiclibrary", "Activatewindow(Musiclibrary)"),75 ("Musicplaylist", "Musicplaylist", "Musicplaylist", "Activatewindow(Musicplaylist)"),76 ("Musicplaylisteditor", "Musicplaylisteditor", "Musicplaylisteditor", "Activatewindow(Musicplaylisteditor)"),77 ("Musicinformation", "Musicinformation", "Musicinformation", "Activatewindow(Musicinformation)"),78 ("Video", "Video", "Video", "Activatewindow(Video)"),79 ("Videofiles", "Videofiles", "Videofiles", "Activatewindow(Videofiles)"),80 ("Videolibrary", "Videolibrary", "Videolibrary", "Activatewindow(Videolibrary)"),81 ("Videoplaylist", "Videoplaylist", "Videoplaylist", "Activatewindow(Videoplaylist)"),82 ("Systeminfo", "Systeminfo", "Systeminfo", "Activatewindow(Systeminfo)"),83 ("Guicalibration", "Guicalibration", "Guicalibration", "Activatewindow(Guicalibration)"),84 ("Screencalibration", "Screencalibration", "Screencalibration", "Activatewindow(Screencalibration)"),85 ("Picturessettings", "Picturessettings", "Picturessettings", "Activatewindow(Picturessettings)"),86 ("Programssettings", "Programssettings", "Programssettings", "Activatewindow(Programssettings)"),87 ("Weathersettings", "Weathersettings", "Weathersettings", "Activatewindow(Weathersettings)"),88 ("Musicsettings", "Musicsettings", "Musicsettings", "Activatewindow(Musicsettings)"),89 ("Systemsettings", "Systemsettings", "Systemsettings", "Activatewindow(Systemsettings)"),90 ("Videossettings", "Videossettings", "Videossettings", "Activatewindow(Videossettings)"),91 ("Networksettings", "Networksettings", "Networksettings", "Activatewindow(Networksettings)"),92 ("Appearancesettings", "Appearancesettings", "Appearancesettings", "Activatewindow(Appearancesettings)"),93 ("Scripts", "Scripts", "Scripts", "Activatewindow(Scripts)"),94 ("Gamesaves", "Gamesaves", "Gamesaves", "Activatewindow(Gamesaves)"),95 ("Profiles", "Profiles", "Profiles", "Activatewindow(Profiles)"),96 ("Virtualkeyboard", "Virtualkeyboard", "Virtualkeyboard", "Activatewindow(Virtualkeyboard)"),97 ("Volumebar", "Volumebar", "Volumebar", "Activatewindow(Volumebar)"),98 ("Favourites", "Favourites", "Favourites", "Activatewindow(Favourites)"),99 ("Musicosd", "Musicosd", "Musicosd", "Activatewindow(Musicosd)"),100 ("Visualisationsettings", "Visualisationsettings", "Visualisationsettings", "Activatewindow(Visualisationsettings)"),101 ("Visualisationpresetlist", "Visualisationpresetlist", "Visualisationpresetlist", "Activatewindow(Visualisationpresetlist)"),102 ("Osdvideosettings", "Osdvideosettings", "Osdvideosettings", "Activatewindow(Osdvideosettings)"),103 ("Osdaudiosettings", "Osdaudiosettings", "Osdaudiosettings", "Activatewindow(Osdaudiosettings)"),104 ("Videobookmarks", "Videobookmarks", "Videobookmarks", "Activatewindow(Videobookmarks)"),105 ("Profilesettings", "Profilesettings", "Profilesettings", "Activatewindow(Profilesettings)"),106 ("Locksettings", "Locksettings", "Locksettings", "Activatewindow(Locksettings)"),107 ("Contentsettings", "Contentsettings", "Contentsettings", "Activatewindow(Contentsettings)"),108 ("Networksetup", "Networksetup", "Networksetup", "Activatewindow(Networksetup)"),109 ("Smartplaylisteditor", "Smartplaylisteditor", "Smartplaylisteditor", "Activatewindow(Smartplaylisteditor)"),110 ("Smartplaylistrule", "Smartplaylistrule", "Smartplaylistrule", "Activatewindow(Smartplaylistrule)"),111 ("Movieinformation", "Movieinformation", "Movieinformation", "Activatewindow(Movieinformation)"),112 ("Scriptsdebuginfo", "Scriptsdebuginfo", "Scriptsdebuginfo", "Activatewindow(Scriptsdebuginfo)"),113 ("Fullscreenvideo", "Fullscreenvideo", "Fullscreenvideo", "Activatewindow(Fullscreenvideo)"),114 ("Visualisation", "Visualisation", "Visualisation", "Activatewindow(Visualisation)"),115 ("Slideshow", "Slideshow", "Slideshow", "Activatewindow(Slideshow)"),116 ("Filestackingdialog", "Filestackingdialog", "Filestackingdialog", "Activatewindow(Filestackingdialog)"),117 ("Weather", "Weather", "Weather", "Activatewindow(Weather)"),118 ("Screensaver", "Screensaver", "Screensaver", "Activatewindow(Screensaver)"),119 ("Videoosd", "Videoosd", "Videoosd", "Activatewindow(Videoosd)"),120 ("Videomenu", "Videomenu", "Videomenu", "Activatewindow(Videomenu)"),121 ("Filebrowser", "Filebrowser", "Filebrowser", "Activatewindow(Filebrowser)"),122 ("Startup", "Startup", "Startup", "Activatewindow(Startup)"),123 ("Startwindow", "Startwindow", "Startwindow", "Activatewindow(Startwindow)"),124 ("Loginscreen", "Loginscreen", "Loginscreen", "Activatewindow(Loginscreen)"),125 ("Musicoverlay", "Musicoverlay", "Musicoverlay", "Activatewindow(Musicoverlay)"),126 ("Videooverlay", "Videooverlay", "Videooverlay", "Activatewindow(Videooverlay)"),127 ("Pictureinfo", "Pictureinfo", "Pictureinfo", "Activatewindow(Pictureinfo)"),128 ("Pluginsettings", "Pluginsettings", "Pluginsettings", "Activatewindow(Pluginsettings)"),129 ("Fullscreeninfo", "Fullscreeninfo", "Fullscreeninfo", "Activatewindow(Fullscreeninfo)"),130 ("PlayerControls", "Player Controls", "Player Controls", "ActivateWindow(PlayerControls)"),131)),132)133# actions handled by XBMC. For a list of all actions see: http://xbmc.org/wiki/?title=Action_IDs#General_actions_available_throughout_most_of_XBMC134135GENERAL_ACTIONS = (136(eg.ActionGroup, "General", "General", None, (137 ("Left", "Left", "Move left off a control.", "Left"),138 ("Right", "Right", "Move right off a control.", "Right"),139 ("Up", "Up", "Move up off a control.", "Up"),140 ("Down", "Down", "Move down off a control.", "Down"),141 ("PageUp", "Page Up", "Scroll up on page in a list, thumb, or text view.", "PageUp"),142 ("PageDown", "Page Down", "Scroll down on page in a list, thumb, or text view.", "PageDown"),143 ("Select", "Select", "Select a button, or an item from a list of thumb view.", "Select"),144 ("Highlight", "Highlight", "Highlight an item in a list or thumb view.", "highlight"),145 ("ParentDir", "ParentDir", "Go up a folder to the parent folder.", "parentdir"),146 ("PreviousMenu", "PreviousMenu", "Go back to the previous menu screen.", "previousmenu"),147 ("Info", "Info", "Show the information about the currently highlighted item, or currently playing item.", "info"),148 ("Screenshot", "Screenshot", "Take a screenshot of the current screen..", "Screenshot"),149 ("PowerOff", "PowerOff", "Shutdown and power off.", "PowerOff"),150 ("VolumeUp", "VolumeUp", "Increase the volume of playback..", "VolumeUp"),151 ("VolumeDown", "VolumeDown", "Decrease the volume of playback..", "VolumeDown"),152 ("Mute", "Mute", "Mute the volume..", "Mute"),153 ("ContextMenu", "ContextMenu", "Pops up a contextual menu.", "ContextMenu"),154 ("ScrollUp", "ScrollUp", "Variable speed scroll up for analog keys (stick or triggers).", "ScrollUp"),155 ("ScrollDown", "ScrollDown", "Variable speed scroll down for analog keys (stick or triggers).", "ScrollDown"),156 ("Close", "Close", "Used to close a dialog.", "Close"),157 ("Number0", "Number0", "Used to input the number 0.", "Number0"),158 ("Number1", "Number1", "Used to input the number 1.", "Number1"),159 ("Number2", "Number2", "Used to input the number 2.", "Number2"),160 ("Number3", "Number3", "Used to input the number 3.", "Number3"),161 ("Number4", "Number4", "Used to input the number 4.", "Number4"),162 ("Number5", "Number5", "Used to input the number 5.", "Number5"),163 ("Number6", "Number6", "Used to input the number 6.", "Number6"),164 ("Number7", "Number7", "Used to input the number 7.", "Number7"),165 ("Number8", "Number8", "Used to input the number 8.", "Number8"),166 ("Number9", "Number9", "Used to input the number 9.", "Number9"),167)),168)169170# actions handled by XBMC. For a list of all actions see: http://xbmc.org/wiki/?title=Action_IDs#General_actions_available_while_video_or_music_are_playing171172MEDIA_PLAYING_ACTIONS = (173(eg.ActionGroup, "MediaPlaying", "Media playing", None, (174 ("Play", "Play", "Play the selected item (or folder of items), or unpause a paused item..", "Play"),175 ("Pause", "Pause", " Pause the currently playing item. .", "Pause"),176 ("Stop", "Stop", " Stop the currently playing item. .", "Stop"),177 ("FastForward", "FastForward", "Toggle the fastforward speed between normal play, 2x, 4x, 8x, 16x, and 32x..", "FastForward"),178 ("Rewind", "Rewind", "Toggle the rewind speed between normal play, 2x, 4x, 8x, 16x, and 32x..", "Rewind"),179 ("SkipNext", "SkipNext", "Skip to the next item in a playlist..", "SkipNext"),180 ("SkipPrevious", "SkipPrevious", "Skip to the previous item in a playlist..", "SkipPrevious"),181 ("FullScreen", "FullScreen", "Toggles fullscreen modes (either visualisation or video playback).", "FullScreen"),182 ("CodecInfo", "CodecInfo", "Show codec information about the currently playing item (during video or visualisation playback).", "CodecInfo"),183 ("AnalogSeekForward", "AnalogSeekForward", "Variable speed seeking for analog keys (stick or triggers).", "AnalogSeekForward"),184 ("AnalogSeekBack", "AnalogSeekBack", "Variable speed seeking for analog keys (stick or triggers).", "AnalogSeekBack"),185 ("AnalogFastForward", "AnalogFastForward", "Variable speed fast forward for analog keys (stick or triggers).", "AnalogFastForward"),186 ("AnalogRewind", "AnalogRewind", "Variable speed rewind for analog keys (stick or triggers).", "AnalogRewind"),187 ("PartyMode", "Party Mode", "Party mode.", "PlayerControl(PartyMode)"),188 ("Random", "Random", "Random.", "PlayerControl(Random)"),189 ("Repeat", "Repeat", "Repeat.", "PlayerControl(Repeat)"),190 ("UpdateVideoLibrary", "Update Video Library", "Update the video library.", "UpdateLibrary(Video)"),191 ("UpdateMusicLibrary", "Update Music Library", "Update the music library.", "UpdateLibrary(Music)"),192 ("IncreaseRating", "IncreaseRating", "Unused.", "IncreaseRating"),193 ("DecreaseRating", "DecreaseRating", "Unused .", "DecreaseRating"),194 ("EjectTray", "Eject Tray", "Close or open the DVD tray.", "EjectTray"),195 ("Record", "Record", "Starts recording.", "Record"),196 ("PlayDVD", "Play DVD", "Plays the inserted CD or DVD media from the DVD-ROM Drive.", "PlayDVD"),197 ("LastFMLove", "Last FM Love", "Add the current playing last.fm radio track to the last.fm loved tracks.", "LastFM.Love"),198 ("LastFMBan", "Last FM Ban", "Ban the current playing last.fm radio track.", "LastFM.Ban"),199)),200)201# Actions handled by XBMC. For a list of all actions see: http://xbmc.org/wiki/?title=Action_IDs#Actions_available_only_in_Music_and_Videos_windows_only202203PLAYLIST_ACTIONS = (204(eg.ActionGroup, "Playlist", "Playlist", None, (205 ("Playlist", "Playlist", "Toggle to playlist view from My Music or My Videos.", "Playlist"),206 ("Queue", "Queue", "Queue the item to the current playlist.", "Queue"),207 ("MoveItemUp", "MoveItemUp", "Used to rearrange playlists.", "MoveItemUp"),208 ("MoveItemDown", "MoveItemDown", "Used to rearrange playlists.", "MoveItemDown"),209)),210)211212# Actions handled by XBMC. For a list of all actions see: http://xbmc.org/wiki/?title=Action_IDs#Actions_available_only_in_Full_Screen_Video213214FULLSCREEN_VIDEO_ACTIONS = (215(eg.ActionGroup, "FullscreenVideo", "FullScreen Video", None, (216 ("StepForward", "StepForward", "Step forward 1% in the movie..", "StepForward"),217 ("StepBack", "StepBack", "Step back 1% in the movie..", "StepBack"),218 ("BigStepForward", "BigStepForward", "Step forward 10% in the movie..", "BigStepForward"),219 ("BigStepBack", "BigStepBack", "Step back 10% in the movie..", "BigStepBack"),220 ("SmallStepBack", "SmallStepBack", "Step back 7 seconds in the current video..", "SmallStepBack"),221 ("OSD", "OSD", "Toggles the OSD while playing an item..", "OSD"),222 ("AspectRatio", "AspectRatio", "Toggle through the various aspect ratio modes (Normal is the preferred option)..", "AspectRatio"),223 ("ShowSubtitles", "ShowSubtitles", "Toggles whether subtitles are shown or not..", "ShowSubtitles"),224 ("NextSubtitle", "NextSubtitle", "Change to the next subtitle language, if there is more than one..", "NextSubtitle"),225 ("SubtitleDelayMinus", "SubtitleDelayMinus", "Decrease the delay amount of subtitles (use if subtitles are displaying too late).", "SubtitleDelayMinus"),226 ("SubtitleDelayPlus", "SubtitleDelayPlus", "Increase the delay amount of subtitles (use if subtitles are displaying too early).", "SubtitleDelayPlus"),227 ("AudioDelayMinus", "AudioDelayMinus", "Decrease the delay amount of audio (use if audio is being heard too early).", "AudioDelayMinus"),228 ("AudioDelayPlus", "AudioDelayPlus", "Increase the delay amount of audio (use if audio is being heard too late).", "AudioDelayPlus"),229 ("AudioNextLanguage", "AudioNextLanguage", "Change to the next audio track in a video with multiple audio tracks..", "AudioNextLanguage"),230 ("mplayerosd", "mplayerosd", "Show Mplayer's OSD.", "mplayerosd"),231 ("ShowTime", "ShowTime", "Used to show the current play time in music + video playback.", "ShowTime"),232 ("ShowVideoMenu", "ShowVideoMenu", "Go to the DVD Video menu when playing a DVD..", "ShowVideoMenu"),233)),234)235236# Actions handled by XBMC. For a list of all actions see: http://xbmc.org/wiki/?title=Action_IDs#Actions_available_during_a_picture_slideshow237238SLIDESHOW_ACTIONS = (239(eg.ActionGroup, "PictureSlideshow", "Picture slideshow", None, (240 ("NextPicture", "NextPicture", "Move to the next picture in a slideshow..", "NextPicture"),241 ("PreviousPicture", "PreviousPicture", "Move to the previous picture in a slideshow..", "PreviousPicture"),242 ("ZoomOut", "ZoomOut", "Used in picture or slideshow to zoom out of the current image..", "ZoomOut"),243 ("ZoomIn", "ZoomIn", "Used in picture or slideshow to zoom in to the current image..", "ZoomIn"),244 ("ZoomNormal", "ZoomNormal", "Normal (fullscreen) viewing in My Pictures.", "ZoomNormal"),245 ("ZoomLevel1", "ZoomLevel1", "Zoom to 120% in My Pictures.", "ZoomLevel1"),246 ("ZoomLevel2", "ZoomLevel2", "Zoom to 150% in My Pictures.", "ZoomLevel2"),247 ("ZoomLevel3", "ZoomLevel3", "Zoom to 200% in My Pictures.", "ZoomLevel3"),248 ("ZoomLevel4", "ZoomLevel4", "Zoom to 280% in My Pictures.", "ZoomLevel4"),249 ("ZoomLevel5", "ZoomLevel5", "Zoom to 400% in My Pictures.", "ZoomLevel5"),250 ("ZoomLevel6", "ZoomLevel6", "Zoom to 600% in My Pictures.", "ZoomLevel6"),251 ("ZoomLevel7", "ZoomLevel7", "Zoom to 900% in My Pictures.", "ZoomLevel7"),252 ("ZoomLevel8", "ZoomLevel8", "Zoom to 1350% in My Pictures.", "ZoomLevel8"),253 ("ZoomLevel9", "ZoomLevel9", "Zoom to 2000% in My Pictures.", "ZoomLevel9"),254 ("AnalogMove", "AnalogMove", "Move in the calibration screens, and while zoomed in My Pictures..", "AnalogMove"),255 ("Rotate", "Rotate", "Rotate a picture in My Pictures.", "Rotate"),256)),257)258# Actions handled by XBMC. For a list of all actions see: http://xbmc.org/wiki/?title=Action_IDs#Actions_available_in_screen_calibration259260CALIBRATION_ACTIONS = (261(eg.ActionGroup, "ScreenCalibration", "Screen calibration", None, (262 ("NextCalibration", "NextCalibration", "Used in Video + GUI calibration.", "NextCalibration"),263 ("ResetCalibration", "ResetCalibration", "Used in Video + GUI calibration.", "ResetCalibration"),264 ("AnalogMove", "AnalogMove", "Move in the calibration screens, and while zoomed in My Pictures..", "AnalogMove"),265 ("NextResolution", "NextResolution", "Used in Video calibration.", "NextResolution"),266)),267)268269# Actions handled by XBMC. For a list of all actions see: http://xbmc.org/wiki/?title=Action_IDs#Actions_available_in_the_File_Manager270271FILEMANAGER_ACTIONS = (272(eg.ActionGroup, "FileManager", "File Manager", None, (273 ("Delete", "Delete", "Used in My Files to delete a file..", "Delete"),274 ("Copy", "Copy", "Used in My Files to copy a file..", "Copy"),275 ("Move", "Move", "Used in My Files to move a file..", "Move"),276 ("Rename", "Rename", "Used in My Files to rename a file..", "Rename"),277)),278)279# Actions handled by XBMC. For a list of all actions see: http://xbmc.org/wiki/?title=Action_IDs#Actions_available_in_the_on-screen_keyboard280281ON_SCREEN_KEYBOARD_ACTIONS = (282(eg.ActionGroup, "On-screenKeyboard", "On-screen keyboard", None, (283 ("BackSpace", "BackSpace", "Used in the virtual keyboards to delete one letter..", "BackSpace"),284 ("Shift", "Shift", "Used in Virtual Keyboard to switch to upper or lower case letters.", "Shift"),285 ("Symbols", "Symbols", "Used in Virtual Keyboard to switch to or from symbols mode.", "Symbols"),286 ("CursorLeft", "CursorLeft", "Used in Virtual Keyboard to move the current cursor point to the left.", "CursorLeft"),287 ("CursorRight", "CursorRight", "Used in Virtual Keyboard to move the current cursor point to the right.", "CursorRight"),288)),289)290291# Actions handled by XBMC. For a list of all actions see: http://xbmc.org/wiki/?title=Action_IDs#Actions_available_during_a_music_visualisation292293VISUALISATION_ACTIONS = (294(eg.ActionGroup, "MusicVisualisation", "Music visualisation", None, (295 ("OSD", "OSD", "Toggles the OSD while playing an item..", "OSD"),296 ("ShowPreset", "ShowPreset", "Shows the current visualisation preset (milkdrop/spectrum).", "ShowPreset"),297 ("PresetList", "PresetList", "Pops up the visualisation preset list (milkdrop/spectrum).", "PresetList"),298 ("NextPreset", "NextPreset", "Next visualisation preset.", "NextPreset"),299 ("PreviousPreset", "PreviousPreset", "Previous visualisation preset.", "PreviousPreset"),300 ("LockPreset", "LockPreset", "Lock the current visualisation preset.", "LockPreset"),301 ("RandomPreset", "RandomPreset", "Switch to a new random preset.", "RandomPreset"),302 ("increasevisrating", "increasevisrating", "increasevisrating.", "increasevisrating"),303 ("decreasevisrating", "decreasevisrating", "decreasevisrating.", "decreasevisrating"),304)),305)306307SHUTDOWN_ACTIONS = (308(eg.ActionGroup, "ShutdownRelated", "Shutdown related", None, (309 ("Quit", "Quit XBMC", "Quit XBMC.", "Quit"),310 ("RestartApp", "Restart XBMC", "Restarts XBMC.", "RestartApp"),311 ("Reset", "Reset Computer", "Reset the computer.", "Reset"),312 ("Shutdown", "Shutdown Computer", "Trigger default Shutdown action defined in System Settings, Default Quit on Windows.", "Shutdown"),313 ("Powerdown", "Powerdown Computer", "Powerdown system.", "Powerdown"),314 ("Suspend", "Suspend Computer", "Suspends (S3 / S1 depending on bios setting) the System.", "Suspend"),315 ("Hibernate", "Hibernate Computer", "Hibernate (S5) the System.", "Hibernate"),316 ("Reboot", "Reboot Computer", "Cold reboots the system (power cycle).", "Reboot"),317 ("Restart", "Restart Computer", "Cold reboots the system (power cycle).", "Restart"),318)),319)320321UNCATEGORIZED_ACTIONS = (322(eg.ActionGroup, "UncategorizedActions", "Uncategorized actions", None, (323 ("JumpSMS2", "JumpSMS2", "JumpSMS2.", "JumpSMS2"),324 ("JumpSMS3", "JumpSMS3", "JumpSMS3.", "JumpSMS3"),325 ("JumpSMS4", "JumpSMS4", "JumpSMS4.", "JumpSMS4"),326 ("JumpSMS5", "JumpSMS5", "JumpSMS5.", "JumpSMS5"),327 ("JumpSMS6", "JumpSMS6", "JumpSMS6.", "JumpSMS6"),328 ("JumpSMS7", "JumpSMS7", "JumpSMS7.", "JumpSMS7"),329 ("JumpSMS8", "JumpSMS8", "JumpSMS8.", "JumpSMS8"),330 ("JumpSMS9", "JumpSMS9", "JumpSMS9.", "JumpSMS9"),331 ("FilterClear", "FilterClear", "FilterClear.", "FilterClear"),332 ("FilterSMS2", "FilterSMS2", "FilterSMS2.", "FilterSMS2"),333 ("FilterSMS3", "FilterSMS3", "FilterSMS3.", "FilterSMS3"),334 ("FilterSMS4", "FilterSMS4", "FilterSMS4.", "FilterSMS4"),335 ("FilterSMS5", "FilterSMS5", "FilterSMS5.", "FilterSMS5"),336 ("FilterSMS6", "FilterSMS6", "FilterSMS6.", "FilterSMS6"),337 ("FilterSMS7", "FilterSMS7", "FilterSMS7.", "FilterSMS7"),338 ("FilterSMS8", "FilterSMS8", "FilterSMS8.", "FilterSMS8"),339 ("FilterSMS9", "FilterSMS9", "FilterSMS9.", "FilterSMS9"),340 ("FirstPage", "FirstPage", "FirstPage.", "FirstPage"),341 ("LastPage", "LastPage", "LastPage.", "LastPage"),342343 ("HideSubMenu", "HideSubMenu", "<Depreciated>.", "HideSubMenu"),344345 ("ToggleSource", "ToggleSource", "ToggleSource.", "ToggleSource"),346 ("Remove", "Remove", "Remove.", "Remove"),347348 ("AudioToggleDigital", "AudioToggleDigital", "AudioToggleDigital.", "AudioToggleDigital"),349350 ("OSDLeft", "OSDLeft", "OSDLeft.", "OSDLeft"),351 ("OSDRight", "OSDRight", "OSDRight.", "OSDRight"),352 ("OSDUp", "OSDUp", "OSDUp.", "OSDUp"),353 ("OSDDown", "OSDDown", "OSDDown.", "OSDDown"),354 ("OSDSelect", "OSDSelect", "OSDSelect.", "OSDSelect"),355 ("OSDValuePlus", "OSDValuePlus", "OSDValuePlus.", "OSDValuePlus"),356 ("OSDValueMinus", "OSDValueMinus", "OSDValueMinus.", "OSDValueMinus"),357358 ("ToggleWatched", "ToggleWatched", "ToggleWatched.", "ToggleWatched"),359 ("ScanItem", "ScanItem", "ScanItem.", "ScanItem"),360361 ("Enter", "Enter", "Enter.", "Enter"),362 ("IncreaseRating", "IncreaseRating", "IncreaseRating.", "IncreaseRating"),363 ("DecreaseRating", "DecreaseRating", "DecreaseRating.", "DecreaseRating"),364 ("ToggleFullScreen", "ToggleFullScreen", "ToggleFullScreen.", "ToggleFullScreen"),365 ("NextScene", "NextScene", "NextScene.", "NextScene"),366 ("PreviousScene", "PreviousScene", "PreviousScene.", "PreviousScene"),367 ("NextLetter", "NextLetter", "NextLetter.", "NextLetter"),368 ("PrevLetter", "PrevLetter", "PrevLetter.", "PrevLetter"),369)),370)371372# Remote buttons handled by XBMC. For a list of all buttons see: http://xbmc.org/wiki/?title=Keymap.xml#Remote_Buttons373374REMOTE_BUTTONS = (375(eg.ActionGroup, "Remote", "Remote", None, (376 ("RemoteLeft", "Left", "Move left off a control.", "left"),377 ("RemoteRight", "Right", "Move right off a control.", "right"),378 ("RemoteUp", "Up", "Move up off a control.", "up"),379 ("RemoteDown", "Down", "Move down off a control.", "down"),380 ("RemoteSelect", "Select", "Select a button, or an item from a list of thumb view.", "select"),381 ("RemoteBack", "Back", "", "back"),382 ("RemoteMenu", "Menu", "", "menu"),383 ("RemoteInfo", "Info", "", "info"),384 ("RemoteDisplay", "Display", "", "display"),385 ("RemoteTitle", "Title", "", "title"),386 ("RemotePlay", "Play", "", "play"),387 ("RemotePause", "Pause", "", "pause"),388 ("RemoteReverse", "Reverse", "", "reverse"),389 ("RemoteForward", "Forward", "", "forward"),390 ("RemoteSkipPlus", "Skip +", "", "skipplus"),391 ("RemoteSkipMinus", "Skip -", "", "skipminus"),392 ("RemoteStop", "Stop", "", "stop"),393 ("Remote0", "0", "", "zero"),394 ("Remote1", "1", "", "one"),395 ("Remote2", "2", "", "two"),396 ("Remote3", "3", "", "three"),397 ("Remote4", "4", "", "four"),398 ("Remote5", "5", "", "five"),399 ("Remote6", "6", "", "six"),400 ("Remote7", "7", "", "seven"),401 ("Remote8", "8", "", "eight"),402 ("Remote9", "9", "", "nine"),403 ("RemotePower", "Power", "", "power"),404 ("RemoteMyTV", "My TV", "", "myTV"),405 ("RemoteMyMusic", "My Music", "", "mymusic"),406 ("RemoteMyPictures", "My Pictures", "", "mypictures"),407 ("RemoteMyVideo", "My Video", "", "myvideo"),408 ("RemoteRecord", "Record", "", "record"),409 ("RemoteStart", "Start", "", "start"),410 ("RemoteVolPlus", "Vol +", "", "volumeplus"),411 ("RemoteVolMinus", "Vol -", "", "volumeminus"),412 ("Remotechannelplus", "channelplus", "", "channelplus"),413 ("Remotechannelminus", "channelminus", "", "channelminus"),414 ("Remotepageplus", "pageplus", "", "pageplus"),415 ("Remotepageminus", "pageminus", "", "pageminus"),416 ("RemoteMute", "Mute", "", "mute"),417 ("RemoteRecordedTV", "Recorded TV", "", "recordedtv"),418 ("RemoteLiveTV", "Live TV", "", "livetv"),419 ("RemoteStar", "*", "", "star"),420 ("Remote#", "#", "", "hash"),421 ("RemoteClear", "Clear", "", "clear"),422 ("Remoteguide", "guide", "", "guide"),423 ("Remoteenter", "enter", "", "enter"),424 ("Remotexbox", "xbox", "", "xbox"),425 ("Remoteteletext", "teletext", "", "teletext"),426 ("Remotered", "red", "", "red"),427 ("Remotegreen", "green", "", "green"),428 ("Remoteyellow", "yellow", "", "yellow"),429 ("Remoteblue", "blue", "", "blue"),430 ("Remotesubtitle", "subtitle", "", "subtitle"),431 ("Remotelanguage", "language", "", "language"),432)),433)434# Remote buttons handled by XBMC. For a list of all buttons see: http://xbmc.org/wiki/?title=Keymap.xml#Gamepad_Buttons435436GAMEPAD_BUTTONS = (437(eg.ActionGroup, "Gamepad", "Gamepad", None, (438 ("GamepadA", "a", "a.", "a"),439 ("GamepadB", "b", "b.", "b"),440 ("GamepadX", "x", "x.", "x"),441 ("GamepadY", "y", "y.", "y"),442 ("GamepadWhite", "white", "white.", "white"),443 ("GamepadBlack", "black", "black.", "black"),444 ("GamepadStart", "start", "start.", "start"),445 ("GamepadBack", "back", "back.", "back"),446 ("GamepadLeftThumbButton", "leftthumbbutton", "leftthumbbutton.", "leftthumbbutton"),447 ("GamepadRightThumbButton", "rightthumbbutton", "rightthumbbutton.", "rightthumbbutton"),448 ("GamepadLeftThumbStick", "leftthumbstick", "leftthumbstick.", "leftthumbstick"),449 ("GamepadLeftThumbStickUp", "leftthumbstickup", "leftthumbstickup.", "leftthumbstickup"),450 ("GamepadLeftThumbStickDown", "leftthumbstickdown", "leftthumbstickdown.", "leftthumbstickdown"),451 ("GamepadLeftThumbStickLeft", "leftthumbstickleft", "leftthumbstickleft.", "leftthumbstickleft"),452 ("GamepadLeftThumbStickRight", "leftthumbstickright", "leftthumbstickright.", "leftthumbstickright"),453 ("GamepadRightThumbStick", "rightthumbstick", "rightthumbstick.", "rightthumbstick"),454 ("GamepadRightThumbStickUp", "rightthumbstickup", "rightthumbstickup.", "rightthumbstickup"),455 ("GamepadRightThumbStickDown", "rightthumbstickdown", "rightthumbstickdown.", "rightthumbstickdown"),456 ("GamepadRightThumbStickLeft", "rightthumbstickleft", "rightthumbstickleft.", "rightthumbstickleft"),457 ("GamepadRightThumbStickRight", "rightthumbstickright", "rightthumbstickright.", "rightthumbstickright"),458 ("GamepadLeftTrigger", "lefttrigger", "lefttrigger.", "lefttrigger"),459 ("GamepadRightTrigger", "righttrigger", "righttrigger.", "righttrigger"),460 ("GamepadLeftAnalogTrigger", "leftanalogtrigger", "leftanalogtrigger.", "leftanalogtrigger"),461 ("GamepadRightAnalogTrigger", "rightanalogtrigger", "rightanalogtrigger.", "rightanalogtrigger"),462 ("GamepadDpadLeft", "dpadleft", "dpadleft.", "dpadleft"),463 ("GamepadDpadRight", "dpadright", "dpadright.", "dpadright"),464 ("GamepadDpadUp", "dpadup", "dpadup.", "dpadup"),465 ("GamepadDpadDown", "dpaddown", "dpaddown.", "dpaddown"),466)),467)468469# Support functions470def ParseString2(text, filterFunc=None):471 start = 0472 chunks = []473 last = len(text) - 1474 while 1:475 pos = text.find('{{', start)476 if pos < 0:477 break478 if pos == last:479 break480 chunks.append(text[start:pos])481 start = pos + 2482 end = text.find('}}', start)483 if end == -1:484 raise SyntaxError("unmatched bracket")485 word = text[start:end]486 res = None487 if filterFunc:488 res = filterFunc(word)489 if res is None:490 res = eval(word, {}, eg.globals.__dict__)491 chunks.append(unicode(res))492 start = end + 2493 chunks.append(text[start:])494 return "".join(chunks)495496497class ActionPrototype(eg.ActionClass):498 def __call__(self):499 try:500 self.plugin.xbmc.send_action(self.value, ACTION_BUTTON)501 except:502 raise self.Exceptions.ProgramNotRunning503504# actions handled by XBMC. For a list of all actions see: http://xbmc.org/wiki/?title=Action_IDs#General_actions_available_throughout_most_of_XBMC505"""506CONFIGURABLE_ACTIONS = (507(eg.ActionGroup, "General", "General", None, (508 ("UpdateLibrary", "UpdateLibrary", "UpdateLibrary", "UpdateLibrary(Video)"),509)),510)511"""512class UpdateLibrary(eg.ActionBase):513 def __call__(self, libraryType="Video", updatePath=""):514 try:515 self.plugin.xbmc.send_action("UpdateLibrary("+libraryType+","+updatePath+")", ACTION_BUTTON)516 except:517 raise self.Exceptions.ProgramNotRunning518519 def Configure(self, libraryType="Video", updatePath="" ):520 panel = eg.ConfigPanel()521 textControl1 = wx.TextCtrl(panel, -1, libraryType)522 textControl2 = wx.TextCtrl(panel, -1, updatePath)523 panel.sizer.Add(textControl1, 1, wx.EXPAND)524 panel.sizer.Add(textControl2, 1, wx.EXPAND)525 while panel.Affirmed():526 panel.SetResult(textControl1.GetValue())527 panel.SetResult(textControl2.GetValue())528529class ButtonPrototype(eg.ActionClass):530 def __call__(self):531 try:532 packet = PacketBUTTON(map_name=str("R1"), button_name=str(self.value), repeat=0)533 packet.send(self.plugin.xbmc.sock, self.plugin.xbmc.addr, self.plugin.xbmc.uid)534 except:535 raise self.Exceptions.ProgramNotRunning536537class GamepadPrototype(eg.ActionClass):538 def __call__(self):539 try:540 packet = PacketBUTTON(map_name=str("XG"), button_name=str(self.value), repeat=0)541 packet.send(self.plugin.xbmc.sock, self.plugin.xbmc.addr, self.plugin.xbmc.uid)542 except:543 raise self.Exceptions.ProgramNotRunning544545class XBMC_HTTP_API:546547 def __init__(self):548 self.ip = "127.0.0.1"549 self.port = "80"550 return551552 def connect(self, ip=None, port=None):553 if ip: self.ip = ip554 if port: self.port = port555 print 'HTTP API connected'556557 def send(self, method, params = ""):558 try:559 responce = urllib.urlopen('http://'+self.ip+':'+self.port+'/xbmcCmds/xbmcHttp?command='+method+'('+urllib.quote(eg.ParseString(params), ':\\')+')').readlines()560 except IOError:561# print 'HTTP API connection error:'+' http://'+self.ip+':'+self.port+'\n'+method+'('+urllib.quote(eg.ParseString(params), ':\\')+')'562 eg.PrintError('HTTP API connection error:'+' http://'+self.ip+':'+self.port+'\n'+method+'('+urllib.quote(eg.ParseString(params), ':\\')+')')563 else:564 if (''.join(responce).find('<html>') != -1):565 responce2 = {}566 for lines in responce:567 if (lines.find('<html>') != -1): lines = lines[lines.find('<html>')+6:]568 if (lines.find('</html>') != -1): lines = lines[:lines.find('</html>')]569 if (lines.find('<li>') != -1):570 if (lines.find('OK') != -1):571 responce2 = 'OK'572 elif (lines.find('ERROR') != -1):573 responce2 = lines[4:].rstrip('\n').split(':', 1)574 elif (lines.find(':') != -1):575 lines = lines[4:].rstrip('\n').split(':', 1)576 responce2[lines[0]] = lines[1]577 else:578 responce2 = lines[4:].rstrip('\n')579 else:580 if (lines.rstrip('\n') != ''):581 responce2 = lines.rstrip('\n')582 return responce2583584 def close(self):585 print 'HTTP API connection closed'586587class XBMC_JSON_RPC:588589 def __init__(self):590 self.jsoninit = {'jsonrpc':'2.0', 'id':1}591 self.ip = "127.0.0.1"592 self.port = "80"593 return594595 def connect(self, ip=None, port=None):596 if ip: self.ip = ip597 if port: self.port = port598 print 'JSON-RPC connected'599600 def send(self, method, params = None):601 self.jsoninit['method'] = method602 if params: self.jsoninit['params'] = params603 try:604 responce = urllib.urlopen('http://'+self.ip+':'+self.port+'/jsonrpc', json.dumps(self.jsoninit)).read()605 except IOError:606# print 'JSON-RPC connection error:'+' http://'+self.ip+':'+self.port+'\n'+json.dumps(self.jsoninit)607 eg.PrintError('JSON-RPC connection error:'+' http://'+self.ip+':'+self.port+'\n'+json.dumps(self.jsoninit))608 else:609# print responce610 return json.loads(responce)611612 def close(self):613 print 'JSON-RPC connection closed'614615class GetCurrentlyPlayingFilename(eg.ActionClass):616 description = "Get filename of currently playing file"617618 def __call__(self):619 responce = self.plugin.JSON_RPC.send('Player.GetActivePlayers')620 if (responce != None):621 Method = None622 if (responce['result']['picture']): Method = 'Picture'623 elif (responce['result']['video']): Method = 'Video'624 elif (responce['result']['audio']): Method = 'Audio'625 if Method:626 print 'Method: ', Method627 if (Method != 'Picture'):628 responce = self.plugin.JSON_RPC.send(Method+'Playlist.GetItems')629# print 'eg.result: ', responce['items'][responce['current']]['file']630 return responce['result']['items'][responce['result']['current']]['file']631 else:632 responce = self.plugin.HTTP_API.send('getcurrentlyplaying')633 if responce:634 if (responce['result']['Filename'] == ''):635 print 'No file playing'636 return responce['result']['Filename']637 else:638 raise self.Exceptions.ProgramNotRunning639 else:640 print 'No file playing'641 else:642 responce = self.plugin.HTTP_API.send('getcurrentlyplaying')643 if responce:644 if (responce['Filename'] == ''):645 print 'No file playing'646 return responce['Filename']647 else:648 raise self.Exceptions.ProgramNotRunning649650class SendNotification(eg.ActionClass):651 description = "Send a notification to the connected XBMC"652653 def __call__(self, title, message):654 try:655 self.plugin.xbmc.send_notification(str(eg.ParseString(title)), str(eg.ParseString(message)))656 except UnicodeEncodeError:657# print "Error: ascii charecters only."658 eg.PrintError("Error: ascii charecters only.")659 except:660 raise self.Exceptions.ProgramNotRunning661 def Configure(self, title='Hello', message='world'):662 panel = eg.ConfigPanel()663 Title = wx.TextCtrl(panel, -1, value=title)664 Message = wx.TextCtrl(panel, -1, value=message)665 panel.sizer.Add(wx.StaticText(panel, -1, "Title"))666 panel.sizer.Add(Title)667 panel.sizer.Add(wx.StaticText(panel, -1, "Message"))668 panel.sizer.Add(Message)669 while panel.Affirmed():670 panel.SetResult(Title.GetValue(), Message.GetValue())671672class HTTPAPI(eg.ActionClass):673 description = "Run any <a href='http://wiki.xbmc.org/index.php?title=Web_Server_HTTP_API'>XBMC HTTP API</a> command."674675 def __call__(self, command, param, category, log):676 if param:677 responce = self.plugin.HTTP_API.send(command, param)678 else:679 responce = self.plugin.HTTP_API.send(command)680 if responce != None:681# print 'Result:\n', responce682 if log:683 import pprint684 print 'Result:'685 pprint.PrettyPrinter(indent=2).pprint(responce)686 return responce687 else:688 raise self.Exceptions.ProgramNotRunning689690 def Configure(self, command="GetCurrentPlaylist", param="", category=0, log=True):691 class record:692 pass693 httpapi = record()694 httpapi.Headers = []695 httpapi.Commands = []696 OldCategory = category697698 def OnUpdate(event):699 UpdateCommands()700 try:701 with open(os.path.join(eg.folderPath.RoamingAppData, 'EventGhost', 'plugins', 'XBMC2', 'httpapi.dat'), 'rb') as f:702 import pickle703 httpapi.Headers, httpapi.Commands = pickle.load(f)704 except IOError:705# print 'Failed to open: httpapi.dat'706 eg.PrintError('Failed to open: httpapi.dat')707 else:708 category = OldCategory709 HBoxControl.Clear()710 for i in httpapi.Headers:711 HBoxControl.Append(i)712 HBoxControl.SetValue(httpapi.Headers[category])713 UpdateCommandCtrl(HBoxControl.GetSelection())714 def OnCommandChange(event):715 if event.GetEventObject() == comboBoxControl:716 syntax.SetLabel(httpapi.Commands[HBoxControl.GetSelection()][1][event.GetSelection()])717 description.SetLabel(httpapi.Commands[HBoxControl.GetSelection()][2][event.GetSelection()])718 description.Wrap(480)719 else:720 UpdateCommandCtrl(event.GetSelection())721 def UpdateCommandCtrl(Selection):722 value = comboBoxControl.GetValue()723 comboBoxControl.Clear()724 for i in httpapi.Commands[Selection][0]:725 comboBoxControl.Append(i)726 comboBoxControl.SetValue(value)727728 def GetText(nodes):729 Text = ''730 for node in nodes.childNodes:731 if node.nodeType == Node.TEXT_NODE: Text += node.data732 else: Text += GetText(node)733 return Text734 def UpdateCommands():735 httpapi.Headers = [];httpapi.Commands = []736 doc = xml.dom.minidom.parse(urllib.urlopen('http://wiki.xbmc.org/index.php?title=Web_Server_HTTP_API'))737 for h3 in doc.getElementsByTagName("h3")[11:-1]:738 for span in h3.getElementsByTagName("span"):739 httpapi.Headers.append(span.childNodes[0].data)740 Header = 0741 for node in doc.getElementsByTagName("table")[3:8]:742 for node2 in node.getElementsByTagName("tr")[1:]:743 httpapi.Commands.append([[],[],[]])744 node3 = node2.getElementsByTagName("td")[0]745 for node4 in node3.childNodes:746 if node4.nodeType == Node.TEXT_NODE:747 Text = node4.data.strip()748 httpapi.Commands[Header][1].append(Text)749 Pos = Text.find('(')750 if (Pos != -1):751 httpapi.Commands[Header][0].append(Text[:Pos])752 else:753 httpapi.Commands[Header][0].append(Text)754 else:755 print '<'+node4.tagName+'>'756 httpapi.Commands[Header][2].append(GetText(node2.getElementsByTagName("td")[1]).strip())757 Header += 1758# import os759 if not os.path.exists(os.path.join(eg.folderPath.RoamingAppData, 'EventGhost', 'plugins', 'XBMC2')):760 os.makedirs(os.path.join(eg.folderPath.RoamingAppData, 'EventGhost', 'plugins', 'XBMC2'))761762 with open(os.path.join(eg.folderPath.RoamingAppData, 'EventGhost', 'plugins', 'XBMC2', 'httpapi.dat'), 'wb') as f:763 import pickle764 pickle.dump((httpapi.Headers, httpapi.Commands), f, 1)765766 import os767 try:768 with open(os.path.join(eg.folderPath.RoamingAppData, 'EventGhost', 'plugins', 'XBMC2', 'httpapi.dat'), 'rb') as f:769 import pickle770 httpapi.Headers, httpapi.Commands = pickle.load(f)771 except IOError:772 category = 0773 httpapi.Headers = ['No categorys']774 httpapi.Commands = [[['No commands'],[''],['']]]775 panel = eg.ConfigPanel()776 HBoxControl = wx.ComboBox(panel, -1, value=httpapi.Headers[category], choices=httpapi.Headers, style=wx.CB_READONLY)777 comboBoxControl = wx.ComboBox(panel, -1, value=command, choices=httpapi.Commands[category][0])778 comboBoxControl.SetStringSelection(command)779 textControl1 = wx.TextCtrl(panel, -1, param, size=(500, -1))780 Category = wx.BoxSizer(wx.HORIZONTAL)781 Category.Add(wx.StaticText(panel, -1, "Category"))782 Category.Add(HBoxControl)783 Category.Add(wx.StaticText(panel, -1, "Command"))784 Category.Add(comboBoxControl)785 panel.sizer.Add(wx.StaticText(panel, -1, "Choose or type in a HTTP API command and add parameter(s)"))786 panel.sizer.Add(Category)787 panel.sizer.Add(textControl1)788 panel.sizer.Add(wx.StaticText(panel, -1, "Command syntax:"))789 if (comboBoxControl.GetSelection() != -1):790 syntax = wx.TextCtrl(panel, -1, httpapi.Commands[category][1][comboBoxControl.GetSelection()], (1, 70), size=(500,-1), style=wx.TE_READONLY)791 else:792 syntax = wx.TextCtrl(panel, -1, '', (1, 70), size=(500,-1), style=wx.TE_READONLY)793 panel.sizer.Add(syntax)794 panel.sizer.Add(wx.StaticBox(panel, -1, 'Command description:', size=(500, 150)))795 if (comboBoxControl.GetSelection() != -1):796 description = wx.StaticText(panel, -1, httpapi.Commands[category][2][comboBoxControl.GetSelection()], (5, 105), style=wx.ALIGN_LEFT)797 else:798 description = wx.StaticText(panel, -1, '', (5, 105), style=wx.ALIGN_LEFT)799 description.Wrap(480)800 CheckBox = wx.CheckBox(panel, -1, 'Show result in the log')801 CheckBox.SetValue(log)802 UpdateButton = wx.Button(panel, -1, 'Update')803 UpdateButton.Bind(wx.EVT_BUTTON, OnUpdate)804 Bottom = wx.BoxSizer(wx.HORIZONTAL)805 Bottom.Add(CheckBox)806 Bottom.Add(UpdateButton,0,wx.LEFT,280)807 panel.sizer.Add(Bottom)808 panel.Bind(wx.EVT_COMBOBOX, OnCommandChange)809 while panel.Affirmed():810 panel.SetResult(comboBoxControl.GetValue(), textControl1.GetValue(), HBoxControl.GetSelection(), CheckBox.GetValue())811812class JSONRPC(eg.ActionClass):813 description = "Run any <a href='http://wiki.xbmc.org/index.php?title=JSON_RPC'>XBMC JSON-RPC</a> method"814815 def __call__(self, method="JSONRPC.Introspect", param="", log=True):816 if param:817 responce = self.plugin.JSON_RPC.send(method, ast.literal_eval(ParseString2(param)))818 else:819 responce = self.plugin.JSON_RPC.send(method)820 if responce != None:821 if responce.has_key('result'):822 if log:823 print 'Result:\n', json.dumps(responce['result'], sort_keys=True, indent=2)824 return responce['result']825 elif responce.has_key('error'):826# print 'Error:\n', json.dumps(responce['error'], sort_keys=True, indent=2)827 eg.PrintError('Error:\n', json.dumps(responce['error'], sort_keys=True, indent=2))828 else:829# print 'Got bad JSON-RPC responce', responce830 eg.PrintError('Got bad JSON-RPC responce', responce)831 else:832 raise self.Exceptions.ProgramNotRunning833834 def Configure(self, method="JSONRPC.Introspect", param="", log=True):835 import os836 import pickle837 class record:838 Namespaces = ['No namespaces']839 Methods = {'No namespaces':['No methods']}840 Descriptions = {'No namespaces':['']}841 jsonrpc = record()842 def OnUpdate(event):843 UpdateMethods()844 try:845 with open(os.path.join(eg.folderPath.RoamingAppData, 'EventGhost', 'plugins', 'XBMC2', 'jsonrpc.dat'), 'rb') as f:846 jsonrpc.Namespaces, jsonrpc.Methods, jsonrpc.Descriptions = pickle.load(f)847 except IOError:848# print 'Error opening: jsonrpc.dat'849 eg.PrintError('Error opening: jsonrpc.dat')850 else:851 HBoxControl.Clear()852 for i in jsonrpc.Namespaces:853 HBoxControl.Append(i)854 HBoxControl.SetValue(method[:method.find('.')])855 UpdateMethodCtrl(HBoxControl.GetSelection())856 def UpdateMethods():857 jsonrpc.Namespaces = []858 jsonrpc.Methods = {}859 jsonrpc.Descriptions = {}860 OldNamespace = ''861 responce = self.plugin.JSON_RPC.send('JSONRPC.Introspect', json.loads('{"getdescriptions": true, "getpermissions": false}'))862 if responce != None:863 if responce.has_key('result'):864 for method in responce['result']['commands']:865 namespace = method['command'][:method['command'].find('.')]866 if OldNamespace != namespace:867 jsonrpc.Namespaces.append(namespace)868 jsonrpc.Methods[namespace] = []869 jsonrpc.Descriptions[namespace] = []870 OldNamespace = namespace871 jsonrpc.Methods[namespace].append(method['command'][method['command'].find('.')+1:])872 jsonrpc.Descriptions[namespace].append(method['description'])873 if not os.path.exists(os.path.join(eg.folderPath.RoamingAppData, 'EventGhost', 'plugins', 'XBMC2')):874 os.makedirs(os.path.join(eg.folderPath.RoamingAppData, 'EventGhost', 'plugins', 'XBMC2'))875 with open(os.path.join(eg.folderPath.RoamingAppData, 'EventGhost', 'plugins', 'XBMC2', 'jsonrpc.dat'), 'wb') as f:876 pickle.dump((jsonrpc.Namespaces, jsonrpc.Methods, jsonrpc.Descriptions), f, 1)877 return False878 elif responce.has_key('error'):879# print 'Error', responce['error']880 eg.PrintError('Error', responce['error'])881 return responce['error']882 else:883# print 'Got bad JSON-RPC responce', responce884 eg.PrintError('Got bad JSON-RPC responce', responce)885 return False886 else:887 return False888 def UpdateMethodCtrl(Selection):889 comboBoxControl.Clear()890 for i in jsonrpc.Methods[jsonrpc.Namespaces[Selection]]:891 comboBoxControl.Append(i)892 comboBoxControl.SetValue(method[method.find('.')+1:])893 def OnMethodChange(event):894 if event.GetEventObject() == comboBoxControl:895 description.SetLabel(jsonrpc.Descriptions[jsonrpc.Namespaces[HBoxControl.GetSelection()]][event.GetSelection()])896 description.Wrap(480)897 else:898 UpdateMethodCtrl(event.GetSelection())899# comboBoxControl.Clear()900# for i in jsonrpc.Methods[jsonrpc.Namespaces[event.GetSelection()]]:901# comboBoxControl.Append(i)902903 panel = eg.ConfigPanel()904 try:905 with open(os.path.join(eg.folderPath.RoamingAppData, 'EventGhost', 'plugins', 'XBMC2', 'jsonrpc.dat'), 'rb') as f:906 jsonrpc.Namespaces, jsonrpc.Methods, jsonrpc.Descriptions = pickle.load(f)907 except IOError:908# print 'Error opening: jsonrpc.dat'909 eg.PrintError('Error opening: jsonrpc.dat')910 HBoxControl = wx.ComboBox(panel, -1, value=method[:method.find('.')], choices=jsonrpc.Namespaces, style=wx.CB_READONLY)911 comboBoxControl = wx.ComboBox(panel, -1, value=method[method.find('.')+1:], choices=jsonrpc.Methods[jsonrpc.Namespaces[HBoxControl.GetSelection()]] , style=wx.CB_READONLY)912 textControl2 = wx.TextCtrl(panel, -1, param, size=(500, -1))913 Category = wx.BoxSizer(wx.HORIZONTAL)914 Category.Add(wx.StaticText(panel, -1, "Namespace"))915 Category.Add(HBoxControl)916 Category.Add(wx.StaticText(panel, -1, "Method"))917 Category.Add(comboBoxControl)918 panel.sizer.Add(wx.StaticText(panel, -1, "Choose a JSON-RPC Method and add any parameter(s)"))919 panel.sizer.Add(Category)920 panel.sizer.Add(textControl2)921 panel.sizer.Add(wx.StaticBox(panel, -1, 'Method description:', size=(500, 150)))922 if (comboBoxControl.GetSelection() != -1):923 description = wx.StaticText(panel, -1, jsonrpc.Descriptions[jsonrpc.Namespaces[HBoxControl.GetSelection()]][comboBoxControl.GetSelection()], (5, 70), style=wx.ALIGN_LEFT)924 else:925 description = wx.StaticText(panel, -1, '', (5, 70), style=wx.ALIGN_LEFT)926 description.Wrap(480)927 Bottom = wx.BoxSizer(wx.HORIZONTAL)928 CheckBox = wx.CheckBox(panel, -1, 'Show result in the log')929 CheckBox.SetValue(log)930 Bottom.Add(CheckBox)931 UpdateButton = wx.Button(panel, -1, 'Update')932 UpdateButton.Bind(wx.EVT_BUTTON, OnUpdate)933 Bottom.Add(UpdateButton,0,wx.LEFT,280)934 panel.sizer.Add(Bottom)935 panel.Bind(wx.EVT_COMBOBOX, OnMethodChange)936 while panel.Affirmed():937 panel.SetResult(HBoxControl.GetValue()+'.'+comboBoxControl.GetValue(), textControl2.GetValue(), CheckBox.GetValue())938939#class StopRepeating(eg.ActionClass):940# name = "Stop Repeating"941# description = "Stops a button repeating."942943# def __call__(self):944# try:945# self.plugin.xbmc.release_button()946# except:947# raise self.Exceptions.ProgramNotRunning948949950# And now we define the actual plugin:951952class XBMC2(eg.PluginClass):953 def __init__(self):954# self.ip = "127.0.0.1"955# self.port = port956 ButtonsGroup = self.AddGroup("Buttons", "Button actions to send to XBMC")957 ButtonsGroup.AddActionsFromList(REMOTE_BUTTONS, ButtonPrototype)958 ButtonsGroup.AddActionsFromList(GAMEPAD_BUTTONS, GamepadPrototype)959 ActionsGroup = self.AddGroup("Actions", "Actions to send to XBMC")960 ActionsGroup.AddActionsFromList(GENERAL_ACTIONS, ActionPrototype)961 ActionsGroup.AddActionsFromList(MEDIA_PLAYING_ACTIONS, ActionPrototype)962 ActionsGroup.AddActionsFromList(PLAYLIST_ACTIONS, ActionPrototype)963 ActionsGroup.AddActionsFromList(FULLSCREEN_VIDEO_ACTIONS, ActionPrototype)964 ActionsGroup.AddActionsFromList(SLIDESHOW_ACTIONS, ActionPrototype)965 ActionsGroup.AddActionsFromList(CALIBRATION_ACTIONS, ActionPrototype)966 ActionsGroup.AddActionsFromList(FILEMANAGER_ACTIONS, ActionPrototype)967 ActionsGroup.AddActionsFromList(ON_SCREEN_KEYBOARD_ACTIONS, ActionPrototype)968 ActionsGroup.AddActionsFromList(VISUALISATION_ACTIONS, ActionPrototype)969 ActionsGroup.AddActionsFromList(SHUTDOWN_ACTIONS, ActionPrototype)970 ActionsGroup.AddActionsFromList(UNCATEGORIZED_ACTIONS, ActionPrototype)971# ConfigurableGroup = ActionsGroup.AddGroup("Configurable", "Actions that have configurable settings")972# ConfigurableGroup.AddAction(UpdateLibrary)973 self.AddActionsFromList(WINDOWS, ActionPrototype)974975 TestGroup = self.AddGroup("Experimental", "Experimental")976 TestGroup.AddAction(JSONRPC)977 TestGroup.AddAction(HTTPAPI)978 TestGroup.AddAction(GetCurrentlyPlayingFilename)979 TestGroup.AddAction(SendNotification)980981# self.AddAction(StopRepeating)982 self.xbmc = XBMCClient("EventGhost")983 self.JSON_RPC = XBMC_JSON_RPC()984 self.HTTP_API = XBMC_HTTP_API()985986 def Configure(self, ip="127.0.0.1", port="80"):987# def Configure(self, ip="127.0.0.1", IPs = ['127.0.0.1', '192.168.0.100']):988 panel = eg.ConfigPanel()989 textControl = wx.TextCtrl(panel, -1, ip)990 textControl2 = wx.TextCtrl(panel, -1, port)991# textControl = panel.ComboBox(992# ip,993# IPs,994# style=wx.CB_DROPDOWN,995# validator=eg.DigitOnlyValidator()996# )997 panel.sizer.Add(wx.StaticText(panel, -1, "IP address of XBMC ( 127.0.0.1 is this computer )"))998# panel.sizer.Add(textControl, 1, wx.EXPAND)999 panel.sizer.Add(textControl)1000 panel.sizer.Add(textControl2)1001 while panel.Affirmed():1002 panel.SetResult(textControl.GetValue(), textControl2.GetValue())10031004 def __start__(self, ip='127.0.0.1', port='80'):1005 self.ip = ip1006 self.port = port1007 try:1008 self.xbmc.connect(ip=ip)1009# self.xbmc.connect()1010# self.xbmc.connect(ip="192.168.0.100")1011# self.stopThreadEvent = Event()1012# thread = Thread(target=self.ThreadWorker, args=(self.stopThreadEvent,))1013# thread.start()1014 except:1015 raise self.Exceptions.ProgramNotRunning1016 self.JSON_RPC.connect(ip=ip, port=port)1017 self.HTTP_API.connect(ip=ip, port=port)10181019 def __stop__(self):1020 try:1021# self.stopThreadEvent.set()1022 self.xbmc.close()1023 except:1024 pass10251026 def __close__(self):1027 pass10281029# def ThreadWorker(self, stopThreadEvent):1030# while not stopThreadEvent.isSet():1031# self.TriggerEvent("MyTimerEvent") ...

Full Screen

Full Screen

player.py

Source:player.py Github

copy

Full Screen

1#2# Copyright (C) 2014-3# Sean Poyser (seanpoyser@gmail.com)4#5# This Program is free software; you can redistribute it and/or modify6# it under the terms of the GNU General Public License as published by7# the Free Software Foundation; either version 2, or (at your option)8# any later version.9#10# This Program is distributed in the hope that it will be useful,11# but WITHOUT ANY WARRANTY; without even the implied warranty of12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13# GNU General Public License for more details.14#15# You should have received a copy of the GNU General Public License16# along with XBMC; see the file COPYING. If not, write to17# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.18# http://www.gnu.org/copyleft/gpl.html19#20import xbmc21import xbmcgui22import favourite23import utils24ADDON = utils.ADDON25ADDONID = utils.ADDONID26FRODO = utils.FRODO27PLAYMEDIA_MODE = utils.PLAYMEDIA_MODE28ACTIVATEWINDOW_MODE = utils.ACTIVATEWINDOW_MODE29RUNPLUGIN_MODE = utils.RUNPLUGIN_MODE30ACTION_MODE = utils.ACTION_MODE31PLAY_PLAYLISTS = ADDON.getSetting('PLAY_PLAYLISTS') == 'true'32def playCommand(originalCmd, contentMode=False):33 try:34 xbmc.executebuiltin('Dialog.Close(busydialog)') #Isengard fix35 cmd = favourite.tidy(originalCmd)36 37 #if a 'Super Favourite' favourite just do it38 if ADDONID in cmd:39 return xbmc.executebuiltin(cmd)40 #if in contentMode just do it41 if contentMode:42 xbmc.executebuiltin('ActivateWindow(Home)') #some items don't play nicely if launched from wrong window43 if cmd.lower().startswith('activatewindow'):44 cmd = cmd.replace('")', '",return)') #just in case return is missing 45 return xbmc.executebuiltin(cmd)46 if cmd.startswith('RunScript'): 47 #workaround bug in Frodo that can cause lock-up48 #when running a script favourite49 if FRODO:50 xbmc.executebuiltin('ActivateWindow(Home)')51 if PLAY_PLAYLISTS:52 import playlist53 if playlist.isPlaylist(cmd):54 return playlist.play(cmd) 55 if 'ActivateWindow' in cmd:56 return activateWindowCommand(cmd) 57 if 'PlayMedia' in cmd:58 return playMedia(originalCmd)59 if cmd.lower().startswith('executebuiltin'):60 try: 61 cmd = cmd.split('"', 1)[-1]62 cmd = cmd.rsplit('")')[0]63 except:64 pass65 xbmc.executebuiltin(cmd)66 except Exception, e:67 utils.log('Error in playCommand')68 utils.log('Command: %s' % cmd)69 utils.log('Error: %s' % str(e)) 70def activateWindowCommand(cmd):71 cmds = cmd.split(',', 1)72 #special case for filemanager73 if '10003' in cmds[0] or 'filemanager' in cmds[0].lower():74 xbmc.executebuiltin(cmd)75 return 76 plugin = None77 activate = None78 if len(cmds) == 1:79 activate = cmds[0]80 else:81 activate = cmds[0]+',return)'82 plugin = cmds[1][:-1]83 #check if it is a different window and if so activate it84 id = str(xbmcgui.getCurrentWindowId()) 85 if id not in activate:86 xbmc.executebuiltin(activate)87 if plugin: 88 xbmc.executebuiltin('Container.Update(%s)' % plugin)89def playMedia(original): 90 import re91 cmd = favourite.tidy(original).replace(',', '') #remove spurious commas92 93 try: mode = int(favourite.getOption(original, 'mode'))94 except: mode = 095 if mode == PLAYMEDIA_MODE: 96 xbmc.executebuiltin(cmd)97 return98 plugin = re.compile('"(.+?)"').search(cmd).group(1)99 if len(plugin) < 1:100 xbmc.executebuiltin(cmd)101 return102 if mode == ACTIVATEWINDOW_MODE: 103 try: winID = int(favourite.getOption(original, 'winID'))104 except: winID = 10025105 #check if it is a different window and if so activate it106 id = xbmcgui.getCurrentWindowId()107 if id != winID :108 xbmc.executebuiltin('ActivateWindow(%d)' % winID)109 110 cmd = 'Container.Update(%s)' % plugin111 xbmc.executebuiltin(cmd)112 return113 if mode == RUNPLUGIN_MODE:114 cmd = 'RunPlugin(%s)' % plugin115 xbmc.executebuiltin(cmd)116 return117 #if all else fails just execute it...

Full Screen

Full Screen

context.py

Source:context.py Github

copy

Full Screen

1from __future__ import unicode_literals2import urllib.request, urllib.parse, urllib.error3from kodi_six import xbmc, xbmcgui4def log(x):5 xbmc.log(repr(x), xbmc.LOGERROR)6channel = xbmc.getInfoLabel('ListItem.Label')7try:8 channel = channel.decode()9except:10 pass11try:12 channel = channel.encode()13except:14 pass15channel = urllib.parse.quote_plus(channel)16try:17 d = xbmcgui.Dialog()18 select = d.select("IPTV Recorder", ["Add Timed Recording",19 "Add Daily Timed Recording",20 "Add Weekly Timed Recording",21 "Record and Play"])22 if select != -1:23 if select == 0:24 cmd = "ActivateWindow(videos,plugin://plugin.video.iptv.recorder/record_one_time/%s,return)" % (channel)25 result = xbmc.executebuiltin(cmd)26 elif select == 1:27 cmd = "ActivateWindow(videos,plugin://plugin.video.iptv.recorder/record_daily_time/%s,return)" % (channel)28 result = xbmc.executebuiltin(cmd)29 elif select == 2:30 cmd = "ActivateWindow(videos,plugin://plugin.video.iptv.recorder/record_weekly_time/%s,return)" % (channel)31 result = xbmc.executebuiltin(cmd)32 elif select == 3:33 cmd = "ActivateWindow(videos,plugin://plugin.video.iptv.recorder/record_and_play/%s,return)" % (channel)34 result = xbmc.executebuiltin(cmd)35except:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pyatom automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful