def _extract_biblio(self, page, id=None): if not "snippet" in page: raise ProviderContentMalformedError json_response = provider._load_json(page) this_video_json = json_response["items"][0] dict_of_keylists = { 'title': ['snippet', 'title'], 'channel_title': ['snippet', 'channelTitle'], 'published_date': ['snippet', 'publishedAt'] } biblio_dict = provider._extract_from_data_dict(this_video_json, dict_of_keylists) try: biblio_dict["year"] = biblio_dict["published_date"][0:4] except KeyError: pass biblio_dict["url"] = id biblio_dict["repository"] = "YouTube" return biblio_dict
def _extract_metrics(self, page, status_code=200, id=None): if status_code != 200: if status_code == 404: return {} else: raise (self._get_error(status_code)) if not "kind" in page: raise ProviderContentMalformedError json_response = provider._load_json(page) this_video_json = json_response["items"][0] dict_of_keylists = { 'youtube:views': ['statistics', 'viewCount'], 'youtube:likes': ['statistics', 'likeCount'], 'youtube:dislikes': ['statistics', 'dislikeCount'], 'youtube:favorites': ['statistics', 'favoriteCount'], 'youtube:comments': ['statistics', 'commentCount'], } metrics_dict = provider._extract_from_data_dict( this_video_json, dict_of_keylists) metrics_dict = provider._metrics_dict_as_ints(metrics_dict) return metrics_dict
def _extract_metrics(self, page, status_code=200, id=None): if status_code != 200: if status_code == 404: return {} else: raise(self._get_error(status_code)) if not "snippet" in page: raise ProviderContentMalformedError json_response = provider._load_json(page) this_video_json = json_response["items"][0] dict_of_keylists = { 'youtube:views' : ['statistics', 'viewCount'], 'youtube:likes' : ['statistics', 'likeCount'], 'youtube:dislikes' : ['statistics', 'dislikeCount'], 'youtube:favorites' : ['statistics', 'favoriteCount'], 'youtube:comments' : ['statistics', 'commentCount'], } metrics_dict = provider._extract_from_data_dict(this_video_json, dict_of_keylists) metrics_dict = provider._metrics_dict_as_ints(metrics_dict) return metrics_dict
def _extract_metrics_for_via_citation_call(self, data, status_code=200, id=None): dict_of_keylists = { 'altmetric_com:gplus_posts' : ['cited_by_gplus_count'], 'altmetric_com:facebook_posts' : ['cited_by_fbwalls_count'], 'altmetric_com:blog_posts' : ['cited_by_feeds_count'] } entry = data["results"][0] metrics_dict = provider._extract_from_data_dict(entry, dict_of_keylists) return metrics_dict
def _extract_aliases(self, page, id=None): dict_of_keylists = {"url": ["figshare_url"]} item = self._extract_figshare_record(page, id) aliases_dict = provider._extract_from_data_dict(item, dict_of_keylists) if aliases_dict: aliases_list = [(namespace, nid) for (namespace, nid) in aliases_dict.iteritems()] else: aliases_list = [] return aliases_list
def _extract_metrics_for_via_citation_call(self, data, status_code=200, id=None): dict_of_keylists = { 'altmetric_com:gplus_posts': ['cited_by_gplus_count'], 'altmetric_com:facebook_posts': ['cited_by_fbwalls_count'], 'altmetric_com:blog_posts': ['cited_by_feeds_count'] } entry = data["results"][0] metrics_dict = provider._extract_from_data_dict( entry, dict_of_keylists) return metrics_dict
def _extract_metrics(self, page, status_code=200, id=None): if status_code != 200: if status_code == 404: return {} else: raise (self._get_error(status_code)) dict_of_keylists = { 'figshare:shares': ['shares'], 'figshare:downloads': ['downloads'], 'figshare:views': ['views'] } item = self._extract_figshare_record(page, id) metrics_dict = provider._extract_from_data_dict(item, dict_of_keylists) return metrics_dict
def _extract_metrics(self, page, status_code=200, id=None): if status_code != 200: if status_code == 404: return {} else: raise (self._get_error(status_code)) dict_of_keylists = { "figshare:shares": ["shares"], "figshare:downloads": ["downloads"], "figshare:views": ["views"], } item = self._extract_item(page, id) metrics_dict = provider._extract_from_data_dict(item, dict_of_keylists) return metrics_dict
def _extract_metrics(self, page, status_code=200, id=None): if status_code != 200: if status_code == 404: return {} else: raise(self._get_error(status_code)) dict_of_keylists = { 'figshare:shares' : ['shares'], 'figshare:downloads' : ['downloads'], 'figshare:views' : ['views'] } item = self._extract_figshare_record(page, id) metrics_dict = provider._extract_from_data_dict(item, dict_of_keylists) return metrics_dict
def _extract_biblio(self, page, id=None): dict_of_keylists = { 'title': ['title'], 'genre': ['defined_type'], #'authors_literal' : ['authors'], 'published_date': ['published_date'] } item = self._extract_figshare_record(page, id) biblio_dict = provider._extract_from_data_dict(item, dict_of_keylists) biblio_dict["repository"] = "figshare" try: biblio_dict["year"] = int(biblio_dict["published_date"][-4:]) except (KeyError, TypeError): pass if "genre" in biblio_dict: genre = biblio_dict["genre"].lower() #override if genre in ["figure", "poster"]: genre = biblio_dict["genre"] elif genre == "presentation": genre = "slides" elif genre == "paper": genre = "article" elif genre == "media": genre = "video" else: genre = "dataset" #includes fileset biblio_dict["genre"] = genre if biblio_dict["genre"] == "article": biblio_dict["free_fulltext_url"] = self._get_templated_url( self.provenance_url_template, id, "provenance") # the authors data is messy, so just give up for now # if "authors_literal" in biblio_dict: # surname_list = [author["last_name"] for author in biblio_dict["authors_literal"]] # if surname_list: # biblio_dict["authors"] = ", ".join(surname_list) # del biblio_dict["authors_literal"] return biblio_dict
def _extract_biblio(self, page, id=None): dict_of_keylists = { 'title' : ['title'], 'genre' : ['defined_type'], #'authors_literal' : ['authors'], 'published_date' : ['published_date'] } item = self._extract_figshare_record(page, id) biblio_dict = provider._extract_from_data_dict(item, dict_of_keylists) biblio_dict["repository"] = "figshare" try: biblio_dict["year"] = int(biblio_dict["published_date"][-4:]) except (KeyError, TypeError): pass if "genre" in biblio_dict: genre = biblio_dict["genre"].lower() #override if genre in ["figure", "poster"]: genre = biblio_dict["genre"] elif genre == "presentation": genre = "slides" elif genre == "paper": genre = "article" elif genre == "media": genre = "video" else: genre = "dataset" #includes fileset biblio_dict["genre"] = genre if biblio_dict["genre"] == "article": biblio_dict["free_fulltext_url"] = self._get_templated_url(self.provenance_url_template, id, "provenance") # the authors data is messy, so just give up for now # if "authors_literal" in biblio_dict: # surname_list = [author["last_name"] for author in biblio_dict["authors_literal"]] # if surname_list: # biblio_dict["authors"] = ", ".join(surname_list) # del biblio_dict["authors_literal"] return biblio_dict
def _extract_metrics(self, page, status_code=200, id=None): if status_code != 200: if status_code == 404: return {} else: raise(self._get_error(status_code)) if not "sources" in page: raise ProviderContentMalformedError json_response = provider._load_json(page) this_article = json_response[0]["sources"][0]["metrics"] dict_of_keylists = { 'plosalm:html_views' : ['html'], 'plosalm:pdf_views' : ['pdf'] } metrics_dict = provider._extract_from_data_dict(this_article, dict_of_keylists) return metrics_dict
def _extract_metrics(self, page, status_code=200, id=None): if status_code != 200: if status_code == 404: return {} else: raise (self._get_error(status_code)) if not "user_id" in page: raise ProviderContentMalformedError json_response = provider._load_json(page) this_video_json = json_response[0] dict_of_keylists = { "vimeo:plays": ["stats_number_of_plays"], "vimeo:likes": ["stats_number_of_likes"], "vimeo:comments": ["stats_number_of_comments"], } metrics_dict = provider._extract_from_data_dict(this_video_json, dict_of_keylists) return metrics_dict
def _extract_metrics(self, page, status_code=200, id=None): if status_code != 200: if status_code == 404: return {} else: raise(self._get_error(status_code)) if not "user_id" in page: raise ProviderContentMalformedError json_response = provider._load_json(page) this_video_json = json_response[0] dict_of_keylists = { 'vimeo:plays' : ['stats_number_of_plays'], 'vimeo:likes' : ['stats_number_of_likes'], 'vimeo:comments' : ['stats_number_of_comments'] } metrics_dict = provider._extract_from_data_dict(this_video_json, dict_of_keylists) return metrics_dict
def _extract_biblio(self, page, id=None): json_response = provider._load_json(page) this_video_json = json_response[0] dict_of_keylists = { 'title': ['title'], 'authors': ['user_name'], 'published_date': ['upload_date'], 'url': ['url'] } biblio_dict = provider._extract_from_data_dict(this_video_json, dict_of_keylists) try: biblio_dict["year"] = biblio_dict["published_date"][0:4] except KeyError: pass biblio_dict["repository"] = "Vimeo" return biblio_dict
def _extract_biblio(self, page, id=None): json_response = provider._load_json(page) this_video_json = json_response[0] dict_of_keylists = { "title": ["title"], "authors": ["user_name"], "published_date": ["upload_date"], "url": ["url"], } biblio_dict = provider._extract_from_data_dict(this_video_json, dict_of_keylists) try: biblio_dict["year"] = biblio_dict["published_date"][0:4] except KeyError: pass biblio_dict["repository"] = "Vimeo" return biblio_dict