def show_popup_and_wait(self, episode, next_up_page, still_watching_page): try: play_time = self.player.getTime() total_time = self.player.getTotalTime() except RuntimeError: self.log('exit early because player is no longer running', 2) return False, False progress_step_size = calculate_progress_steps(total_time - play_time) next_up_page.set_item(episode) next_up_page.set_progress_step_size(progress_step_size) still_watching_page.set_item(episode) still_watching_page.set_progress_step_size(progress_step_size) played_in_a_row_number = get_setting_int('playedInARow') self.log('played in a row settings %s' % played_in_a_row_number, 2) self.log('played in a row %s' % self.state.played_in_a_row, 2) showing_next_up_page = False showing_still_watching_page = False if int(self.state.played_in_a_row) <= int(played_in_a_row_number): self.log( 'showing next up page as played in a row is %s' % self.state.played_in_a_row, 2) next_up_page.show() set_property('service.upnext.dialog', 'true') showing_next_up_page = True else: self.log( 'showing still watching page as played in a row %s' % self.state.played_in_a_row, 2) still_watching_page.show() set_property('service.upnext.dialog', 'true') showing_still_watching_page = True while (self.player.isPlaying() and (total_time - play_time > 1) and not next_up_page.is_cancel() and not next_up_page.is_watch_now() and not still_watching_page.is_still_watching() and not still_watching_page.is_cancel()): try: play_time = self.player.getTime() total_time = self.player.getTotalTime() except RuntimeError: if showing_next_up_page: next_up_page.close() showing_next_up_page = False if showing_still_watching_page: still_watching_page.close() showing_still_watching_page = False break remaining = total_time - play_time runtime = episode.get('runtime') if not self.state.pause: if showing_next_up_page: next_up_page.update_progress_control(remaining=remaining, runtime=runtime) elif showing_still_watching_page: still_watching_page.update_progress_control( remaining=remaining, runtime=runtime) sleep(100) return showing_next_up_page, showing_still_watching_page
def launch_popup(self, episode, playlist_item): episode_id = episode.get('episodeid') no_play_count = episode.get('playcount') is None or episode.get( 'playcount') == 0 include_play_count = True if self.state.include_watched else no_play_count if not include_play_count or self.state.current_episode_id == episode_id: return if not playlist_item: self.state.queued = self.api.queue_next_item(episode) # We have a next up episode choose mode if get_setting_int('simpleMode') == 0: next_up_page = UpNext('script-upnext-upnext-simple.xml', addon_path(), 'default', '1080i') still_watching_page = StillWatching( 'script-upnext-stillwatching-simple.xml', addon_path(), 'default', '1080i') else: next_up_page = UpNext('script-upnext-upnext.xml', addon_path(), 'default', '1080i') still_watching_page = StillWatching( 'script-upnext-stillwatching.xml', addon_path(), 'default', '1080i') showing_next_up_page, showing_still_watching_page = self.show_popup_and_wait( episode, next_up_page, still_watching_page) should_play_default, should_play_non_default = self.extract_play_info( next_up_page, showing_next_up_page, showing_still_watching_page, still_watching_page) if not self.state.track: self.log('exit launch_popup early due to disabled tracking', 2) return play_item_option_1 = (should_play_default and self.state.play_mode == 0) play_item_option_2 = (should_play_non_default and self.state.play_mode == 1) if not play_item_option_1 and not play_item_option_2: return self.log('playing media episode', 2) # Signal to trakt previous episode watched event(message='NEXTUPWATCHEDSIGNAL', data=dict(episodeid=self.state.current_episode_id), encoding='base64') if playlist_item or self.state.queued: try: # Play playlist media, only seek/skip if media has not already played through if should_play_non_default: self.player.seekTime(self.player.getTotalTime()) self.player.playnext() except RuntimeError: pass elif self.api.has_addon_data(): # Play add-on media self.api.play_addon_item() else: # Play local media self.api.play_kodi_item(episode)
def __init__(self): self.__dict__ = self._shared_state self.play_mode = get_setting_int('autoPlayMode') self.include_watched = get_setting_bool('includeWatched') self.current_tv_show_id = None self.current_episode_id = None self.tv_show_id = None self.played_in_a_row = 1 self.last_file = None self.track = False self.pause = False
def notification_time(self, total_time=None): # Alway use metadata, when available if self.data.get('notification_time'): self.offset_used = True return int(self.data.get('notification_time')) # Some consumers send the offset when the credits start (e.g. Netflix) if total_time and self.data.get('notification_offset'): self.offset_used = True return total_time - int(self.data.get('notification_offset')) # Use a customized notification time, when configured if total_time and get_setting_bool('customAutoPlayTime'): if total_time > 60 * 60: return get_setting_int('autoPlayTimeXL') if total_time > 40 * 60: return get_setting_int('autoPlayTimeL') if total_time > 20 * 60: return get_setting_int('autoPlayTimeM') if total_time > 10 * 60: return get_setting_int('autoPlayTimeS') return get_setting_int('autoPlayTimeXS') # Use one global default, regardless of episode length return get_setting_int('autoPlaySeasonTime')
def update_progress_control(self, remaining=None, runtime=None): self.current_progress_percent = self.current_progress_percent - self.progress_step_size try: self.progress_control = self.getControl(3014) except RuntimeError: # Occurs when skin does not include progress control pass else: self.progress_control.setPercent(self.current_progress_percent) # pylint: disable=no-member,useless-suppression if remaining: self.setProperty('remaining', from_unicode('%02d' % remaining)) if runtime: self.setProperty( 'endtime', from_unicode( localize_time(datetime.now() + timedelta(seconds=runtime)))) if self.current_progress_percent <= 0: if get_setting_int('autoPlayMode') == 0: self.set_watch_now(True) else: Player().stop()
def launch_popup(self, episode, source=None): episode_id = episode.get('episodeid') no_play_count = episode.get('playcount') is None or episode.get( 'playcount') == 0 include_play_count = True if self.state.include_watched else no_play_count if not include_play_count or self.state.current_episode_id == episode_id: # play_next = False # keep_playing = True # return play_next, keep_playing # Don't play next file, but keep playing current file return False, True # Add next file to playlist if existing playlist is not being used if source != 'playlist': self.state.queued = self.api.queue_next_item(episode) # We have a next up episode choose mode if get_setting_int('simpleMode') == 0: next_up_page = UpNext('script-upnext-upnext-simple.xml', addon_path(), 'default', '1080i') still_watching_page = StillWatching( 'script-upnext-stillwatching-simple.xml', addon_path(), 'default', '1080i') else: next_up_page = UpNext('script-upnext-upnext.xml', addon_path(), 'default', '1080i') still_watching_page = StillWatching( 'script-upnext-stillwatching.xml', addon_path(), 'default', '1080i') showing_next_up_page, showing_still_watching_page = self.show_popup_and_wait( episode, next_up_page, still_watching_page) should_play_default, should_play_non_default = self.extract_play_info( next_up_page, showing_next_up_page, showing_still_watching_page, still_watching_page) if not self.state.track: self.log('exit launch_popup early due to disabled tracking', 2) # play_next = False # keep_playing = showing_next_up_page # return play_next, keep_playing # Don't play next file # Stop if Still Watching? popup was shown to prevent unwanted playback when using FF or skip return False, showing_next_up_page play_item_option_1 = (should_play_default and self.state.play_mode == 0) play_item_option_2 = (should_play_non_default and self.state.play_mode == 1) if not play_item_option_1 and not play_item_option_2: # play_next = False # keep_playing = next_up_page.is_cancel() if showing_next_up_page else still_watching_page.is_cancel() # keep_playing = keep_playing and not get_setting_bool('stopAfterClose') # return play_next, keep_playing # Don't play next file, and stop current file if no playback option selected return False, ((next_up_page.is_cancel() if showing_next_up_page else still_watching_page.is_cancel()) and not get_setting_bool('stopAfterClose')) self.log('playing media episode', 2) # Signal to trakt previous episode watched event(message='NEXTUPWATCHEDSIGNAL', data=dict(episodeid=self.state.current_episode_id), encoding='base64') if source == 'playlist' or self.state.queued: # Play playlist media if should_play_non_default: # Only start the next episode if the user asked for it specifically self.player.playnext() elif self.api.has_addon_data(): # Play add-on media self.api.play_addon_item() else: # Play local media self.api.play_kodi_item(episode) # play_next = True # keep_playing = True # return play_next, keep_playing # Play next file, and keep playing current file return True, True