aakatov / anki-media-internalizer

This Anki addon finds http references, downloads files into the internal local storage and updates the references.
https://ankiweb.net/shared/info/221033553
8 stars 2 forks source link

menu item "Internalize Media" no longer available on clicking the Deck Options button #1

Closed HarshIceHummer closed 7 years ago

HarshIceHummer commented 8 years ago

I have used your addon previously and it worked great until I installed another addon from https://ankiweb.net/shared/info/1114708966 .

After installing this addon, the menu item "Internalize Media" is no longer available on clicking the Deck Options button. Is there somewhere else I can find it?

aakatov commented 8 years ago

Thanks for reporting this issue. Unfortunately, it won't be fixed until Anki 2.1.0 release that introduces the new hook "showDeckOptions". However, the other add-on will need to be fixed too. There isn't any other place where you can find it, but for the meantime, you can edit "Clear Field Formatting HTML" add-on script in your Anki. Go to Tools - Add-ons - Clear Field Formatting HTML - Edit... Find the following piece of code:

def showOptions(self, did):
    m = QMenu(self.mw)
    a = m.addAction(_("Rename"))
    a.connect(a, SIGNAL("triggered()"), lambda did=did: self._rename(did))
    a = m.addAction(_("Options"))
    a.connect(a, SIGNAL("triggered()"), lambda did=did: self._options(did))
    a = m.addAction(_("Export"))
    a.connect(a, SIGNAL("triggered()"), lambda did=did: self._export(did))
    a = m.addAction(_("Delete"))
    a.connect(a, SIGNAL("triggered()"), lambda did=did: self._delete(did))
    #
    runHook("deckHooker", self, did, m)
    #
    m.exec_(QCursor.pos())

And replace it with:

def showOptions(self, did):
    m = QMenu(self.mw)
    a = m.addAction(_("Rename"))
    a.connect(a, SIGNAL("triggered()"), lambda did=did: self._rename(did))
    a = m.addAction(_("Options"))
    a.connect(a, SIGNAL("triggered()"), lambda did=did: self._options(did))
    a = m.addAction(_("Export"))
    a.connect(a, SIGNAL("triggered()"), lambda did=did: self._export(did))
    a = m.addAction(_("Delete"))
    a.connect(a, SIGNAL("triggered()"), lambda did=did: self._delete(did))
    # Media Internalizer
    a = m.addAction("Internalize Media")
    a.connect(a, SIGNAL("triggered()"), lambda did=did: self._internalize(did))
    #
    runHook("deckHooker", self, did, m)
    #
    m.exec_(QCursor.pos())

Save and restart Anki.

HarshIceHummer commented 8 years ago

Thank you for replying. However, the addon is still not working. It's throwing this error now.

Traceback (most recent call last): File "C:\Users\Mahesh\Documents\Anki\addons_Clear_Field_Formatting_HTML.py", line 390, in a.connect(a, SIGNAL("triggered()"), lambda did=did: self._internalize(did)) File "C:\Users\Mahesh\Documents\Anki\addons\Media_Internalizer.py", line 55, in internailzeMedia filename = retrieveURL(self.mw, url) File "C:\Users\Mahesh\Documents\Anki\addons\Media_Internalizer.py", line 30, in retrieveURL filecontents = urllib2.urlopen(req).read() File "urllib2.py", line 126, in urlopen File "urllib2.py", line 400, in open File "urllib2.py", line 418, in _open File "urllib2.py", line 378, in _call_chain File "urllib2.py", line 1215, in https_open File "urllib2.py", line 1174, in do_open File "httplib.py", line 958, in request File "httplib.py", line 992, in _send_request File "httplib.py", line 954, in endheaders File "httplib.py", line 814, in _send_output File "aqt\sync.py", line 441, in _incrementalSend File "httplib.py", line 1160, in connect File "httplib.py", line 741, in _tunnel File "httplib.py", line 371, in _read_status httplib.BadStatusLine: ''

aakatov commented 8 years ago

This looks like a server or connection problem.

Raised if a server responds with a HTTP status code that we don’t understand.

Does this error appear on one specific note or all of them? If it doesn't work for all notes, check your network and proxy settings.

Update: I fixed the script, so it doesn't crash Anki when this exception occurs. Please, reinstall the add-on (code 221033553).