Skip to content

Instantly share code, notes, and snippets.

@bcdavasconcelos
Last active January 6, 2020 23:40
Show Gist options
  • Save bcdavasconcelos/5a5c0d8c1aae10d6ee19289f3cb8670f to your computer and use it in GitHub Desktop.
Save bcdavasconcelos/5a5c0d8c1aae10d6ee19289f3cb8670f to your computer and use it in GitHub Desktop.
Still on test phase, so to speak. #Archive
tell application id "DNtp"
set theRecords to the selection
if theRecords is {} then error "Please select some contents."
repeat with theRecord in theRecords
set customMD to custom meta data of theRecord
try
set theBibkey to mdbibkey of customMD
on error
set theBibkey to ""
end try
try
set thebibkey2 to ""
set the thebibkey2 to "http://127.0.0.1:23119/better-bibtex/items?/" & theBibkey & ".csljson"
set the json_record to download JSON from thebibkey2
set the json_record to item 1 of json_record
set theAuthor to family of item 1 of author of json_record & ", " & |given| of item 1 of author of json_record
add custom meta data theAuthor for "authors" to theRecord
set theTitle to title of json_record
add custom meta data theTitle for "title" to theRecord
set thePublisher to publisher of json_record
add custom meta data thePublisher for "publisher" to theRecord
set theJournal to |container-title| of json_record as text
add custom meta data theJournal for "journal" to theRecord as text
set thePlace to |publisher-place| of json_record
add custom meta data thePlace for "place" to theRecord
set theYear to item 1 of item 1 of |date-parts| of issued of json_record
add custom meta data theYear for "date" to theRecord
set theLanguage to language of json_record
add custom meta data theLanguage for "Language" to theRecord
set theDoi to DOI of json_record
add custom meta data theDoi for "doi" to theRecord
set theISBN to ISBN of json_record
add custom meta data theISBN for "is?n" to theRecord
set theSeries to |collection-title| of json_record
add custom meta data theSeries for "sertitle" to theRecord
set theType to |type| of json_record
add custom meta data theType for "type" to theRecord
set theEditor to family of item 1 of editor of json_record & ", " & |given| of item 1 of editor of json_record
add custom meta data theEditor for "editor" to theRecord
set theTranslator to family of item 1 of translator of json_record & ", " & |given| of item 1 of translator of json_record
add custom meta data theTranslator for "Translator" to theRecord
set theURL2 to |url| of json_record
add custom meta data theURL2 for "URL2" to theRecord
set theAbstract to abstract of json_record
add custom meta data theAbstract for "abstract" to theRecord
end try
end repeat
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment