コード例 #1
0
def run(item):
    logger.info()
    with futures.ThreadPoolExecutor() as executor:
        future = executor.submit(next_ep, item)
        item = future.result()
    if item.next_ep:
        return play_from_library(item)
コード例 #2
0
def run(item):
    logger.info()
    with futures.ThreadPoolExecutor() as executor:
        future = executor.submit(next_ep, item)
        item = future.result()
    if item.next_ep:
        from platformcode.launcher import play_from_library
        return play_from_library(item)
コード例 #3
0
def next_ep(item):
    logger.info()

    item.next_ep = False
    item.show_server = True

    VL = True if item.videolibrary else False

    time_over = False
    time_limit = time() + 30
    TimeFromEnd = config.get_setting('next_ep_seconds')

    # wait until the video plays
    while not platformtools.is_playing() and time() < time_limit:
        sleep(1)

    while platformtools.is_playing() and not time_over:
        try:
            Total = xbmc.Player().getTotalTime()
            Actual = xbmc.Player().getTime()
            Difference = Total - Actual
            if Total > TimeFromEnd >= Difference:
                time_over = True
        except:
            break

    if time_over:

        # check i next file exist
        current_filename = os.path.basename(item.strm_path)
        base_path = os.path.basename(
            os.path.normpath(os.path.dirname(item.strm_path)))
        path = filetools.join(config.get_videolibrary_path(),
                              config.get_setting("folder_tvshows"), base_path)
        fileList = []
        strmList = []
        for file in os.listdir(path):
            if file.endswith('.strm'):
                fileList.append(file)

        for strm in fileList:
            se = re.search(r"(\d+)x(\d+)", strm)
            se = se.group(0).split("x")
            strmList.append([int(se[0]), int(se[1]), strm])
        strmList = sorted(strmList, key=lambda s: (s[0], s[1]))

        for index, value in enumerate(strmList):
            if current_filename == value[2]:
                nextIndex = index + 1
                break

        if nextIndex == 0 or nextIndex == len(strmList):
            next_file = None
        else:
            next_file = strmList[nextIndex][2]

        # start next episode window after x time
        if next_file:
            season = strmList[nextIndex][0]
            episode = strmList[nextIndex][1]
            next_ep = '%sx%s' % (season, str(episode).zfill(2))
            info_file = next_file.replace("strm", "nfo")
            item = Item(action='play_from_library',
                        channel='videolibrary',
                        contentEpisodeNumber=episode,
                        contentSeason=season,
                        contentTitle=next_ep,
                        contentType='episode',
                        infoLabels={
                            'episode': episode,
                            'mediatype': 'episode',
                            'season': season,
                            'title': next_ep
                        },
                        strm_path=filetools.join(base_path, next_file))

            global INFO
            INFO = filetools.join(path, info_file)

            nextDialog = NextDialog(ND, config.get_runtime_path())
            nextDialog.show()
            while platformtools.is_playing(
            ) and not nextDialog.is_still_watching():
                xbmc.sleep(100)
                pass

            nextDialog.close()
            logger.info('Next Episode: ' + str(nextDialog.stillwatching))

            if nextDialog.stillwatching or nextDialog.continuewatching:
                item.next_ep = True
                xbmc.Player().stop()
                if VL:
                    sleep(1)
                    xbmc.executebuiltin('Action(Back)')
                    sleep(0.5)

                    return play_from_library(item)
            else:
                item.show_server = False
                if VL:
                    sleep(1)
                    xbmc.executebuiltin('Action(Back)')
                    sleep(0.5)
                    return None

    return item
コード例 #4
0
def next_ep(item):
    logger.info()
    condition = config.get_setting('next_ep')
    item.next_ep = False
    item.show_server = True

    VL = True if item.videolibrary else False

    time_over = False
    time_limit = time() + 30
    time_steps = [20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]
    time_setting = config.get_setting('next_ep_seconds')
    TimeFromEnd = time_setting if time_setting > 10 else time_steps[
        time_setting]

    # wait until the video plays
    while not platformtools.is_playing() and time() < time_limit:
        sleep(1)

    while platformtools.is_playing() and time_over == False:
        try:
            Total = xbmc.Player().getTotalTime()
            Actual = xbmc.Player().getTime()
            Difference = Total - Actual
            if Total > TimeFromEnd >= Difference:
                time_over = True
        except:
            break

    if time_over:
        if condition == 1:  # hide server afther x second
            item.show_server = False
        elif condition == 2:  # play next fileif exist

            # check i next file exist
            current_filename = os.path.basename(item.strm_path)
            base_path = os.path.basename(
                os.path.normpath(os.path.dirname(item.strm_path)))
            path = filetools.join(config.get_videolibrary_path(),
                                  config.get_setting("folder_tvshows"),
                                  base_path)
            fileList = []
            for file in filetools.listdir(path):
                if file.endswith('.strm'):
                    fileList.append(file)

            fileList.sort()

            nextIndex = fileList.index(current_filename) + 1
            if nextIndex == 0 or nextIndex == len(fileList):
                next_file = None
            else:
                next_file = fileList[nextIndex]
                logger.info('NEXTFILE' + next_file)

            # start next episode window afther x time
            if next_file:
                from core.item import Item
                season_ep = next_file.split('.')[0]
                season = season_ep.split('x')[0]
                episode = season_ep.split('x')[1]
                next_ep = '%sx%s' % (season, episode)
                item = Item(action='play_from_library',
                            channel='videolibrary',
                            contentEpisodeNumber=episode,
                            contentSeason=season,
                            contentTitle=next_ep,
                            contentType='tvshow',
                            infoLabels={
                                'episode': episode,
                                'mediatype': 'tvshow',
                                'season': season,
                                'title': next_ep
                            },
                            strm_path=filetools.join(base_path, next_file))

                global INFO
                INFO = filetools.join(path, next_file.replace("strm", "nfo"))
                logger.info('NEXTINFO' + INFO)

                nextDialog = NextDialog(ND, config.get_runtime_path())
                nextDialog.show()
                while platformtools.is_playing(
                ) and not nextDialog.is_still_watching():
                    xbmc.sleep(100)
                    pass

                nextDialog.close()
                logger.info('Next Episode: ' + str(nextDialog.stillwatching))

                if nextDialog.stillwatching or nextDialog.continuewatching:
                    item.next_ep = True
                    xbmc.Player().stop()
                    if VL:
                        sleep(1)
                        xbmc.executebuiltin('Action(Back)')
                        sleep(0.5)
                        from platformcode.launcher import play_from_library
                        return play_from_library(item)
                else:
                    item.show_server = False
                    if VL:
                        sleep(1)
                        xbmc.executebuiltin('Action(Back)')
                        sleep(0.5)
                        return None

    return item