Git Product home page Git Product logo

pyleo's Introduction

Build Status PyPI version PyPI - Downloads

PyLeo - Unofficial Lingualeo API python library

Installation

pip install pyleo

Example usage

CLI tool for upload dictionary (ororo.tv_dict*.csv) from Ororo.tv to LinguaLeo

pyleo upload -f ororo.tv_dict.csv -u [email protected] -p Your_password

Where:

  • -f - Ororo.tv dictionary filename
  • -u - LinguaLeo username
  • -p - LinguaLeo password

Import as Python module

import json
from pyleo.api import LeoApi

api_instance = LeoApi('[email protected]', 'password')

if api_instance.need_auth:
    api_instance.auth()  # Authorize user

# add word to LinguaLeo user dictionary
api_instance.add_word('placebo', 'Имитация лекарства')

# get word translation from LinguaLeo
translation = json.loads(api_instance.get_translations('fake').decode('utf-8'))

print(json.dumps(translation, indent=4, sort_keys=True, ensure_ascii=False))

sample API response

{
    "_hash": "0000.0",
    "error_msg": "",
    "experienceSkills": null,
    "meatballs": 55,
    "notify_count": 2,
    "questData": {
        "leoClothing": 0,
        "meatballs": 55,
        "task_actions_finished": [
            [
                1,
                1
            ]
        ],
        "task_num": 1,
        "task_num_prev": 0,
        "task_state": 2
    },
    "userdict3": {
        "is_user": false,
        "lang": {
            "current": "ru",
            "target": "en"
        },
        "lemmas": [
            {
                "lemma_id": 15421,
                "lemma_value": "FAKE",
                "speech_part": {
                    "code": "Noun",
                    "name": "существительное",
                    "short_name": "сущ."
                },
                "speech_part_id": 7
            },
            {
                "lemma_id": 15421,
                "lemma_value": "FAKE",
                "speech_part": {
                    "code": "Verb",
                    "name": "глагол",
                    "short_name": "глаг."
                },
                "speech_part_id": 12
            }
        ],
        "sound_url": "https://audiocdn.lingualeo.com/v2/1/15421-631152008.mp3",
        "transcription": "feɪk",
        "translations": [
            {
                "is_blame": 0,
                "is_owner": false,
                "is_user": 0,
                "rating": 1,
                "rating_avg": 0.206543,
                "rating_user_vote": 0,
                "source": "",
                "speech_part_id": 0,
                "star": 1,
                "translate_id": 29600,
                "translate_value": "подделка",
                "translate_votes": 56991
            },
            {
                "is_blame": 0,
                "is_owner": false,
                "is_user": 0,
                "rating": 0,
                "rating_avg": 0.2,
                "rating_user_vote": 0,
                "source": "",
                "speech_part_id": 0,
                "star": 3,
                "translate_id": 29604,
                "translate_value": "прикидываться",
                "translate_votes": 14627
            },
            {
                "is_blame": 0,
                "is_owner": false,
                "is_user": 0,
                "rating": 0,
                "rating_avg": 0.2,
                "rating_user_vote": 0,
                "source": "",
                "speech_part_id": 0,
                "star": 3,
                "translate_id": 2630670,
                "translate_value": "мошенничать",
                "translate_votes": 9581
            },
            {
                "is_blame": 0,
                "is_owner": false,
                "is_user": 0,
                "rating": 0,
                "rating_avg": 0.2,
                "rating_user_vote": 0,
                "source": "",
                "speech_part_id": 0,
                "star": 3,
                "translate_id": 135960,
                "translate_value": "фальшивый",
                "translate_votes": 4921
            },
            {
                "is_blame": 0,
                "is_owner": false,
                "is_user": 0,
                "rating": 0,
                "rating_avg": 0.2,
                "rating_user_vote": 0,
                "source": "",
                "speech_part_id": 7,
                "star": 3,
                "translate_id": 4021671,
                "translate_value": "подделка",
                "translate_votes": 3951
            }
        ],
        "word_count": 44926,
        "word_id": 15421,
        "word_speech_parts": {
            "12": {
                "code": "Verb",
                "name": "глагол",
                "short_name": "глаг."
            },
            "7": {
                "code": "Noun",
                "name": "существительное",
                "short_name": "сущ."
            }
        },
        "word_top": 3,
        "word_type": 1,
        "word_value": "fake"
    },
    "utcServerTime": 1551600000
}

pyleo's People

Contributors

dorokhin avatar

Stargazers

 avatar

Watchers

 avatar

pyleo's Issues

Add dictionary export from ororo.tv to Lingualeo

Add dictionary export from ororo.tv to Lingualeo

pyleo export --csv-file ororo-dictionary.csv --login you_login --password you_password

Discovered 100 word(s) in CSV file
[0/100] Word flame exists.
[1/100] Word caption added.
[2/100] Word request exists.
...

TypeError: urlencode() got an unexpected keyword argument 'quote_via' in Python 3.4

Build 3.4 | failed

======================================================================
ERROR: test_get_word_ (tests.unit.test_api.TestApi)

Traceback (most recent call last):
File "/opt/python/3.4.6/lib/python3.4/unittest/mock.py", line 1142, in patched
return func(*args, **keywargs)
File "/home/travis/build/dorokhin/pyleo/tests/unit/test_api.py", line 47, in test_get_word_
result = json.loads(self.test_instance.get_word(word).decode('utf-8'))['userdict3']['word_id']
File "/home/travis/build/dorokhin/pyleo/pyleo/api.py", line 84, in get_word_
query_string = parse.urlencode(payload, quote_via=parse.quote_plus)
TypeError: urlencode() got an unexpected keyword argument 'quote_via'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.