├── README.md ├── Source ├── Calculate.py ├── CurrencyExchange.py ├── icon.png └── info.plist ├── app_key.jpg ├── customize.jpg ├── jpy.jpg └── usd.jpg /README.md: -------------------------------------------------------------------------------- 1 | # Currency 2 | 3 | Alfred Workflow Currency Exchange. Convert any currency to CNY. 4 | 5 | ## API 6 | 7 | The free API is from [jisuapi.com](https://www.jisuapi.com/) 8 | 9 | Please apply from here: 10 | [https://www.jisuapi.com/api/exchange/](https://www.jisuapi.com/api/exchange/) 11 | 12 | Then fill in the appkey in Alfred Workflows Environment Variables. 13 | ![app_key](app_key.jpg) 14 | 15 | ## Usage 16 | ``` 17 | usd 100 18 | ``` 19 | 20 | ![usd](usd.jpg) 21 | 22 | ``` 23 | jpy 1000 24 | ``` 25 | 26 | ![jpy](jpy.jpg) 27 | 28 | Press enter than the result will copy to you clipboard. 29 | 30 | ## Customize 31 | 32 | Here is the code in workflow editor. 33 | 34 | ```shell 35 | python3 Calculate.py THB CNY $1 36 | ``` 37 | 38 | You can convert any currency to another by modify the Script text field, like THB to CNY. 39 | 40 | ![customize](customize.jpg) -------------------------------------------------------------------------------- /Source/Calculate.py: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/python3 2 | # -*- coding: UTF-8 -*- 3 | 4 | import sys 5 | import os 6 | from CurrencyExchange import CurrencyExchange 7 | 8 | # please config app_key in Workflow Environment Variables 9 | app_key = os.getenv('app_key') 10 | # from currency 11 | original_currency = sys.argv[1] 12 | # to currency 13 | destination_currency = sys.argv[2] 14 | # alfred input amount 15 | input = sys.argv[3].replace(",", "") 16 | query = float(input) 17 | 18 | currency_exchange = CurrencyExchange(app_key) 19 | currency_exchange.calculate(original_currency, destination_currency, query) 20 | -------------------------------------------------------------------------------- /Source/CurrencyExchange.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | # -*- coding: UTF-8 -*- 3 | 4 | import urllib.parse 5 | from urllib import request 6 | import json 7 | 8 | 9 | class CurrencyExchange: 10 | api = "https://api.jisuapi.com/exchange/convert" 11 | 12 | def __init__(self, app_key): 13 | self.app_key = app_key 14 | 15 | def calculate(self, original_currency, destination_currency, input_amount): 16 | param = {'from': original_currency, 'to': destination_currency, 'appkey': self.app_key, 'amount': input_amount} 17 | param_string = urllib.parse.urlencode(param) 18 | url = self.api + "?" + param_string 19 | with request.urlopen(url) as f: 20 | data = f.read() 21 | if f.status == 200: 22 | content = data.decode('utf-8') 23 | result = json.loads(content) 24 | if result['status'] == 0: 25 | exchange = result['result']['rate'] 26 | output_amount = result['result']['camount'] 27 | subtitle = str(input_amount) + " " + original_currency + " to " + destination_currency + " with exchange rate " + exchange + " = " + str( 28 | output_amount) 29 | output_dict = {'items': [{'title': output_amount, 'subtitle': subtitle, 'arg': output_amount}]} 30 | print(json.dumps(output_dict)) 31 | else: 32 | print(str(result['status']) + ':' + result['msg']) 33 | else: 34 | print('request fail') -------------------------------------------------------------------------------- /Source/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adin283/Currency/5b67fb232c4990984c063377be6f3e4ae5bc184e/Source/icon.png -------------------------------------------------------------------------------- /Source/info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | bundleid 6 | com.kevinlab.currency 7 | category 8 | Tools 9 | connections 10 | 11 | 08CFA9A0-B23C-40F2-A831-6271B32D6C37 12 | 13 | 14 | destinationuid 15 | BD0B2D10-2B56-4E3E-8AEF-474C2518DD97 16 | modifiers 17 | 0 18 | modifiersubtext 19 | 20 | vitoclose 21 | 22 | 23 | 24 | 3E0D43CD-D9DA-4A5E-B890-F36273751535 25 | 26 | 27 | destinationuid 28 | F87DBD9F-58AB-4F2B-92C3-A184B1E93FFF 29 | modifiers 30 | 0 31 | modifiersubtext 32 | 33 | vitoclose 34 | 35 | 36 | 37 | 412728A2-AD7C-41EC-BDBE-6F25C9148F74 38 | 39 | 40 | destinationuid 41 | B694857D-9F42-4749-B720-E08E123004F5 42 | modifiers 43 | 0 44 | modifiersubtext 45 | 46 | vitoclose 47 | 48 | 49 | 50 | 852302C7-5FBA-4AD0-BD3E-68A3FBE28587 51 | 52 | 53 | destinationuid 54 | B75DAC7C-6320-4E93-8F0C-B44ADB7E1FD6 55 | modifiers 56 | 0 57 | modifiersubtext 58 | 59 | vitoclose 60 | 61 | 62 | 63 | 8F28771A-0449-4FD5-95CB-3C9CCA45526B 64 | 65 | 66 | destinationuid 67 | 30CC47E3-1DA1-4F10-BB0E-70931676BF60 68 | modifiers 69 | 0 70 | modifiersubtext 71 | 72 | vitoclose 73 | 74 | 75 | 76 | 8F339D26-DB7E-49BA-9D5A-452C084832F6 77 | 78 | 79 | destinationuid 80 | 9CDFACD8-142D-404F-BDEA-95A09778FCD1 81 | modifiers 82 | 0 83 | modifiersubtext 84 | 85 | vitoclose 86 | 87 | 88 | 89 | D34AD9B8-149A-42F3-8A24-976F78F89B6D 90 | 91 | 92 | destinationuid 93 | 6AC0EA93-72EF-4BBE-96FB-7A23DDBEDD06 94 | modifiers 95 | 0 96 | modifiersubtext 97 | 98 | vitoclose 99 | 100 | 101 | 102 | ED714287-BF56-4A5F-B033-6B11DC43FD7B 103 | 104 | 105 | destinationuid 106 | 1598381B-58E0-4A32-827A-B072A2C14567 107 | modifiers 108 | 0 109 | modifiersubtext 110 | 111 | vitoclose 112 | 113 | 114 | 115 | 116 | createdby 117 | Kevin 118 | description 119 | Currency Exchange 120 | disabled 121 | 122 | name 123 | Currency 124 | objects 125 | 126 | 127 | config 128 | 129 | alfredfiltersresults 130 | 131 | alfredfiltersresultsmatchmode 132 | 0 133 | argumenttrimmode 134 | 0 135 | argumenttype 136 | 0 137 | escaping 138 | 100 139 | keyword 140 | usd 141 | queuedelaycustom 142 | 3 143 | queuedelayimmediatelyinitially 144 | 145 | queuedelaymode 146 | 0 147 | queuemode 148 | 1 149 | runningsubtext 150 | loading 151 | script 152 | require_once('CurrencyExchange.php'); 153 | 154 | $currencyExchange = new CurrencyExchange(); 155 | 156 | $currencyExchange->caculate("USD", "CNY", {query}); 157 | scriptargtype 158 | 0 159 | scriptfile 160 | 161 | subtext 162 | USD to CNY 163 | title 164 | USD to CNY 165 | type 166 | 1 167 | withspace 168 | 169 | 170 | type 171 | alfred.workflow.input.scriptfilter 172 | uid 173 | 08CFA9A0-B23C-40F2-A831-6271B32D6C37 174 | version 175 | 2 176 | 177 | 178 | config 179 | 180 | autopaste 181 | 182 | clipboardtext 183 | 184 | transient 185 | 186 | 187 | type 188 | alfred.workflow.output.clipboard 189 | uid 190 | BD0B2D10-2B56-4E3E-8AEF-474C2518DD97 191 | version 192 | 2 193 | 194 | 195 | config 196 | 197 | autopaste 198 | 199 | clipboardtext 200 | 201 | transient 202 | 203 | 204 | type 205 | alfred.workflow.output.clipboard 206 | uid 207 | F87DBD9F-58AB-4F2B-92C3-A184B1E93FFF 208 | version 209 | 2 210 | 211 | 212 | config 213 | 214 | alfredfiltersresults 215 | 216 | alfredfiltersresultsmatchmode 217 | 0 218 | argumenttrimmode 219 | 0 220 | argumenttype 221 | 0 222 | escaping 223 | 100 224 | keyword 225 | jpy 226 | queuedelaycustom 227 | 3 228 | queuedelayimmediatelyinitially 229 | 230 | queuedelaymode 231 | 0 232 | queuemode 233 | 1 234 | runningsubtext 235 | loading 236 | script 237 | require_once('CurrencyExchange.php'); 238 | 239 | $currencyExchange = new CurrencyExchange(); 240 | 241 | $currencyExchange->caculate("JPY", "CNY", {query}); 242 | scriptargtype 243 | 0 244 | scriptfile 245 | 246 | subtext 247 | JPY to CNY 248 | title 249 | JPY to CNY 250 | type 251 | 1 252 | withspace 253 | 254 | 255 | type 256 | alfred.workflow.input.scriptfilter 257 | uid 258 | 3E0D43CD-D9DA-4A5E-B890-F36273751535 259 | version 260 | 2 261 | 262 | 263 | config 264 | 265 | alfredfiltersresults 266 | 267 | alfredfiltersresultsmatchmode 268 | 0 269 | argumenttrimmode 270 | 0 271 | argumenttype 272 | 0 273 | escaping 274 | 100 275 | keyword 276 | thb 277 | queuedelaycustom 278 | 3 279 | queuedelayimmediatelyinitially 280 | 281 | queuedelaymode 282 | 0 283 | queuemode 284 | 1 285 | runningsubtext 286 | loading 287 | script 288 | require_once('CurrencyExchange.php'); 289 | 290 | $currencyExchange = new CurrencyExchange(); 291 | 292 | $currencyExchange->caculate("THB", "CNY", {query}); 293 | scriptargtype 294 | 0 295 | scriptfile 296 | 297 | subtext 298 | THB to CNY 299 | title 300 | THB to CNY 301 | type 302 | 1 303 | withspace 304 | 305 | 306 | type 307 | alfred.workflow.input.scriptfilter 308 | uid 309 | 8F28771A-0449-4FD5-95CB-3C9CCA45526B 310 | version 311 | 2 312 | 313 | 314 | config 315 | 316 | autopaste 317 | 318 | clipboardtext 319 | 320 | transient 321 | 322 | 323 | type 324 | alfred.workflow.output.clipboard 325 | uid 326 | 30CC47E3-1DA1-4F10-BB0E-70931676BF60 327 | version 328 | 2 329 | 330 | 331 | config 332 | 333 | autopaste 334 | 335 | clipboardtext 336 | 337 | transient 338 | 339 | 340 | type 341 | alfred.workflow.output.clipboard 342 | uid 343 | B75DAC7C-6320-4E93-8F0C-B44ADB7E1FD6 344 | version 345 | 2 346 | 347 | 348 | config 349 | 350 | alfredfiltersresults 351 | 352 | alfredfiltersresultsmatchmode 353 | 0 354 | argumenttrimmode 355 | 0 356 | argumenttype 357 | 0 358 | escaping 359 | 100 360 | keyword 361 | eur 362 | queuedelaycustom 363 | 3 364 | queuedelayimmediatelyinitially 365 | 366 | queuedelaymode 367 | 0 368 | queuemode 369 | 1 370 | runningsubtext 371 | loading 372 | script 373 | require_once('CurrencyExchange.php'); 374 | 375 | $currencyExchange = new CurrencyExchange(); 376 | 377 | $currencyExchange->caculate("EUR", "CNY", {query}); 378 | scriptargtype 379 | 0 380 | scriptfile 381 | 382 | subtext 383 | EUR to CNY 384 | title 385 | EUR to CNY 386 | type 387 | 1 388 | withspace 389 | 390 | 391 | type 392 | alfred.workflow.input.scriptfilter 393 | uid 394 | 852302C7-5FBA-4AD0-BD3E-68A3FBE28587 395 | version 396 | 2 397 | 398 | 399 | config 400 | 401 | alfredfiltersresults 402 | 403 | alfredfiltersresultsmatchmode 404 | 0 405 | argumenttrimmode 406 | 0 407 | argumenttype 408 | 0 409 | escaping 410 | 100 411 | keyword 412 | hkd 413 | queuedelaycustom 414 | 3 415 | queuedelayimmediatelyinitially 416 | 417 | queuedelaymode 418 | 0 419 | queuemode 420 | 1 421 | runningsubtext 422 | loading 423 | script 424 | require_once('CurrencyExchange.php'); 425 | 426 | $currencyExchange = new CurrencyExchange(); 427 | 428 | $currencyExchange->caculate("HKD", "CNY", {query}); 429 | scriptargtype 430 | 0 431 | scriptfile 432 | 433 | subtext 434 | HKD to CNY 435 | title 436 | HKD to CNY 437 | type 438 | 1 439 | withspace 440 | 441 | 442 | type 443 | alfred.workflow.input.scriptfilter 444 | uid 445 | D34AD9B8-149A-42F3-8A24-976F78F89B6D 446 | version 447 | 2 448 | 449 | 450 | config 451 | 452 | autopaste 453 | 454 | clipboardtext 455 | 456 | transient 457 | 458 | 459 | type 460 | alfred.workflow.output.clipboard 461 | uid 462 | 6AC0EA93-72EF-4BBE-96FB-7A23DDBEDD06 463 | version 464 | 2 465 | 466 | 467 | config 468 | 469 | alfredfiltersresults 470 | 471 | alfredfiltersresultsmatchmode 472 | 0 473 | argumenttrimmode 474 | 0 475 | argumenttype 476 | 0 477 | escaping 478 | 100 479 | keyword 480 | sgd 481 | queuedelaycustom 482 | 3 483 | queuedelayimmediatelyinitially 484 | 485 | queuedelaymode 486 | 0 487 | queuemode 488 | 1 489 | runningsubtext 490 | loading 491 | script 492 | require_once('CurrencyExchange.php'); 493 | 494 | $currencyExchange = new CurrencyExchange(); 495 | 496 | $currencyExchange->caculate("SGD", "CNY", {query}); 497 | scriptargtype 498 | 0 499 | scriptfile 500 | 501 | subtext 502 | SGD to CNY 503 | title 504 | SGD to CNY 505 | type 506 | 1 507 | withspace 508 | 509 | 510 | type 511 | alfred.workflow.input.scriptfilter 512 | uid 513 | 412728A2-AD7C-41EC-BDBE-6F25C9148F74 514 | version 515 | 2 516 | 517 | 518 | config 519 | 520 | autopaste 521 | 522 | clipboardtext 523 | 524 | transient 525 | 526 | 527 | type 528 | alfred.workflow.output.clipboard 529 | uid 530 | B694857D-9F42-4749-B720-E08E123004F5 531 | version 532 | 2 533 | 534 | 535 | config 536 | 537 | autopaste 538 | 539 | clipboardtext 540 | 541 | transient 542 | 543 | 544 | type 545 | alfred.workflow.output.clipboard 546 | uid 547 | 1598381B-58E0-4A32-827A-B072A2C14567 548 | version 549 | 2 550 | 551 | 552 | config 553 | 554 | alfredfiltersresults 555 | 556 | alfredfiltersresultsmatchmode 557 | 0 558 | argumenttrimmode 559 | 0 560 | argumenttype 561 | 0 562 | escaping 563 | 100 564 | keyword 565 | idr 566 | queuedelaycustom 567 | 3 568 | queuedelayimmediatelyinitially 569 | 570 | queuedelaymode 571 | 0 572 | queuemode 573 | 1 574 | runningsubtext 575 | loading 576 | script 577 | require_once('CurrencyExchange.php'); 578 | 579 | $currencyExchange = new CurrencyExchange(); 580 | 581 | $currencyExchange->caculate("IDR", "CNY", {query}); 582 | scriptargtype 583 | 0 584 | scriptfile 585 | 586 | subtext 587 | IDR to CNY 588 | title 589 | IDR to CNY 590 | type 591 | 1 592 | withspace 593 | 594 | 595 | type 596 | alfred.workflow.input.scriptfilter 597 | uid 598 | ED714287-BF56-4A5F-B033-6B11DC43FD7B 599 | version 600 | 2 601 | 602 | 603 | config 604 | 605 | alfredfiltersresults 606 | 607 | alfredfiltersresultsmatchmode 608 | 0 609 | argumenttrimmode 610 | 0 611 | argumenttype 612 | 0 613 | escaping 614 | 100 615 | keyword 616 | vnd 617 | queuedelaycustom 618 | 3 619 | queuedelayimmediatelyinitially 620 | 621 | queuedelaymode 622 | 0 623 | queuemode 624 | 1 625 | runningsubtext 626 | loading 627 | script 628 | require_once('CurrencyExchange.php'); 629 | 630 | $currencyExchange = new CurrencyExchange(); 631 | 632 | $currencyExchange->caculate("VND", "CNY", {query}); 633 | scriptargtype 634 | 0 635 | scriptfile 636 | 637 | subtext 638 | VND to CNY 639 | title 640 | VND to CNY 641 | type 642 | 1 643 | withspace 644 | 645 | 646 | type 647 | alfred.workflow.input.scriptfilter 648 | uid 649 | 8F339D26-DB7E-49BA-9D5A-452C084832F6 650 | version 651 | 2 652 | 653 | 654 | config 655 | 656 | autopaste 657 | 658 | clipboardtext 659 | 660 | transient 661 | 662 | 663 | type 664 | alfred.workflow.output.clipboard 665 | uid 666 | 9CDFACD8-142D-404F-BDEA-95A09778FCD1 667 | version 668 | 2 669 | 670 | 671 | readme 672 | Keywords are one of Alfred's most commonly used and most useful ways of launching actions. Set a keyword and connect it to the action(s) you want to perform. 673 | 674 | Type your keyword into Alfred, followed by your input text if needed, and you'll be on your way to boosting your productivity! 675 | uidata 676 | 677 | 08CFA9A0-B23C-40F2-A831-6271B32D6C37 678 | 679 | xpos 680 | 130 681 | ypos 682 | 40 683 | 684 | 1598381B-58E0-4A32-827A-B072A2C14567 685 | 686 | xpos 687 | 330 688 | ypos 689 | 1000 690 | 691 | 30CC47E3-1DA1-4F10-BB0E-70931676BF60 692 | 693 | xpos 694 | 330 695 | ypos 696 | 350 697 | 698 | 3E0D43CD-D9DA-4A5E-B890-F36273751535 699 | 700 | xpos 701 | 130 702 | ypos 703 | 190 704 | 705 | 412728A2-AD7C-41EC-BDBE-6F25C9148F74 706 | 707 | xpos 708 | 130 709 | ypos 710 | 850 711 | 712 | 6AC0EA93-72EF-4BBE-96FB-7A23DDBEDD06 713 | 714 | xpos 715 | 330 716 | ypos 717 | 680 718 | 719 | 852302C7-5FBA-4AD0-BD3E-68A3FBE28587 720 | 721 | xpos 722 | 130 723 | ypos 724 | 520 725 | 726 | 8F28771A-0449-4FD5-95CB-3C9CCA45526B 727 | 728 | xpos 729 | 130 730 | ypos 731 | 350 732 | 733 | 8F339D26-DB7E-49BA-9D5A-452C084832F6 734 | 735 | xpos 736 | 130 737 | ypos 738 | 1160 739 | 740 | 9CDFACD8-142D-404F-BDEA-95A09778FCD1 741 | 742 | xpos 743 | 330 744 | ypos 745 | 1160 746 | 747 | B694857D-9F42-4749-B720-E08E123004F5 748 | 749 | xpos 750 | 330 751 | ypos 752 | 850 753 | 754 | B75DAC7C-6320-4E93-8F0C-B44ADB7E1FD6 755 | 756 | xpos 757 | 330 758 | ypos 759 | 520 760 | 761 | BD0B2D10-2B56-4E3E-8AEF-474C2518DD97 762 | 763 | xpos 764 | 330 765 | ypos 766 | 40 767 | 768 | D34AD9B8-149A-42F3-8A24-976F78F89B6D 769 | 770 | xpos 771 | 130 772 | ypos 773 | 680 774 | 775 | ED714287-BF56-4A5F-B033-6B11DC43FD7B 776 | 777 | xpos 778 | 130 779 | ypos 780 | 1000 781 | 782 | F87DBD9F-58AB-4F2B-92C3-A184B1E93FFF 783 | 784 | xpos 785 | 330 786 | ypos 787 | 190 788 | 789 | 790 | version 791 | 1.0 792 | webaddress 793 | http://blog.zhuwenbo.net 794 | 795 | 796 | -------------------------------------------------------------------------------- /app_key.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adin283/Currency/5b67fb232c4990984c063377be6f3e4ae5bc184e/app_key.jpg -------------------------------------------------------------------------------- /customize.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adin283/Currency/5b67fb232c4990984c063377be6f3e4ae5bc184e/customize.jpg -------------------------------------------------------------------------------- /jpy.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adin283/Currency/5b67fb232c4990984c063377be6f3e4ae5bc184e/jpy.jpg -------------------------------------------------------------------------------- /usd.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adin283/Currency/5b67fb232c4990984c063377be6f3e4ae5bc184e/usd.jpg --------------------------------------------------------------------------------