Ejemplo n.º 1
0
def preview(addon: xbmcaddon.Addon, timerid: int, player: 'xbmc.Player') -> None:

    addon_dir = xbmcvfs.translatePath(addon.getAddonInfo('path'))

    timer = Timer.init_from_settings(timerid)

    if timer._is_playing_media_timer():
        icon_file = os.path.join(
            addon_dir, "resources", "assets", "icon.png")

        xbmcgui.Dialog().notification(addon.getLocalizedString(
            32027), addon.getLocalizedString(32110) % addon.getLocalizedString(32004 + timerid),
            icon=icon_file)

        if is_script(timer.s_path):
            run_addon(timer.s_path)

        elif timer.s_mediatype == PICTURE:
            play_slideshow(timer.s_path, shuffle=timer.b_shuffle)

        else:
            playlist = build_playlist(path=timer.s_path, label=timer.s_label)
            player.play(playlist)

    else:
        xbmcgui.Dialog().notification(addon.getLocalizedString(
            32027), addon.getLocalizedString(32109))
Ejemplo n.º 2
0
class XbmcContext(Context):
    def __init__(self, log, settings):
        super(XbmcContext, self).__init__(log, settings)
        self.addon = Addon()

    def getLocalizedString(self, id):
        return self.addon.getLocalizedString(id)    
    
    def getProfileDir(self):
        profileDir = xbmc.translatePath(self.addon.getAddonInfo('profile'))
        return profileDir
import xbmcvfs
from xbmcaddon import Addon


# get scraper object
AddonId = "metadata.media.passion.org"
Addon   = Addon( AddonId )

# set variables
token   = Addon.getSetting( "token" )
token64 = Addon.getSetting( "token64" )
login   = Addon.getSetting( "username" )
passw   = Addon.getSetting( "password" )

if settingId == "username":
    heading = Addon.getLocalizedString( 30001 )
    default = login
    hidden  = False
elif settingId == "password":
    heading = Addon.getLocalizedString( 30002 )
    default = passw
    hidden  = True

# condition pour mettre a jour la base
UpdateUserDB = False

# initialize Keyboard
kb = xbmc.Keyboard( default, heading, hidden )
# optional hidden pass
kb.setHiddenInput( hidden )
# call Keyboard
Ejemplo n.º 4
0
    steamExe = getSteamExe(addon)
    cmd = [ahkExe, "%s" % steamExe, addon.getSetting('username'), addon.getSetting('password')]
    subprocess.check_call(cmd)

def getSteamExe(addon):
    steamFolder = addon.getSetting('steam_install_folder')
    steamBinPath = os.path.join(steamFolder, STEAM_BINARY_NAME)
    if not os.path.isfile(steamBinPath):
        raise NotFoundError(addon.getLocalizedString(71004))
    return steamBinPath

    
class NotFoundError(BaseException):
    
    def __init__(self, msg):
        self.msg = msg

if __name__ == "__main__":
    addon = Addon(__scriptID__)
    try:
        launchSteamBpm(addon)
    except CalledProcessError as e:
        log('AHK return code: %d' % e.returncode)
        msg = addon.getLocalizedString(72000 + e.returncode)
        log(msg, LOGERROR)
        dialog = Dialog() 
        dialog.ok(addon.getLocalizedString(71005), msg)
    except BaseException as e:
        log(str(e), LOGERROR)
        dialog = Dialog() 
        dialog.ok(addon.getLocalizedString(71005), str(e))
Ejemplo n.º 5
0
if settingId == "username":
    default = login
    heading = 30003
    hidden  = False
elif settingId == "password":
    default = passw
    heading = 30004
    hidden  = True

# condition pour la compatibiliter, si aucun token n'est trouve cela veut surement dire que c'est une vielle version du scraper
hasToken = ( bool( Addon.getSetting( "token" ) ) == bool( Addon.getSetting( "tokenb64" ) ) == True )


# initialize Keyboard
kb = xbmc.Keyboard( default, Addon.getLocalizedString( heading ), hidden )
# optional hidden pass
kb.setHiddenInput( hidden )
# call Keyboard
kb.doModal()
# si confirmation on continue les changement
if kb.isConfirmed():
    # recup du text
    text = kb.getText()
    # si le text est pas vide et pas pareil que le default ou pas de token, on change
    if text:# and ( text != default or not hasToken ):
        # set our codes
        if settingId == "username":
            token = sha.new( text.lower() + passw ).hexdigest()
            tokenb64 = b64encode( text )
        else:
from xbmcaddon import Addon


# get scraper object
AddonId = "metadata.media.passion.org"
Addon   = Addon( AddonId )

# set variables
token   = Addon.getSetting( "token" )
token64 = Addon.getSetting( "token64" )
login   = Addon.getSetting( "username" )
passw   = Addon.getSetting( "password" )

if settingId == "username":
    default = login
    heading = Addon.getLocalizedString( 30003 )
    hidden  = False
elif settingId == "password":
    default = passw
    heading = Addon.getLocalizedString( 30004 )
    hidden  = True

# condition pour mettre a jour la base
UpdateUserDB = False

# initialize Keyboard
kb = xbmc.Keyboard( default, heading, hidden )
# optional hidden pass
kb.setHiddenInput( hidden )
# call Keyboard
kb.doModal()
Ejemplo n.º 7
0
import xbmc
import xbmcvfs
from xbmcaddon import Addon

# get scraper object
AddonId = "metadata.passion.xbmc.org"
Addon = Addon(AddonId)

# set variables
token = Addon.getSetting("token" + settingMP)
token64 = Addon.getSetting("token64" + settingMP)
login = Addon.getSetting("username" + settingMP)
passw = Addon.getSetting("password" + settingMP)

if settingId == "username" + settingMP:
    heading = Addon.getLocalizedString(30003)
    default = login
    hidden = False
elif settingId == "password" + settingMP:
    heading = Addon.getLocalizedString(30004 + int(bool(settingMP)))
    default = passw
    hidden = True

# condition pour mettre a jour la base
UpdateUserDB = False

# initialize Keyboard
kb = xbmc.Keyboard(default, heading, hidden)
# optional hidden pass
kb.setHiddenInput(hidden)
# call Keyboard
# -*- coding: utf-8 -*-

import os
import sys

import xbmc
import xbmcgui
import xbmcvfs
from xbmcaddon import Addon

addon = Addon('plugin.video.telequebec')
addon_cache_basedir = os.path.join(
    xbmc.translatePath(addon.getAddonInfo('path')).decode('utf-8'), ".cache")

if sys.argv[1].lower() == "full":
    print "[" + addon.getAddonInfo('name') + "] deleting full cache"
    for root, dirs, files in os.walk(addon_cache_basedir):
        for file in files:
            xbmcvfs.delete(os.path.join(root, file))
    xbmcgui.Dialog().ok(addon.getAddonInfo('name'),
                        addon.getLocalizedString(32108),
                        addon.getLocalizedString(32109))
Ejemplo n.º 9
0
            ))
            # recent tracks:
            artwork.recent_1.setLabel('- [B]{0}[/B] by {1}'.format(
                recent_tracks['recently_played'][0]['title'], recent_tracks['recently_played'][0]['artist']
            ))
            artwork.recent_2.setLabel('- [B]{0}[/B] by {1}'.format(
                recent_tracks['recently_played'][1]['title'], recent_tracks['recently_played'][1]['artist']
            ))
            artwork.recent_3.setLabel('- [B]{0}[/B] by {1}'.format(
                recent_tracks['recently_played'][2]['title'], recent_tracks['recently_played'][2]['artist']
            ))
        sleep(5000)

    log('Artwork closed')
    del artwork


if __name__ == '__main__':
    PLUGIN.run()
    # empty previous thumbnails or create add-on data folder:
    if os.path.exists(ADDON_DATA_FOLDER):
        empty_directory(ADDON_DATA_FOLDER)
    else:
        os.makedirs(ADDON_DATA_FOLDER)

    if sys.argv[0] == 'PLUGIN://{0}/'.format(ADDON_ID) and not ADDON.getSetting('username'):
        executebuiltin('Notification("{0}", "{1}", 6000, "special://home/addons/{2}/icon.png")'
                       .format(ADDON.getLocalizedString(30000),
                               ADDON.getLocalizedString(32202),
                               ADDON_ID))
Ejemplo n.º 10
0
def reset_volume(addon: xbmcaddon.Addon) -> None:

    vol_default = addon.getSettingInt("vol_default")
    set_volume(vol_default)
    xbmcgui.Dialog().notification(addon.getLocalizedString(
        32027), addon.getLocalizedString(32112))
Ejemplo n.º 11
0
class KodiWrapper:
    """ A wrapper around all Kodi functionality """
    def __init__(self, routing=None):
        """ Initialize the Kodi wrapper """
        self.routing = None
        if routing:
            self.routing = routing
            self._handle = self.routing.handle
            self._url = self.routing.base_url
        self._addon = Addon()
        self._system_locale_works = None
        self._addon_name = self._addon.getAddonInfo('name')
        self._addon_id = self._addon.getAddonInfo('id')
        self._global_debug_logging = self.get_global_setting(
            'debug.showloginfo')  # Returns a boolean
        self._debug_logging = self.get_setting_as_bool('debug_logging')
        self._cache_path = self.get_userdata_path() + 'cache/'

    def show_listing(self,
                     title_items,
                     category=None,
                     sort='unsorted',
                     content=None,
                     cache=True):
        """ Show a virtual directory in Kodi """
        if content:
            # content is one of: files, songs, artists, albums, movies, tvshows, episodes, musicvideos, videos, images, games
            xbmcplugin.setContent(self._handle, content=content)

        # Jump through hoops to get a stable breadcrumbs implementation
        category_label = ''
        if category:
            if not content:
                category_label = self._addon_name + ' / '
            if self.kids_mode():
                category_label += 'KIDS / '
            if isinstance(category, int):
                category_label += self.localize(category)
            else:
                category_label += category
        elif not content:
            category_label = self._addon_name
            if self.kids_mode():
                category_label += ' / KIDS'

        xbmcplugin.setPluginCategory(handle=self._handle,
                                     category=category_label)

        # Add all sort methods to GUI (start with preferred)
        xbmcplugin.addSortMethod(handle=self._handle,
                                 sortMethod=SORT_METHODS[sort])
        for key in sorted(SORT_METHODS):
            if key != sort:
                xbmcplugin.addSortMethod(handle=self._handle,
                                         sortMethod=SORT_METHODS[key])

        # Add the listings
        listing = []
        for title_item in title_items:
            list_item = self._generate_listitem(title_item)

            is_folder = bool(not title_item.is_playable and title_item.path)
            url = title_item.path if title_item.path else None
            listing.append((url, list_item, is_folder))

        succeeded = xbmcplugin.addDirectoryItems(self._handle, listing,
                                                 len(listing))
        xbmcplugin.endOfDirectory(self._handle, succeeded, cacheToDisc=cache)

    @staticmethod
    def _generate_listitem(title_item):
        """ Generate a ListItem from a TitleItem """
        from xbmcgui import ListItem

        # Three options:
        #  - item is a virtual directory/folder (not playable, path)
        #  - item is a playable file (playable, path)
        #  - item is non-actionable item (not playable, no path)
        is_folder = bool(not title_item.is_playable and title_item.path)
        is_playable = bool(title_item.is_playable and title_item.path)

        list_item = ListItem(label=title_item.title, path=title_item.path)

        if title_item.prop_dict:
            list_item.setProperties(title_item.prop_dict)
        list_item.setProperty(key='IsPlayable',
                              value='true' if is_playable else 'false')

        list_item.setIsFolder(is_folder)

        if title_item.art_dict:
            list_item.setArt(title_item.art_dict)

        if title_item.info_dict:
            # type is one of: video, music, pictures, game
            list_item.setInfo(type='video', infoLabels=title_item.info_dict)

        if title_item.stream_dict:
            # type is one of: video, audio, subtitle
            list_item.addStreamInfo('video', title_item.stream_dict)

        if title_item.context_menu:
            list_item.addContextMenuItems(title_item.context_menu)

        return list_item

    def play(self, title_item, license_key=None):
        """ Play the passed TitleItem.
        :type title_item: TitleItem
        :type license_key: string
        """
        play_item = self._generate_listitem(title_item)
        play_item.setProperty('inputstreamaddon', 'inputstream.adaptive')
        play_item.setProperty('inputstream.adaptive.max_bandwidth',
                              str(self.get_max_bandwidth() * 1000))
        play_item.setProperty('network.bandwidth',
                              str(self.get_max_bandwidth() * 1000))
        play_item.setProperty('inputstream.adaptive.manifest_type', 'mpd')
        play_item.setMimeType('application/dash+xml')
        play_item.setContentLookup(False)

        if license_key is not None:
            play_item.setProperty('inputstream.adaptive.license_type',
                                  'com.widevine.alpha')
            play_item.setProperty('inputstream.adaptive.license_key',
                                  license_key)

        if title_item.subtitles_path:
            play_item.setSubtitles(title_item.subtitles_path)

        # To support video playback directly from RunPlugin() we need to use xbmc.Player().play instead of
        # setResolvedUrl that only works with PlayMedia() or with internal playable menu items
        xbmcplugin.setResolvedUrl(self._handle, True, listitem=play_item)

        if self.get_setting_as_bool('showsubtitles'):
            while not xbmc.Player().isPlaying() and not xbmc.Monitor(
            ).abortRequested():
                xbmc.sleep(100)
            xbmc.Player().showSubtitles(True)

    @staticmethod
    def get_search_string(heading='', message=''):
        """ Ask the user for a search string """
        search_string = None
        keyboard = xbmc.Keyboard(message, heading)
        keyboard.doModal()
        if keyboard.isConfirmed():
            search_string = to_unicode(keyboard.getText())
        return search_string

    def show_ok_dialog(self, heading='', message=''):
        """ Show Kodi's OK dialog """
        from xbmcgui import Dialog
        if not heading:
            heading = self._addon.getAddonInfo('name')
        return Dialog().ok(heading=heading, line1=message)

    def show_notification(self,
                          heading='',
                          message='',
                          icon='info',
                          time=4000):
        """ Show a Kodi notification """
        from xbmcgui import Dialog
        if not heading:
            heading = self._addon.getAddonInfo('name')
        Dialog().notification(heading=heading,
                              message=message,
                              icon=icon,
                              time=time)

    def show_multiselect(self,
                         heading='',
                         options=None,
                         autoclose=0,
                         preselect=None,
                         use_details=False):
        """ Show a Kodi multi-select dialog """
        from xbmcgui import Dialog
        if not heading:
            heading = self._addon.getAddonInfo('name')
        return Dialog().multiselect(heading=heading,
                                    options=options,
                                    autoclose=autoclose,
                                    preselect=preselect,
                                    useDetails=use_details)

    def show_progress(self, heading='', message=''):
        """ Show a Kodi progress dialog """
        from xbmcgui import DialogProgress
        if not heading:
            heading = self._addon.getAddonInfo('name')
        progress = DialogProgress()
        progress.create(heading=heading, line1=message)
        return progress

    def show_progress_background(self, heading='', message=''):
        """ Show a Kodi progress dialog """
        from xbmcgui import DialogProgressBG
        if not heading:
            heading = self._addon.getAddonInfo('name')
        progress = DialogProgressBG()
        progress.create(heading=heading, message=message)
        return progress

    def set_locale(self):
        """ Load the proper locale for date strings """
        import locale
        locale_lang = self.get_global_setting('locale.language').split('.')[-1]
        try:
            # NOTE: This only works if the platform supports the Kodi configured locale
            locale.setlocale(locale.LC_ALL, locale_lang)
            return True
        except Exception as exc:  # pylint: disable=broad-except
            if locale_lang == 'en_gb':
                return True
            self.log("Your system does not support locale '{locale}': {error}",
                     LOG_DEBUG,
                     locale=locale_lang,
                     error=exc)
            return False

    def localize(self, string_id, **kwargs):
        """ Return the translated string from the .po language files, optionally translating variables """
        if kwargs:
            import string
            return string.Formatter().vformat(
                self._addon.getLocalizedString(string_id), (),
                SafeDict(**kwargs))

        return self._addon.getLocalizedString(string_id)

    def get_setting(self, setting_id, default=None):
        """ Get an add-on setting """
        value = to_unicode(self._addon.getSetting(setting_id))
        if value == '' and default is not None:
            return default
        return value

    def get_setting_as_bool(self, setting):
        """ Get an add-on setting as a boolean value """
        return self.get_setting(setting).lower() == "true"

    def set_setting(self, setting_id, setting_value):
        """ Set an add-on setting """
        return self._addon.setSetting(setting_id, setting_value)

    def open_settings(self):
        """ Open the add-in settings window """
        self._addon.openSettings()

    @staticmethod
    def get_global_setting(setting):
        """ Get a Kodi setting """
        import json
        json_result = xbmc.executeJSONRPC(
            '{"jsonrpc": "2.0", "method": "Settings.GetSettingValue", "params": {"setting": "%s"}, "id": 1}'
            % setting)
        return json.loads(json_result).get('result', dict()).get('value')

    def get_cache(self, key, ttl=None):
        """ Get an item from the cache
        :type key: list[str]
        :type ttl: int
        """
        import time

        fullpath = self._cache_path + '.'.join(key)

        if not self.check_if_path_exists(fullpath):
            return None

        if ttl and time.mktime(
                time.localtime()) - self.stat_file(fullpath).st_mtime() > ttl:
            return None

        with self.open_file(fullpath, 'r') as fdesc:
            try:
                import json
                value = json.load(fdesc)
                self.log('Fetching {file} from cache', file=fullpath)
                return value
            except (ValueError, TypeError):
                return None

    def set_cache(self, key, data):
        """ Store an item in the cache
        :type key: list[str]
        :type data: str
        """
        if not self.check_if_path_exists(self._cache_path):
            self.mkdirs(self._cache_path)

        fullpath = self._cache_path + '.'.join(key)
        with self.open_file(fullpath, 'w') as fdesc:
            import json
            self.log('Storing to cache as {file}', file=fullpath)
            json.dump(data, fdesc)

    def invalidate_cache(self, ttl=None):
        """ Clear the cache """
        if not self.check_if_path_exists(self._cache_path):
            return
        _, files = self.listdir(self._cache_path)
        import time
        now = time.mktime(time.localtime())
        for filename in files:
            fullpath = self._cache_path + filename
            if ttl and now - self.stat_file(fullpath).st_mtime() < ttl:
                continue
            self.delete_file(fullpath)

    def get_max_bandwidth(self):
        """ Get the max bandwidth based on Kodi and add-on settings """
        addon_max_bandwidth = int(self.get_setting('max_bandwidth', '0'))
        global_max_bandwidth = int(
            self.get_global_setting('network.bandwidth'))
        if addon_max_bandwidth != 0 and global_max_bandwidth != 0:
            return min(addon_max_bandwidth, global_max_bandwidth)
        if addon_max_bandwidth != 0:
            return addon_max_bandwidth
        if global_max_bandwidth != 0:
            return global_max_bandwidth
        return 0

    def get_proxies(self):
        """ Return a usable proxies dictionary from Kodi proxy settings """
        usehttpproxy = self.get_global_setting('network.usehttpproxy')
        if usehttpproxy is not True:
            return None

        try:
            httpproxytype = int(
                self.get_global_setting('network.httpproxytype'))
        except ValueError:
            httpproxytype = 0

        socks_supported = has_socks()
        if httpproxytype != 0 and not socks_supported:
            # Only open the dialog the first time (to avoid multiple popups)
            if socks_supported is None:
                self.show_ok_dialog('',
                                    self.localize(30966))  # Requires PySocks
            return None

        proxy_types = ['http', 'socks4', 'socks4a', 'socks5', 'socks5h']
        if 0 <= httpproxytype < 5:
            httpproxyscheme = proxy_types[httpproxytype]
        else:
            httpproxyscheme = 'http'

        httpproxyserver = self.get_global_setting('network.httpproxyserver')
        httpproxyport = self.get_global_setting('network.httpproxyport')
        httpproxyusername = self.get_global_setting(
            'network.httpproxyusername')
        httpproxypassword = self.get_global_setting(
            'network.httpproxypassword')

        if httpproxyserver and httpproxyport and httpproxyusername and httpproxypassword:
            proxy_address = '%s://%s:%s@%s:%s' % (
                httpproxyscheme, httpproxyusername, httpproxypassword,
                httpproxyserver, httpproxyport)
        elif httpproxyserver and httpproxyport and httpproxyusername:
            proxy_address = '%s://%s@%s:%s' % (httpproxyscheme,
                                               httpproxyusername,
                                               httpproxyserver, httpproxyport)
        elif httpproxyserver and httpproxyport:
            proxy_address = '%s://%s:%s' % (httpproxyscheme, httpproxyserver,
                                            httpproxyport)
        elif httpproxyserver:
            proxy_address = '%s://%s' % (httpproxyscheme, httpproxyserver)
        else:
            return None

        return dict(http=proxy_address, https=proxy_address)

    @staticmethod
    def get_cond_visibility(condition):
        """ Test a condition in XBMC """
        return xbmc.getCondVisibility(condition)

    def has_inputstream_adaptive(self):
        """ Whether InputStream Adaptive is installed and enabled in add-on settings """
        return self.get_setting(
            'useinputstreamadaptive',
            'true') == 'true' and xbmc.getCondVisibility(
                'System.HasAddon(inputstream.adaptive)') == 1

    def credentials_filled_in(self):
        """ Whether the add-on has credentials filled in """
        return bool(
            self.get_setting('username') and self.get_setting('password'))

    @staticmethod
    def kodi_version():
        """ Returns major Kodi version """
        return int(xbmc.getInfoLabel('System.BuildVersion').split('.')[0])

    def can_play_drm(self):
        """ Whether this Kodi can do DRM using InputStream Adaptive """
        return self.get_setting('usedrm',
                                'true') == 'true' and self.get_setting(
                                    'useinputstreamadaptive',
                                    'true') == 'true' and self.supports_drm()

    def supports_drm(self):
        """ Whether this Kodi version supports DRM decryption using InputStream Adaptive """
        return self.kodi_version() > 17

    def get_userdata_path(self):
        """ Return the profile's userdata path """
        return to_unicode(
            xbmc.translatePath(self._addon.getAddonInfo('profile')))

    def get_addon_path(self):
        """ Return the profile's addon path """
        return to_unicode(xbmc.translatePath(self._addon.getAddonInfo('path')))

    def get_addon_info(self, key):
        """ Return addon information """
        return self._addon.getAddonInfo(key)

    @staticmethod
    def listdir(path):
        """ Return all files in a directory (using xbmcvfs)"""
        from xbmcvfs import listdir
        return listdir(path)

    def mkdir(self, path):
        """ Create a directory (using xbmcvfs) """
        from xbmcvfs import mkdir
        self.log("Create directory '{path}'.", LOG_DEBUG, path=path)
        return mkdir(path)

    def mkdirs(self, path):
        """ Create directory including parents (using xbmcvfs) """
        from xbmcvfs import mkdirs
        self.log("Recursively create directory '{path}'.",
                 LOG_DEBUG,
                 path=path)
        return mkdirs(path)

    @staticmethod
    def check_if_path_exists(path):
        """ Whether the path exists (using xbmcvfs)"""
        from xbmcvfs import exists
        return exists(path)

    @staticmethod
    @contextmanager
    def open_file(path, flags='r'):
        """ Open a file (using xbmcvfs) """
        from xbmcvfs import File
        fdesc = File(path, flags)
        yield fdesc
        fdesc.close()

    @staticmethod
    def stat_file(path):
        """ Return information about a file (using xbmcvfs) """
        from xbmcvfs import Stat
        return Stat(path)

    def delete_file(self, path):
        """ Remove a file (using xbmcvfs) """
        from xbmcvfs import delete
        self.log("Delete file '{path}'.", LOG_DEBUG, path=path)
        return delete(path)

    def end_of_directory(self):
        """ Close a virtual directory, required to avoid a waiting Kodi """
        xbmcplugin.endOfDirectory(handle=self._handle,
                                  succeeded=False,
                                  updateListing=False,
                                  cacheToDisc=False)

    def log(self, message, log_level=LOG_INFO, **kwargs):
        """ Log info messages to Kodi """
        if not self._global_debug_logging and self._debug_logging and log_level in [
                LOG_DEBUG, LOG_INFO
        ]:
            # If Debug Logging is not enabled, Kodi filters everything up to NOTICE out
            log_level = LOG_NOTICE
        if kwargs:
            import string
            message = string.Formatter().vformat(message, (),
                                                 SafeDict(**kwargs))
        message = '[{addon}] {message}'.format(addon=self._addon_id,
                                               message=message)
        xbmc.log(msg=from_unicode(message), level=log_level)

    def kids_mode(self):
        """ Returns if kids zone is active """
        if self.get_setting_as_bool('force_kids_zone'):
            return True

        if self.routing and self.routing.path.startswith('/kids'):
            return True
        return False
            # recent tracks:
            artwork.recent_1.setLabel('- [B]{0}[/B] by {1}'.format(
                recent_tracks['recently_played'][0]['title'],
                recent_tracks['recently_played'][0]['artist']))
            artwork.recent_2.setLabel('- [B]{0}[/B] by {1}'.format(
                recent_tracks['recently_played'][1]['title'],
                recent_tracks['recently_played'][1]['artist']))
            artwork.recent_3.setLabel('- [B]{0}[/B] by {1}'.format(
                recent_tracks['recently_played'][2]['title'],
                recent_tracks['recently_played'][2]['artist']))
        sleep(5000)

    log('Artwork closed')
    del artwork


if __name__ == '__main__':
    PLUGIN.run()
    # empty previous thumbnails or create add-on data folder:
    if os.path.exists(ADDON_DATA_FOLDER):
        empty_directory(ADDON_DATA_FOLDER)
    else:
        os.makedirs(ADDON_DATA_FOLDER)

    if sys.argv[0] == 'PLUGIN://{0}/'.format(
            ADDON_ID) and not ADDON.getSetting('username'):
        executebuiltin(
            'Notification("{0}", "{1}", 6000, "special://home/addons/{2}/icon.png")'
            .format(ADDON.getLocalizedString(30000),
                    ADDON.getLocalizedString(32202), ADDON_ID))
Ejemplo n.º 13
0
import xbmcvfs
from xbmcaddon import Addon


# get scraper object
AddonId = "metadata.passion.xbmc.org"
Addon   = Addon( AddonId )

# set variables
token   = Addon.getSetting( "token"    + settingMP )
token64 = Addon.getSetting( "token64"  + settingMP )
login   = Addon.getSetting( "username" + settingMP )
passw   = Addon.getSetting( "password" + settingMP )

if settingId == "username" + settingMP:
    heading = Addon.getLocalizedString( 30003 )
    default = login
    hidden  = False
elif settingId == "password" + settingMP:
    heading = Addon.getLocalizedString( 30004 + int( bool( settingMP ) ) )
    default = passw
    hidden  = True

# condition pour mettre a jour la base
UpdateUserDB = False

# initialize Keyboard
kb = xbmc.Keyboard( default, heading, hidden )
# optional hidden pass
kb.setHiddenInput( hidden )
# call Keyboard
Ejemplo n.º 14
0
import os
import sys

import xbmc
import xbmcgui
import xbmcvfs
from xbmcaddon import Addon

addon = Addon('plugin.video.telequebec')
addon_cache_basedir = os.path.join(xbmc.translatePath(addon.getAddonInfo('path')),".cache")

if sys.argv[1].lower() == "full":
    print "["+addon.getAddonInfo('name')+"] deleting full cache"
    for root, dirs, files in os.walk(addon_cache_basedir):
        for file in files:
            xbmcvfs.delete(os.path.join(root,file))
    xbmcgui.Dialog().ok(addon.getAddonInfo('name'), addon.getLocalizedString(32108),addon.getLocalizedString(32109))

Ejemplo n.º 15
0
# -*- coding: utf-8 -*-

import os
import sys

import xbmc
import xbmcgui
import xbmcvfs
from xbmcaddon import Addon

addon = Addon('plugin.infologique.TVAgo')
addon_cache_basedir = os.path.join(xbmc.translatePath(addon.getAddonInfo('path')).decode('utf-8'),".cache")

if sys.argv[1].lower() == "full":
    print "["+addon.getAddonInfo('name')+"] deleting full cache"
    for root, dirs, files in os.walk(addon_cache_basedir):
        for file in files:
            xbmcvfs.delete(os.path.join(root,file))
    xbmcgui.Dialog().ok(addon.getAddonInfo('name'), addon.getLocalizedString(32108),addon.getLocalizedString(32109))