Skip to content

Instantly share code, notes, and snippets.

@faymek
Created March 30, 2025 17:44
Show Gist options
  • Save faymek/c52cdd7f873a7ac62dbc3f753de69d7c to your computer and use it in GitHub Desktop.
Save faymek/c52cdd7f873a7ac62dbc3f753de69d7c to your computer and use it in GitHub Desktop.
given a bibtext entry, convert to coins xml, append it in a hidden DOM, then [zotero connector](https://www.zotero.org/download/connectors) can detect all of them.
entry = {
"number": "JVET-S2001",
"title": "Versatile Video Coding (Draft 10), Document JVET-S2001",
"author": "B. Bross, J. Chen, S. Liu, Y.-K. Wang",
"booktitle": "Joint Video Experts Team (JVET) of ITU-T SG 16 WP 3 and ISO/IEC JTC 1/SC 29/WG 11, 19th Meeting",
"date": "2020-10-08",
"address": "Geneva, Switzerland",
"url": "https://jvet-experts.org/doc_end_user/documents/19_Teleconference/wg11/JVET-S2001-v17.zip",
}
def entry_authors(entry):
if entry["status"] != "Normal" or entry["authors"] == "":
authors = []
else:
authors = []
for a in entry["authorDetails"]:
name = a["author"]
idx = name.rfind(".")
if idx != -1:
name = name[:idx] + ". " + name[idx + 1 :].strip()
authors.append(name)
return authors
def export_bibtex(entry):
authors = entry_authors(entry)
if len(authors) == 0:
return ""
authors_repr = " and ".join(authors)
lines = [
f"@inproceedings{{{entry['number']},",
f" title = {{{entry['title']}}},",
f" author = {{{authors_repr}}},",
f" booktitle = {{{entry['booktitle']}}},",
f" date = {{{entry['date']}}},",
f" address = {{{entry['address']}}},",
f" url = {{{entry['uPage']}}}",
"}",
]
bibtex = "\n".join(lines)
return bibtex
def export_coins(entry):
# "B. Bross, J. Chen, S. Liu, Y.-K. Wang"
authors = entry_authors(entry)
if len(authors) == 0:
return ""
if ". " in authors[0]:
author1_first, author1_last = authors[0].rsplit(". ", 1)
else:
author1_first, author1_last = "", authors[0]
data = {
"url_ver": "Z39.88-2004",
"ctx_ver": "Z39.88-2004",
"rft_val_fmt": "info:ofi/fmt:kev:mtx:book",
"rft.genre": "proceeding",
"rft.atitle": entry["title"],
"rft.btitle": entry["booktitle"],
"rft.place": entry["address"],
"rft.date": entry["date"],
"rft.aufirst": author1_first,
"rft.aulast": author1_last,
}
info = ""
for key, value in data.items():
encoded_value = urllib.parse.quote_plus(value)
info += f"{key}={encoded_value}&"
for author in authors[1:]:
encoded_value = urllib.parse.quote_plus(author)
info += f"rft.au={encoded_value}&"
info = info[:-5]
coins = f"<span class='Z3988' title='{info}'></span>"
return coins
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment