Giter Site home page Giter Site logo

Forvo about anki-addons HOT 17 OPEN

ospalh avatar ospalh commented on September 28, 2024 2
Forvo

from anki-addons.

Comments (17)

ELLIOTTCABLE avatar ELLIOTTCABLE commented on September 28, 2024 2

I'd just like to point out that the $1/mo plan now literally mentions Anki now, as a motivation to purchase the plan.

IMHO, that's tacit endorsement of DA. Maybe e-mail them and double-check? But it sounds to me like this needs to be re-enabled!

from anki-addons.

Zacharias030 avatar Zacharias030 commented on September 28, 2024 2

I just wanted to point out a rudimentary hack for anyone interested in this issue that enables access to the Forvo mp3 files by circumventing the official API entirely and no sign-up is required.

I modified the original ForvoDownloader class from the forvo-feature branch to look like this (and saved it in a file forvo_free.py in the downloaders module:

...

import re
import base64

from ..download_entry import DownloadEntry
from .downloader import AudioDownloader


class ForvoDownloader(AudioDownloader):
   """Download pronunciations from Forvo via accessing the website instead of their API."""
    def __init__(self):
        AudioDownloader.__init__(self)
        self.file_extension = u'.mp3'
        self.icon_url = 'http://www.forvo.com/'
        self.field_data = None

    def download_files(self, field_data):
        """
        Get pronunciations of a word from Forvo
        """
        self.downloads_list = []
        self.field_data = field_data
        if field_data.split:
            return
        if not field_data.word:
            return
        self.maybe_get_icon()

        assert (self.language)

        webPageUrl = "https://forvo.com/word/%s/#%s" % (self.field_data.word, self.language)
        webPageText = self.get_data_from_url(webPageUrl)

        PageTextList = re.findall("<em id=\"%s.*?</article>" % self.language, webPageText, re.DOTALL)
        if len(PageTextList) == 0:
            return '{"status":"error"}'
        PageText = PageTextList[0]
        pronunciations = re.findall("Play\(\d+,'(.*?)'", PageText)
        for l in range(len(pronunciations)):
            pronunciations[l] = "https://forvo.com/mp3/" + base64.b64decode(pronunciations[l]).decode()
        self.get_items(pronunciations)

    def get_items(self, items_list):
        for itm in items_list:
            extras = dict(Source='Forvo.com')
            if self.language:
                extras['Language'] = self.language
            try:
                file_path = self.get_tempfile_from_url(itm)
                # I guess the try is not really necessary. Anyway.
            except (ValueError, KeyError):
                continue
            entry = DownloadEntry(
                self.field_data, file_path, extras, self.site_icon)
            entry.file_extension = self.file_extension
            self.downloads_list.append(entry)

You also need to register this class in the __init__.py of the downloaders module:

...
from .forvo_free import ForvoDownloader

downloaders = [
    ...
    ForvoDownloader(),
]

from anki-addons.

ospalh avatar ospalh commented on September 28, 2024 1

Looks like Forvo changed their policies. There is now a buck/month plan. They still say not encourage customers to get keys”, but when they *pay for the key, that doesn’t make too much sense.
What is not making sense, too, is that they say “no caching” and “creative commons” both.
Worth watching. Maybe there will be a general Forvo downloader some day.

from anki-addons.

gabriel4649 avatar gabriel4649 commented on September 28, 2024 1

Is there still no interest on the forvo downloader? I am willing to pay the $1 month for the convenience and I am sure other users would be. Perhaps there could be a dialog where the user can input his or her API key and thus enable the forvo feature. If there is interest on this, I might be able to write it myself and submit a PR. Great job with the downloader!!! I use it almost everyday and it is an essential part of my Anki work-flow.

from anki-addons.

ospalh avatar ospalh commented on September 28, 2024

Short answer: no.

Discussed at Google Groups.

On the other hand, i think giving another developer a hand is something else than encouraging end users to get a Forvo key. So, just look around at the branches of this repo. Or more specific, at the downloaders directory.

from anki-addons.

sardeie avatar sardeie commented on September 28, 2024

Thank you.

from anki-addons.

Schpeet avatar Schpeet commented on September 28, 2024

I added the forvo downloader, and replaced the init.py file in my downloaders folder with the one here, as well as replacing the text XXXXXXXX with my forvo API key...but am having a lot of issues! Can anyone help me?
screen shot 2015-07-31 at 4 02 50 pm

from anki-addons.

ospalh avatar ospalh commented on September 28, 2024

Looks like you copied a saved web page to __init__.py. That won’t work. Even if the web page was showing an appropriate Python script.

And where is “here”? There is no link in your comment.

You should copy back the old __ini__.py, get it from here (see? a link!) or re-download the whole add-on. In cases one and three you should then edit the file.

from anki-addons.

Schpeet avatar Schpeet commented on September 28, 2024

Ah OK, thanks I just copied and pasted the text into the file and it works great now.

from anki-addons.

ospalh avatar ospalh commented on September 28, 2024

The Forvo web page still says "You can't (…) encourage end users to get their own API keys. This is forbidden.”, so i will not encourage end users to get their own API keys.

from anki-addons.

gabriel4649 avatar gabriel4649 commented on September 28, 2024

Ah I see, that is such a bizarre policy... Yet they ask for donations on their main website, as if it were a non-profit project. Thank you for your reply!

from anki-addons.

ospalh avatar ospalh commented on September 28, 2024

No, their terms of use are largely unchanged, still contain

  • It is not allowed to cache audio pronunciations.
  • You can't […] encourage end users to get their own API keys.

from anki-addons.

ospalh avatar ospalh commented on September 28, 2024

As this is free software, other people can do that, and risk the legal trouble, if they want to.
I am not too motivated to work on this any more.

from anki-addons.

ospalh avatar ospalh commented on September 28, 2024

OK, nice.
At the moment i am not 100 % sure that i won’t use a variant of this idea.

Also:

  1. This is just a comment, not a git commit in your repo.
  2. The name ForvoDownloader is already taken for the API based version.
  3. The code looks like Python 2, and so like an Anki 2.0 add-on, not an Anki 2.1 add-on.

from anki-addons.

Zacharias030 avatar Zacharias030 commented on September 28, 2024

Would you like me to create a pull request with points 1.-3. fixed? I wasn't sure if you were interested so I didn't invest the time yet.

Re: 3. I thought the plugin is Anki 2.0 only?

from anki-addons.

ospalh avatar ospalh commented on September 28, 2024

3: Yes. When i have come around to updating this add-on to 2.1, then i’ll have another look at this and i may – or may not – do Forvo this way.

from anki-addons.

ospalh avatar ospalh commented on September 28, 2024

3: Yes. When i have come around to updating this add-on to 2.1, then i’ll have another look at this and i may – or may not – do Forvo this way.

See also https://ospalh.github.io/anki-addons/2017/10/26/Anki_21.html
(The motivation that went up to “a bit” has gone down again, to “maybe a tiny bit some time”.)

from anki-addons.

Related Issues (20)

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.