sckott / habanero

client for Crossref search API

Home Page:https://habanero.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Replacement of forward slash in URL

tardigradus opened this issue · comments

With Python 3.6.8 and habanero 0.7.4, the / in the DOI-part of the field url is replaced by %2F, e.g.
the bibtex entry returned by www.doi2bib.org for the DOI 10.1021/acs.jpcc.0c05161 has the element

url = {https://doi.org/10.1021/acs.jpcc.0c05161}

However, when I run

bibtex_string = habanero.cn.content_negotiation(ids = doi)

with that DOI, the string I obtain contains

url = {https://doi.org/10.1021%2Facs.jpcc.0c05161}

Is this supposed to happen?

Thanks for the issue. Can you show a complete example? including whats returned

if you do a curl request in bash/etc. the url is already like that, so it's not habanero

curl -L -H "Accept: application/x-bibtex" "https://doi.org/10.1021/acs.jpcc.0c05161"
@article{Shao_2020,
	doi = {10.1021/acs.jpcc.0c05161},
	url = {https://doi.org/10.1021%2Facs.jpcc.0c05161},
	year = 2020,
	month = {oct},
	publisher = {American Chemical Society ({ACS})},
	volume = {124},
	number = {43},
	pages = {23479--23489},
	author = {Jingjing Shao and Vincent Pohl and Lukas Eugen Marsoner Steinkasserer and Beate Paulus and Jean Christophe Tremblay},
	title = {Electronic Current Mapping of Transport through Defective Zigzag Graphene Nanoribbons},
	journal = {The Journal of Physical Chemistry C}
}

Thanks for looking at this. An MWE is

import habanero
bibtex_string = habanero.cn.content_negotiation(ids='10.1021/acs.jpcc.0c05161')
print(bibtex_string)

which results in

@article{Shao_2020,
        doi = {10.1021/acs.jpcc.0c05161},
        url = {https://doi.org/10.1021%2Facs.jpcc.0c05161},
        year = 2020,
        month = {oct},
        publisher = {American Chemical Society ({ACS})},
        volume = {124},
        number = {43},
        pages = {23479--23489},
        author = {Jingjing Shao and Vincent Pohl and Lukas Eugen Marsoner Steinkasserer and Beate Paulus and Jean Christophe Tremblay},
        title = {Electronic Current Mapping of Transport through Defective Zigzag Graphene Nanoribbons},
        journal = {The Journal of Physical Chemistry C}
}

I was comparing this with the output on the page

https://www.doi2bib.org/bib/10.1021/acs.jpcc.0c05161

but this comparison is obviously invalid. Am I just stuck with what Crossref returns and have to tweak the string myself, or are there some knobs I can turn when I access the API?

Thanks for the example.

Looks like an easy fix is to do:

import habanero
bibtex_string = habanero.cn.content_negotiation(ids='10.1021/acs.jpcc.0c05161')
from urllib.parse import unquote
unquote(bibtex_string)

I may put something like this in habanero, but I'm waiting to hear back to see if it can be fixed on their side

Thanks, WFM!

issue https://gitlab.com/crossref/issues/-/issues/1612

its in their backlog for now, will keep this open until fixed

still in the backlog, seems like it's not getting fixed