return topics def get_posts(self, topic_url): posts = [] soup = self.make_soup(topic_url) posts_container = soup.findAll("ul", "forums") post_containers = posts_container[0].findAll("li") for post in post_containers: if post.find("span", "bbp-reply-post-date") is not None: post_date = post.find("span", "bbp-reply-post-date").string post_permalink = post.find("a", "bbp-reply-permalink").attrs['href'] post_user_link = post.find("a", "bbp-author-avatar").attrs['href'] post_content = str(post.find("div", "bbp-reply-content")) post_dict = { 'post_permalink': post_permalink, 'post_user_link': post_user_link, 'post_date': post_date, 'post_content': post_content } posts.append(post_dict) return posts registry.register(ForumPlugin)
tags = [] hashtags = tweet['entities']['hashtags'] for hashtag in hashtags: tag = hashtag['text'] tags.append(tag) # get @mentions # favorite_count mentions = [] atmentions = tweet['entities']['user_mentions'] for usermention in atmentions: mention = "@" + str(usermention['screen_name']) tags.append(mention) #print post_id #print twitterusername_exists(username, course_code) if username_exists(username, course_code, self.platform): usr_dict = get_userdetails(username, self.platform) if retweeted: insert_share(usr_dict, post_id, retweeted_id, message,username,fullname, timestamp, course_code, self.platform, self.platform_url, tags=tags, shared_username=retweeted_username) else: insert_post(usr_dict, post_id,message,fullname,username, timestamp, course_code, self.platform, self.platform_url, tags=tags) def get_verbs(self): return self.xapi_verbs def get_objects(self): return self.xapi_objects registry.register(TwitterPlugin)
print 'added closed/opened card!' elif data['old'][change[0]] is True: insert_closedopen_object(usr_dict, data['card']['id'], '%s:%s' % ('Opened', data['card']['name']), u_id, author, date, course_code, self.platform, self.platform_url, 'Task', 'opened', obj_parent=data['list']['name'], obj_parent_type='Collection') #TODO: RP print 'added closed/opened card!' def get_verbs(self): return self.xapi_verbs def get_objects(self): return self.xapi_objects registry.register(TrelloPlugin)
topic_containers = soup.findAll("ul", "topic") for topic_item in topic_containers: topic_link = topic_item.find("a", "bbp-topic-permalink").attrs['href'] topic_title = topic_item.find("a", "bbp-topic-permalink").string topic_author = topic_item.find("a", "bbp-author-avatar").attrs['href'] topic_dict = {'topic_link': topic_link, 'topic_title': topic_title, 'topic_author': topic_author } topics.append(topic_dict) return topics def get_posts(self, topic_url): posts = [] soup = self.make_soup(topic_url) posts_container = soup.findAll("ul", "forums") post_containers = posts_container[0].findAll("li") for post in post_containers: if post.find("span", "bbp-reply-post-date") is not None: post_date = post.find("span", "bbp-reply-post-date").string post_permalink = post.find("a", "bbp-reply-permalink").attrs['href'] post_user_link = post.find("a", "bbp-author-avatar").attrs['href'] post_content = str(post.find("div", "bbp-reply-content")) post_dict = {'post_permalink': post_permalink, 'post_user_link': post_user_link, 'post_date': post_date, 'post_content': post_content } posts.append(post_dict) return posts registry.register(ForumPlugin)
if author not in displayname_username_dict: displayname_username_dict[author] = username if username_exists(username, course_code, self.platform): usr_dict = get_userdetails(username, self.platform) insert_blogpost(usr_dict, link, message, author, username, post_date, course_code, self.platform, self.platform_url, tags=tags) return displayname_username_dict def insert_blogcomments(self, member_commentfeed, course_code, displayname_username_dict): d = feedparser.parse(member_commentfeed) for post in d.entries: link = post.link slash_pos = post.link.rfind("/") parent_link = post.link[:slash_pos+1] path = urlparse.urlparse(parent_link).path parent_username = path.split('/')[1] message = post.title + " " + post.content[0]['value'] author = post.author post_date = dateutil.parser.parse(post.published) if author != "Anonymous" and author in displayname_username_dict: post_username = displayname_username_dict[author] post_date = dateutil.parser.parse(post.published) if username_exists(post_username, course_code, self.platform): usr_dict = get_userdetails(post_username, self.platform) insert_comment(usr_dict, parent_link, link, message, post_username, author, post_date, course_code, self.platform, self.platform_url, shared_username=parent_username) registry.register(BlogrssPlugin)
replyComm = Comment() replyComm.isReply = True replyComm.commId = reply['id'] snippet = reply['snippet'] replyComm.authorDispName = snippet['authorChannelUrl'] #snippet['authorDisplayName'] id_creator_dict[reply['id']] = snippet['authorChannelUrl'] id_creator_displayname_dict[reply['id']] = author replyComm.parentId = snippet['parentId'] #snippet['parentId'] if snippet.get('textOriginal'): replyComm.text = snippet['textOriginal'] else: replyComm.text = snippet['textDisplay'] if snippet.get('videoId'): replyComm.videoId = snippet['videoId'] replyComm.videoUrl = STR_YT_VIDEO_BASE_URL + replyComm.videoId if snippet.get('channelId'): replyComm.channelId = snippet['channelId'] replyComm.channelUrl = STR_YT_CHANNEL_BASE_URL + replyComm.channelId replyComm.updatedAt = snippet['updatedAt'] commList.append(replyComm) return commList,id_creator_dict,id_creator_displayname_dict registry.register(YoutubePlugin)
post_id, xapi_settings.OBJECT_NOTE, created_time, parent_user=user) if 'comments' in post: for comment in post['comments']['data']: comment_created_time = comment['created_time'] comment_from_uid = comment['from']['id'] comment_message = comment['message'] comment_id = comment['id'] comment_id = group_url + comment_id # print 'comment ID: %s' % comment_id if username_exists(comment_from_uid, unit, self.platform): comment_user = get_user_from_screen_name( comment_from_uid, self.platform) insert_comment(comment_user, post_id, comment_id, comment_message, comment_created_time, unit, self.platform, self.platform_url, parent_user=user) registry.register(FacebookPlugin)
elif action == self.ACTION_TYPE_COMMENT_CARD: value = 'commented in %s' % self.italicize( contexts[index]['definition']['name']['en-US']) value = value + self.SEPARATOR_HTML_TAG_BR value = value + self.italicize( self.replace_linechange_with_br_tag(object_val)) elif action == self.ACTION_TYPE_CLOSE_CARD: value = "closed %s in %s" % ( self.italicize(object_val), self.italicize(contexts[index]['definition']['name']['en-US'])) elif action == self.ACTION_TYPE_OPEN_CARD: value = "opened %s in %s" % ( self.italicize(object_val), self.italicize(contexts[index]['definition']['name']['en-US'])) else: value = self.italicize(object_val) return value def italicize(self, value): return '<i>%s</i>' % (value) def replace_linechange_with_br_tag(self, target): return target.replace('\n', '<br>') registry.register(TrelloPlugin)
config_json_keys = ['user', 'password', 'apikey'] #from DIPluginDashboardMixin xapi_objects_to_includein_platformactivitywidget = ['Bookmark'] xapi_verbs_to_includein_verbactivitywidget = ['created', 'commented'] def __init__(self): pass def perform_import(self, retrieval_param, course_code): # Setup Twitter API Keys user = os.environ.get("DIIGO_USER") password = os.environ.get("DIIGO_PASSWORD") apikey = os.environ.get("DIIGO_API_KEY") # call api and process bookmarks here # retrieval_param will contain a single tag # for each insert check if user exists and then get user details # then process returned json and call insert_link or insert_comment ''' if username_exists(username, course_code, self.platform): usr_dict = get_userdetails(username, self.platform) insert_bookmark(usr_dict, post_id,message,fullname,username, timestamp, course_code, self.platform, self.platform_url, tags=tags) insert_comment(usr_dict, forum_link, post_permalink, post_content, post_username, post_username, post_date, course_code, self.platform, self.platform_url, shared_username=forum_author) ''' registry.register(DiigoPlugin)
verb = 'Updated' fine_name = ' %s (lines changed: %s - add:%s, del:%s)' % ( self.italicize(contexts[3]['definition']['name']['en-US']), contexts[4]['definition']['name']['en-US'], contexts[5]['definition']['name']['en-US'], contexts[6]['definition']['name']['en-US']) if action == self.EVENT_TYPE_REMOVE_FILE: verb = 'Removed' fine_name = ' %s' % (self.italicize(contexts[3]['definition']['name']['en-US'])) commit_title = 'from: %s' % (self.italicize(contexts[1]['definition']['name']['en-US'])) value = verb + fine_name + self.SEPARATOR_HTML_TAG_BR + commit_title elif action == self.EVENT_TYPE_ASSIGN_MEMBER: value = 'Added %s to %s' % (self.italicize(object_val), self.italicize(contexts[1]['definition']['name']['en-US'])) else: value = self.italicize(object_val) return value def italicize(self, value): return '<i>%s</i>' % (value) def replace_linechange_with_br_tag(self, target): return target.replace('\n','<br>') registry.register(GithubPlugin)
# print 'object ID: %s' % post_id if 'likes' in post: for like in post['likes']['data']: like_uid = like['id'] like_id = group_url + like_uid # print 'like ID: %s' % like_id if username_exists(like_uid, unit, self.platform): like_user = get_user_from_screen_name(from_uid, self.platform) insert_like(like_user, like_id, message, unit, self.platform, self.platform_url, post_id, xapi_settings.OBJECT_NOTE, created_time, parent_user=user) if 'comments' in post: for comment in post['comments']['data']: comment_created_time = comment['created_time'] comment_from_uid = comment['from']['id'] comment_message = comment['message'] comment_id = comment['id'] comment_id = group_url + comment_id # print 'comment ID: %s' % comment_id if username_exists(comment_from_uid, unit, self.platform): comment_user = get_user_from_screen_name(comment_from_uid, self.platform) insert_comment(comment_user, post_id, comment_id, comment_message, comment_created_time, unit, self.platform, self.platform_url, parent_user=user) registry.register(FacebookPlugin)
config_json_keys = ['user', 'password', 'apikey'] #from DIPluginDashboardMixin xapi_objects_to_includein_platformactivitywidget = ['Bookmark'] xapi_verbs_to_includein_verbactivitywidget = ['created', 'commented'] def __init__(self): pass def perform_import(self, retrieval_param, course_code): # Setup Twitter API Keys user = os.environ.get("DIIGO_USER") password = os.environ.get("DIIGO_PASSWORD") apikey = os.environ.get("DIIGO_API_KEY") # call api and process bookmarks here # retrieval_param will contain a single tag # for each insert check if user exists and then get user details # then process returned json and call insert_link or insert_comment ''' if username_exists(username, course_code, self.platform): usr_dict = get_userdetails(username, self.platform) insert_bookmark(usr_dict, post_id,message,fullname,username, timestamp, course_code, self.platform, self.platform_url, tags=tags) insert_comment(usr_dict, forum_link, post_permalink, post_content, post_username, post_username, post_date, course_code, self.platform, self.platform_url, shared_username=forum_author) ''' registry.register(DiigoPlugin)
parent_link = post.link[:slash_pos+1] path = urlparse.urlparse(parent_link).path parent_username = path.split('/')[1] message = post.title + " " + post.content[0]['value'] author = post.author post_date = dateutil.parser.parse(post.published) if author != "Anonymous" and author in displayname_username_dict: post_username = displayname_username_dict[author] post_date = dateutil.parser.parse(post.published) if username_exists(post_username, unit, self.platform): user = get_user_from_screen_name(post_username, self.platform) parent_user = None try: parent_user = get_user_from_screen_name(parent_username, self.platform) except: pass if parent_user is not None: insert_comment(user, parent_link, link, message, post_date, unit, self.platform, self.platform_url, parent_user = parent_user) else: insert_comment(user, parent_link, link, message, post_date, unit, self.platform, self.platform_url, parent_user = parent_user, parent_user_external = post_username) registry.register(BlogrssPlugin)
parent_user=parent_user) else: insert_share(user, post_id, retweeted_id, message, timestamp, unit, self.platform, self.platform_url, tags=tags, parent_external_user=retweeted_username) else: insert_post(user, post_id, message, timestamp, unit, self.platform, self.platform_url, tags=tags) def get_verbs(self): return self.xapi_verbs def get_objects(self): return self.xapi_objects registry.register(TwitterPlugin)
maxResults=max_result_num, order=result_order, videoId=channel_id, pageToken=next_page_token).execute() else: ret = service.commentThreads().list( part=id_val, maxResults=max_result_num, order=result_order, videoId=channel_id).execute() else: # Extract data from social media by channel ID if next_page_token is not "": ret = service.commentThreads().list( part=id_val, maxResults=max_result_num, order=result_order, channelId=channel_id, pageToken=next_page_token).execute() else: ret = service.commentThreads().list( part=id_val, maxResults=max_result_num, order=result_order, channelId=channel_id).execute() return ret registry.register(YoutubePlugin)