コード例 #1
0
    def playAllExtras(self, path, target, extrasParentTitle):
        # Check if the use database setting is enabled
        extrasDb = None
        if Settings.isDatabaseEnabled():
            extrasDb = ExtrasDB()

        # Create the extras class that will be used to process the extras
        videoExtras = VideoExtrasBase(path, target, extrasParentTitle)

        # Perform the search command
        # No need for fanart default as only getting a list to play, not display
        files = videoExtras.findExtras(extrasDb=extrasDb)
        del videoExtras

        ExtrasPlayer.playAll(files, extrasParentTitle)
コード例 #2
0
    def playExtra(self,
                  path,
                  target,
                  filename,
                  extrasParentTitle="",
                  forceResume=False,
                  fromStart=False):
        # Check if the use database setting is enabled
        extrasDb = None
        if Settings.isDatabaseEnabled():
            extrasDb = ExtrasDB()

        # Create the extras class that will be used to process the extras
        videoExtras = VideoExtrasBase(path, target, extrasParentTitle)

        # Perform the search command
        # No need for fanart default as only getting a list to play, not display
        files = videoExtras.findExtras(extrasDb=extrasDb)
        del videoExtras

        for anExtra in files:
            if anExtra.isFilenameMatch(filename):
                log("MenuNavigator: Found  = %s" % filename)

                # Check if we are forcing playback from the start
                if fromStart is not False:
                    anExtra.setResumePoint(0)

                # If part way viewed prompt the user for resume or play from beginning
                if (anExtra.getResumePoint()) > 0 and (forceResume
                                                       is not True):
                    resumeWindow = VideoExtrasResumeWindow.createVideoExtrasResumeWindow(
                        anExtra.getDisplayResumePoint())
                    resumeWindow.doModal()

                    # Check the return value, if exit, then we play nothing
                    if resumeWindow.isExit():
                        return
                    # If requested to restart from beginning, reset the resume point before playing
                    if resumeWindow.isRestart():
                        anExtra.setResumePoint(0)
                    # Default is to actually resume

                ExtrasPlayer.performPlayAction(anExtra, extrasParentTitle)
コード例 #3
0
    def markAsUnwatched(self, path, target, filename):
        # If marking as watched we need to set the resume time so it doesn't
        # start in the middle the next time it starts
        if Settings.isDatabaseEnabled():
            # Create the extras class that will be used to process the extras
            videoExtras = VideoExtrasBase(path, target)

            # Perform the search command
            extrasDb = ExtrasDB()
            # We are only updating the DB for an entry already shown, no need for fanart
            files = videoExtras.findExtras(extrasDb=extrasDb)
            del videoExtras
            del extrasDb

            for anExtra in files:
                if anExtra.isFilenameMatch(filename):
                    log("MenuNavigator: Found  = %s" % filename)
                    anExtra.setResumePoint(0)
                    anExtra.saveState()
                    # Update the display
                    xbmc.executebuiltin("Container.Refresh")
コード例 #4
0
import xbmc
import xbmcaddon

# Import the common settings
from resources.lib.settings import log
# Load the database interface
from resources.lib.database import ExtrasDB
# Load the cache cleaner
from resources.lib.CacheCleanup import CacheCleanup

ADDON = xbmcaddon.Addon(id='script.videoextras')


#########################
# Main
#########################
if __name__ == '__main__':
    log("VideoExtrasCleanup: Cleanup called (version %s)" % ADDON.getAddonInfo('version'))

    try:
        # Start by removing the database
        extrasDb = ExtrasDB()
        extrasDb.cleanDatabase()
        del extrasDb

        # Also tidy up any of the cache files that exist
        CacheCleanup.removeAllCachedFiles()

    except:
        log("VideoExtrasCleanup: %s" % traceback.format_exc(), xbmc.LOGERROR)
コード例 #5
0
                if ("plugin://" in sys.argv[2]) and not forceExtrasSupport:
                    if sys.argv[1] == "check":
                        xbmcgui.Window(12003).setProperty(
                            "HideVideoExtrasButton", "true")
                else:
                    # Create the extras class that deals with any extras request
                    videoExtras = VideoExtras(sys.argv[2])

                    # We are either running the command or just checking for existence
                    if sys.argv[1] == "check":
                        videoExtras.checkButtonEnabled()
                    else:
                        # Check if the use database setting is enabled
                        extrasDb = None
                        if Settings.isDatabaseEnabled():
                            extrasDb = ExtrasDB()
                        # Perform the search command
                        files = videoExtras.findExtras(
                            extrasDb=extrasDb,
                            defaultFanArt=SourceDetails.getFanArt())
                        # need to display the extras
                        videoExtras.run(files)

                    del videoExtras
        else:
            # Close any open dialogs
            xbmc.executebuiltin("Dialog.Close(all, true)", True)

            log("VideoExtras: Running as Addon/Plugin")
            xbmc.executebuiltin("RunAddon(script.videoextras)")
    except:
コード例 #6
0
    def showExtras(self,
                   path,
                   target,
                   extrasParentTitle="",
                   extrasDefaultFanArt="",
                   extrasDefaultIconImage=""):
        # Check if the use database setting is enabled
        extrasDb = None
        if Settings.isDatabaseEnabled():
            extrasDb = ExtrasDB()

        # Create the extras class that will be used to process the extras
        videoExtras = VideoExtrasBase(path, target, extrasParentTitle)

        # Perform the search command
        files = videoExtras.findExtras(extrasDb=extrasDb,
                                       defaultFanArt=extrasDefaultFanArt)
        del videoExtras

        tvShowTitle = ""
        if target == MenuNavigator.TVSHOWS:
            tvShowTitle = extrasParentTitle

        if len(files) > 0:
            # Start by adding an option to Play All
            anItem = xbmcgui.ListItem(ADDON.getLocalizedString(32101),
                                      path=path)
            # Get the first items fanart for the play all option
            anItem.setProperty("Fanart_Image", files[0].getFanArt())

            if tvShowTitle != "":
                anItem.setInfo('video', {'TvShowTitle': tvShowTitle})

            if extrasParentTitle != "":
                anItem.setInfo('video', {'Title': extrasParentTitle})

            if extrasDefaultIconImage != "":
                anItem.setIconImage(extrasDefaultIconImage)

            anItem.addContextMenuItems([], replaceItems=True)
            url = self._build_url({
                'mode': 'playallextras',
                'foldername': target,
                'path': path,
                'parentTitle': extrasParentTitle
            })
            xbmcplugin.addDirectoryItem(handle=self.addon_handle,
                                        url=url,
                                        listitem=anItem,
                                        isFolder=False)

        # Check if we want to have YouTube Extra Support
        if Settings.isYouTubeSearchSupportEnabled():
            self._getVideoPluginLink(extrasParentTitle, 'plugin.video.youtube',
                                     32116, extrasDefaultIconImage,
                                     extrasDefaultFanArt)

        # Check if we want to have Vimeo Extra Support
        if Settings.isVimeoSearchSupportEnabled():
            self._getVideoPluginLink(extrasParentTitle, 'plugin.video.vimeo',
                                     32122, extrasDefaultIconImage,
                                     extrasDefaultFanArt)

        # Add each of the extras to the list to display
        for anExtra in files:
            # Create the list item
            li = anExtra.createListItem(
                parentTitle=extrasParentTitle,
                tvShowTitle=tvShowTitle,
                defaultIconImage=extrasDefaultIconImage)
            # Hack, if the "TotalTime" and "ResumeTime" are set on the list item
            # and it is partially watched, then Kodi will display the continue dialog
            # However we can not get what the user selects from this dialog, so it
            # will always continue.  Found out that we can hack this by clearing
            # the "TotalTime" property
            # http://forum.xbmc.org/showthread.php?tid=192627
            li.setProperty("TotalTime", "")

            li.addContextMenuItems([], replaceItems=True)
            li.addContextMenuItems(self._getContextMenu(
                anExtra, target, path, extrasParentTitle),
                                   replaceItems=True)
            url = self._build_url({
                'mode':
                'playextra',
                'foldername':
                target,
                'path':
                path,
                'filename':
                anExtra.getFilename().encode("utf-8"),
                'parentTitle':
                extrasParentTitle
            })
            xbmcplugin.addDirectoryItem(handle=self.addon_handle,
                                        url=url,
                                        listitem=li,
                                        isFolder=False)

        xbmcplugin.endOfDirectory(self.addon_handle)