|
5 | 5 | import copy |
6 | 6 | import csv |
7 | 7 | import pprint |
| 8 | +import datetime |
| 9 | +import itertools |
| 10 | +import warnings |
8 | 11 | from typing import Dict, List |
9 | 12 | from ._navigator import Navigator |
10 | 13 | from ._proxy_generator import ProxyGenerator |
@@ -257,13 +260,29 @@ def citedby(self, object: Publication)->_SearchScholarIterator: |
257 | 260 | :param object: The Publication object for the bibtex exportation |
258 | 261 | :type object: Publication |
259 | 262 | """ |
260 | | - if object['container_type'] == "Publication": |
261 | | - publication_parser = PublicationParser(self.__nav) |
262 | | - return publication_parser.citedby(object) |
263 | | - else: |
| 263 | + |
| 264 | + if object['container_type'] != "Publication": |
264 | 265 | self.logger.warning("Object not supported for bibtex exportation") |
265 | 266 | return |
266 | 267 |
|
| 268 | + if object["bib"]["citedby"] < 999: |
| 269 | + return PublicationParser(self.__nav).citedby(object) |
| 270 | + else: |
| 271 | + try: |
| 272 | + year_low = int(object["bib"]["pub_year"]) |
| 273 | + year_end = int(datetime.date.today().year) |
| 274 | + except KeyError: |
| 275 | + self.logger.warning("Unknown publication year for paper %s, may result in incorrect number of citedby papers.", object["bib"]["title"]) |
| 276 | + return PublicationParser(self.__nav).citedby(object) |
| 277 | + |
| 278 | + pub_id = int(object["citedby_url"].split("=")[1].split("&")[0]) |
| 279 | + iter_list = [] |
| 280 | + while year_low < year_end: |
| 281 | + iter_list.append(self.search_citedby(publication_id=pub_id, year_low=year_low, year_high=year_low+1)) |
| 282 | + year_low += 1 |
| 283 | + |
| 284 | + return itertools.chain(*iter_list) |
| 285 | + |
267 | 286 | def search_author_id(self, id: str, filled: bool = False, sortby: str = "citedby", publication_limit: int = 0)->Author: |
268 | 287 | """Search by author id and return a single Author object |
269 | 288 | :param sortby: select the order of the citations in the author page. Either by 'citedby' or 'year'. Defaults to 'citedby'. |
|
0 commit comments