Coder Social home page Coder Social logo

anki-export-from-browser's Introduction

Export cards selected in the Browser

Rationale

Sometime, I want to export only some notes. And the cards are not all in the same deck. I wanted to be able to just select cards in the browser and export them. Thus, this add-on is here.

Another problem with anki's exporting system is that it exports cards, and not notes. Image that you have a card in a deck, and its sibling (other card of the same note) in another deck. And that you export the deck of the first card. Only the first card will be exported. Now, if you import the exported package, Anki will eventually detect that some siblings are missing, and will generate those as new cards. Thus the entire review history of the siblings will be missing. Personnally, I prefer to export siblings, even if it means exporting more than a deck. But since people may disagree, this option is configurable.

Warnings

Bug in deck exported before 2020-feb-02

A previous version of the add-on add an hidden bug. When you exported cards selected in the browser, the file you obtained contained information about ALL decks. Even the decks unrelated to any card you selected.

This create no bug when you imported those cards, since those decks without cards were ignored by Anki. However, it means that those deck contained extra information they were not supposed to contains. It contained the list of all of your decks, and this can be read by any people knowing how to read database content.

I assume and hope that this was not a security problem for anyone, and that no "list of decks" contained sensitive information. But if your list of deck did contain sensitive informatio, I beg your pardon and you should ensore those shared decks are not publicly shared anymore.

Special field add-on

Currently, this add-on is not compatible with "special field" add-on. This will change in the future, I sent a correction to the other add-on, I can't do more immediately.

Usage

Open the Browser, select the cards you want to export. Then go to Edit>Export selection (Ctrl+Shift+E), and the standard exporting window will open, but with a new options: "Browser's selection". Keeping this option, you can export your selection as you exported decks.

Configuration

You can ignore this section. Unless you really want to export cards without their siblings in package/exporters installed by other add-ons, default should be okay.

"siblings": A mapping stating, for each kind of export option, whether you want that cards are exported with their siblings (other cards from the same note).

  • null means that you use the "default" setting.
  • true means that, when you export a card, you export their siblings.
  • false means that you can export cards without their siblings.

The entry of the "siblings" mapping are keys of exporter, or the constant "default". To control exporter created by other add-on, check their code to find their "key" value, and add it to this mapping. The default values are:

  • "default": the default value, when no other are used.
  • "Notes in Plain Text": exporting notes as txt files.
  • "Cards in Plain Text": exporting cards as txt files.
  • "Anki Deck Package": exporting a .apkg file If another exporter is added by an add-on, add its key to this mapping

"Anki 2.0 Deck" is not listed. Indeed, when the entire collection is exported, this parameter becomes useless.

Internal

This add-on change

  • in aqt.exporting, the method ExportDialog.__init__. The new method calls the previous version of the method.
  • in aqt.exporting, the methods ExportDialog.setup, ExportDialog.accept. The new methods do not call the previous version of the method.
  • in anki.exporting, the method Exporter.cardIds is modified. The former version of the method is called if the exporter is called from the browser with a non-empty selection.
  • in anki.exporting, the method Exporter.__init__ is modified. The former version of the method is called.
  • in anki.exporting, the method AnkiExporter.exportInto is redefined, not calling the previous version. This change is used to decide which decks are changed. This change is sent to Anki in a (pull request)[ankitects/anki#434].

Version 2.0

Sorry, but no such version, unless someone wants to pay for it.

Links, licence and credits

Key Value
Copyright Arthur Milchior [email protected]
Debugged by ijgnd
Based on Anki code by Damien Elmes [email protected]
License GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
Source in https://github.com/Arthur-Milchior/anki-export-from-browser
Addon number 1983204951

anki-export-from-browser's People

Contributors

arthur-milchior avatar ijgnd avatar

Stargazers

 avatar

Watchers

 avatar James Cloos avatar

anki-export-from-browser's Issues

name 'mw' is not defined

Debug info:

Anki 2.1.13 (3ba55990) Python 3.6.7 Qt 5.12.1 PyQt 5.11.3
Platform: Windows 10
Flags: frz=True ao=True sv=1

Caught exception:
  File "C:\Users\epistularum\AppData\Roaming\Anki2\addons21\1983204951\browser.py", line 9, in <lambda>
    a.triggered.connect(lambda : ExportDialog(mw,cids=browser.selectedCards()))
<class 'NameError'>: name 'mw' is not defined

'TextCardExporter' object has no attribute 'count'

I exported my cards in browser as Cards in Plain Text, then an error occured.

Debug info:
Anki 2.1.9 (ae67c976) Python 3.6.7 Qt 5.12.1 PyQt 5.11.3
Platform: Windows 10
Flags: frz=True ao=True sv=2

Caught exception:
File "C:\Users\L.M.Sherlock\AppData\Roaming\Anki2\addons21\1983204951\exportFromBrowser.py", line 149, in accept
self.exporter.count) % self.exporter.count
<class 'AttributeError'>: 'TextCardExporter' object has no attribute 'count'

L183 - "name 'r' is not defined"

First of all: Thanks for another great add-on.

But I get an error with "Export cards selected in the Browser" when I try to export a deck to apkg via File-Export in the main window. This happens with the compiled version 2.1.9 from Ankiweb in linux with no other-add-ons installed. I didn't modify the config of this add-on.

Debug info:
Anki 2.1.9 (ae67c976) Python 3.6.7 Qt 5.12.1 PyQt 5.11.3
Platform: Linux
Flags: frz=False ao=True sv=1
Add-ons possibly involved: Export cards selected in the Browser

Caught exception:
  File "/home/ij/.local/share/Anki2/addons21/1983204951/exportFromBrowser.py", line 138, in accept
    self.exporter.exportInto(file)
  File "/home/ij/projects/Anki_2019-02-23/anki/exporting.py", line 261, in exportInto
    media = self.doExport(z, path)
  File "/home/ij/projects/Anki_2019-02-23/anki/exporting.py", line 269, in doExport
    AnkiExporter.exportInto(self, colfile)
  File "/home/ij/.local/share/Anki2/addons21/1983204951/exportFromBrowser.py", line 212, in exportInto
    cids = self.cardIds()#ONLY CHANGE !!!!
  File "/home/ij/.local/share/Anki2/addons21/1983204951/exportFromBrowser.py", line 183, in cardIds
    debug(f"cids: {self.did}, returning {r}")
<class 'NameError'>: name 'r' is not defined

Not working on Anki 2.1.20beta10

When I click export selected from the menu it just brings up the default export dialog as if I had done File->export. I can no longer export what was selected with the add-on. I can however use the now built in function, but it is in a different menu and that will surely confuse people

Conflict with special fields

I was messing with this and realized a past version of this add-on that I have still works perfectly (I'm currently on 2.1.19) and it does not conflict with the special fields add-on. Is there a reason for the new update? I attached the version I'm using
1983204951*.zip

[question] default separator in csv

Can you tell me what is default separator used in csv export?
I want to open it in LibreOffice Calc and have each Anki field in separate column, but I can't figure out what is the proper separator. Neither tab, nor comma, nor semicolon works.
Does it save as UTF-8 or another?
Would it be possible to set individual separator?
Here is example how tab is trying to open:
https://imgur.com/GoCAdSC

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.