wilddom / memrise2anki-extension

An extension for Anki 2 that downloads and converts a course from Memrise into an Anki deck.
ISC License
159 stars 22 forks source link

SSL error when downloading media files #62

Closed Alkisum closed 5 years ago

Alkisum commented 6 years ago

When I import a Memrise Course with media files, I receive this error message:

<urlopen error [Errno 1] _ssl.c:504: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure>

https://static.memrise.com/uploads/things/audio/86087923_160218_0714_28.mp3
Traceback (most recent call last):
  File "/home/val/.local/share/Anki2/addons/Memrise_Course_Importer/importer.py", line 146, in run
    course = self.memriseService.loadCourse(self.url, MemriseCourseLoader.Observer(self))
  File "/home/val/.local/share/Anki2/addons/Memrise_Course_Importer/memrise.py", line 788, in loadCourse
    return courseLoader.loadCourse(self.getCourseIdFromUrl(url))
  File "/home/val/.local/share/Anki2/addons/Memrise_Course_Importer/memrise.py", line 578, in loadCourse
    level = self.loadLevel(course, levelIndex)
  File "/home/val/.local/share/Anki2/addons/Memrise_Course_Importer/memrise.py", line 692, in loadLevel
    self.notify('thingLoaded', thing)
  File "/home/val/.local/share/Anki2/addons/Memrise_Course_Importer/memrise.py", line 559, in notify
    getattr(observer, signal)(*attrs, **kwargs)
  File "/home/val/.local/share/Anki2/addons/Memrise_Course_Importer/importer.py", line 70, in thingLoaded
    self.downloadMedia(thing)
  File "/home/val/.local/share/Anki2/addons/Memrise_Course_Importer/importer.py", line 51, in downloadMedia
    audio.localUrl = self.sender.download(audio.remoteUrl)
  File "/home/val/.local/share/Anki2/addons/Memrise_Course_Importer/importer.py", line 117, in download
    raise e
urllib2.URLError: <urlopen error [Errno 1] _ssl.c:504: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure>

Here some more information of my system: OS: Manjaro 17.1.7 Python: 3.6.4 Anki: 2.0.50 memrise2anki-extension: 1.1

I don't know if this is a general problem or just a bad configuration of my system.

Thanks for your work!

peixian commented 6 years ago

@Alkisum I'm having this issue too, I think it's because the version of python bundled with Anki is 2.7.3, and it's having trouble negotiating with the memrise servers on a proper TLS version, since 2.7.3's urllib SSL library is wayyy too old.

peixian commented 6 years ago

@Alkisum the OS X version of anki works downloading audio files from memrise btw

Alkisum commented 6 years ago

@peixian Thank you so much for the information! I would like to avoid using the OS X version, is there any workaround to make memrise2anki-extension download media files from Memrise?

peixian commented 6 years ago

@Alkisum you could try rebuilding the linux version of Anki from source and replace the python version

Alkisum commented 6 years ago

Thanks for your help @peixian, I actually decided to go with OS X and it worked perfectly.

Troyciv commented 6 years ago

The SSL problem seems to be caused by some issue with urllib2. The internet suggests to use requests instead.

Is @wilddom still maintaining this project?

wilddom commented 6 years ago

@Troyciv The problem has been accurately analyzed by @peixian. Even when switching to requests, as far as I know there are quite some dependencies involved in order to get SNI working. Maybe I'll consider rewriting the addon for Anki 2.1, but I don't know for sure.

wilddom commented 5 years ago

I just pushed an update for Anki 2.1