Hi Christiaan,

I see there is a “download” verb indeed. I don’t quite understand how to use 
it. Could you provide an example please?

Best wishes,

Luc


> On 18 Jul 2020, at 23:17, Christiaan Hofman <cmhof...@gmail.com> wrote:
> 
> What you could also do is add the URL for the PDF (if you can construct it, 
> e.g. as a oadoi.org <http://oadoi.org/> URL) to the imported item, and then 
> using the download command to let BibDesk download it.
> 
> Christiaan
> 
>> On 18 Jul 2020, at 20:03, Luc Bourhis via Bibdesk-users 
>> <bibdesk-users@lists.sourceforge.net 
>> <mailto:bibdesk-users@lists.sourceforge.net>> wrote:
>> 
>> Hi Jason,
>> 
>> sure. My script takes a DOI from the clipboard, then add a new record as 
>> well as grabbing the PDF from sci-hub. The latter part is done with a Ruby 
>> script. Unfortunately it sometimes fail, in which case, I just open the 
>> sci-hub page in Safari, and then I get the PDF manually, and drop it in the 
>> newly created Bibdesk entry. You could easily edit my script to always do 
>> that. Here is the Applescript part. Notice that I rely on the Applescript 
>> library _string. It can still be found thanks to the wayback machine at 
>> https://web.archive.org/web/20170816081647/http://applescript.bratis-lover.net/library/string/
>>  
>> <https://web.archive.org/web/20170816081647/http://applescript.bratis-lover.net/library/string/>
>> 
>> I have a similar script automatically creating entries from an arxiv number 
>> (this is a preprint server very popular with mathematicians and physicists).
>> 
>> Best wishes,
>> 
>> Luc
>> 
>> 
>> set _string to load script alias ((path to home folder as text) & 
>> "Developer:AppleScript:_string.scpt")
>> 
>> property scihub : true
>> property debug : false
>> 
>> set myShellPrefs to load script file ((path to preferences as string) & 
>> "org.ljbo3.shell.scpt")
>> 
>> set pdf to null
>> if scihub then
>>      tell application "Finder" to get (container of (path to me)) as string
>>      set here to POSIX path of result
>>      try
>>              do shell script (myShell of myShellPrefs) & " -c 'cd \"" & here 
>> & "\"; cd ruby; rbenv exec bundler exe ruby download_from_sci_hub.rb " & 
>> (the clipboard) & "'"
>>              set pdf to result
>>      on error errmsg number errno
>>              tell application "Safari"
>>                      if debug then
>>                              display dialog "Download failed!"
>>                      end if
>>                      open location "https://sci-hub.tw/ 
>> <https://sci-hub.tw/>" & (the clipboard)
>>                      activate
>>              end tell
>>      end try
>> end if
>> tell application "BibDesk"
>>      try
>>              set doc to get first document
>>      on error errmsg number errno
>>              display dialog "Please open a BibDesk document first!" buttons 
>> {"OK"}
>>              return
>>      end try
>>      set doi to the clipboard as text
>>      set doi to _string's lstripString(_string's trimStart(doi), 
>> "https://doi.org/ <https://doi.org/>")
>>      set pubs to (import doc from doi)
>>      if length of pubs = 1 then
>>              set pub to item 1 of pubs
>>      else
>>              display notification "I did not find any publication with that 
>> DOI."
>>              return
>>      end if
>>      tell pub
>>              if pdf is not null then
>>                      add (POSIX file pdf) to beginning of linked files
>>                      auto file
>>              end if
>>      end tell
>>      show pub
>> end tell
>> 
>> 
>>> On 13 Jul 2020, at 14:37, Craggs, Jason G. <crag...@health.missouri.edu 
>>> <mailto:crag...@health.missouri.edu>> wrote:
>>> 
>>> Luc,
>>> 
>>> That sounds like a great script. The first thing that came to mind: could 
>>> you add a timer of some sort and then refresh/reload?
>>> 
>>>  Any chance of sharing?
>>> 
>>> Cheers,
>>> Jason 
>>> 
>>> Sent from my phone; please pardon any communication catastrophes.
>>> 
>>> On Jul 13, 2020, at 7:27 AM, Luc Bourhis via Bibdesk-users 
>>> <bibdesk-users@lists.sourceforge.net 
>>> <mailto:bibdesk-users@lists.sourceforge.net>> wrote:
>>> 
>>> 
>>> WARNING: This message has originated from an External Source. This may be a 
>>> phishing expedition that can result in unauthorized access to our IT 
>>> System. Please use proper judgment and caution when opening attachments, 
>>> clicking links, or responding to this email.
>>> Hi,
>>> 
>>> I have an AppleScript executing the following statements
>>> 
>>> add (POSIX file pdf) to beginning of linked files
>>> auto file
>>> 
>>> It works perfectly except that the thumbnail is not generated. I am talking 
>>> about that which appears in the item windown and in the right panel of the 
>>> main window. I get a generic white document icon instead. Right-clicking on 
>>> it and choosing “Reload” does create the thumbnail fine. It would be nice 
>>> if the script was able to do that without my intervention!
>>> 
>>> Version 1.7.7 on MacOS 10.14.6.
>>> 
>>> Best wishes,
>>> 
>>> Luc J Bourhis
> 
> _______________________________________________
> Bibdesk-users mailing list
> Bibdesk-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/bibdesk-users

_______________________________________________
Bibdesk-users mailing list
Bibdesk-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-users

Reply via email to