engine.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:script.simkl 作者: SIMKL 项目源码 文件源码
def _thread_tracker(self):
        log("in tracker thread")
        total_time = self.getTotalTime()
        total_time_min = int(get_setting("min-length"))
        perc_mark = int(get_setting("scr-pct"))
        self._is_detected = True
        timeout = 1000
        # if total_time set and is lower than total_time_min then we do not start the loop at all and stop the thread,
        if total_time <= 0 or total_time > total_time_min:
            while self._playback_lock.isSet() and not xbmc.abortRequested:
                try:
                    # The max() assures that the total time is over two minutes
                    # preventing it from scrobbling while buffering and solving #31
                    if min(99, 100 * self.getTime() / max(120, total_time)) >= perc_mark:
                        success = self._api.mark_as_watched(self._item)
                        if not success:
                            if timeout == 1000:
                                log("Failed to scrobble")
                                notify(get_str(32080))
                                timeout = 30000
                            elif (self.getTime() / total_time) > 0.95:
                                log("Stopped scrobbling")
                                notify(get_str(32081))
                                break
                            else:
                                log("Retrying")

                        elif success and bool(get_setting("bubble")):
                            self._show_bubble(self._item)
                            break
                except:
                    pass
                xbmc.sleep(timeout)
        log('track stop')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号