Пример #1
0
    def onClick(self, control):
        WINDOW_LIST_ID = 51
        # Check to make sure that this click was for the extras list
        if control != WINDOW_LIST_ID:
            return

        # Check the YouTube Search first, as if there are no Extras on disk
        # There will not be a PlayAll button and it will just be the YouTube Link
        youtubePosition = 0
        vimeoPosition = 0
        if len(self.files) > 0:
            youtubePosition = youtubePosition + 1
            vimeoPosition = vimeoPosition + 1

        if Settings.isYouTubeSearchSupportEnabled():
            vimeoPosition = vimeoPosition + 1
            if self.getCurrentListPosition() == youtubePosition:
                anItem = self.getListItem(youtubePosition)
                searchDetails = anItem.getProperty("search")
                log("VideoExtras: Running YouTube Addon/Plugin with search %s" % searchDetails)
                xbmc.executebuiltin("RunAddon(plugin.video.youtube,%s)" % searchDetails)
                return

        if Settings.isVimeoSearchSupportEnabled() and self.getCurrentListPosition() == vimeoPosition:
                anItem = self.getListItem(vimeoPosition)
                searchDetails = anItem.getProperty("search")
                log("VideoExtras: Running Vimeo Addon/Plugin with search %s" % searchDetails)
                xbmc.executebuiltin("RunAddon(plugin.video.vimeo,%s)" % searchDetails)
                return

        # Check for the Play All case
        if self.getCurrentListPosition() == 0:
            ExtrasPlayer.playAll(self.files, SourceDetails.getTitle())
            return

        # Get the item that was clicked on
        extraItem = self._getCurrentSelection()

        if extraItem is None:
            # Something has gone very wrong, there is no longer the item that was selected
            log("VideoExtrasWindow: Unable to match item to current selection")
            return

        # If part way viewed prompt the user for resume or play from beginning
        if extraItem.getResumePoint() > 0:
            resumeWindow = VideoExtrasResumeWindow.createVideoExtrasResumeWindow(extraItem.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():
                extraItem.setResumePoint(0)
            # Default is to actually resume
            del resumeWindow

        ExtrasPlayer.performPlayAction(extraItem, SourceDetails.getTitle())
Пример #2
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)
Пример #3
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)
Пример #4
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)
Пример #5
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)
Пример #6
0
    def onAction(self, action):
        # actioncodes from https://github.com/xbmc/xbmc/blob/master/xbmc/guilib/Key.h
        ACTION_PREVIOUS_MENU = 10
        ACTION_NAV_BACK = 92
        ACTION_CONTEXT_MENU = 117

        if (action == ACTION_PREVIOUS_MENU) or (action == ACTION_NAV_BACK):
            log("VideoExtrasWindow: Close Action received: %s" % str(action.getId()))
            self.close()
        elif action == ACTION_CONTEXT_MENU:
            youtubePosition = 0
            vimeoPosition = 0
            if len(self.files) > 0:
                youtubePosition = youtubePosition + 1
                vimeoPosition = vimeoPosition + 1

            if Settings.isYouTubeSearchSupportEnabled():
                vimeoPosition = vimeoPosition + 1
                # Check to see if the context menu has been called up for the You Tube option
                if self.getCurrentListPosition() == youtubePosition:
                    contextWindow = VideoPluginContextMenu.createYouTubeContextMenu(SourceDetails.getTitle())
                    contextWindow.doModal()
                    del contextWindow
                    return

            if Settings.isVimeoSearchSupportEnabled() and self.getCurrentListPosition() == vimeoPosition:
                contextWindow = VideoPluginContextMenu.createVimeoContextMenu(SourceDetails.getTitle())
                contextWindow.doModal()
                del contextWindow
                return

            # Check for the Play All case
            if self.getCurrentListPosition() == 0:
                return

            # Get the item that was clicked on
            extraItem = self._getCurrentSelection()
            # create the context window
            contextWindow = VideoExtrasContextMenu.createVideoExtrasContextMenu(extraItem)
            contextWindow.doModal()

            # Check the return value, if exit, then we play nothing
            if contextWindow.isExit():
                return
            # If requested to restart from beginning, reset the resume point before playing
            if contextWindow.isRestart():
                extraItem.setResumePoint(0)
                ExtrasPlayer.performPlayAction(extraItem, SourceDetails.getTitle())

            if contextWindow.isResume():
                ExtrasPlayer.performPlayAction(extraItem, SourceDetails.getTitle())

            if contextWindow.isMarkUnwatched():
                # Need to remove the row from the database
                if Settings.isDatabaseEnabled():
                    # Refresh the screen now that we have change the flag
                    extraItem.setResumePoint(0)
                    extraItem.saveState()
                    self.onInit()

            if contextWindow.isMarkWatched():
                # 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():
                    extraItem.setResumePoint(extraItem.getTotalDuration())
                    extraItem.saveState()
                    self.onInit()

            if contextWindow.isEditTitle():
                # Prompt the user for the new name
                keyboard = xbmc.Keyboard()
                keyboard.setDefault(extraItem.getDisplayName())
                keyboard.doModal()

                if keyboard.isConfirmed():
                    try:
                        newtitle = keyboard.getText().decode("utf-8")
                    except:
                        newtitle = keyboard.getText()

                    # Only set the title if it has changed
                    if (newtitle != extraItem.getDisplayName()) and (len(newtitle) > 0):
                        result = extraItem.setTitle(newtitle, isTV=SourceDetails.isTv())
                        if not result:
                            xbmcgui.Dialog().ok(ADDON.getLocalizedString(32102), ADDON.getLocalizedString(32109))
                        else:
                            self.onInit()

            if contextWindow.isEditPlot():
                # Prompt the user for the new plot description
                keyboard = xbmc.Keyboard()
                keyboard.setDefault(extraItem.getPlot())
                keyboard.doModal()

                if keyboard.isConfirmed():
                    try:
                        newplot = keyboard.getText().decode("utf-8")
                    except:
                        newplot = keyboard.getText()

                    # Only set the plot if it has changed
                    if (newplot != extraItem.getPlot()) and ((len(newplot) > 0) or (extraItem.getPlot() is not None)):
                        result = extraItem.setPlot(newplot, isTV=SourceDetails.isTv())
                        if not result:
                            xbmcgui.Dialog().ok(ADDON.getLocalizedString(32102), ADDON.getLocalizedString(32115))
                        else:
                            self.onInit()

            del contextWindow
Пример #7
0
    def showList(self, exList):
        # Get the list of display names
        displayNameList = []
        for anExtra in exList:
            log("VideoExtrasDialog: filename: %s" % anExtra.getFilename())
            displayNameList.append(anExtra.getDisplayName())

        # Check if we are supporting YouTube Search
        vimeoPosition = -4
        if Settings.isVimeoSearchSupportEnabled():
            vimeoPosition = 0
            displayNameList.insert(0, ADDON.getLocalizedString(32122))

        # Check if we are supporting YouTube Search
        youtubePosition = -3
        if Settings.isYouTubeSearchSupportEnabled():
            youtubePosition = 0
            vimeoPosition = vimeoPosition + 1
            displayNameList.insert(0, ADDON.getLocalizedString(32116))

        addPlayAll = (len(exList) > 1)
        if addPlayAll:
            youtubePosition = youtubePosition + 1
            vimeoPosition = vimeoPosition + 1
            # Play All Selection Option
            displayNameList.insert(0, ADDON.getLocalizedString(32101))

        # Show the list to the user
        select = xbmcgui.Dialog().select(ADDON.getLocalizedString(32001), displayNameList)

        # User has made a selection, -1 is exit
        if select != -1:
            xbmc.executebuiltin("Dialog.Close(all, true)", True)
            waitLoop = 0
            while xbmc.Player().isPlaying() and waitLoop < 10:
                xbmc.sleep(100)
                waitLoop = waitLoop + 1
            xbmc.Player().stop()
            # Give anything that was already playing time to stop
            while xbmc.Player().isPlaying():
                xbmc.sleep(100)
            if (select == 0) and (addPlayAll is True):
                ExtrasPlayer.playAll(exList, SourceDetails.getTitle())
            elif select == youtubePosition:
                searchDetails = "/search/?q=%s+Extras" % urllib.quote_plus(SourceDetails.getTitle().encode('utf8'))
                log("VideoExtras: Running YouTube Addon/Plugin with search %s" % searchDetails)
                xbmc.executebuiltin("RunAddon(plugin.video.youtube,%s)" % searchDetails)
            elif select == vimeoPosition:
                searchDetails = "/search/?q=%s+Extras" % urllib.quote_plus(SourceDetails.getTitle().encode('utf8'))
                log("VideoExtras: Running Vimeo Addon/Plugin with search %s" % searchDetails)
                xbmc.executebuiltin("RunAddon(plugin.video.vimeo,%s)" % searchDetails)
            else:
                itemToPlay = select
                # If we added the PlayAll option to the list need to allow for it
                # in the selection, so add one
                if addPlayAll is True:
                    itemToPlay = itemToPlay - 1
                if vimeoPosition >= 0:
                    itemToPlay = itemToPlay - 1
                if youtubePosition >= 0:
                    itemToPlay = itemToPlay - 1
                log("VideoExtrasDialog: Start playing %s" % exList[itemToPlay].getFilename())
                ExtrasPlayer.performPlayAction(exList[itemToPlay], SourceDetails.getTitle())
        else:
            return False
        return True
Пример #8
0
    def onClick(self, control):
        WINDOW_LIST_ID = 51
        # Check to make sure that this click was for the extras list
        if control != WINDOW_LIST_ID:
            return

        # Check the YouTube Search first, as if there are no Extras on disk
        # There will not be a PlayAll button and it will just be the YouTube Link
        youtubePosition = 0
        vimeoPosition = 0
        if len(self.files) > 0:
            youtubePosition = youtubePosition + 1
            vimeoPosition = vimeoPosition + 1

        if Settings.isYouTubeSearchSupportEnabled():
            vimeoPosition = vimeoPosition + 1
            if self.getCurrentListPosition() == youtubePosition:
                anItem = self.getListItem(youtubePosition)
                searchDetails = anItem.getProperty("search")
                log("VideoExtras: Running YouTube Addon/Plugin with search %s"
                    % searchDetails)
                xbmc.executebuiltin("RunAddon(plugin.video.youtube,%s)" %
                                    searchDetails)
                return

        if Settings.isVimeoSearchSupportEnabled(
        ) and self.getCurrentListPosition() == vimeoPosition:
            anItem = self.getListItem(vimeoPosition)
            searchDetails = anItem.getProperty("search")
            log("VideoExtras: Running Vimeo Addon/Plugin with search %s" %
                searchDetails)
            xbmc.executebuiltin("RunAddon(plugin.video.vimeo,%s)" %
                                searchDetails)
            return

        # Check for the Play All case
        if self.getCurrentListPosition() == 0:
            ExtrasPlayer.playAll(self.files, SourceDetails.getTitle())
            return

        # Get the item that was clicked on
        extraItem = self._getCurrentSelection()

        if extraItem is None:
            # Something has gone very wrong, there is no longer the item that was selected
            log("VideoExtrasWindow: Unable to match item to current selection")
            return

        # If part way viewed prompt the user for resume or play from beginning
        if extraItem.getResumePoint() > 0:
            resumeWindow = VideoExtrasResumeWindow.createVideoExtrasResumeWindow(
                extraItem.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():
                extraItem.setResumePoint(0)
            # Default is to actually resume
            del resumeWindow

        ExtrasPlayer.performPlayAction(extraItem, SourceDetails.getTitle())
Пример #9
0
    def onAction(self, action):
        # actioncodes from https://github.com/xbmc/xbmc/blob/master/xbmc/guilib/Key.h
        ACTION_PREVIOUS_MENU = 10
        ACTION_NAV_BACK = 92
        ACTION_CONTEXT_MENU = 117

        if (action == ACTION_PREVIOUS_MENU) or (action == ACTION_NAV_BACK):
            log("VideoExtrasWindow: Close Action received: %s" %
                str(action.getId()))
            self.close()
        elif action == ACTION_CONTEXT_MENU:
            youtubePosition = 0
            vimeoPosition = 0
            if len(self.files) > 0:
                youtubePosition = youtubePosition + 1
                vimeoPosition = vimeoPosition + 1

            if Settings.isYouTubeSearchSupportEnabled():
                vimeoPosition = vimeoPosition + 1
                # Check to see if the context menu has been called up for the You Tube option
                if self.getCurrentListPosition() == youtubePosition:
                    contextWindow = VideoPluginContextMenu.createYouTubeContextMenu(
                        SourceDetails.getTitle())
                    contextWindow.doModal()
                    del contextWindow
                    return

            if Settings.isVimeoSearchSupportEnabled(
            ) and self.getCurrentListPosition() == vimeoPosition:
                contextWindow = VideoPluginContextMenu.createVimeoContextMenu(
                    SourceDetails.getTitle())
                contextWindow.doModal()
                del contextWindow
                return

            # Check for the Play All case
            if self.getCurrentListPosition() == 0:
                return

            # Get the item that was clicked on
            extraItem = self._getCurrentSelection()
            # create the context window
            contextWindow = VideoExtrasContextMenu.createVideoExtrasContextMenu(
                extraItem)
            contextWindow.doModal()

            # Check the return value, if exit, then we play nothing
            if contextWindow.isExit():
                return
            # If requested to restart from beginning, reset the resume point before playing
            if contextWindow.isRestart():
                extraItem.setResumePoint(0)
                ExtrasPlayer.performPlayAction(extraItem,
                                               SourceDetails.getTitle())

            if contextWindow.isResume():
                ExtrasPlayer.performPlayAction(extraItem,
                                               SourceDetails.getTitle())

            if contextWindow.isMarkUnwatched():
                # Need to remove the row from the database
                if Settings.isDatabaseEnabled():
                    # Refresh the screen now that we have change the flag
                    extraItem.setResumePoint(0)
                    extraItem.saveState()
                    self.onInit()

            if contextWindow.isMarkWatched():
                # 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():
                    extraItem.setResumePoint(extraItem.getTotalDuration())
                    extraItem.saveState()
                    self.onInit()

            if contextWindow.isEditTitle():
                # Prompt the user for the new name
                keyboard = xbmc.Keyboard()
                keyboard.setDefault(extraItem.getDisplayName())
                keyboard.doModal()

                if keyboard.isConfirmed():
                    try:
                        newtitle = keyboard.getText().decode("utf-8")
                    except:
                        newtitle = keyboard.getText()

                    # Only set the title if it has changed
                    if (newtitle != extraItem.getDisplayName()) and (
                            len(newtitle) > 0):
                        result = extraItem.setTitle(newtitle,
                                                    isTV=SourceDetails.isTv())
                        if not result:
                            xbmcgui.Dialog().ok(
                                ADDON.getLocalizedString(32102),
                                ADDON.getLocalizedString(32109))
                        else:
                            self.onInit()

            if contextWindow.isEditPlot():
                # Prompt the user for the new plot description
                keyboard = xbmc.Keyboard()
                keyboard.setDefault(extraItem.getPlot())
                keyboard.doModal()

                if keyboard.isConfirmed():
                    try:
                        newplot = keyboard.getText().decode("utf-8")
                    except:
                        newplot = keyboard.getText()

                    # Only set the plot if it has changed
                    if (newplot != extraItem.getPlot()) and (
                        (len(newplot) > 0) or
                        (extraItem.getPlot() is not None)):
                        result = extraItem.setPlot(newplot,
                                                   isTV=SourceDetails.isTv())
                        if not result:
                            xbmcgui.Dialog().ok(
                                ADDON.getLocalizedString(32102),
                                ADDON.getLocalizedString(32115))
                        else:
                            self.onInit()

            del contextWindow
Пример #10
0
    def showList(self, exList):
        # Get the list of display names
        displayNameList = []
        for anExtra in exList:
            log("VideoExtrasDialog: filename: %s" % anExtra.getFilename())
            displayNameList.append(anExtra.getDisplayName())

        # Check if we are supporting YouTube Search
        vimeoPosition = -4
        if Settings.isVimeoSearchSupportEnabled():
            vimeoPosition = 0
            displayNameList.insert(0, ADDON.getLocalizedString(32122))

        # Check if we are supporting YouTube Search
        youtubePosition = -3
        if Settings.isYouTubeSearchSupportEnabled():
            youtubePosition = 0
            vimeoPosition = vimeoPosition + 1
            displayNameList.insert(0, ADDON.getLocalizedString(32116))

        addPlayAll = (len(exList) > 1)
        if addPlayAll:
            youtubePosition = youtubePosition + 1
            vimeoPosition = vimeoPosition + 1
            # Play All Selection Option
            displayNameList.insert(0, ADDON.getLocalizedString(32101))

        # Show the list to the user
        select = xbmcgui.Dialog().select(ADDON.getLocalizedString(32001),
                                         displayNameList)

        # User has made a selection, -1 is exit
        if select != -1:
            xbmc.executebuiltin("Dialog.Close(all, true)", True)
            waitLoop = 0
            while xbmc.Player().isPlaying() and waitLoop < 10:
                xbmc.sleep(100)
                waitLoop = waitLoop + 1
            xbmc.Player().stop()
            # Give anything that was already playing time to stop
            while xbmc.Player().isPlaying():
                xbmc.sleep(100)
            if (select == 0) and (addPlayAll is True):
                ExtrasPlayer.playAll(exList, SourceDetails.getTitle())
            elif select == youtubePosition:
                searchDetails = "/search/?q=%s+Extras" % urllib.quote_plus(
                    SourceDetails.getTitle().encode('utf8'))
                log("VideoExtras: Running YouTube Addon/Plugin with search %s"
                    % searchDetails)
                xbmc.executebuiltin("RunAddon(plugin.video.youtube,%s)" %
                                    searchDetails)
            elif select == vimeoPosition:
                searchDetails = "/search/?q=%s+Extras" % urllib.quote_plus(
                    SourceDetails.getTitle().encode('utf8'))
                log("VideoExtras: Running Vimeo Addon/Plugin with search %s" %
                    searchDetails)
                xbmc.executebuiltin("RunAddon(plugin.video.vimeo,%s)" %
                                    searchDetails)
            else:
                itemToPlay = select
                # If we added the PlayAll option to the list need to allow for it
                # in the selection, so add one
                if addPlayAll is True:
                    itemToPlay = itemToPlay - 1
                if vimeoPosition >= 0:
                    itemToPlay = itemToPlay - 1
                if youtubePosition >= 0:
                    itemToPlay = itemToPlay - 1
                log("VideoExtrasDialog: Start playing %s" %
                    exList[itemToPlay].getFilename())
                ExtrasPlayer.performPlayAction(exList[itemToPlay],
                                               SourceDetails.getTitle())
        else:
            return False
        return True