• calebaharrison208

    Hi: I've got an action extension through the Workflow App that calls and runs the following URL-shortening (via Bitly) Pythonista script:

    import requests
    import json
    import clipboard
    import webbrowser
    import console
    
    LongURL = str(clipboard.get())
    
    query_params = {'access_token' : 'MYTOKEN',
                    'longUrl' : str(clipboard.get())}
                    
    endpoint = 'https://api-ssl.bitly.com/v3/shorten'
    response = requests.get(endpoint, params= query_params)
    
    data = json.loads(response.content)
    
    if data['status_code'] != 500:
        clipboard.set(data['data']['url'])
        webbrowser.open('safari-'+LongURL)
    
    if data['status_code'] == 500:
        alert = console.alert('URL already shortened!', 'Return to Safari?', 'Safari', hide_cancel_button=True)
        if alert == 0:
            webbrowser.open('safari-'+LongURL)
    

    Is there a URL scheme that will just open Safari in iOS to the last opened tab/page? That is, I currently can't figure out a way to return to Safari after running the Pythonista action without telling Safari to open either a blank page or a specific page (in this case, the initial URL that I shortened, to prevent my returning to Safari from counting as a link view).

    I've tried safari-http://a to see if that would work, to no avail. Any help is appreciated!

    posted in Pythonista read more
  • calebaharrison208

    Hey Folks,

    I'm having a hard time figuring out my workflow, here. My goal is this:

    • Visit any webpage (specifically those with 'www.' subdomain)
    • Hit javascript bookmarklet
    • Bookmarklet sends domain name to Editorial, which strips 'www.' from domain
      • Some of my 1p website fields do not have the 'www.' in them, and won't be found (i.e. 'www.google.com' does not pull up 'google.com')
    • Editorial sends stripped text to 1p as search.

    Here's what I have so far.

    ###Bookmarklet

    javascript:window.location='editorial://?command=1pSearch&input='+window.location.hostname

    The command runs, but it just runs the command on an empty input, it seems. That is, 1p launches with a blank search.

    ###1pSearch Workflow

    Here's the link to my workflow.

    Any help is appreciated!

    posted in Editorial read more
  • calebaharrison208

    Ah, took me some time to figure out how to script that with JS, but you're right, it works better that way. If anybody is interested, here's my bookmarklet:

    javascript:text=window.location.hostname;if(/www\./.test(text)){text=text.replace(/www\./,"");window.location='onepassword://search/'+text;}else{window.location='onepassword://search/'+text;}
    

    Thanks for the quick response, Ole!

    posted in Editorial read more
  • calebaharrison208

    Okay, so bear in mind, I'm very new to python, Pythonista, and coding in general. [e.g. halfway through Udacity's Intro to Comp Sci course new.] So I will understand if the best answer is to my question is "play around with it until it works".

    Right now, I have the following set up:

    -PushMenu [https://github.com/kalcher/pushmenu] allows me to send text from the OS X pasteboard to my iOS devices via Growl + Prowl [www.prowlapp.com]

    -Prowl [which is able to launch custom URL schemes upon receiving a notification] opens the push notification containing the text that was sent over by PushMenu

    At this point, I have to open Prowl, select the text, and paste it into whatever place I need it. I would LIKE to have a Pythonista script that Prowl can auto-launch upon receiving a push notification. I imagine it would act as follows:

    -Get content of push notification [Prowl's API seems to allow this in conjunction with some python libraries that were created, though I'm not proficient at weeding through APIs: http://www.prowlapp.com/api.php and https://github.com/babs/pyrowl]

    -Copy content to iOS clipboard

    Once these steps are done, I imagine I could either just navigate to the app I wish to use the clipboard in, or perhaps send it to a Drafts/Launch Center Pro action.

    Again, I realize I'm basically doing an entire script request here, so if that's too much work don't worry about it. That being said, it would be great to have a (relatively) seamless way to transfer clipboards from OS X to iOS. If anybody has any advice/suggestions regarding how this could be done or why it can't be, I would greatly appreciate it! TIA

    posted in Pythonista read more
  • calebaharrison208

    Right you are. Thanks!

    posted in Pythonista read more
  • calebaharrison208

    I currently have two scripts in Pythonista that work great: one adds iOS clipboard to .txt file in Dropbox, the other adds contents of .txt file in Dropbox to iOS clipboard. I am using this to "sync" clipboards between iOS and OS X. I am also attempting to use LaunchCenterPro to run the two scripts.

    However, whenever I select the scripts in LaunchCenterPro, I get the following error message:

    http://d.pr/i/sygG [Not Found: You have no script with the name 'CBtoDB.py' in your library.]

    (I also get this note when I am creating an iOS desktop shortcut to actions using 'http://omz-software.com/pythonista/shortcut'.)

    Does anybody know what is going on? As you can see in my screenshot, I clearly do have a file named 'CBtoDB'...so what gives? Why is '.py' being appended to my action names? Thanks!

    posted in Pythonista read more
  • calebaharrison208

    @ccc @filippocld wow, you two rock! Thank you so much. I will fiddle with it this afternoon and try to get it all set up with the Prowl api and such. There's a high chance I may come crawling back, begging for help...but I will try not to. :)

    posted in Pythonista read more
  • calebaharrison208

    filippocld: I would love to make it myself (and share it!) but as I said, I'm very new to both python and Pythonista. I don't really understand what sort of functions/libraries I need to use/to import to do this. In other words, I can see most of the pieces to the puzzle (at least I think I can..), but I have no idea how to begin fitting them together.

    (I'm responding as if you meant to type 'why' rather than 'who' -- sorry if that is a mistake on my part)

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!