Esempio n. 1
0
    def start_playback(self):
        try:

            if self.playback_started:
                return

            tools.closeAllDialogs()

            self.playback_started = True
            self.scrobbled = False

            self.traktStartWatching()

            self.media_length = self.getTotalTime()

            if tools.playList.size(
            ) == 1 and self.smart_playlists == 'true' and self.media_type == 'episode':
                self.smart_module.build_playlist(params=self.params)

            if tools.playList.size() == tools.playList.getposition() + 1 \
                    and self.media_type == 'episode' \
                    and self.smart_playlists == 'true':
                smartPlay.SmartPlay(
                    self.original_action_args).append_next_season()

        except:
            import traceback
            traceback.print_exc()
            pass
Esempio n. 2
0
 def showsSearchResults(self, query):
     query = tools.quote_plus(tools.unquote(query))
     trakt_list = trakt.json_response('search/show?query=%s&extended=full&type=show&field=title' % query)
     if trakt_list is None:
         tools.cancel_directory()
         return
     self.showListBuilder([show for show in trakt_list if float(show['score']) > 0])
     tools.closeAllDialogs()
     tools.closeDirectory('tvshows')
Esempio n. 3
0
 def moviesSearchResults(self, query):
     query = tools.quote_plus(tools.unquote(query))
     trakt_list = trakt.json_response('search/movie?query=%s' % query)
     if trakt_list is None:
         tools.cancel_directory()
         return
     self.commonListBuilder([movie for movie in trakt_list if float(movie['score']) > 0])
     tools.closeAllDialogs()
     tools.closeDirectory('movies')
Esempio n. 4
0
    def play_source(self, stream_link, args, resume_time=None, params=None):
        try:
            self.pre_cache_initiated = False
            if resume_time is not None:
                self.offset = float(resume_time)

            self.params = params

            if stream_link is None:
                tools.cancelPlayback()
                raise Exception

            self.playing_file = stream_link
            self.original_action_args = args
            self.smart_module = smartPlay.SmartPlay(self.original_action_args)

            args = tools.get_item_information(args)
            self.args = args

            if 'showInfo' in args:
                self.media_type = 'episode'
                # Workaround for estuary skin to allow episode information to be displayed in Video Top Info
                args['art']['tvshow.clearlogo'] = args['art'].get(
                    'clearlogo', '')
            else:
                self.media_type = 'movie'

            self.trakt_id = args['ids']['trakt']

            orginalArgs = json.loads(tools.unquote(self.original_action_args))

            if 'resume' in orginalArgs:
                if orginalArgs['resume'] == 'true':
                    self.tryGetBookmark()

            self.handleBookmark()

            item = tools.menuItem(path=stream_link)
            args['info']['FileNameAndPath'] = tools.unquote(stream_link)
            item.setInfo(type='video', infoLabels=args['info'])
            item.setArt(args['art'])
            item.setCast(args['cast'])
            item.setUniqueIDs(args['ids'])

            tools.closeBusyDialog()
            tools.closeAllDialogs()

            tools.resolvedUrl(syshandle, True, item)

            self.keepAlive()

        except:
            traceback.print_exc()
            pass
Esempio n. 5
0
    def moviesSearch(self, actionArgs=None):

        if actionArgs == None:
            k = tools.showKeyboard('', tools.lang(32016))
            k.doModal()
            query = (k.getText() if k.isConfirmed() else None)
            if query == None or query == '':
                return
        else:
            query = actionArgs
        database.addSearchHistory(query, 'movie')
        query = tools.deaccentString(tools.display_string(query))
        tools.quote(query)
        tools.closeAllDialogs()
        tools.closeDirectory('movies')
        tools.execute("Container.Update(%s?action=moviesSearchResults&actionArgs=%s, replace)'" % (sysaddon, query))
Esempio n. 6
0
    def fill_playlist(self, params=None):
        try:
            tools.cancelPlayback()
        except:
            import traceback
            traceback.print_exc()
            pass
        tools.closeAllDialogs()

        if self.display_style == '0':
            self.window = PersistentBackground(
                *SkinManager().confirm_skin_path('persistent_background.xml'),
                actionArgs=self.actionArgs)

        self.window.setText(tools.lang(32094))
        self.window.show()

        self.window.setText(tools.lang(32095))

        tools.playList.clear()

        season = self.info_dictionary['info']['season']
        episode = self.info_dictionary['info']['episode']

        self.window.setText(tools.lang(32096))

        self.window.setText(tools.lang(32097))

        self.build_playlist(season, episode, params=params)

        self.window.setText(tools.lang(40322))

        tools.log(
            'Begining play from Season %s Episode %s' % (season, episode),
            'info')

        self.window.close()

        tools.player().play(tools.playList)
Esempio n. 7
0
    def keepAlive(self):

        for i in range(0, 480):
            tools.kodi.sleep(250)
            if self.isPlayingVideo():
                break

        for i in range(0, 480):
            if self.AVStarted:
                break

        tools.closeAllDialogs()

        self.media_length = self.getTotalTime()

        if self.offset is not None and self.offset != 0:
            tools.log("Seeking {} seconds".format(self.offset))
            self.seekTime(self.offset)
            self.offset = None

        while self.isPlayingVideo() and not self.scrobbled:
            try:
                watched_percentage = self.getWatchedPercent()
                time_left = int(self.getTotalTime()) - int(self.getTime())

                try:
                    self.current_time = self.getTime()

                except:
                    import traceback
                    traceback.print_exc()
                    pass

                if not self.playback_started:
                    tools.kodi.sleep(1000)
                    continue

                if watched_percentage > 80 or time_left <= self.min_time_before_scrape:

                    if self.pre_cache_initiated is False:

                        try:
                            if tools.getSetting(
                                    'smartPlay.preScrape') == 'true':
                                self.pre_cache_initiated = True
                                smartPlay.SmartPlay(
                                    self.original_action_args).pre_scrape()
                        except:
                            import traceback
                            traceback.print_exc()
                            pass

                if watched_percentage > 80:
                    self.traktStopWatching()
                    self.handleBookmark()
                    break

            except:
                import traceback
                traceback.print_exc()
                tools.kodi.sleep(1000)
                continue

            tools.kodi.sleep(1000)

        else:
            self.traktStopWatching()
            return

        if tools.getSetting('smartplay.playingnextdialog') == 'true' or \
                tools.getSetting('smartplay.stillwatching') == 'true':
            endpoint = int(tools.getSetting('playingnext.time'))
        else:
            endpoint = False

        if endpoint:
            while self.isPlayingVideo():
                if int(self.getTotalTime()) - int(self.getTime()) <= endpoint:
                    tools.execute(
                        'RunPlugin("plugin://plugin.video.seren/?action=runPlayerDialogs")'
                    )
                    break
                else:
                    tools.kodi.sleep(1000)

        self.traktStopWatching()