def tag_videos(self, video_entries, tags):
        from gdata.media import Group, Keywords
        remove_set, add_set, replace_tags = googlecl.base.generate_tag_sets(
            tags)
        for video in video_entries:
            if not video.media:
                video.media = Group()
            if not video.media.keywords:
                video.media.keywords = Keywords()

            # No point removing tags if the video has no keywords,
            # or we're replacing the keywords.
            if video.media.keywords.text and remove_set and not replace_tags:
                current_tags = video.media.keywords.text.replace(', ', ',')
                current_set = set(current_tags.split(','))
                video.media.keywords.text = ','.join(current_set - remove_set)

            if replace_tags or not video.media.keywords.text:
                video.media.keywords.text = ','.join(add_set)
            elif add_set:
                video.media.keywords.text += ',' + ','.join(add_set)

            self.UpdateVideoEntry(video)
Add or remove tags on a list of videos.
dataset/ETHPy150Open vinitkumar/googlecl/src/googlecl/youtube/service.py/YouTubeServiceCL.tag_videos