Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translations stopped working today #125

Open
allenweiss opened this issue Nov 11, 2022 · 4 comments
Open

Translations stopped working today #125

allenweiss opened this issue Nov 11, 2022 · 4 comments

Comments

@allenweiss
Copy link

For the past several months, this worked fine but now I'm getting this when I call this

lingo.get_translations(word to translate, source=sr, target=tg)

duolingo.DuolingoException: Could not get translations

Anybody run into this problem?

@Otto-AA
Copy link

Otto-AA commented Nov 12, 2022

The same happens to me.

My code looks like this:

lingo = duolingo.Duolingo(username, password)
translations = lingo.get_translations(['da'], source='ro', target='en')

which makes a request to this url: https://d2.duolingo.com/api/1/dictionary/hints/ro/en?tokens=%5B%22da%22%5D

with the following 404 response:

<html>
 <head>
  <title>404 Not Found</title>
 </head>
 <body>
  <h1>404 Not Found</h1>
  The resource could not be found.<br/><br/>
/api/1/dictionary/hints/ro/en


 </body>
</html>

@JASchilz
Copy link
Contributor

JASchilz commented Dec 3, 2022

Another library user here. Following @Otto-AA 's link, now results in:

This site can’t be reached
d2.duolingo.com’s server IP address could not be found.

I'm guessing that this particular endpoint is not coming back. :)

I've been casually searching but haven't yet found any other projects in other languages that identify an alternative for this endpoint. If anyone does, could you post it here?

@allenweiss
Copy link
Author

I just switched to googletrans
It does everything I need in translations.

@mbrookes
Copy link

mbrookes commented Oct 7, 2023

I'm using https://github.com/ssut/py-googletrans. Translations for single words can be problematic when the word has more than one meaning or part of speech, but it's good enough for my purposes.

## Returns a list of all vocabulary seen by user, arranged by parts of speech

import duolingo
import inspect
import googletrans

# Fix for broken password support - use JWT inst
source = inspect.eadgetsource(duolingo)
new_source = source.replace('jwt=None', 'jwt')
new_source = source.replace('self.jwt = None', ' ')
exec(new_source, duolingo.__dict__)

lingo  = duolingo.Duolingo('username', jwt='your_jwt_here')
translator = googletrans.Translator()

allwords = []
vocab = lingo.get_vocabulary(language_abbr='pt')

for element in vocab['vocab_overview']:
    if element['pos'] == "Verb":
        word = {'word': element['infinitive'], 'pos': element['pos']}
    else:
        word = {'word': element['word_string'], 'pos': element['pos']}

    if word not in allwords:
        allwords.append(word)

# Vocabulary is returned most recently practiced first, so reverse it
allwords.reverse()

parts = [
    'Noun',
    'Verb',
    'Pronoun',
    'Adjective',
    'Adverb',
    'Preposition',
    'Determiner',
    'Conjunction',
    'Interjection',
    'Numeral'
]

print('\nVocabulary:')

for pos in parts:
    print('\n\n{pos}s:\n'.format(pos=pos))
    for element in allwords:
        if element["pos"] == pos:
            print('{word} - {trans}'.format(
                word=element["word"],
                trans=translator.translate(element["word"], src='pt', dest='en').text)
            )

Worth noting that you can pass an array and have it translate words in bulk, but one at a time was easier here, and I haven't hit any rate limits yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants