Push Tabs from Mobile Safari to Safari on the Mac | macorios.com
I found this post through ticci’s Pinboard, I think. Not sure anymore. I wanted to change the script, but couldn’t figure out how. I’m still not very good at Python.
First what does this Python script do: It uses Pythonista to create and upload a .webloc file to Dropbox, which Hazel opens with your default browser.
The only thing I wanted to change was instead of pushing a .webloc file, I would prefer to safe a plain text file. This post describes how you can configure Hazel to search through a text file and make it open any links contained in it. (Mentioned in the Hazel tutorial.)
Although the change to the script is very easy, I couldn’t figure out how to configure Pythonista to use the entire Dropbox rather than its own app directory. The reason being that Pythonista has a Dropbox sync script, which requires to use an app directory. This way there’s now a folder in the Pythonista folder with all the links, which every Pythonista installation syncs and Hazel monitors one more folder. Oh well.
Enough whining. Changed script:
import sys from dropboxlogin import get_client dropbox_client = get_client() import datetime s = sys.argv #get URL fmt = '%Y-%m-%d_%H.%M.%S' #Get and define time and date dt = str(datetime.datetime.now().strftime(fmt)) ##Make a time and date stamp newname = 'Link_' + dt + '.txt' #Rename file to ‘Link_date_time.webloc’ print newname + s response = dropbox_client.put_file('/Attachments/' + newname, s) #Upload file to Dropbox