Jump to content

[Update!!]Currency converter workflow for Alfred 3


Recommended Posts

 

590ae60323483_ScreenShot2017-05-04at4_27_00PM.thumb.png.f1837a8b687c0a759c5873b481524591.png590ae60bd9515_ScreenShot2017-05-04at4_27_45PM.thumb.png.a448027da5e8d0c32b1c171c99417f41.png

 

I wrote a workflow in ruby to convert currency. Requires Alfred v3.

 

Notice: The Old versions(v1.2-) api has been out of service at June 5, 2018. Please update to v1.3+ to keep using currency conversion feature.

 

Github  Download

 

Features:

 

  1. Support 30+ currency units with fixer.io.
  2. Basic support for sign. e.g.,$,¥,£,etc.
  3. Customizable displayed currency units and base unit. Input once to get all result.

 

Usage:

 

  1. Tap 'cy' to get latest exchange rates. Tap 'cy money' to get exchanged result. You can press enter to send the result to the clipboard.
  2. Tap 'add-cy', 'remove-cy' to customize displayed currency units. Tap 'base-cy' to set base currency unit.

 

Hope you like it. :)

 

Edited by jin5354
Link to comment

This looks really clean, and the “Last Updated” is a welcome touch. Questions:

  • How often are exchange rates updated?
  • When are they updated, in the Workflow’s life? Meaning, are they auto-updated before or after we make queries, or at specific times (when?), or does it use another method?
  • Where is the exchange rates info coming from?

Requests:

  • Add Bitcoin support.
  • Let us type a number to get an immediate converted value.

And a small note:

  • There’s no point on zipping an Alfred Workflow. The .alfredworkflow format is itself a .zip with a renamed extension.


 

Edited by vitor
Link to comment
6 minutes ago, vitor said:

This looks really clean, and the “Last Updated” is a welcome touch. Questions:

 

  • How often are exchange rates updated?
  • When are they updated, in the Workflow’s life? Meaning, are they auto-updated before or after we make queries, or at specific times (when?), or does it use another method?
  • Where is the exchange rates info coming from?

 

The info comes from Fixer.io, a free api where you can get exchange rates published by the European Central Bank. Fixed.io updates it's data daily around 4PM CET(actually not accurately, maybe some delay or advance). Everytime we make queries it'll send request to fixer.io to get latest data.

 

I'll modify this workflow's extension later, thank you for your hint.:)

Link to comment
  • 4 months later...

Thanks for this. The currency converter I've used for the past few years died some months ago, with no sign of an update or fix. So I am glad to be able to switch over to this workflow you have kindly provided. Cheers...

 

P.S. The download file still needs to be unzipped. In case you forgot to correct that.

Edited by jenz
Link to comment
  • 1 month later...
  • 1 month later...
  • 1 month later...

Thank you for this wonderful workflow!

 

I was wondering how can I customize it as follows:

 

1. Remove the "cy" prefix to trigger the workflow, instead having the currency code itself (which is always a suffix) as the trigger (i. e. 100 USD or 100 EUR). This is similar to Spotlight.

2. Making the workflow work whether you put a space between the numeric value and the currency code or not (i. e. 100USD = 100 USD).

 
Thanks!
Link to comment
  • 4 weeks later...
  • 1 month later...

It would be nice if "cy EUR" (so without a number) would already display the exchange rates for in this case the EUR. Currently it is required to enter "cy 1 EUR" to get any results.

 

Furthermore it would be cool to have the option that the listed "converted to"-Currency aren't shown alphabetically, but in order of usage, so the workflow should learn and adapt to the currency I convert to (& copy the conversion result) most often. This allows me to just hit "Enter" or "Arrow down + Enter" to copy my desired result, instead of closely looking at the results and using "CMD + Listnumber".

Link to comment
  • 1 month later...
6 hours ago, ymolodtsov said:

The converter completely stopped working for some reason. It's a shame, it was the best one in my opinion. It can barely recognize its own command.

 

I just updated this post.

The old versions(v1.2-) api has been out of service at June 5, 2018. Please update to v1.3+ to keep using??.

Link to comment
  • 1 month later...

I've just noticed strange behaviour: for some reason it doesn't really work for euro when I specifically type it. Works with any other currency I choose, but if it's 'cy 100 eur' there it just falls back to the usual Alfred search.

Edited by ymolodtsov
Link to comment
On 7/17/2018 at 5:49 AM, ymolodtsov said:

I've just noticed strange behaviour: for some reason it doesn't really work for euro when I specifically type it. Works with any other currency I choose, but if it's 'cy 100 eur' there it just falls back to the usual Alfred search.

3

Sorry, I tried but cannot reproduce this issue, 'cy 100 eur' works fine at version 1.4 on my laptop. 'Falls back to the usual Alfred search' may be caused by occasional failed API request, because of the unstable network, which should back to normal after a few seconds or just retap the command. If you can 100% reproduce this issue please report the steps to me, thank you.:)

Link to comment

Not sure of the etiquette here, but I've modified this workflow to handle Bitcoin as well.

 

It's my first time ever writing Ruby, or for Alfred, so please bear with me if I'm not following best practices, and Jin5354 - if you wish to incorporate any of this into your existing code base (or improve upon it), by all means please feel free.

 

The only files that have been altered are BTC.png has been added to the flags directory, and convert.rb has been modified. However, rather than posting only those files and expecting people to take it apart and put it back together, I'll just post the modded workflow. It seems the board won't accept this file type as an attachment, so I just threw it on a file hosting service: https://nofile.io/f/2Orgj7NKZ7z/Currency.Convert.v1.4.btcmod.alfredworkflow

 

I hope that someone finds this useful, and if for any reason this is against etiquette or the rules, by all means let me know and I'll take it down.


Cheers!

Link to comment
4 minutes ago, AJCrowley said:

so please bear with me if I'm not following best practices

 

The proper and polite thing to do (for a project that hasn't been abandoned) would be to fork the workflow on GitHub (here's the link from the OP) and then submit a pull request with your changes there.

 

It's certainly helpful to users to provide an updated version of the exported workflow, but makes life unnecessarily difficult for the workflow developer if you'd like your changes incorporated upstream.

 

Link to comment
26 minutes ago, deanishe said:

 

The proper and polite thing to do (for a project that hasn't been abandoned) would be to fork the workflow on GitHub (here's the link from the OP) and then submit a pull request with your changes there.

 

Thanks, I did consider submitting a PR, but I don't know if the original dev would want this admittedly somewhat scrappy code in their lovely project. I wouldn't feel right submitting a PR without properly integrating it with the add/remove functionality, and for now, it's just hacked in there.


If they do, they're free to use it.

 

If I get around to developing a more elegant solution, I'll definitely fork/PR.

Edited by AJCrowley
Link to comment

Ok @deanishe, I've done it the right way.

 

Added in support for BTC through add/remove as with other currencies, and can also set BTC as the base.

 

I've forked the original author's repo and submitted a pull request. If there's anything else I should do to keep everything proper, I'd appreciate the advice!


In the meantime, you can check it out here: https://github.com/AJCrowley/alfred3-workflow-CurrencyConvert

 

Thanks!

Edited by AJCrowley
Link to comment
  • 1 month later...

Api url on Exchange Rate Api.io has changed to https://api.exchangeratesapi.io/latest

So in code, u need to replace https://exchangeratesapi.io/api/latest with https://api.exchangeratesapi.io/latest (add.rb, base.rb, convert.rb and remove.rb)

Maybe this could be replaced by some variable so in case of this change u don't need to replace it on 6 places

 

Cheers,

   DD

 

Link to comment
  • 3 weeks later...

This does not work for me. I have downloaded both versions 1.5 and 1.3 with the same result. Alfred does not recognize the units.

Double clicking the .alfredworkflow file does not properly install the workflow. 

Thanks for any suggestions to fix. 

 

Output from debugging mode is below:

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Starting debug for 'Currency Convert'

[2018-09-16 13:01:06][ERROR: input.scriptfilter] Code 1: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:918:in `connect': SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: sslv3 alert handshake failure (OpenSSL::SSL::SSLError)
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:918:in `block in connect'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/timeout.rb:52:in `timeout'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:918:in `connect'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:862:in `do_start'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:851:in `start'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:582:in `start'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:477:in `get_response'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:454:in `get'
    from ./convert.rb:80:in `<main>'
[2018-09-16 13:01:10][ERROR: input.scriptfilter] Code 1: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:918:in `connect': SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: sslv3 alert handshake failure (OpenSSL::SSL::SSLError)
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:918:in `block in connect'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/timeout.rb:52:in `timeout'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:918:in `connect'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:862:in `do_start'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:851:in `start'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:582:in `start'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:477:in `get_response'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:454:in `get'
    from ./convert.rb:50:in `<main>'
[2018-09-16 13:01:10][ERROR: input.scriptfilter] Code 1: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:918:in `connect': SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: sslv3 alert handshake failure (OpenSSL::SSL::SSLError)
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:918:in `block in connect'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/timeout.rb:52:in `timeout'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:918:in `connect'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:862:in `do_start'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:851:in `start'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:582:in `start'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:477:in `get_response'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:454:in `get'
    from ./convert.rb:50:in `<main>'
[2018-09-16 13:01:10][ERROR: input.scriptfilter] Code 1: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:918:in `connect': SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: sslv3 alert handshake failure (OpenSSL::SSL::SSLError)
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:918:in `block in connect'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/timeout.rb:52:in `timeout'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:918:in `connect'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:862:in `do_start'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:851:in `start'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:582:in `start'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:477:in `get_response'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:454:in `get'
    from ./convert.rb:50:in `<main>'
[2018-09-16 13:01:11][ERROR: input.scriptfilter] Code 1: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:918:in `connect': SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: sslv3 alert handshake failure (OpenSSL::SSL::SSLError)
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:918:in `block in connect'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/timeout.rb:52:in `timeout'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:918:in `connect'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:862:in `do_start'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:851:in `start'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:582:in `start'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:477:in `get_response'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:454:in `get'
    from ./convert.rb:50:in `<main>'
[2018-09-16 13:01:11][ERROR: input.scriptfilter] Code 1: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:918:in `connect': SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: sslv3 alert handshake failure (OpenSSL::SSL::SSLError)
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:918:in `block in connect'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/timeout.rb:52:in `timeout'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:918:in `connect'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:862:in `do_start'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:851:in `start'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:582:in `start'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:477:in `get_response'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:454:in `get'
    from ./convert.rb:50:in `<main>'

 

------------------------------------------------------------------------------------------------------------

Screen Shot 2018-09-16 at 12.59.58 PM.png

Screen Shot 2018-09-16 at 12.59.47 PM.png

Link to comment

Hi @StevenP, welcome to the forum.

 

14 minutes ago, StevenP said:

This does not work for me. I have downloaded both versions 1.5 and 1.3 with the same result

 

By the looks of it, the problem isn't the workflow, it's your system:

 

sslv3 alert handshake failure (OpenSSL::SSL::SSLError)

 

Which version of macOS are you using? If it's older than High Sierra, it has a very, very old version of OpenSSL that does not support SSLv3.

 

 

Edited by deanishe
Link to comment
53 minutes ago, deanishe said:

Hi @StevenP, welcome to the forum.

...

Which version of macOS are you using? If it's older than High Sierra, it has a very, very old version of OpenSSL that does not support SSLv3.

 

Yes, I'm using Yosemite. OK, so I can resolve by updating the OS.

Is it possible to install an older version of Currency converter to use with an OS like Yosemite?

Thanks in any event,

SP

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...