Skip to content

Commit

Permalink
Merge pull request #60 from noeleont/fix/author_names
Browse files Browse the repository at this point in the history
fix: creator/author field

Thanks @noeleont for the contribution.
  • Loading branch information
e-alizadeh authored Nov 16, 2023
2 parents 901c210 + 59d3fad commit c5b7c59
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion zotero2readwise/zotero.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,19 @@ def __post_init__(self):
# Sample {'dc:relation': ['http://zotero.org/users/123/items/ABC', 'http://zotero.org/users/123/items/DEF']}
if self.relations:
self.relations = self.relations.get("dc:relation")

if self.creators:
et_al = "et al."
max_length = 1024 - len(et_al)
creators_str = ", ".join(self.creators)
if len(creators_str) > max_length:
# Reset creators_str and find the first n creators that fit in max_length
creators_str = ""
while self.creators and len(creators_str) < max_length:
creators_str += self.creators.pop() + ", "
creators_str += et_al
self.creators = creators_str

self.creators = ", ".join(self.creators) if self.creators else None

def get_nonempty_params(self) -> Dict:
return {k: v for k, v in self.__dict__.items() if v}
Expand Down

0 comments on commit c5b7c59

Please sign in to comment.