Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python2
- # -*- coding: utf8 -*-
- import pynotify
- import requests
- import urllib2
- import json
- import sys
- API_KEY = '<paste_here>'
- def main():
- pynotify.init('Basic')
- for word in sys.stdin:
- response = requests.get(
- "https://translate.yandex.net/api/v1.5/tr.json/translate",
- params={
- 'key': API_KEY,
- 'text': urllib2.quote(word),
- 'lang': 'ru',
- 'format': 'plain',
- 'options': '1'
- }
- )
- data = response.json()
- n = pynotify.Notification(u"Перевод", data['text'][0])
- # n.set_timeout(pynotify.EXPIRES_NEVER)
- n.show()
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement