def _resumeFromBookmark(self): log.debug('bookmarker : before wait for gotFPS') # # wait for fps to be set by log scaper for a max of 10 seconds # cnt = 0 # while self.fps is None and cnt < 100: # time.sleep(0.1) # cnt += 1 # # if self.fps is None: # log.warn('Timed out waiting for fps to be set on bookmarker') # else: # log.debug('bookmarker : after wait for gotFPS') bookmarkSecs = self.program.getBookmark() if bookmarkSecs > 0 and bookmarkSecs < (self.program.getDuration() * 60): fb = formatSeconds(bookmarkSecs) log.debug('Resuming recording at bookmarked position of %s' % fb) showPopup(self.program.title(), self.translator.get(m.RESUMING_AT) % fb) self.player.seekTime(bookmarkSecs) while self.player.getTime() < bookmarkSecs: log.debug('Waiting for player time %s to seek past bookmark of %s' %(formatSeconds(self.player.getTime()), fb)) xbmc.sleep(SLEEP_MILLIS) else: log.debug('Recording has no bookmark or bookmark exceeds program length')
def _resumeFromBookmark(self): log.debug('bookmarker : before wait for gotFPS') # # wait for fps to be set by log scaper for a max of 10 seconds # cnt = 0 # while self.fps is None and cnt < 100: # time.sleep(0.1) # cnt += 1 # # if self.fps is None: # log.warn('Timed out waiting for fps to be set on bookmarker') # else: # log.debug('bookmarker : after wait for gotFPS') bookmarkSecs = self.program.getBookmark() if bookmarkSecs > 0 and bookmarkSecs < (self.program.getDuration() * 60): fb = formatSeconds(bookmarkSecs) log.debug('Resuming recording at bookmarked position of %s' % fb) showPopup(self.program.title(), self.translator.get(m.RESUMING_AT) % fb) self.player.seekTime(bookmarkSecs) while self.player.getTime() < bookmarkSecs: log.debug( 'Waiting for player time %s to seek past bookmark of %s' % (formatSeconds(self.player.getTime()), fb)) xbmc.sleep(SLEEP_MILLIS) else: log.debug( 'Recording has no bookmark or bookmark exceeds program length')
def _resumeFromBookmark(self): log.debug('bookmarker : before wait for gotFPS') bookmarkSecs = self.program.getBookmark() if bookmarkSecs > 0 and bookmarkSecs < (self.program.getDuration() * 60): fb = formatSeconds(bookmarkSecs) log.debug('Resuming recording at bookmarked position of %s' % fb) showPopup(self.program.title(), self.translator.get(m.RESUMING_AT) % fb) self.player.seekTime(bookmarkSecs) while self.player.getTime() < bookmarkSecs: log.debug('Waiting for player time %s to seek past bookmark of %s' %(formatSeconds(self.player.getTime()), fb)) xbmc.sleep(SLEEP_MILLIS) else: log.debug('Recording has no bookmark or bookmark exceeds program length')
def _saveLastPositionAsBookmark(self): lastPos = self.player.tracker.getLastPosition() log.debug('Setting bookmark on %s to %s' %(safe_str(self.program.title()), formatSeconds(lastPos))) try: self.program.setBookmark(lastPos) except: log.exception('_saveLastPositionAsBookmark catchall')
def _saveLastPositionAsBookmark(self): lastPos = self.player.tracker.getLastPosition() log.debug('Setting bookmark on %s to %s' % (safe_str(self.program.title()), formatSeconds(lastPos))) try: self.program.setBookmark(lastPos) except: log.exception('_saveLastPositionAsBookmark catchall')
def _resumeFromBookmark(self): log.debug('bookmarker : before wait for gotFPS') bookmarkSecs = self.program.getBookmark() if bookmarkSecs > 0 and bookmarkSecs < (self.program.getDuration() * 60): fb = formatSeconds(bookmarkSecs) log.debug('Resuming recording at bookmarked position of %s' % fb) showPopup(self.program.title(), self.translator.get(m.RESUMING_AT) % fb) self.player.seekTime(bookmarkSecs) while self.player.getTime() < bookmarkSecs: log.debug( 'Waiting for player time %s to seek past bookmark of %s' % (formatSeconds(self.player.getTime()), fb)) xbmc.sleep(SLEEP_MILLIS) else: log.debug( 'Recording has no bookmark or bookmark exceeds program length')
def _trackCommercials(self): """Method run in a separate thread to skip over commercials""" try: if len(self._breaks) == 0: log.debug( 'Recording %s has no comm breaks, exiting comm tracker' % safe_str(self.program.title())) return while self.player.isPlaying(): pos = self.player.getTime() if self._isInBreak(pos) and not self._currentBreak.skipped: log.debug('entered comm break = %s' % self._currentBreak) if self._isCloseToStartOfCommercial( pos) and not self._wasUserSkippingAround(pos): log.debug('Comm skip activated!') showPopup( self.program.title(), self.translator.get(m.SKIPPING_COMMERCIAL) % formatSeconds(self._currentBreak.duration()), 3000) self.player.seekTime(self._currentBreak.end) self._waitForPlayerToPassCommercialBreak() self._currentBreak.skipped = True if self._landedInCommercial(pos): log.debug( "Landed in comm break and want to skip forward") showPopup( self.program.title(), self.translator.get(m.FORWARDING_THROUGH) % formatSeconds(self._currentBreak.duration()), 3000) self.player.seekTime(self._currentBreak.end) self._waitForPlayerToPassCommercialBreak() self._currentBreak.skipped = True xbmc.sleep(SLEEP_MILLIS) log.debug('Commercial tracker thread exiting') except: log.exception('_trackCommercials catchall')
def buildPlayList(self): mlog.debug("> _buildPlayList") playlistItem = xbmcgui.ListItem() title = self.program.fullTitle() comms = self.program.getCommercials() if len(comms) > 0: title += '(%s breaks - %s)' % (len(comms), ', '.join(map(lambda c: formatSeconds(c.start), comms))) playlistItem.setInfo( "video", { "Genre" : self.program.category(), "Studio" : self.program.formattedChannel(), "Title" : title, "Plot" : self.program.formattedDescription() }) # TODO: Set start offset if a comm break starts at 0.0 # playlistItem.setProperty('StartOffset', '256.4') mlog.debug("< _buildPlayList") return playlistItem
def buildPlayList(self): mlog.debug("> _buildPlayList") playlistItem = xbmcgui.ListItem() title = self.program.fullTitle() comms = self.program.getCommercials() if len(comms) > 0: title += '(%s breaks - %s)' % (len(comms), ', '.join( map(lambda c: formatSeconds(c.start), comms))) playlistItem.setInfo( "video", { "Genre": self.program.category(), "Studio": self.program.formattedChannel(), "Title": title, "Plot": self.program.formattedDescription() }) # TODO: Set start offset if a comm break starts at 0.0 # playlistItem.setProperty('StartOffset', '256.4') mlog.debug("< _buildPlayList") return playlistItem
def _trackCommercials(self): """Method run in a separate thread to skip over commercials""" try: if len(self._breaks) == 0: log.debug('Recording %s has no comm breaks, exiting comm tracker' % safe_str(self.program.title())) return while self.player.isPlaying(): pos = self.player.getTime() if self._isInBreak(pos) and not self._currentBreak.skipped: log.debug('entered comm break = %s' % self._currentBreak) if self._isCloseToStartOfCommercial(pos) and not self._wasUserSkippingAround(pos): log.debug('Comm skip activated!') showPopup(self.program.title(), self.translator.get(m.SKIPPING_COMMERCIAL) % formatSeconds(self._currentBreak.duration()), 3000) self.player.seekTime(self._currentBreak.end) self._waitForPlayerToPassCommercialBreak() self._currentBreak.skipped = True if self._landedInCommercial(pos): log.debug("Landed in comm break and want to skip forward") showPopup(self.program.title(), self.translator.get(m.FORWARDING_THROUGH) % formatSeconds(self._currentBreak.duration()), 3000) self.player.seekTime(self._currentBreak.end) self._waitForPlayerToPassCommercialBreak() self._currentBreak.skipped = True xbmc.sleep(SLEEP_MILLIS) log.debug('Commercial tracker thread exiting') except: log.exception('_trackCommercials catchall')