def _on_video_like(self, context, re_match): video_id = context.get_param('video_id') like = re_match.group('method') == 'like' client = self.get_client(context) helper.do_xml_error(context, self, client.like_video(video_id=video_id, like=like)) context.get_ui().refresh_container() return True
def _on_channel_subscribe(self, context, re_match): channel_id = context.get_param('channel_id') client = self.get_client(context) if re_match.group('method') == 'subscribe': helper.do_xml_error(context, self, client.subscribe_channel(channel_id=channel_id)) else: helper.do_xml_error(context, self, client.unsubscribe_channel(channel_id=channel_id)) pass context.get_ui().refresh_container() return True
def _on_group_join(self, context, re_match): group_id = context.get_param('group_id') client = self.get_client(context) if re_match.group('method') == 'join': helper.do_xml_error(context, self, client.join_group(group_id=group_id)) else: helper.do_xml_error(context, self, client.leave_group(group_id=group_id)) pass context.get_ui().refresh_container() return True
def _on_video_watch_later(self, context, re_match): video_id = context.get_param('video_id') method = re_match.group('method') client = self.get_client(context) if method == 'add': helper.do_xml_error(context, self, client.add_video_to_watch_later(video_id=video_id)) elif method=='remove': helper.do_xml_error(context, self, client.remove_video_from_watch_later(video_id=video_id)) pass context.get_ui().refresh_container() return True
def _on_play(self, context, re_match): def _compare(item): vq = context.get_settings().get_video_quality() return vq - item['resolution'] video_id = context.get_param('video_id') client = self.get_client(context) video_item = helper.do_xml_video_response(context, self, client.get_video_info(video_id)) xml = self.get_client(context).get_video_streams(video_id=video_id) if not do_xml_error(context, self, xml): return False video_streams = helper.do_xml_to_video_stream(context, self, xml) video_stream = kodion.utils.select_stream(context, video_streams) video_item.set_uri(video_stream['url']) return video_item