def _resumeFromBookmark(self): bookmarkSecs = self._program.getBookmark() if bookmarkSecs > 0: fb = mythtv.formatSeconds(bookmarkSecs) log.debug('Resuming recording at bookmarked position of %s' % fb) ui.showPopup(self._program.title(), 'Resuming at %s)' %(fb)) self._player.seekTime(bookmarkSecs) while self._player.getTime() < bookmarkSecs: log.debug('Waiting for player time %s to seek past bookmark of %s' %( mythtv.formatSeconds(self._player.getTime()), fb)) xbmc.sleep(SLEEP_MILLIS) else: log.debug('Recording has no bookmark')
def _resumeFromBookmark(self): bookmarkSecs = self._program.getBookmark() if bookmarkSecs > 0: fb = mythtv.formatSeconds(bookmarkSecs) log.debug('Resuming recording at bookmarked position of %s' % fb) ui.showPopup(self._program.title(), 'Resuming at %s)' % (fb)) self._player.seekTime(bookmarkSecs) while self._player.getTime() < bookmarkSecs: log.debug( 'Waiting for player time %s to seek past bookmark of %s' % (mythtv.formatSeconds(self._player.getTime()), fb)) xbmc.sleep(SLEEP_MILLIS) else: log.debug('Recording has no bookmark')
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' % self._program.title()) return while self._player.isPlaying(): pos = self._player.getTime() if self._isInBreak(pos): log.debug('entered comm break = %s' % self._currentBreak) if self._isCloseToStartOfCommercial( pos) and not self._wasUserSkippingAround(pos): log.debug('Comm skip activated!') ui.showPopup( self._program.title(), 'Skipping commercial %s' % mythtv.formatSeconds( self._currentBreak.duration())) self._player.seekTime(self._currentBreak.end) self._waitForPlayerToPassCommercialBreak() else: log.debug( 'Position in comm skip region but not activated') 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 - ' % len(comms) for b in self._program.getCommercials(): title += mythtv.formatSeconds(b.start) title += ', ' title += ')' playlistItem.setInfo( "video", { "Genre": self._program.category(), "Studio": self._program.formattedChannel(), "Title": title, "Plot": self._program.formattedDescription() }) #playlistItem.setProperty('AspectRatio', '1.85 : 1') playlistItem.setIconImage(self._program.getLocalThumbnailPath()) playlistItem.setThumbnailImage(self._program.getLocalThumbnailPath()) mlog.debug("< _buildPlayList") return playlistItem
def test_formatSeconds(self): self.assertEquals('0s', mythtv.formatSeconds(0.00)) self.assertEquals('1s', mythtv.formatSeconds(1.99)) self.assertEquals('5m', mythtv.formatSeconds(60*5)) self.assertEquals('5m 45s', mythtv.formatSeconds(60*5+45)) self.assertEquals('3h 5m 45s', mythtv.formatSeconds(3*60*60 + 60*5 + 45)) self.assertEquals('3h', mythtv.formatSeconds(3*60*60)) self.assertEquals('3h 59m', mythtv.formatSeconds(3*60*60 + 60*59)) self.assertEquals('3h 5s', mythtv.formatSeconds(3*60*60 + 5))
def _saveLastPositionAsBookmark(self): lastPos = self._player.getTracker().getLastPosition() log.debug('Setting bookmark on %s to %s' % (self._program.title(), mythtv.formatSeconds(lastPos))) try: self._program.setBookmark(lastPos) except: log.exception('_saveLastPositionAsBookmark catchall')
def _saveLastPositionAsBookmark(self): lastPos = self._player.getTracker().getLastPosition() log.debug('Setting bookmark on %s to %s' %( self._program.title(), mythtv.formatSeconds(lastPos))) try: self._program.setBookmark(lastPos) except: log.exception('_saveLastPositionAsBookmark catchall')
def test_formatSeconds(self): self.assertEquals('0s', mythtv.formatSeconds(0.00)) self.assertEquals('1s', mythtv.formatSeconds(1.99)) self.assertEquals('5m', mythtv.formatSeconds(60 * 5)) self.assertEquals('5m 45s', mythtv.formatSeconds(60 * 5 + 45)) self.assertEquals('3h 5m 45s', mythtv.formatSeconds(3 * 60 * 60 + 60 * 5 + 45)) self.assertEquals('3h', mythtv.formatSeconds(3 * 60 * 60)) self.assertEquals('3h 59m', mythtv.formatSeconds(3 * 60 * 60 + 60 * 59)) self.assertEquals('3h 5s', mythtv.formatSeconds(3 * 60 * 60 + 5))
def _buildPlayList(self): mlog.debug("> _buildPlayList") playlistItem = xbmcgui.ListItem() title = self._program.fullTitle() comms = self._program.getCommercials() if len(comms) > 0: title += '(%s breaks - ' % len(comms) for b in self._program.getCommercials(): title += mythtv.formatSeconds(b.start) title += ', ' title += ')' playlistItem.setInfo("video", {"Genre" : self._program.category(), "Studio" : self._program.formattedChannel(), "Title": title, "Plot": self._program.formattedDescription()} ) #playlistItem.setProperty('AspectRatio', '1.85 : 1') playlistItem.setIconImage(self._program.getLocalThumbnailPath()) playlistItem.setThumbnailImage(self._program.getLocalThumbnailPath()) 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' % self._program.title()) return while self._player.isPlaying(): pos = self._player.getTime() if self._isInBreak(pos): log.debug('entered comm break = %s' % self._currentBreak) if self._isCloseToStartOfCommercial(pos) and not self._wasUserSkippingAround(pos): log.debug('Comm skip activated!') ui.showPopup(self._program.title(), 'Skipping commercial %s' % mythtv.formatSeconds(self._currentBreak.duration())) self._player.seekTime(self._currentBreak.end) self._waitForPlayerToPassCommercialBreak() else: log.debug('Position in comm skip region but not activated') xbmc.sleep(SLEEP_MILLIS) log.debug('Commercial tracker thread exiting') except: log.exception('_trackCommercials catchall')
def __repr__(self): return "%s {start = %s, end = %s, duration = %s}" % ( type(self).__name__, mythtv.formatSeconds(self.start), mythtv.formatSeconds(self.end), mythtv.formatSeconds(self.duration()))