def play_addon_item(data, encoding, resume=False): """Function to play next addon item, either using JSONRPC Player.Open or by passthrough back to the addon""" play_url = data.get('play_url') if play_url: log('Playing from addon - {0}'.format(play_url)) utils.jsonrpc(method='Player.Open', params={'item': { 'file': play_url }}, options={'resume': resume}, no_response=True) return play_info = data.get('play_info') if play_info: log('Sending as {0} to addon - {1}'.format(encoding, play_info)) utils.event(message=data.get('id'), data=play_info, sender='upnextprovider', encoding=encoding) return log('Error: no addon data available for playback', utils.LOGWARNING)
def play_addon_item(self): if self.data.get('play_url'): self.log('Playing the next episode directly: %(play_url)s' % self.data, 2) jsonrpc(method='Player.Open', params=dict(item=dict(file=self.data.get('play_url')))) else: self.log('Sending %(encoding)s data to add-on to play: %(play_info)s' % dict(encoding=self.encoding, **self.data), 2) event(message=self.data.get('id'), data=self.data.get('play_info'), sender='upnextprovider', encoding=self.encoding)
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 update_timestamp(self, play_time, total_time): if not self.credits_detected(): return self.hash_index['detected_at'] = self.hash_index['current'][0] self.hashes.timestamps[self.hashes.episode] = play_time self.state.set_popup_time(total_time=total_time, detected_time=play_time) utils.event('upnext_trigger')
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
# icd # icd_ok # --------------------------------------------------------------------------------------------------------------- # 事件发生日期 data["HappenDate"] = utils.data_check_type(esData[15]['v']) # 发现或知悉日期 data["KnowDate"] = utils.data_check_type(esData[16]['v']) # 医疗器械实际使用场所 _report_data_33 = esData[17]['v'] data["useplace"] = utils.data_check_type(utils.use(_report_data_33)) # 事件后果 _report_data_34 = esData[19]['v'] data["event_consequence"] = utils.data_check_type(utils.event(_report_data_34)) # 事件陈述 data["event_memo"] = utils.data_check_type(esData[21]['v']) # --------------------------------------------------------------------------------------------------------------- # 报告人类别 _report_data_36 = esData[45]['v'] data["reporter_class"] = utils.data_check_type(utils.type_report(_report_data_36)) # 报告人 data["reporter"] = utils.data_check_type(esData[46]['v']) # --------------------------------------------------------------------------------------------------------------- # 死亡时间 data["death_time"] = utils.data_check_type(esData[20]['v']) if not data["death_time"]: data["death_time"] = '0000-00-00'
# icd_ok # --------------------------------------------------------------------------------------------------------------- # 事件发生日期 data["HappenDate"] = utils.data_check_type(esData[15]['v']) # 发现或知悉日期 data["KnowDate"] = utils.data_check_type(esData[16]['v']) # 医疗器械实际使用场所 _report_data_33 = esData[17]['v'] data["useplace"] = utils.data_check_type(utils.use(_report_data_33)) # 事件后果 _report_data_34 = esData[19]['v'] data["event_consequence"] = utils.data_check_type( utils.event(_report_data_34)) # 事件陈述 data["event_memo"] = utils.data_check_type(esData[21]['v']) # --------------------------------------------------------------------------------------------------------------- # 报告人类别 _report_data_36 = esData[45]['v'] data["reporter_class"] = utils.data_check_type( utils.type_report(_report_data_36)) # 报告人 data["reporter"] = utils.data_check_type(esData[46]['v']) # --------------------------------------------------------------------------------------------------------------- # 死亡时间 data["death_time"] = utils.data_check_type(esData[20]['v']) if not data["death_time"]:
def _run(self): self.log('Started') self.running = True next_item, source = self.state.get_next() # No next item to play, get out of here if not next_item: self.log('Exiting: no next item to play') play_next = False keep_playing = True self._post_run(play_next, keep_playing) has_next_item = False return has_next_item # Add next file to playlist if existing playlist is not being used if self.state.enable_queue and source[-len('playlist'):] != 'playlist': self.state.queued = api.queue_next_item(self.state.data, next_item) # Create Kodi dialog to show UpNext or Still Watching? popup popup_state = self._create_popup(next_item, source) # Display popup and update state of controls popup_state = self._display_popup(popup_state) # Close dialog once we are done with it self._remove_popup() # Update played in a row count if auto_play otherwise reset self.state.played_in_a_row = (self.state.played_in_a_row + 1 if popup_state['auto_play'] else 1) # Update shuffle state self.state.shuffle = popup_state['shuffle'] # Signal to Trakt that current item has been watched utils.event(message='NEXTUPWATCHEDSIGNAL', data={'episodeid': self.state.get_episodeid()}, encoding='base64') # Popup closed prematurely if not popup_state['done']: self.log('Exiting: popup force closed', utils.LOGWARNING) has_next_item = False # Shuffle start request elif popup_state['shuffle_start']: self.log('Exiting: shuffle requested') has_next_item = False popup_state['done'] = False elif not (popup_state['auto_play'] or popup_state['play_now']): self.log('Exiting: playback not selected') has_next_item = True popup_state['done'] = False if not popup_state['done']: play_next = False # Stop playing if Stop button was clicked on popup, or if Still # Watching? popup was shown (to prevent unwanted playback that can # occur if fast forwarding through popup), or not starting shuffle keep_playing = (not popup_state['stop'] and (popup_state['show_upnext'] or popup_state['shuffle_start'])) self._post_run(play_next, keep_playing) # Run again if shuffle started to get new random episode if popup_state['shuffle_start']: return self._run() return has_next_item # Request playback of next file based on source and type self._play_next_video(next_item, source, popup_state) play_next = True keep_playing = True self._post_run(play_next, keep_playing) has_next_item = True return has_next_item
def send_signal(sender, upnext_info): """Helper function for addons to send data to UpNext""" # Exit if not enough addon information provided required_episode_info = ['current_episode', 'next_episode'] required_addon_info = ['play_url', 'play_info'] if not (any(info in upnext_info for info in required_episode_info) and any(info in upnext_info for info in required_addon_info)): log('Error: Invalid UpNext info - {0}'.format(upnext_info), utils.LOGWARNING) return # Extract ListItem or InfoTagVideo details for use by UpNext for key, val in upnext_info.items(): thumb = '' fanart = '' tvshowid = str(constants.UNKNOWN_DATA) if isinstance(val, xbmcgui.ListItem): thumb = val.getArt('thumb') fanart = val.getArt('fanart') tvshowid = val.getProperty('tvshowid') val = val.getVideoInfoTag() if not isinstance(val, xbmc.InfoTagVideo): continue # Use show title as substitute for missing ListItem tvshowid tvshowid = (tvshowid if tvshowid != str(constants.UNKNOWN_DATA) else val.getTVShowTitle()) or constants.UNKNOWN_DATA # Fallback for available date information firstaired = val.getFirstAired() or val.getPremiered() or val.getYear() # Runtime used to evaluate endtime in UpNext popup, if available runtime = val.getDuration() if utils.supports_python_api(18) else 0 # Prefer outline over full plot for UpNext popup plot = val.getPlotOutline() or val.getPlot() # Prefer user rating over scraped rating rating = val.getUserRating() or val.getRating() upnext_info[key] = { 'episodeid': val.getDbId(), 'tvshowid': tvshowid, 'title': val.getTitle(), 'art': { 'thumb': thumb, 'tvshow.fanart': fanart, }, 'season': val.getSeason(), 'episode': val.getEpisode(), 'showtitle': val.getTVShowTitle(), 'plot': plot, 'playcount': val.getPlayCount(), 'rating': rating, 'firstaired': firstaired, 'runtime': runtime } upnext_info = _copy_episode_details(upnext_info) utils.event(sender=sender, message='upnext_data', data=upnext_info, encoding='base64')
#icd # icd_ok #--------------------------------------------------------------------------------------------------------------- #事件发生日期 data["HappenDate"] = utils.data_check_type(esData[15]['v']) #发现或知悉日期 data["KnowDate"] = utils.data_check_type(esData[16]['v']) #医疗器械实际使用场所 _report_data_33 = esData[17]['v'] data["useplace"] = utils.data_check_type(utils.use(_report_data_33)) #事件后果 _report_data_34 = esData[19]['v'] data["event_consequence"] = utils.data_check_type(utils.event(_report_data_34)) #事件陈述 data["event_memo"] = utils.data_check_type(esData[21]['v']) #--------------------------------------------------------------------------------------------------------------- #报告人类别 _report_data_36 = esData[45]['v'] data["reporter_class"] = utils.data_check_type(utils.type_report(_report_data_36)) #报告人 data["reporter"] = utils.data_check_type(esData[46]['v']) #--------------------------------------------------------------------------------------------------------------- #死亡时间 data["death_time"] = utils.data_check_type(esData[20]['v']) if not data["death_time"]: