Exemplo n.º 1
0
def _daemon():
    previous_getDVDState = 4 # this should insure only on rip is done
    while ( not xbmc.abortRequested ):
        xbmc.sleep( 250 )
        if xbmc.getDVDState() == 4 and previous_getDVDState != 4:
            utils.log( "Disc Detected, Checking for Movie Disc(s)", xbmc.LOGNOTICE )
            xbmc.sleep( 3000 )
            previous_getDVDState = xbmc.getDVDState()
            disc = makemkv.makeMKV( general_settings ).findDisc( general_settings[ "temp_folder" ] )
            if disc:
                utils.log( "Movie Disc Detected", xbmc.LOGNOTICE )
                if general_settings[ "movie_disc_insertion" ] == "Rip":
                    makeMKV().rip( disc )
                elif general_settings[ "movie_disc_insertion" ] == "Notify":
                    pass
                elif general_settings[ "movie_disc_insertion" ] == "Stream":
                    pass
                elif general_settings[ "movie_disc_insertion" ] == "Ask":
                    pass
                elif general_settings[ "movie_disc_insertion" ] == "Backup":
                    pass
                else: #do nothing
                    pass
        elif xbmc.getDVDState() !=4:
            previous_getDVDState = xbmc.getDVDState()
Exemplo n.º 2
0
    def _get(self, key):
        if key == 'lang':
            return xbmc.getLanguage()

        elif key == 'langname':
            langname = xbmc.getLanguage()
            if langname.find('Oromo') != -1:
                langname = 'Oromo'
            else:
                for tag in (' (', ';', ','):
                    i = langname.find(tag)
                    if i != -1:
                        langname = langname[0:i]
                        break
            try:
                LANGCODE[langname]
            except KeyError:
                return 'English'
            else:
                return langname

        elif key == 'langcode':
            return LANGCODE[self._get('langname')]

        elif key == 'dvd':
            state = {0: 'open', 1: 'notready', 2: 'ready', 3: 'empty', 4: 'present', 5: None}
            return state[xbmc.getDVDState()]

        elif key == 'mem':
            return xbmc.getFreeMem() # MB

        elif key == 'time':
            return xbmc.getGlobalIdleTime()

        elif key == 'skin':
            return xbmc.getSkinDir()

        elif key == 'ip':
            return xbmc.getIPAddress()

        elif key == 'platform':
            if self._platform == -1:
                for platform in ('linux', 'windows', 'android', 'atv2', 'ios', 'osx'):
                    if xbmc.getCondVisibility('system.platform.' + platform):
                        self._platform = platform
                        break
                else:
                    self._platform = None
            return self._platform

        elif key == 'is_64bits':
            return sys.maxsize > 2**32

        elif key == 'support':
            if not self._support['all']:
                for src, dst in (('video', 'video'), ('music', 'audio'), ('picture', 'picture')):
                    self._support[dst] = [x[1:] for x in xbmc.getSupportedMedia(src).split('|')]
                    self._support['all'].extend(self._support[dst])
            return self._support

        elif key == 'region':
            if not self._region:
                for tag in ('dateshort', 'datelong', 'time', 'meridiem', 'tempunit', 'speedunit'):
                    self._region[tag] = xbmc.getRegion(tag)
            return self._region

        else:
            raise AttributeError, key
Exemplo n.º 3
0
    def onIDLE(self):
        action = addon.getSetting('on__action')

        if (action == 'Minimize') or (action == 'Quit') or (
                action == 'Powerdown') or (action
                                           == 'Hibernate') or (action
                                                               == 'Suspend'):
            xbmc.executebuiltin('xbmc.' + action + '()')

        if (action == 'RunScript') or (action == 'RunAppleScript'):
            xbmc.executebuiltin('xbmc.' + action + '(' +
                                addon.getSetting('on__file_scripts') + ', ' +
                                addon.getSetting('on__optional_parameter') +
                                ')')

        if (action == 'System.Exec') or (action == 'System.ExecWait'):
            if addon.getSetting('on__execute_file_cmd') == 'File':
                xbmc.executebuiltin(
                    'xbmc.' + action + '(' +
                    addon.getSetting('on__file_execs') + ', ' +
                    addon.getSetting('on__optional_parameter') + ')')
            if addon.getSetting('on__execute_file_cmd') == 'CMD':
                xbmc.executebuiltin('xbmc.' + action + '(' +
                                    addon.getSetting('on__cmd') + ')')

        if action == 'PlayMedia':
            windowtype = addon.getSetting('on__windowtype')
            if windowtype == 'Fullscreen':
                windowtypeint = 0
            if windowtype == 'Preview':
                windowtypeint = 1

            if addon.getSetting('on__type_playmedia') == 'Playlist':
                if addon.getSetting('on__isdir') == 'true':
                    xbmc.executebuiltin(
                        'xbmc.' + action + '(' +
                        addon.getSetting('on__folder_playmedia') + ', ' +
                        str(windowtypeint) + ')')
                else:
                    xbmc.executebuiltin(
                        'xbmc.' + action + '(' +
                        addon.getSetting('on__file_playmedia') + ', ' +
                        str(windowtypeint) + ', ' +
                        addon.getSetting('on__offset') + ')')

            if addon.getSetting('on__type_playmedia') == 'Audio/Video-File':
                if addon.getSetting('on__isdir') == 'true':
                    xbmc.executebuiltin(
                        'xbmc.' + action + '(' +
                        addon.getSetting('on__folder_playmedia') + ', ' +
                        str(windowtypeint) + ')')
                else:
                    xbmc.executebuiltin(
                        'xbmc.' + action + '(' +
                        addon.getSetting('on__file_playmedia') + ', ' +
                        str(windowtypeint) + ')')

            if (addon.getSetting('on__type_playmedia') == 'URL'):
                xbmc.executebuiltin('xbmc.' + action + '(' +
                                    addon.getSetting('on__url_playmedia') +
                                    ', ' + str(windowtypeint) + ')')

        if action == 'SlideShow':
            if addon.getSetting('on__slideshow_recursive'):
                xbmc.executebuiltin(
                    'xbmc.' + action + '(' + addon.getSetting('on__folder') +
                    ', ' + 'recursive' + ', ' +
                    addon.getSetting('on__slideshow_randomtype') + ')')
            else:
                xbmc.executebuiltin(
                    'xbmc.' + action + '(' + addon.getSetting('on__folder') +
                    ', ' + addon.getSetting('on__slideshow_randomtype') + ')')

        if action == 'RecursiveSlideShow':
            xbmc.executebuiltin('xbmc.' + action + '(' +
                                addon.getSetting('on__folder') + ')')

        if action == 'UpdateLibrary':
            if addon.getSetting('on__update_clean_library') == 'music':
                xbmc.executebuiltin('xbmc.' + action + '(music)')
            if addon.getSetting('on__update_clean_library') == 'video':
                xbmc.executebuiltin(
                    'xbmc.' + action + '(video' + ', ' +
                    addon.getSetting('on__opt_fol__upd_vid_lib') + ')')

        if action == 'CleanLibrary':
            xbmc.executebuiltin('xbmc.' + action + '(' +
                                addon.getSetting('on__update_clean_library') +
                                ')')

        if action == 'PlayDVD':
            dvdstate = xbmc.getDVDState()
            dlg = xbmcgui.Dialog()
            if dvdstate == 1:
                dlg.ok('Error', 'Drive not ready')
            elif dvdstate == 16:
                dlg.ok('Error', 'Tray open')
            elif dvdstate == 64:
                dlg.ok('Error', 'No media')
            else:
                xbmc.executebuiltin('xbmc.' + action + '()')

        # Future Gotham addition
##        if action == 'ActivateScreensaver':
##            xbmc.executebuiltin('xbmc.' + action + '()')

        xbmc.sleep(1000)
        if xbmc.Player().isPlaying():
            while (not xbmc.abortRequested):
                TIMEOUT = int(addon.getSetting('on__idle_time_min'))
                IDLE_TIME = xbmc.getGlobalIdleTime()
                if IDLE_TIME < TIMEOUT:
                    xbmc.executebuiltin('xbmc.PlayerControl(Stop)')
                    break

            xbmc.sleep(1000)
Exemplo n.º 4
0
        def onIdle(self):
            action = addon.getSetting('on__action')
            
            if (action == 'Minimize') or (action == 'Quit') or (action == 'Powerdown') or (action == 'Hibernate') or (action == 'Suspend'):
                xbmc.executebuiltin(action + '()')

            if (action == 'RunScript') or (action == 'RunAppleScript'):
                xbmc.executebuiltin(action + '(' + addon.getSetting('on__file_scripts') + ', ' + addon.getSetting('on__optional_parameter') + ')')

            if (action == 'System.Exec') or (action == 'System.ExecWait'):
                if addon.getSetting('on__execute_file_cmd') == 'File':
                    xbmc.executebuiltin(action + '(' + addon.getSetting('on__file_execs') + ', ' + addon.getSetting('on__optional_parameter') + ')')
                if addon.getSetting('on__execute_file_cmd') == 'CMD':
                    xbmc.executebuiltin(action + '(' + addon.getSetting('on__cmd') + ')')

            if action == 'PlayMedia':
                if addon.getSetting('on__random_playmedia') == 'true':
                    xbmc.executebuiltin('PlayerControl(RandomOn)')
                if addon.getSetting('on__repeatall_playmedia') == 'true':
                    xbmc.executebuiltin('PlayerControl(RepeatAll)')
            
                windowtype = addon.getSetting('on__windowtype')
                if windowtype == 'Fullscreen':
                    windowtypeint = 0
                if windowtype == 'Preview':
                    windowtypeint = 1

                if addon.getSetting('on__type_playmedia') == 'Playlist':
                    if addon.getSetting('on__isdir') == 'true':
                        xbmc.executebuiltin(action + '(' + addon.getSetting('on__folder_playmedia') + ', ' + str(windowtypeint) + ')')
                    else:
                        xbmc.executebuiltin(action + '(' + addon.getSetting('on__file_playmedia') + ', ' + str(windowtypeint) + ', ' + addon.getSetting('on__offset') + ')')

                if addon.getSetting('on__type_playmedia') == 'Audio/Video-File':
                    if addon.getSetting('on__isdir') == 'true':
                        xbmc.executebuiltin(action + '(' + addon.getSetting('on__folder_playmedia') + ', ' + str(windowtypeint) + ')')
                    else:
                        xbmc.executebuiltin(action + '(' + addon.getSetting('on__file_playmedia') + ', ' + str(windowtypeint) + ')')

                if (addon.getSetting('on__type_playmedia') == 'URL'):
                    xbmc.executebuiltin(action + '(' + addon.getSetting('on__url_playmedia') + ', ' + str(windowtypeint) + ')')            

            if action == 'SlideShow':
                if addon.getSetting('on__slideshow_recursive'):
                    xbmc.executebuiltin(action + '(' + addon.getSetting('on__folder') + ', ' + 'recursive' + ', ' + addon.getSetting('on__slideshow_randomtype') + ')')
                else:
                    xbmc.executebuiltin(action + '(' + addon.getSetting('on__folder') + ', ' + addon.getSetting('on__slideshow_randomtype') + ')')

            if action == 'RecursiveSlideShow':
                xbmc.executebuiltin(action + '(' + addon.getSetting('on__folder') + ')')

            if action == 'UpdateLibrary':
                if addon.getSetting('on__update_clean_library') == 'music':
                    xbmc.executebuiltin(action + '(music)')
                if addon.getSetting('on__update_clean_library') == 'video':
                    xbmc.executebuiltin(action + '(video' + ', ' + addon.getSetting('on__opt_fol__upd_vid_lib') + ')')

            if action == 'CleanLibrary':
                xbmc.executebuiltin(action + '(' + addon.getSetting('on__update_clean_library') + ')')

            if action == 'PlayDVD':
                dvdstate = xbmc.getDVDState()
                if dvdstate == 1:                
                    xbmc.executebuiltin('Notification(%s, Error: Drive not ready)' %(addon_name) )
                elif dvdstate == 16:
                    xbmc.executebuiltin('Notification(%s, Error: Tray open)' %(addon_name) )
                elif dvdstate == 64:
                    xbmc.executebuiltin('Notification(%s, Error: No media)' %(addon_name) )
                else:
                    xbmc.executebuiltin(action + '()')
        
            if action == 'ActivateScreensaver':
                ver = xbmc.getInfoLabel('System.BuildVersion')
                verint = int(ver.replace(ver[ver.find('.'):], ''))
                if verint > 12:
                    xbmc.executebuiltin(action + '()')


            xbmc.sleep(1000)
            if xbmc.Player().isPlaying():
                while (not xbmc.abortRequested):            
                    timeout = int(addon.getSetting('on__idle_time_min'))
                    idleTime = xbmc.getGlobalIdleTime()
                    if idleTime < timeout:
                        xbmc.executebuiltin('PlayerControl(Stop)')
                        break

                xbmc.sleep(1000)
Exemplo n.º 5
0
    def _get(self, key):
        if key == 'lang':
            return xbmc.getLanguage()

        elif key == 'langname':
            langname = xbmc.getLanguage()
            if langname.find('Oromo') != -1:
                langname = 'Oromo'
            else:
                for tag in (' (', ';', ','):
                    i = langname.find(tag)
                    if i != -1:
                        langname = langname[0:i]
                        break
            try:
                LANGCODE[langname]
            except KeyError:
                return 'English'
            else:
                return langname

        elif key == 'langcode':
            return LANGCODE[self._get('langname')]

        elif key == 'dvd':
            state = {
                0: 'open',
                1: 'notready',
                2: 'ready',
                3: 'empty',
                4: 'present',
                5: None
            }
            return state[xbmc.getDVDState()]

        elif key == 'mem':
            return xbmc.getFreeMem()  # MB

        elif key == 'time':
            return xbmc.getGlobalIdleTime()

        elif key == 'skin':
            return xbmc.getSkinDir()

        elif key == 'ip':
            return xbmc.getIPAddress()

        elif key == 'platform':
            if self._platform == -1:
                for platform in ('linux', 'windows', 'android', 'atv2', 'ios',
                                 'osx'):
                    if xbmc.getCondVisibility('system.platform.' + platform):
                        self._platform = platform
                        break
                else:
                    self._platform = None
            return self._platform

        elif key == 'is_64bits':
            return sys.maxsize > 2**32

        elif key == 'support':
            if not self._support['all']:
                for src, dst in (('video', 'video'), ('music', 'audio'),
                                 ('picture', 'picture')):
                    self._support[dst] = [
                        x[1:] for x in xbmc.getSupportedMedia(src).split('|')
                    ]
                    self._support['all'].extend(self._support[dst])
            return self._support

        elif key == 'region':
            if not self._region:
                for tag in ('dateshort', 'datelong', 'time', 'meridiem',
                            'tempunit', 'speedunit'):
                    self._region[tag] = xbmc.getRegion(tag)
            return self._region

        else:
            raise AttributeError, key
Exemplo n.º 6
0
    def onIDLE(self):
        action = addon.getSetting('on__action')
            
        if (action == 'Minimize') or (action == 'Quit') or (action == 'Powerdown') or (action == 'Hibernate') or (action == 'Suspend'):
            xbmc.executebuiltin('xbmc.' + action + '()')

        if (action == 'RunScript') or (action == 'RunAppleScript'):
            xbmc.executebuiltin('xbmc.' + action + '(' + addon.getSetting('on__file_scripts') + ', ' + addon.getSetting('on__optional_parameter') + ')')

        if (action == 'System.Exec') or (action == 'System.ExecWait'):
            if addon.getSetting('on__execute_file_cmd') == 'File':
                xbmc.executebuiltin('xbmc.' + action + '(' + addon.getSetting('on__file_execs') + ', ' + addon.getSetting('on__optional_parameter') + ')')
            if addon.getSetting('on__execute_file_cmd') == 'CMD':
                xbmc.executebuiltin('xbmc.' + action + '(' + addon.getSetting('on__cmd') + ')')

        if action == 'PlayMedia':
            windowtype = addon.getSetting('on__windowtype')
            if windowtype == 'Fullscreen':
                windowtypeint = 0
            if windowtype == 'Preview':
                windowtypeint = 1

            if addon.getSetting('on__type_playmedia') == 'Playlist':
                if addon.getSetting('on__isdir') == 'true':
                    xbmc.executebuiltin('xbmc.' + action + '(' + addon.getSetting('on__folder_playmedia') + ', ' + str(windowtypeint) + ')')
                else:
                    xbmc.executebuiltin('xbmc.' + action + '(' + addon.getSetting('on__file_playmedia') + ', ' + str(windowtypeint) + ', ' + addon.getSetting('on__offset') + ')')

            if addon.getSetting('on__type_playmedia') == 'Audio/Video-File':
                if addon.getSetting('on__isdir') == 'true':
                    xbmc.executebuiltin('xbmc.' + action + '(' + addon.getSetting('on__folder_playmedia') + ', ' + str(windowtypeint) + ')')
                else:
                    xbmc.executebuiltin('xbmc.' + action + '(' + addon.getSetting('on__file_playmedia') + ', ' + str(windowtypeint) + ')')

            if (addon.getSetting('on__type_playmedia') == 'URL'):
                xbmc.executebuiltin('xbmc.' + action + '(' + addon.getSetting('on__url_playmedia') + ', ' + str(windowtypeint) + ')')            

        if action == 'SlideShow':
            if addon.getSetting('on__slideshow_recursive'):
                xbmc.executebuiltin('xbmc.' + action + '(' + addon.getSetting('on__folder') + ', ' + 'recursive' + ', ' + addon.getSetting('on__slideshow_randomtype') + ')')
            else:
                xbmc.executebuiltin('xbmc.' + action + '(' + addon.getSetting('on__folder') + ', ' + addon.getSetting('on__slideshow_randomtype') + ')')

        if action == 'RecursiveSlideShow':
            xbmc.executebuiltin('xbmc.' + action + '(' + addon.getSetting('on__folder') + ')')

        if action == 'UpdateLibrary':
            if addon.getSetting('on__update_clean_library') == 'music':
                xbmc.executebuiltin('xbmc.' + action + '(music)')
            if addon.getSetting('on__update_clean_library') == 'video':
                xbmc.executebuiltin('xbmc.' + action + '(video' + ', ' + addon.getSetting('on__opt_fol__upd_vid_lib') + ')')

        if action == 'CleanLibrary':
            xbmc.executebuiltin('xbmc.' + action + '(' + addon.getSetting('on__update_clean_library') + ')')

        if action == 'PlayDVD':
            dvdstate = xbmc.getDVDState()
            dlg = xbmcgui.Dialog()
            if dvdstate == 1:                
                dlg.ok('Error', 'Drive not ready')
            elif dvdstate == 16:
                dlg.ok('Error', 'Tray open')
            elif dvdstate == 64:
                dlg.ok('Error', 'No media')
            else:
                xbmc.executebuiltin('xbmc.' + action + '()')

        # Future Gotham addition
##        if action == 'ActivateScreensaver':
##            xbmc.executebuiltin('xbmc.' + action + '()')


        xbmc.sleep(1000)
        if xbmc.Player().isPlaying():
            while (not xbmc.abortRequested):            
                TIMEOUT = int(addon.getSetting('on__idle_time_min'))
                IDLE_TIME = xbmc.getGlobalIdleTime()
                if IDLE_TIME < TIMEOUT:
                    xbmc.executebuiltin('xbmc.PlayerControl(Stop)')
                    break

            xbmc.sleep(1000)