Пример #1
0
 def _get_methods( self, cwd ):
     # language module
     self._language_ = xbmc.Language( cwd ).getLocalizedString
     # settings module, try catch necessary as not all scripts have settings
     try:
         self._settings_ = xbmc.Settings( cwd )
     except:
         self._settings_ = None
Пример #2
0
 def getLocalizedString( self, str_id ):
     """getLocalizedString(id) -- Returns an addon's localized 'unicode string'.
     id             : integer - id# for string you want to localize.
     *Note, You can use the above as keywords for arguments.
     example:
      - locstr = self.Addon.getLocalizedString(id=6)
     """
     locstr = ""
     try: locstr = xbmc.Language( self.cwd ).getLocalizedString( str_id )
     except: pass
     if not bool( locstr ):
         locstr = xbmc.getLocalizedString( str_id )
     return locstr
Пример #3
0
import sys
import os
import urllib

import xbmc
import xbmcgui

# get the language and settings objects
_ = xbmc.Language( os.path.dirname( os.path.dirname( os.getcwd() ) ) ).getLocalizedString
Settings = xbmc.Settings( os.path.dirname( os.path.dirname( os.getcwd() ) ) )

__plugin__ = "weather.com plus"
__pluginname__ = "weather.com+"
__author__ = "nuka1195"


class Main:
    def __init__( self, package=None ):
        # class wide progress dialog, maybe smoother
        self.pDialog = xbmcgui.DialogProgress()
        # set initial message to successful
        self.message = 32220
        # select correct url for package
        if ( package == "mappack" ):
            package_url = self._get_package_version()
            # this is used to add extra info to settings
            include_package_name = True
        # check for previous package download
        self._check_previous_download_info( package=package )
        # now get the path to download to
        installation_path = self._get_installation_path()
Пример #4
0

if __name__ == "__main__":
    log("update.py running from __main__")

    # expects lang, pluginName, pluginType
    if len(sys.argv) != 4:
        xbmcgui.Dialog().ok("Update Error",
                            "Not enough arguments were passed for update")
        sys.exit(1)

    try:
        pluginName = sys.argv[1]
        pluginType = sys.argv[2]
        version = sys.argv[3]
        lang_path = xbmc.translatePath("/".join(
            [XBMC_HOME, "plugins", pluginType, pluginName]))
        __lang__ = xbmc.Language(lang_path).getLocalizedString
        up = UpdatePlugin(__lang__, pluginName, pluginType)
        up.removeOriginal()
        up.downloadVersion(version)
        #		cmd = "XBMC.RunPlugin(plugin://%s/%s/)" % (pluginType, pluginName )
        #		xbmc.output("Updated relaunch cmd=" + cmd)
        #		xbmc.executebuiltin(cmd)
        xbmcgui.Dialog().ok(pluginName, __lang__(1010), "v" + version)
    except:
        traceback.print_exc()
        xbmcgui.Dialog().ok("Update Error",
                            "Failed to start update from backup copy!",
                            str(sys.exc_info()[1]))
Пример #5
0

######################################################################################################
def deleteFile(fn):
    try:
        os.remove(fn)
        log("File deleted: " + fn)
    except:
        pass


#######################################################################################################################
# BEGIN !
#######################################################################################################################
try:
    __lang__ = xbmc.Language(DIR_HOME).getLocalizedString
except:
    errorOK()

#######################################################################################################################
# get settings
#######################################################################################################################

list_loc = xbmcplugin.getSetting("list_loc")
list_genre = xbmcplugin.getSetting("list_genre")
list_rate = xbmcplugin.getSetting("list_rate")
min_rate = xbmcplugin.getSetting("min_rate")

#######################################################################################################################
params = get_params()
url = urllib.unquote_plus(params.get("url", ""))
Пример #6
0
	Category module: list of categories to use as folders
"""

# main imports
import os, sys
import time
#from pprint import pprint
from string import find
import xbmc, xbmcgui, xbmcplugin
from urllib import quote_plus, unquote_plus

from pluginAPI.xbmcplugin_const import *
from pluginAPI.bbbLib import *

__plugin__ = sys.modules["__main__"].__plugin__
__lang__ = xbmc.Language(HOME_DIR).getLocalizedString


#################################################################################################################
class _Info:
    def __init__(self, *args, **kwargs):
        self.__dict__.update(kwargs)
        log("Info() self.__dict__=%s" % self.__dict__)


#################################################################################################################
#################################################################################################################
class Main:
    def __init__(self):
        self._parse_argv()  # parse sys.argv
Пример #7
0

#Modules general
import os
import sys
import random
from traceback import print_exc

#Modules XBMC
import xbmc
import xbmcgui


CWD = os.getcwd().rstrip( ";" )

_ = xbmc.Language( CWD ).getLocalizedString


def getUserSkin():
    current_skin = xbmc.getSkinDir()
    force_fallback = os.path.exists( os.path.join( CWD, "resources", "skins", current_skin ) )
    if not force_fallback: current_skin = "Default"
    return current_skin, force_fallback


#class TTT( xbmcgui.WindowXML ):
class TTT( xbmcgui.WindowXMLDialog ):
    def __init__( self, *args, **kwargs ):
        #xbmcgui.WindowXML.__init__( self, *args, **kwargs )
        xbmcgui.WindowXMLDialog.__init__( self, *args, **kwargs )
Пример #8
0
# Script constants 
__scriptname__ = "CU Lyrics"
__author__ = "Amet"
__url__ = "http://xbmc.org/forum/showthread.php?p=449687"
__svn_url__ = ""
__credits__ = "EnderW,Nuka1195"
__version__ = "0.7.6"
__XBMC_Revision__ = "22240"
__svn_revision__ = 0

# Shared resources 
BASE_RESOURCE_PATH = xbmc.translatePath( os.path.join( os.getcwd(), 'resources', 'lib' ) )

sys.path.append (BASE_RESOURCE_PATH)
__language__ = xbmc.Language( os.getcwd() ).getLocalizedString
__settings__ = xbmc.Settings( path=os.getcwd() )


# Start the main gui or settings gui 
if ( __name__ == "__main__" ):
    if ( xbmc.Player().isPlayingAudio() ):
        import gui as gui
        window = "main"
        ui = gui.GUI( "script-XBMC_Lyrics-main.xml" , os.getcwd(), "Default" )
        ui.doModal()
        del ui
        #sys.modules.clear()
    else:
        __settings__.openSettings()
    
Пример #9
0
# -- coding: cp1252 -*-

import os
import sys
from traceback import print_exc

import xbmc
import xbmcgui
import xbmcplugin

CWD = os.getcwd().rstrip(";")

SPECIAL_PROFILE_DIR = xbmc.translatePath("special://profile/")
GET_LOCALIZED_STRING = xbmc.Language(CWD).getLocalizedString

ACTION_PREVIOUS_MENU = 10


class MainGui(xbmcgui.WindowXMLDialog):
    def __init__(self, *args, **kwargs):
        xbmcgui.WindowXMLDialog.__init__(self, *args, **kwargs)
        self.genre_list = kwargs['genre_list']

    def onInit(self):
        self.title = self.getControl(210)
        self.title.setLabel(GET_LOCALIZED_STRING(32000))
        #On identifie la liste par son id
        self.xml_list = self.getControl(200)

        #Création du dictionnaire
        #self.liste_equipe = self.genre_list
Пример #10
0
if not os.path.isdir(xbmc.translatePath(XBMC_HOME)):	# if fails to convert to Q:, old builds
	XBMC_HOME = 'Q:'
	XBMC_PROFILE = 'T:'

# Shared resources
DIR_HOME= os.getcwd().replace(';','')
DIR_RESOURCES = os.path.join( DIR_HOME, "resources" )
DIR_RESOURCES_LIB = os.path.join( DIR_RESOURCES, "lib" )
DIR_USERDATA = '/'.join( [XBMC_PROFILE, "plugin_data", "video", __plugin__] )
DIR_CACHE = xbmc.translatePath('/'.join( [ DIR_USERDATA, "cache"] ))
sys.path.insert(0, xbmc.translatePath(DIR_RESOURCES_LIB) )

# Load Language using xbmc builtin
try:
    # 'resources' now auto appended onto path
    __lang__ = xbmc.Language( xbmc.translatePath(DIR_HOME) ).getLocalizedString
except:
	xbmcgui.Dialog().ok("XBMC Language Error", "Install a newer XBMC build.", str( sys.exc_info()[ 1 ] ))

from bbbLib import *
import reeplayit

#################################################################################################################
class ReeplayitPlugin:
	""" main plugin class """

	# define param key names
	PARAM_TITLE = "title"
	PARAM_PLS_ID = 'plsid'
	PARAM_PLS_COUNT = 'plscount'
	PARAM_PLS_PAGE = 'plspage'
Пример #11
0
import os
import sys
import random
import string
import urllib
from time import strftime
from threading import Timer
from datetime import datetime
from traceback import print_exc

import xbmc
import xbmcgui

scriptPath = os.getcwd()

GET_LOCALIZED_STRING = xbmc.Language(scriptPath).getLocalizedString

RESOURCES = os.path.join(scriptPath, "resources")
GAMES = xbmc.translatePath("special://profile/script_data/Sudoku/Games/")
if not os.path.isdir(GAMES): os.makedirs(GAMES)

ACTION_MOVE_LEFT = 1
ACTION_MOVE_RIGHT = 2
ACTION_MOVE_UP = 3
ACTION_MOVE_DOWN = 4
ACTION_SELECT_ITEM = 7
ACTION_BACK = 9
ACTION_PREVIOUS_MENU = 10
ACTION_SHOW_INFO = 11
ACTION_NEXT = 14
ACTION_PREVIOUS = 15
Пример #12
0
import resources.libs.cplusplus as cpp

import xbmc, xbmcgui, xbmcplugin

import os, os.path

import threading
from Queue import Queue, Empty

global q_in, q_out

# Repertoires
ROOTDIR = os.getcwd().replace(";", "")  # Create a path with valid format

# Support multilangue
__language__ = xbmc.Language(ROOTDIR, "french").getLocalizedString


def getfiles():
    # fonction exécutée par les threads
    # ici je me contente de sauver le contenu avec l'url dans q_out
    global q_in
    global q_out
    try:
        while True:
            title, url, dest = q_in.get_nowait()
            cpp.Cache_Pic(url, dest)
            #thumbnail = download_pic(url,CACHEDIR)
            q_out.put((title, dest))
    except Empty:
        # q_in est vide; on a terminé
Пример #13
0
class Main:
    _ = xbmc.Language( os.getcwd() ).getLocalizedString
    Settings = xbmc.Settings( os.getcwd() )

    def __init__( self, *args, **kwargs ):
        # get current window
        self._get_weather_window()
        # get our new WeatherClient
        self._get_client()
        # if user selected a new map, only need to fetch it
        if ( sys.argv[ 1 ].startswith( "map=" ) ):
            # parse sys.argv for params
            params = dict( arg.split( "=" ) for arg in sys.argv[ 1 ].split( "&" ) )
            # fetch map (map=%s&title=%s&location=
            self._fetch_map( params[ "map" ], params[ "title" ], params[ "location" ] )
        else:
            # set plugin name property
            self._set_plugin_name()
            # clear key properties if new location
            if ( self.new_location ):
                self._clear_properties()
            # initialize our thread list
            """
            thread_list = []
            # get our 36 hour forecast
            current = FetchInfo( self._fetch_36_forecast )
            thread_list += [ current ]
            current.start()
            # get our hour by hour forecast
            current = FetchInfo( self._fetch_hourly_forecast )
            thread_list += [ current ]
            current.start()
            # get our weekend forecast
            current = FetchInfo( self._fetch_weekend_forecast )
            thread_list += [ current ]
            current.start()
            # get our 10 day forecast
            current = FetchInfo( self._fetch_10day_forecast )
            thread_list += [ current ]
            current.start()
            # get our map list and default map
            current = FetchInfo( self._fetch_map_list )
            thread_list += [ current ]
            current.start()
            # join our threads with the main thread
            for thread in thread_list:
               thread.join()
            """
            self._fetch_map_list()
            self._fetch_36_forecast()
            self._fetch_hourly_forecast()
            self._fetch_10day_forecast()
            self._fetch_weekend_forecast()
        # we're finished, exit
        self._exit_script()

    def _get_weather_window( self ):
        # grab the weather window
        self.WEATHER_WINDOW = xbmcgui.Window( 12600 )

    def _set_plugin_name( self ):
        # set plugin name
        self.WEATHER_WINDOW.setProperty( "PluginName", sys.modules[ "__main__" ].__pluginname__ )

    def _get_client( self ):
        self.settings = { "translate": None }
        if ( self.Settings.getSetting( "translate" ) == "true" ):
            self.settings[ "translate" ] = {
                                        "Chinese (Simple)": "en_zh",
                                        "Chinese (Traditional)": "en_zt",
                                        "Dutch": "en_nl",
                                        "French": "en_fr",
                                        "German": "en_de",
                                        "German (Austria)": "en_de",
                                        "Greek": "en_el",
                                        "Italian": "en_it",
                                        "Japanese": "en_ja",
                                        "Korean": "en_ko",
                                        "Portuguese": "en_pt",
                                        "Portuguese (Brazil)": "en_pt",
                                        "Russian": "en_ru",
                                        "Spanish": "en_es",
                                        "Spanish (Mexico)": "en_es",
                                    }.get( xbmc.getLanguage(), None )
        if ( sys.argv[ 1 ].startswith( "map=" ) ):
            self.areacode = xbmc.getInfoLabel( "Window(Weather).Property(AreaCode)" )
        else:
            self.areacode = sys.argv[ 1 ]
        # set if new location
        self.new_location = ( xbmc.getInfoLabel( "Window(Weather).Property(Weather.AreaCode)" ) != self.areacode )
        # if new set it
        if ( self.new_location ):
            self.WEATHER_WINDOW.setProperty( "Weather.AreaCode", self.areacode )
        # setup our radar client
        self.WeatherClient = WeatherClient.WeatherClient( self.areacode, self.settings[ "translate" ] )

    def _set_maps_path( self, path=0, maps_path="", legend_path="" ):
        # we have three possibilities. loading, default (error) or the actual map path
        if ( path == 0 ):
            self.WEATHER_WINDOW.setProperty( "MapStatus", "loading" )
            self.WEATHER_WINDOW.setProperty( "MapPath", "weather.com plus/loading" )
            self.WEATHER_WINDOW.setProperty( "LegendPath", "" )
        elif ( path == 1 ):
            self.WEATHER_WINDOW.setProperty( "MapStatus", "loaded" )
            self.WEATHER_WINDOW.setProperty( "MapPath", maps_path )
            self.WEATHER_WINDOW.setProperty( "LegendPath", legend_path )
        elif ( path == 2 ):
            self.WEATHER_WINDOW.setProperty( "MapStatus", "error" )
            self.WEATHER_WINDOW.setProperty( "MapPath", "weather.com plus/error" )
            self.WEATHER_WINDOW.setProperty( "LegendPath", "" )

    def _clear_properties( self ):
        # clear properties used for visibilty
        self.WEATHER_WINDOW.clearProperty( "Alerts" )
        self.WEATHER_WINDOW.setProperty( "Alerts.Color", "default" )
        self.WEATHER_WINDOW.clearProperty( "Video" )
        self.WEATHER_WINDOW.clearProperty( "36Hour.IsFetched" )
        self.WEATHER_WINDOW.clearProperty( "Weekend.IsFetched" )
        self.WEATHER_WINDOW.clearProperty( "Daily.IsFetched" )
        self.WEATHER_WINDOW.clearProperty( "Hourly.IsFetched" )

    def _clear_map_list( self, list_id ):
        # enumerate thru and clear all map list labels, icons and onclicks
        for count in range( 1, 31 ):
            # these are what the user sees and the action the button performs
            self.WEATHER_WINDOW.clearProperty( "MapList.%d.MapLabel.%d" % ( list_id, count, ) )
            self.WEATHER_WINDOW.clearProperty( "MapList.%d.MapLabel2.%d" % ( list_id, count, ) )
            self.WEATHER_WINDOW.clearProperty( "MapList.%d.MapIcon.%d" % ( list_id, count, ) )
            self.WEATHER_WINDOW.clearProperty( "MapList.%d.MapOnclick.%d" % ( list_id, count, ) )
        # set the default titles
        self._set_map_list_titles( list_id )

    def _set_map_list_titles( self, list_id, title=None, long_title=None ):
        # set map list titles for skinners buttons
        if ( title is None ):
            # non user defined list
            title = ( "", self._( 32800 + int( self.Settings.getSetting( "maplist%d" % ( list_id, ) ) ) ), )[ int( self.Settings.getSetting( "maplist%d" % ( list_id, ) ) ) > 0 ]
            long_title = self._( 32600 + int( self.Settings.getSetting( "maplist%d" % ( list_id, ) ) ) )
        # now set the titles
        self.WEATHER_WINDOW.setProperty( "MapList.%d.ShortTitle" % ( list_id, ), title )
        self.WEATHER_WINDOW.setProperty( "MapList.%d.LongTitle" % ( list_id, ), long_title )

    def _fetch_map_list( self ):
        # exit script if user changed locations
        if ( self.areacode != xbmc.getInfoLabel( "Window(Weather).Property(AreaCode)" ) ):
            return
        # intialize our download variable, we use this so we don't re-download same info
        map_download = []
        # enumerate thru and clear our properties if map is different (if user changed setiings), local and user defined list should be downloaded if location changed
        for count in range( 1, 4 ):
            # do we need to download this list?
            map_download += [ ( self.new_location and int( self.Settings.getSetting( "maplist%d" % ( count, ) ) ) == 1 ) or 
                                            ( self.new_location and int( self.Settings.getSetting( "maplist%d" % ( count, ) ) ) == len( self.WeatherClient.BASE_MAPS ) - 1 ) or 
                                            ( self.WEATHER_WINDOW.getProperty( "MapList.%d.LongTitle" % ( count, ) ) != self._( 32600 + int( self.Settings.getSetting( "maplist%d" % ( count, ) ) ) ) ) ]
            # do we need to clear the info?
            if ( map_download[ count - 1 ] ):
                self._clear_map_list( count )
        # we set this here in case we do not need to download new lists
        current_map = self.WEATHER_WINDOW.getProperty( "Weather.CurrentMapUrl" )
        current_map_title = self.WEATHER_WINDOW.getProperty( "Weather.CurrentMap" )
        # only run if any new map lists
        if ( True in map_download ):
            # we set our maps path property to loading images while downloading
            self._set_maps_path()
            # set default map, we allow skinners to have users set this with a skin string
            # TODO: look at this, seems wrong, when changing locations maps can fail to load.
            default = ( self.WEATHER_WINDOW.getProperty( "Weather.CurrentMap" ), xbmc.getInfoLabel( "Skin.String(TWC.DefaultMap)" ), )[ xbmc.getInfoLabel( "Skin.String(TWC.DefaultMap)" ) != "" and self.WEATHER_WINDOW.getProperty( "Weather.CurrentMap" ) == "" ]
            # enumurate thru map lists and fetch map list
            for maplist_count in range( 1, 4 ):
                # only fetch new list if required
                if ( not map_download[ maplist_count - 1 ] ):
                    continue
                # get the correct category
                map_category = int( self.Settings.getSetting( "maplist%d" % ( maplist_count, ) ) )
                # fetch map list
                category_title, maps = self.WeatherClient.fetch_map_list( map_category, self.Settings.getSetting( "maplist_user_file" ), xbmc.getInfoLabel( "Window(Weather).Property(LocationIndex)" ) )
                # only run if maps were found
                if ( maps is None ):
                    continue
                # set a current_map in case one isn't set
                if ( current_map == "" ):
                    current_map = maps[ 0 ][ 0 ]
                    current_map_title = maps[ 0 ][ 1 ]
                # if user defined map list set the new titles
                if ( category_title is not None ):
                    self._set_map_list_titles( maplist_count, category_title, category_title )
                # enumerate thru our map list and add map and title and check for default
                for count, map in enumerate( maps ):
                    # create our label, icon and onclick event
                    self.WEATHER_WINDOW.setProperty( "MapList.%d.MapLabel.%d" % ( maplist_count, count + 1, ), map[ 1 ] )
                    self.WEATHER_WINDOW.setProperty( "MapList.%d.MapLabel2.%d" % ( maplist_count, count + 1, ), map[ 0 ] )
                    self.WEATHER_WINDOW.setProperty( "MapList.%d.MapIcon.%d" % ( maplist_count, count + 1, ), map[ 1 ].replace( ":", " -" ).replace( "/", " - " ) + ".jpg" )
                    self.WEATHER_WINDOW.setProperty( "MapList.%d.MapOnclick.%d" % ( maplist_count, count + 1, ), "XBMC.RunScript(%s,map=%s&title=%s&location=%s)" % ( sys.argv[ 0 ], map[ 0 ], map[ 1 ], str( map[ 2 ] ) ) )
                    # if we have a match, set our class variable
                    if ( map[ 1 ] == default ):
                        current_map = map[ 0 ]
                        current_map_title = map[ 1 ]
        # fetch the current map
        self._fetch_map( current_map, current_map_title, xbmc.getInfoLabel( "Window(Weather).Property(LocationIndex)" ) )

    def _fetch_map( self, map, title, locationindex=None ):
        # exit script if user changed locations
        if ( self.areacode != xbmc.getInfoLabel( "Window(Weather).Property(AreaCode)" ) ):
            return
        # we set our maps path property to loading images while downloading
        self._set_maps_path()
        # we set Weather.CurrentMap and Weather.CurrentMapUrl, the skin can handle it when the user selects a new map for immediate update
        self.WEATHER_WINDOW.setProperty( "Weather.CurrentMap", title )
        self.WEATHER_WINDOW.setProperty( "Weather.CurrentMapUrl", map )
        # fetch the available map urls
        maps = self.WeatherClient.fetch_map_urls( map, self.Settings.getSetting( "maplist_user_file" ), locationindex )
        # fetch the images
        maps_path, legend_path = self.WeatherClient.fetch_images( maps )
        # hack incase the weather in motion link was bogus
        if ( maps_path == "" and len( maps[ 1 ] ) ):
            maps_path, legend_path = self.WeatherClient.fetch_images( ( maps[ 0 ], [], maps[ 2 ], ) )
        # now set our window properties so multi image will display images 1==success, 2==failure
        self._set_maps_path( ( maps_path == "" ) + 1, maps_path, legend_path )

    def _set_alerts( self, alerts, alertsrss, alertsnotify, alertscolor, alertscount ):
        # send notification if user preference and there are alerts
        if ( alerts != "" and ( int( self.Settings.getSetting( "alert_notify_type" ) ) == 1 or 
            ( alertscolor == "red" and int( self.Settings.getSetting( "alert_notify_type" ) ) > 1 ) or 
            ( alertscolor == "orange" and int( self.Settings.getSetting( "alert_notify_type" ) ) == 3 ) ) and
            ( self.Settings.getSetting( "alert_notify_once" ) == "false" or self.WEATHER_WINDOW.getProperty( "Alerts.RSS" ) != alertsrss )
            ):
            xbmc.executebuiltin( "XBMC.Notification(%s,\"%s\",%d,weather.com plus/alert-%s.png)" % ( self._( 32100 ), alertsnotify, ( 10, 20, 30, 45, 60, 120, 300, 600, )[ int( self.Settings.getSetting( "alert_notify_time" ) ) ] * 1000, alertscolor, ) )
        # set any alerts
        self.WEATHER_WINDOW.setProperty( "Alerts", alerts )
        self.WEATHER_WINDOW.setProperty( "Alerts.RSS", alertsrss )
        self.WEATHER_WINDOW.setProperty( "Alerts.Color", ( "default", alertscolor, )[ alerts != "" ] )
        self.WEATHER_WINDOW.setProperty( "Alerts.Count", ( "", str( alertscount ), )[ alertscount > 1 ] )
        self.WEATHER_WINDOW.setProperty( "Alerts.Label", xbmc.getLocalizedString( 33049 + ( alertscount > 1 ) ) )

    def _set_video( self, video_url ):
        self.WEATHER_WINDOW.setProperty( "Video", video_url )

    def _set_extra_current_info( self, extras ):
        if ( extras ):
            self.WEATHER_WINDOW.setProperty( "Current.Pressure", extras[ 0 ] )
            self.WEATHER_WINDOW.setProperty( "Current.Visibility", "%s %s" % ( extras[ 1 ].split( " " )[ 0 ], { "mile": self._( 32300 ), "miles": self._( 32301 ), "kilometer": self._( 32302 ), "kilometers": self._( 32303 ) }[ extras[ 1 ].split( " " )[ 1 ] ], ) )
            self.WEATHER_WINDOW.setProperty( "Current.Sunrise", extras[ 2 ] )
            self.WEATHER_WINDOW.setProperty( "Current.Sunset", extras[ 3 ] )
        else:
            self.WEATHER_WINDOW.clearProperty( "Current.Pressure" )
            self.WEATHER_WINDOW.clearProperty( "Current.Visibility" )
            self.WEATHER_WINDOW.clearProperty( "Current.Sunrise" )
            self.WEATHER_WINDOW.clearProperty( "Current.Sunset" )

    def _fetch_36_forecast( self, showView=True ):
        # exit script if user changed locations
        if ( self.areacode != xbmc.getInfoLabel( "Window(Weather).Property(AreaCode)" ) ):
            return
        # fetch 36 hour forecast
        alerts, alertsrss, alertsnotify, alertscolor, alertscount, forecasts, extras, video = self.WeatherClient.fetch_36_forecast( self.WEATHER_WINDOW.getProperty( "Video" ) )
        # set any alerts
        self._set_alerts( alerts, alertsrss, alertsnotify, alertscolor, alertscount )
        # set video
        self._set_video( video )
        # set extra info
        self._set_extra_current_info( extras )
        # enumerate thru and set the info
        for day, forecast in enumerate( forecasts ):
            self.WEATHER_WINDOW.setProperty( "36Hour.%d.OutlookIcon" % ( day + 1, ), forecast[ 1 ] )
            self.WEATHER_WINDOW.setProperty( "36Hour.%d.FanartCode" % ( day + 1, ), os.path.splitext( os.path.basename( forecast[ 1 ] ) )[ 0 ] )
            self.WEATHER_WINDOW.setProperty( "36Hour.%d.Outlook" % ( day + 1, ), forecast[ 2 ] )
            self.WEATHER_WINDOW.setProperty( "36Hour.%d.TemperatureColor" % ( day + 1, ), forecast[ 3 ].lower() )
            self.WEATHER_WINDOW.setProperty( "36Hour.%d.TemperatureHeading" % ( day + 1, ), ( xbmc.getLocalizedString( 393 ), xbmc.getLocalizedString( 391 ), )[ forecast[ 3 ] == "Low" ] )
            self.WEATHER_WINDOW.setProperty( "36Hour.%d.Temperature" % ( day + 1, ), forecast[ 4 ] )
            self.WEATHER_WINDOW.setProperty( "36Hour.%d.Precipitation" % ( day + 1, ), forecast[ 6 ] )
            self.WEATHER_WINDOW.setProperty( "36Hour.%d.Forecast" % ( day + 1, ), forecast[ 7 ] )
            self.WEATHER_WINDOW.setProperty( "36Hour.%d.DaylightTitle" % ( day + 1, ), forecast[ 8 ].replace( "Sunrise", xbmc.getLocalizedString( 33027 ) ).replace( "Sunset", xbmc.getLocalizedString( 33028 ) ) )
            self.WEATHER_WINDOW.setProperty( "36Hour.%d.DaylightTime" % ( day + 1, ), forecast[ 9 ] )
            self.WEATHER_WINDOW.setProperty( "36Hour.%d.DaylightType" % ( day + 1, ), ( "sunrise", "sunset", )[ forecast[ 8 ] == "Sunset" ] )
            self.WEATHER_WINDOW.setProperty( "36Hour.%d.Heading" % ( day + 1, ), { "Today": xbmc.getLocalizedString( 33006 ), "Tonight": xbmc.getLocalizedString( 33018 ), "Tomorrow": xbmc.getLocalizedString( 33007 ), "Tomorrow Night": xbmc.getLocalizedString( 33019 ) }[ forecast[ 0 ] ] )
        # use this to hide info until fully fetched
        self.WEATHER_WINDOW.setProperty( "36Hour.IsFetched", "true" )

    def _fetch_hourly_forecast( self ):
        # exit script if user changed locations
        if ( self.areacode != xbmc.getInfoLabel( "Window(Weather).Property(AreaCode)" ) ):
            return
        # fetch hourly forecast
        forecasts = self.WeatherClient.fetch_hourly_forecast()
        # localized long and short date dictionary
        longdate_dict = { "January": xbmc.getLocalizedString( 21 ), "February": xbmc.getLocalizedString( 22 ), "March": xbmc.getLocalizedString( 23 ), "April": xbmc.getLocalizedString( 24 ), "May": xbmc.getLocalizedString( 25 ), "June": xbmc.getLocalizedString( 26 ), "July": xbmc.getLocalizedString( 27 ), "August": xbmc.getLocalizedString( 28 ), "September": xbmc.getLocalizedString( 29 ), "October": xbmc.getLocalizedString( 30 ), "November": xbmc.getLocalizedString( 31 ), "December": xbmc.getLocalizedString( 32 ) }
        shortdate_dict = { "January": xbmc.getLocalizedString( 51 ), "February": xbmc.getLocalizedString( 52 ), "March": xbmc.getLocalizedString( 53 ), "April": xbmc.getLocalizedString( 54 ), "May": xbmc.getLocalizedString( 55 ), "June": xbmc.getLocalizedString( 56 ), "July": xbmc.getLocalizedString( 57 ), "August": xbmc.getLocalizedString( 58 ), "September": xbmc.getLocalizedString( 59 ), "October": xbmc.getLocalizedString( 60 ), "November": xbmc.getLocalizedString( 61 ), "December": xbmc.getLocalizedString( 62 ) }
        # enumerate thru and set the info
        for count, forecast in enumerate( forecasts ):
            # set properties
            self.WEATHER_WINDOW.setProperty( "Hourly.%d.Time" % ( count + 1, ), forecast[ 0 ] )
            self.WEATHER_WINDOW.setProperty( "Hourly.%d.LongDate" % ( count + 1, ), "%s %s" % ( longdate_dict.get( forecast[ 1 ].split( " " )[ 0 ], "" ), forecast[ 1 ].split( " " )[ -1 ], ) )
            self.WEATHER_WINDOW.setProperty( "Hourly.%d.ShortDate" % ( count + 1, ), "%s %s" % ( shortdate_dict.get( forecast[ 1 ].split( " " )[ 0 ], "" ), forecast[ 1 ].split( " " )[ -1 ], ) )
            self.WEATHER_WINDOW.setProperty( "Hourly.%d.OutlookIcon" % ( count + 1, ), forecast[ 2 ] )
            self.WEATHER_WINDOW.setProperty( "Hourly.%d.FanartCode" % ( count + 1, ), os.path.splitext( os.path.basename( forecast[ 2 ] ) )[ 0 ] )
            self.WEATHER_WINDOW.setProperty( "Hourly.%d.Temperature" % ( count + 1, ), forecast[ 3 ] )
            self.WEATHER_WINDOW.setProperty( "Hourly.%d.Outlook" % ( count + 1, ), forecast[ 4 ] )
            self.WEATHER_WINDOW.setProperty( "Hourly.%d.FeelsLike" % ( count + 1, ), forecast[ 5 ] )
            self.WEATHER_WINDOW.setProperty( "Hourly.%d.Precipitation" % ( count + 1, ), forecast[ 6 ] )
            self.WEATHER_WINDOW.setProperty( "Hourly.%d.Humidity" % ( count + 1, ), forecast[ 7 ] )
            self.WEATHER_WINDOW.setProperty( "Hourly.%d.WindDirection" % ( count + 1, ), forecast[ 8 ] )
            self.WEATHER_WINDOW.setProperty( "Hourly.%d.WindSpeed" % ( count + 1, ), forecast[ 9 ] )
            self.WEATHER_WINDOW.setProperty( "Hourly.%d.ShortWindDirection" % ( count + 1, ), forecast[ 10 ] )
            self.WEATHER_WINDOW.setProperty( "Hourly.%d.Sunrise" % ( count + 1, ), forecast[ 11 ] )
            self.WEATHER_WINDOW.setProperty( "Hourly.%d.Sunset" % ( count + 1, ), forecast[ 12 ] )
        # enumerate thru and clear all hourly times
        for count in range( len( forecasts ), 12 ):
            # clear any remaining hourly times as some locals do not have all of them
            self.WEATHER_WINDOW.clearProperty( "Hourly.%d.Time" % ( count + 1, ) )
        # use this to hide info until fully fetched
        self.WEATHER_WINDOW.setProperty( "Hourly.IsFetched", "true" )

    def _fetch_weekend_forecast( self ):
        # exit script if user changed locations
        if ( self.areacode != xbmc.getInfoLabel( "Window(Weather).Property(AreaCode)" ) ):
            return
        # fetch weekend forecast
        forecasts = self.WeatherClient.fetch_weekend_forecast()
        # enumerate thru and set the info
        for day, forecast in enumerate( forecasts ):
            self.WEATHER_WINDOW.setProperty( "Weekend.%d.OutlookIcon" % ( day + 1, ), forecast[ 2 ] )
            self.WEATHER_WINDOW.setProperty( "Weekend.%d.FanartCode" % ( day + 1, ), os.path.splitext( os.path.basename( forecast[ 2 ] ) )[ 0 ] )
            self.WEATHER_WINDOW.setProperty( "Weekend.%d.Outlook" % ( day + 1, ), forecast[ 3 ] )
            self.WEATHER_WINDOW.setProperty( "Weekend.%d.HighTemperature" % ( day + 1, ), forecast[ 5 ] )
            self.WEATHER_WINDOW.setProperty( "Weekend.%d.LowTemperature" % ( day + 1, ), forecast[ 7 ] )
            self.WEATHER_WINDOW.setProperty( "Weekend.%d.Precipitation" % ( day + 1, ), forecast[ 9 ] )
            self.WEATHER_WINDOW.setProperty( "Weekend.%d.Wind" % ( day + 1, ), forecast[ 11 ] )
            self.WEATHER_WINDOW.setProperty( "Weekend.%d.UV" % ( day + 1, ), forecast[ 13 ] )
            self.WEATHER_WINDOW.setProperty( "Weekend.%d.Humidity" % ( day + 1, ), forecast[ 15 ] )
            self.WEATHER_WINDOW.setProperty( "Weekend.%d.Sunrise" % ( day + 1, ), forecast[ 17 ] )
            self.WEATHER_WINDOW.setProperty( "Weekend.%d.Sunset" % ( day + 1, ), forecast[ 19 ] )
            self.WEATHER_WINDOW.setProperty( "Weekend.%d.Forecast" % ( day + 1, ), forecast[ 20 ] )
            self.WEATHER_WINDOW.setProperty( "Weekend.%d.Observed" % ( day + 1, ), forecast[ 21 ] )
            self.WEATHER_WINDOW.setProperty( "Weekend.%d.ObservedPrecipitation" % ( day + 1, ), forecast[ 23 ] )
            self.WEATHER_WINDOW.setProperty( "Weekend.%d.ObservedAvgHighTemperature" % ( day + 1, ), forecast[ 25 ] )
            self.WEATHER_WINDOW.setProperty( "Weekend.%d.ObservedAvgLowTemperature" % ( day + 1, ), forecast[ 27 ] )
            self.WEATHER_WINDOW.setProperty( "Weekend.%d.ObservedRecordHighTemperature" % ( day + 1, ), forecast[ 29 ] )
            self.WEATHER_WINDOW.setProperty( "Weekend.%d.ObservedRecordLowTemperature" % ( day + 1, ), forecast[ 31 ] )
            self.WEATHER_WINDOW.setProperty( "Weekend.%d.DepartureHigh" % ( day + 1, ), forecast[ 33 ] )
            self.WEATHER_WINDOW.setProperty( "Weekend.%d.DepartureHighColor" % ( day + 1, ), ( "low", "high", "default", )[ ( len( forecast[ 33 ] ) and forecast[ 33 ][ 0 ] == "+" ) + ( forecast[ 33 ] == "+0" ) ] )
            self.WEATHER_WINDOW.setProperty( "Weekend.%d.DepartureLow" % ( day + 1, ), forecast[ 34 ] )
            self.WEATHER_WINDOW.setProperty( "Weekend.%d.DepartureLowColor" % ( day + 1, ), ( "low", "high", "default", )[ ( len( forecast[ 34 ] ) and forecast[ 34 ][ 0 ] == "+" ) + ( forecast[ 34 ] == "+0" ) ] )
            # do this last so skin's visibilty works better
            self.WEATHER_WINDOW.setProperty( "Weekend.%d.Date" % ( day + 1, ), forecast[ 1 ] )
        # use this to hide info until fully fetched
        self.WEATHER_WINDOW.setProperty( "Weekend.IsFetched", "true" )

    def _fetch_10day_forecast( self ):
        # exit script if user changed locations
        if ( self.areacode != xbmc.getInfoLabel( "Window(Weather).Property(AreaCode)" ) ):
            return
        # fetch daily forecast
        forecasts = self.WeatherClient.fetch_10day_forecast()
        # localized long and short day dictionary
        longday_dict = { "Mon": xbmc.getLocalizedString( 11 ), "Tue": xbmc.getLocalizedString( 12 ), "Wed": xbmc.getLocalizedString( 13 ), "Thu": xbmc.getLocalizedString( 14 ), "Fri": xbmc.getLocalizedString( 15 ), "Sat": xbmc.getLocalizedString( 16 ), "Sun": xbmc.getLocalizedString( 17 ), "Today": xbmc.getLocalizedString( 33006 ), "Tonight": xbmc.getLocalizedString( 33018 ) }
        shortday_dict = { "Mon": xbmc.getLocalizedString( 41 ), "Tue": xbmc.getLocalizedString( 42 ), "Wed": xbmc.getLocalizedString( 43 ), "Thu": xbmc.getLocalizedString( 44 ), "Fri": xbmc.getLocalizedString( 45 ), "Sat": xbmc.getLocalizedString( 46 ), "Sun": xbmc.getLocalizedString( 47 ), "Today": xbmc.getLocalizedString( 33006 ), "Tonight": xbmc.getLocalizedString( 33018 ) }
        # localized long and short date dictionary
        longdate_dict = { "Jan": xbmc.getLocalizedString( 21 ), "Feb": xbmc.getLocalizedString( 22 ), "Mar": xbmc.getLocalizedString( 23 ), "Apr": xbmc.getLocalizedString( 24 ), "May": xbmc.getLocalizedString( 25 ), "Jun": xbmc.getLocalizedString( 26 ), "Jul": xbmc.getLocalizedString( 27 ), "Aug": xbmc.getLocalizedString( 28 ), "Sep": xbmc.getLocalizedString( 29 ), "Oct": xbmc.getLocalizedString( 30 ), "Nov": xbmc.getLocalizedString( 31 ), "Dec": xbmc.getLocalizedString( 32 ) }
        shortdate_dict = { "Jan": xbmc.getLocalizedString( 51 ), "Feb": xbmc.getLocalizedString( 52 ), "Mar": xbmc.getLocalizedString( 53 ), "Apr": xbmc.getLocalizedString( 54 ), "May": xbmc.getLocalizedString( 55 ), "Jun": xbmc.getLocalizedString( 56 ), "Jul": xbmc.getLocalizedString( 57 ), "Aug": xbmc.getLocalizedString( 58 ), "Sep": xbmc.getLocalizedString( 59 ), "Oct": xbmc.getLocalizedString( 60 ), "Nov": xbmc.getLocalizedString( 61 ), "Dec": xbmc.getLocalizedString( 62 ) }
        # enumerate thru and set the info
        for count, forecast in enumerate( forecasts ):
            self.WEATHER_WINDOW.setProperty( "Daily.%d.LongDay" % ( count + 1, ), longday_dict[ forecast[ 0 ] ] )
            self.WEATHER_WINDOW.setProperty( "Daily.%d.ShortDay" % ( count + 1, ), shortday_dict[ forecast[ 0 ] ] )
            self.WEATHER_WINDOW.setProperty( "Daily.%d.LongDate" % ( count + 1, ), "%s %s" % ( longdate_dict[ forecast[ 1 ].split( " " )[ 0 ] ], forecast[ 1 ].split( " " )[ 1 ], ) )
            self.WEATHER_WINDOW.setProperty( "Daily.%d.ShortDate" % ( count + 1, ), "%s %s" % ( shortdate_dict[ forecast[ 1 ].split( " " )[ 0 ] ], forecast[ 1 ].split( " " )[ 1 ], ) )
            self.WEATHER_WINDOW.setProperty( "Daily.%d.OutlookIcon" % ( count + 1, ), forecast[ 2 ] )
            self.WEATHER_WINDOW.setProperty( "Daily.%d.FanartCode" % ( count + 1, ), os.path.splitext( os.path.basename( forecast[ 2 ] ) )[ 0 ] )
            self.WEATHER_WINDOW.setProperty( "Daily.%d.Outlook" % ( count + 1, ), forecast[ 3 ] )
            self.WEATHER_WINDOW.setProperty( "Daily.%d.HighTemperature" % ( count + 1, ), forecast[ 4 ] )
            self.WEATHER_WINDOW.setProperty( "Daily.%d.LowTemperature" % ( count + 1, ), forecast[ 5 ] )
            self.WEATHER_WINDOW.setProperty( "Daily.%d.Precipitation" % ( count + 1, ), forecast[ 6 ] )
            self.WEATHER_WINDOW.setProperty( "Daily.%d.WindDirection" % ( count + 1, ), forecast[ 7 ] )
            self.WEATHER_WINDOW.setProperty( "Daily.%d.WindSpeed" % ( count + 1, ), forecast[ 8 ] )
            self.WEATHER_WINDOW.setProperty( "Daily.%d.ShortWindDirection" % ( count + 1, ), forecast[ 9 ] )
        # just in case day 10 is missing
        for count in range( len( forecasts ), 10 ):
            self.WEATHER_WINDOW.clearProperty( "Daily.%d.ShortDay" % ( count + 1, ) )
            self.WEATHER_WINDOW.clearProperty( "Daily.%d.LongDay" % ( count + 1, ) )
        # use this to hide info until fully fetched
        self.WEATHER_WINDOW.setProperty( "Daily.IsFetched", "true" )

    def _exit_script( self ):
        # end script
        pass
Пример #14
0
# script constants
__script__ = "Sportlive"
__author__ = "Ppic"
__url__ = "http://code.google.com/p/passion-xbmc/"
__svn_url__ = "http://passion-xbmc.googlecode.com/svn/trunk/scripts/"
__credits__ = "Team XBMC passion, http://passion-xbmc.org/developpement-python/%28script%29-sporlive-display/"
__platform__ = "xbmc media center, [LINUX, OS X, WIN32, XBOX]"
__date__ = "06-03-2009"
__version__ = "1.5.1"
__svn_revision__ = "$Revision: 667 $".replace("Revision", "").strip("$: ")
__XBMC_Revision__ = "20000"  #XBMC Babylon
__useragent__ = "Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1"

import os
import xbmc
import xbmcgui
from traceback import print_exc

BASE_RESOURCE_PATH = os.path.join(os.getcwd(), "resources")
GET_LOCALIZED_STRING = xbmc.Language(os.getcwd()).getLocalizedString

process = os.path.join(BASE_RESOURCE_PATH, "sportlive.pid")
if os.path.exists(process):
    if xbmcgui.Dialog().yesno(GET_LOCALIZED_STRING(32005),
                              GET_LOCALIZED_STRING(32006)):
        os.remove(process)
else:
    file(process, "w").write("")
    xbmc.executebuiltin('XBMC.RunScript(%s)' %
                        os.path.join(os.getcwd(), "sportlive.py"))
Пример #15
0
import xbmcgui
import xbmcplugin
import xbmc

from traceback import print_exc

# Shared resources
BASE_RESOURCE_PATH = os.path.join(os.getcwd(), "resources")
sys.path.append(os.path.join(BASE_RESOURCE_PATH, "lib"))
BASE_URL = [
    "http://passion-xbmc.org/downloads/?cat=7;start=%s",
    "http://passion-xbmc.org/downloads/?cat=24;start=%s"
][int(xbmcplugin.getSetting("skin_type"))]
BASE_DL = "http://passion-xbmc.org/downloads/?sa=downfile;id=%s"
CACHE_DIR = os.path.join(BASE_RESOURCE_PATH, "cache")
Language = xbmc.Language(os.getcwd())
DIALOG_PROGRESS = xbmcgui.DialogProgress()
dialog = xbmcgui.Dialog()
SKIN_DIR = xbmc.translatePath("special://home/skin/")
print SKIN_DIR

import unzip

#variables:
OK = True
skin_unziped = False


def addLink(name, url, iconimage):
    ok = True
    liz = xbmcgui.ListItem(name,
Пример #16
0
# main imports
import os
import xbmcgui
import xbmc

import threading
import binascii
from random import shuffle
import re

_ = xbmc.Language(scriptPath=os.getcwd()).getLocalizedString


class Trivia(xbmcgui.WindowXML):
    # base paths
    BASE_CURRENT_SOURCE_PATH = os.path.join(
        xbmc.translatePath("special://profile/"), "script_data",
        os.path.basename(os.getcwd()))
    # special action codes
    ACTION_NEXT_SLIDE = (
        2,
        3,
        7,
    )
    ACTION_PREV_SLIDE = (
        1,
        4,
    )
    ACTION_EXIT_SCRIPT = (
        9,
        10,
Пример #17
0
    try: sys.path.append( os.path.join( CONTENTS_LIBS, content ) )
    except: print_exc()


#modules custom
from specialpath import *
# custom_sys_stdout_stderr is new module for xbmc output
# for active print debug in output, set "PRINT_DEBUG = True", but use options in settings window.
# if you want force print. start print with "bypass: |bypass_debug: |bypass_comment: "
# NB: the variables bypass not printed, look example at end module custom_sys_stdout_stderr
default_sys_std = sys.stdout, sys.stderr
import custom_sys_stdout_stderr as output


#FONCTION POUR RECUPERER LES LABELS DE LA LANGUE. ( ex: __language__( 0 ) = id="0" du fichier strings.xml )
__language__ = xbmc.Language( ROOTDIR ).getLocalizedString
LANGUAGE_IS_FRENCH = ( xbmc.getLanguage().lower() == "french" )

DIALOG_PROGRESS = xbmcgui.DialogProgress()


def MAIN():
    try: output.PRINT_DEBUG = ( XBMC_SETTINGS.getSetting( "script_debug" ) == "true" )
    except: print_exc()

    # print depend of output.PRINT_DEBUG is True or False
    print "bypass_debug: %s" % str( "-" * 100 )
    print "bypass_debug: Starting %s %s, %s, SVN r%s. Built on %s" % ( __script__, __version__, __statut__, __svn_revision__, __date__ )
    print "bypass_debug: The executable script running is: %s" % os.path.join( os.getcwd(), "default.py" )
    print "bypass_debug: %s" % str( "-" * 100 )
    dialog_error = False
Пример #18
0
import os
import sys
import xbmc
import xbmcgui
import xbmcplugin
import urllib

HOME_DIR = os.getcwd()
names = xbmc.Language(HOME_DIR).getLocalizedString

rai = (names(30015))
alL = (names(33333))


class Main:
    def __init__(self):
        self.getNames()

    def getNames(self):
        gl = [
            ("TVN",
             'http://www.onet.tv/feed/getMoviesCategoryOrTagsDate,15,1,desc,movies.xml?category=11&tags=%28TVN%29&rss=1'
             ),
            ("TVN24",
             'http://www.onet.tv/feed/getMoviesCategoryOrTagsDate,15,1,desc,movies.xml?category=11&tags=%28TVN24%29&rss=1'
             ),
            ("TVN CNBC",
             'http://www.onet.tv/feed/getMoviesCategoryOrTagsDate,15,1,desc,movies.xml?category=11&tags=%28TVN_CNBC%29&rss=1'
             ),
            ("TVN WARSZAWA",
             'http://www.onet.tv/feed/getMoviesCategoryOrTagsDate,15,1,desc,movies.xml?category=11&tags=%28TVN_Warszawa%29&rss=1'
Пример #19
0
			return doc
		except:
			traceback.print_exc()
			return None

	def parseHTMLSource( self, htmlsource ):
		""" parse html source for tagged version and url """
		xbmc.output( "Update().parseHTMLSource()" )
		try:
			url = re.search('Revision \d+:(.*?)<', htmlsource, re.IGNORECASE).group(1).strip()
			tagList = re.compile('<li><a href="(.*?)"', re.MULTILINE+re.IGNORECASE+re.DOTALL).findall(htmlsource)
			if tagList[0] == "../":
				del tagList[0]
			return tagList, url
		except:
			return None, None

if __name__ == "__main__":
	xbmc.output("update.py running from __main__")
	if len(sys.argv) != 3:
		xbmcgui.Dialog().ok("Update error",  "Not enough arguments were passed for update")
		sys.exit(1)

	try:
		lang_path = os.path.join('Q:' + os.sep,'scripts', sys.argv[1])
		up = Update(xbmc.Language( lang_path ).getLocalizedString, sys.argv[1])
		up.removeOriginal()
		up.downloadVersion(sys.argv[2])
		xbmc.executebuiltin('XBMC.RunScript(%s)'%(up.local_dir+'\\default.py'))
	except:
		print "failed to start script update from backup copy!"