tmp=$(mktemp /tmp/arxiv-bib.sh.XXXXXX)
-curl > "${tmp}" "https://arxiv.org/abs/$1"
+while [[ "$1" ]]
+do
-AUTHORS=""
+ id="$1"
-while read line
-do
- [[ "${AUTHORS}" ]] && AUTHORS="${AUTHORS} and "
- AUTHORS="${AUTHORS}${line}"
-done < <(grep '<meta name="citation_author"' "${tmp}" | sed -e 's/^.*content="\([^,]*, .\).*$/\1./')
+ if [[ ${id} =~ ^http ]]
+ then
+ id="$(echo "${id}" | sed -e 's|^.*/\([^\]*\)$|\1|')"
+ fi
+
+ curl -s > "${tmp}" "https://arxiv.org/abs/${id}"
+
+ AUTHORS=""
+
+ while read line
+ do
+ [[ "${AUTHORS}" ]] && AUTHORS="${AUTHORS} and "
+ AUTHORS="${AUTHORS}${line}"
+ done < <(grep '<meta name="citation_author"' "${tmp}" | sed -e 's/^.*content="\([^,]*, .\).*$/\1./')
-TITLE=$(grep '<meta name="citation_title"' x | sed -e 's/^.*content="\([^"]*\)".*$/\1/')
-YEAR=$(echo $1 | sed -e 's/^\(..\).*$/20\1/')
+ TITLE=$(grep '<meta name="citation_title"' ${tmp} | sed -e 's/^.*content="\([^"]*\)".*$/\1/')
+ YEAR=$(echo ${id} | sed -e 's/^\(..\).*$/20\1/')
-cat <<EOF
-@article{arxiv-$1,
+ cat <<EOF
+@article{arxiv-${id},
author={${AUTHORS}},
title={${TITLE}},
journal={CoRR},
- volume={abs/$1},
+ volume={abs/${id}},
year={${YEAR}},
- url={https://arxiv.org/pdf/$1}
+ url={https://arxiv.org/pdf/${id}}
}
EOF
-rm -rf ${tmp}
+ shift
+
+done
+
+
+
+ rm -rf ${tmp}