Jump to content


  • Content Count

  • Joined

  • Last visited

Posts posted by elsatch

  1. After some additional trials, I have just discovered that Workflow cache doesn't work exactly as I expected.


    My goal was to retrieve details from a Youtube video and store them in Workflow cache. As I would repeat my workflow several times, it would make the most sense to have them cached to prevent other queries to the API.


    As an example, I would type in Alfred: yd ckN-uJn9hAI (This will get details from the video at http://youtu.be/ckN-uJn9hAI). I would load each of the details I use more often in Workflow args and send those back to Alfred. I would select one, press enter and that would copy to my clipboard.


    As I retype again the same command, it would retrieve data from the cache and I could copy all the other details. If I wanted to get another video details, I could do yd otherVideoID, but it would still bring back the details from the first video. Given that wf.cache triggers new queries based on time, it would probably fail to bring back the updated details.


    It seems that I will need to create a custom function for this usage, checking the query against previous stored keys and launching the API call just when necessary.


    If there is any other alternative/better way to do this, I would appreciate any kind of advice. It's my first time creating Workflows :)

  2. First of all, thanks for creating this plugin for Alfred!


    I have followed the tutorials to create an extension to access my Youtube video data. Usually I need to retrieve title or description to reuse it somewhere else. I was planning to share it with in Packal so other people can use it too. I created this description of how it works:


    Youtube Video Search

    This workflow retreives details about your latest videos from Youtube. 

    To set it up, you need to configure your Youtube ChannelID and API Key. To do so execute the following commands:
        - ytsetkey: Without parameters, it will take you to the Youtube API page to get your API key. If you supply your API Key as a parameter, it will be stored in your Keychain (and synced among devices).
        - ytsetchannel: Without parameters, it will take you to Youtube Advance Setting page to retrieve your channel ID. If you pass the channel ID as a parameter, it will be stored in the workflow settings. 

    It has the following keywords defined:
        - ys (Youtube Search): retrieves the latest 50 posts from your Youtube account. When you press enter on the results, the video ID will be copied to your clipboard.
        - yo (Youtube Open): takes a video ID as a parameter and opens the Youtube video website for that video.
        - yd (Youtube Details): takes a video ID as a parameter and lists the video details. Pressing enter will copy the result to the clipboard.

    If you ever need to reset this workflow parameters, you can do so using the Magic argument: ys workflow:delsettings.

    Bugs: VideoIDs starting with hypens, breaks the yd call.


    So far everything is working but the Youtube Details keyword. It works if:

    a) Running from the console and passing the parameter, returns correct results. 

    b) Disabling cache in the code and passing static parameter, returns correct results.


    If I try to make it run, it shows the correct message and reverts to default search in a second.


    I have tried the debug option in Alfred and my hypothesis is:

    a) Alfred evaluates yd as I finish typing d (after y)

    b) It evaluates query as empty and passes that as a parameter to get_video_details

    c) Query is sent to Youtube, but it lacks video_id, so it's incomplete.

    d) It returns a JSON that is an empty list (JSON is {u'items': [], u'kind': u'youtube#videoListResponse', u'etag': u'"nlUZBA6NbTS7q9G8D1GljyfTIWI/Rk41fm-2TD0VG1yv0-bkUvcBi9s"', u'pageInfo': {u'resultsPerPage': 0, u'totalResults': 0}}

    e) This empty list is cached

    f) All following searchs are launched against cached data, returning empty responses.


    Argument is set to "Argument Required"


    Is there any way to have Alfred to wait until pressing Enter or Tab before launching the Script Filter?






  • Create New...