def do_xml_channel_response(user_id, context, provider, channel): if isinstance(channel, basestring): channel = ET.fromstring(channel) do_xml_error(context, provider, channel) channel = channel.find('video') pass channel_id = channel.get('id') channel_name = channel.find('name').text is_subscribed = channel.get('is_subscribed') == '1' if provider.is_logged_in() and not is_subscribed: channel_name = '[I]%s[/I]' % channel_name pass image = '' logo_url = channel.find('logo_url') if logo_url is not None and logo_url.text: image = logo_url.text else: thumbnail_url = channel.find('thumbnail_url') if thumbnail_url is not None: image = thumbnail_url.text.replace('200x150', '400x300') pass pass channel_item = DirectoryItem(channel_name, context.create_uri(['user', user_id, 'channel', channel_id]), image=image) # context menu context_menu = [] if provider.is_logged_in(): # join/leave if is_subscribed: text = context.localize(provider._local_map['vimeo.channel.unfollow']) context_menu.append( (text, 'RunPlugin(%s)' % context.create_uri(['channel', 'unsubscribe'], {'channel_id': channel_id}))) else: text = context.localize(provider._local_map['vimeo.channel.follow']) context_menu.append( (text, 'RunPlugin(%s)' % context.create_uri(['channel', 'subscribe'], {'channel_id': channel_id}))) pass pass channel_item.set_context_menu(context_menu) return channel_item
def do_xml_group_response(user_id, context, provider, group): if isinstance(group, basestring): group = ET.fromstring(group) do_xml_error(context, provider, group) group = group.find('video') pass group_id = group.get('id') group_name = group.find('name').text has_joined = group.get('has_joined') == '1' if provider.is_logged_in() and not has_joined: group_name = '[I]%s[/I]' % group_name pass logo_url = group.find('logo_url') image = '' if logo_url is not None and logo_url.text: image = logo_url.text else: thumbnail_url = group.find('thumbnail_url') if thumbnail_url is not None: image = thumbnail_url.text.replace('200x150', '400x300') pass pass group_item = DirectoryItem(group_name, context.create_uri(['user', user_id, 'group', group_id]), image=image) # context menu context_menu = [] if provider.is_logged_in(): # join/leave if has_joined: leave_text = context.localize(provider._local_map['vimeo.group.leave']) context_menu.append( (leave_text, 'RunPlugin(%s)' % context.create_uri(['group', 'leave'], {'group_id': group_id}))) else: join_text = context.localize(provider._local_map['vimeo.group.join']) context_menu.append( (join_text, 'RunPlugin(%s)' % context.create_uri(['group', 'join'], {'group_id': group_id}))) pass pass group_item.set_context_menu(context_menu) return group_item