• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Automating the GraphicConverter Beta Download
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Automating the GraphicConverter Beta Download


  • Subject: Automating the GraphicConverter Beta Download
  • From: Christopher Stone <email@hidden>
  • Date: Fri, 07 Sep 2012 04:46:31 -0500

On Sep 07, 2012, at 02:58, Thorsten Lemke wrote:
I released a new beta.
______________________________________________________________________

Hey Folks,

I usually use Progressive Downloader to download GraphicConverter (and its betas), because it does a better job of maxing-out my bandwidth than most methods.  I got tired of manually doing this, so I wrote a script for the beta download (appended).

The script depends upon Safari to scrape the GC url, which works well for me since Safari is always running on my machine.  The script also opens the correct page, 

While I was at it I also wrote an alias for my bash profile, so I could easily do it from the Terminal as well.

alias dlgcb='cd ~/Downloads; URL="" -sL http://www.lemkesoft.org/beta.html | egrep -i "href="" | awk -F\" '\''{ print $2 }'\''`; curl --remote-name-all -L "${URL}"'

I took a quick look at the regular GC download page, and it should be easily possible to adapt this to download the production app.  I might try to build in some intelligence, so the script checks the version of GC on the machine and only downloads if the file online is newer.

--
Best Regards,
Chris

------------------------------------------------------------------------------------------------
#       Author: Christopher Stone <email@hidden>
#      Created: 2012-09-07 : 03:16
#     Modified: 2012-09-07 : 03:57
#  Application: Safari & Progressive Downloader
#      Purpose: Download GraphicConverter Beta
# Dependencies: None: Only stock OSX components used.
------------------------------------------------------------------------------------------------
--» HANDLERS
------------------------------------------------------------------------------------------------
on goGCBetaPage()
  tell application "Safari"
    make new document with properties {URL:"http://www.lemkesoft.org/beta.html"}
  end tell
end goGCBetaPage
------------------------------------------------------------------------------------------------
on progressiveDownload(_referer, _linkList, _destination)
  tell application "Progressive Downloader"
    activate
    repeat with i in _linkList
      set _task to make new task
      tell _task
        set address to i
        set referer to _referer
        set destination to _destination
      end tell
    end repeat
    if (count of tasks) > 0 then
      resume every task
    else
      error "No Tasks in Progressive Downloader!"
    end if
  end tell
end progressiveDownload
------------------------------------------------------------------------------------------------
on safari_links(regexStr, tagName, tagType)
  set js to "function in_array (array, item) {
  for (var i=0; i < array.length; i++) {
    if ( array[i] == item ) {
      return true;}}
  return false;}
  var a_tags = document.getElementsByTagName('" & tagName & "');
  var href_array = new Array();
  var reg = new RegExp(/" & regexStr & "/i);
  for (var i=0; i < a_tags.length; i++) {
    var href = "" style="font-family: Verdana; color: rgb(0, 0, 0); "> & tagType & ";
    if ( reg.test(href)) {
      if ( !in_array(href_array, href)) {
        href_array.push(href);}}}
 href_array;"
  try
    tell application "Safari" to set linkList to do _javascript_ js in document 1
  on error
    set linkList to {}
  end try
  return linkList
end safari_links
------------------------------------------------------------------------------------------------
on safari_url()
  tell application "Safari" to return URL of front document
end safari_url
------------------------------------------------------------------------------------------------
--» MAIN
------------------------------------------------------------------------------------------------
try

  

  goGCBetaPage()
  delay 0.2
  set pageURL to safari_url()
  set regexStr to "gc.*\\.dmg"
  set linkList to safari_links(regexStr, "*", "href")
  if linkList ≠ {} then
    set linkList to item 1 of linkList as list
    progressiveDownload(pageURL, linkList, POSIX path of (get path to downloads folder))
  end if

  

on error e number n
  set e to "Error: " & e & return & return & "Error Number: " & n
  beep
  tell me to set dDlg to display dialog e buttons {"Cancel", "Copy", "OK"} default button "OK"
  if button returned of dDlg = "Copy" then set the clipboard to e
end try
------------------------------------------------------------------------------------------------

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Re: Downloading the APOD from Safari
  • Next by Date: Re: Downloading the APOD from Safari
  • Previous by thread: Re: Downloading the APOD from Safari
  • Next by thread: GraphicConverter Download
  • Index(es):
    • Date
    • Thread