def onPlayerExit(self): # pylint: disable=invalid-name """Called when player exits""" log(3, '[PlayerInfo {id}] Event onPlayerExit', id=self.thread_id) self.positionthread = None self.push_position(position=self.last_pos, total=self.total) # Set property to let wait_for_resumepoints function know that update resume is done set_property('vrtnu_resumepoints', 'ready')
def add_upnext(self, video_id): """Add Up Next url to Kodi Player""" # Reset vrtnu_resumepoints property set_property('vrtnu_resumepoints', None) url = url_for('play_upnext', video_id=video_id) self.update_position() self.update_total() if self.isPlaying() and self.total - self.last_pos < 1: log(3, '[PlayerInfo {id}] Add {url} to Kodi Playlist', id=self.thread_id, url=url) PlayList(1).add(url) else: log(3, '[PlayerInfo {id}] Add {url} to Kodi Player', id=self.thread_id, url=url) self.play(url)
def onPlayBackStarted(self): # pylint: disable=invalid-name """Called when user starts playing a file""" self.path = getInfoLabel(self.path_infolabel) if self.path.startswith('plugin://plugin.video.vrt.nu/'): self.listen = True else: self.listen = False return log(3, '[PlayerInfo {id}] Event onPlayBackStarted', id=self.thread_id) # Set property to let wait_for_resumepoints function know that update resume is busy set_property('vrtnu_resumepoints', 'busy') # Update previous episode when using "Up Next" if self.path.startswith('plugin://plugin.video.vrt.nu/play/upnext'): self.push_position(position=self.last_pos, total=self.total) # Reset episode data self.video_id = None self.episode_id = None self.episode_title = None self.asset_str = None self.title = None ep_id = play_url_to_id(self.path) # Avoid setting resumepoints for livestreams for channel in CHANNELS: if ep_id.get('video_id') and ep_id.get('video_id') == channel.get( 'live_stream_id'): log(3, '[PlayerInfo {id}] Avoid setting resumepoints for livestream {video_id}', id=self.thread_id, video_id=ep_id.get('video_id')) self.listen = False # Reset vrtnu_resumepoints property before return set_property('vrtnu_resumepoints', None) return # Get episode data needed to update resumepoints from VRT NU Search API episode = self.apihelper.get_single_episode_data( video_id=ep_id.get('video_id'), whatson_id=ep_id.get('whatson_id'), video_url=ep_id.get('video_url')) # Avoid setting resumepoints without episode data if episode is None: # Reset vrtnu_resumepoints property before return set_property('vrtnu_resumepoints', None) return from metadata import Metadata self.video_id = episode.get('videoId') or None self.episode_id = episode.get('episodeId') or None self.episode_title = episode.get('title') or None self.asset_str = Metadata(None, None).get_asset_str(episode) self.title = episode.get('program') # Kodi 17 doesn't have onAVStarted if kodi_version_major() < 18: self.onAVStarted()