Code Monkey home page Code Monkey logo

crowdanki's Introduction

CrowdAnki

Build Status

[中文版介绍]

CrowdAnki is a plugin for http://ankisrs.net/ that allows users to import and export decks/notes and all relevant information in a JSON format. The main purpose is to facilitate crowd-sourcing for Anki decks and notes.

Starting with version 0.6 it also features a close integration with Git. Providing you with an ability to automatically maintain history of edits for your decks.
See more details below.

AnkiWeb link for the plugin: https://ankiweb.net/shared/info/1788670778


Please consider supporting the plugin development by becoming a Patron - this helps me to dedicate more time and love to the project

Become a Patron!


How to collaborate via GitHub

This section illustrates collaboration workflow using GitHub.

Suppose you have a deck named DeckX and you want to collaborate on its improvement with other people. In order to achieve this you will need to:

  1. Export the DeckX. You can do that by going to Anki: File > Export > Export format: CrowdAnki JSON Representation. Include: DeckX.
  2. Create a GitHub account for yourself and ask your collaborators to do the same (see: https://github.com/join).
  3. Create a repository for your deck by following this guide https://guides.github.com/activities/hello-world/#repository. The name of the repository has to correspond to the name of the directory that was created during the export. In our case, it would be named DeckX.
  4. Add collaborators to the repository: https://help.github.com/articles/inviting-collaborators-to-a-personal-repository/.

GUI workflow

Preface:

My goal here is to provide a user-friendly description of collaboration workflow. In order to do that, I looked through multiple GUI git clients. For our purposes here, I think GitHub Desktop is the best choice (as the most user-friendly client that works). There is one problem with GitHub Desktop, though - it doesn't have a Linux version. Which makes me particularly sad, as I use Linux as my main OS. I've considered using GitKraken for this tutorial, but it has some problems that disqualify it for our purposes (but if you're Linux user or if you don't like GitHub Desktop for some reason - you may still want to consider using it).

Initiating collaboration

  1. Install GitHub Desktop for your computer.
  2. Log in to it with you GitHub account, created earlier.
  3. Create a new repository. "Local path" should point to the place you've imported your deck, the name of the repository should be the same as the name of exported directory. Image
  4. Add the content of your directory to the repository, by selecting all of the files, adding some comment in comment field and pressing "Commit to master" Image
  5. Upload the changes you've just made to the GitHub, by pressing button "Publish" and then "Publish <RepositoryName>". In this case, you don't need to create repository in advance, GitHub Desktop will create it for you. Image

To start working on the deck your collaborators need to:

  1. Install GitHub Desktop for their computer.
  2. Clone the repository you've created. They can do that by going to the repository page on GitHub and pressing "Clone or download -> Open in Desktop". Image
  3. Import the deck.

If somebody just wants to use the deck you've uploaded to GitHub - they can import decks directly from there.

How to upload changes

When you or one of your collaborators want to upload changes you've made to the GitHub, you need to:

  1. Get the latest changes from the GitHub, by pressing "Sync" button in the top right corner. Image
  2. Import the deck to combine changes you've made with the changes other people have made.
  3. Export the deck the same directory where your repository is located so that export will overwrite media directory and JSON file in the repository. (As an alternative you can export it elsewhere and copy JSON file and media directory yourself to overwrite the ones that are in repository directory.)
  4. Add the changes you've made to the repository, by selecting all of the files, adding some comment in comment field and pressing "Commit to master" Image
  5. Upload changes you've made to the GitHub, by pressing "Sync" button in the top right corner.

If you just want to get latest changes from other people - you need to perform only steps 1 and 2.

CLI workflow

Initiating collaboration

  1. Install git on your computer.

  2. Go to the directory that resulted from export.

  3. Initialize repository with following commands:

    git init
    git remote add origin [email protected]:<username>/<repository>.git
    

    Where is your GitHub username (in my case Stvad) and is the name of the repository (DeckX). So in our case the command will look like:

    git remote add origin [email protected]:Stvad/DeckX.git
    
  4. Add the content of your directory to the repository:

    git add *
    git commit -m "initial export"
    
  5. Upload changes you've made to the GitHub:

    git push origin master
    

To start working on the deck your collaborators need to:

  1. Install git on their machine.

  2. Clone the repository you've created:

    git clone https://github.com/Stvad/DeckX.git
    
  3. Import the deck.

If somebody just wants to use the deck you've uploaded to GitHub - they can import decks directly from there.

How to upload changes

When you or one of your collaborators want to upload changes you've made to the GitHub, you need to:

  1. Get the latest changes from the GitHub:

    git pull
    
  2. Import the deck to combine changes you've made with the changes other people have made.

  3. Export the deck the same directory where your repository is located so that export will overwrite media directory and JSON file in the repository. (As an alternative you can export it elsewhere and copy JSON file and media directory yourself to overwrite the ones that are in repository directory.)

  4. Add the changes to the repository:

    git add *
    git commit -m "new updates"
    
  5. Upload changes you've made to the GitHub:

    git push origin master
    

If you just want to get latest changes from other people - you need to perform only steps 1 and 2.

Generic collaboration workflow

The current workflow could be described as following:

  • The user creates or imports an Anki deck.
  • He makes some modification to it (i.e. to notes, deck settings, deck structure or note models).
  • Then the user can export the deck in JSON format (accompanied by media directory with media files used in that deck) and share it with other users. For example by creating GitHub repository with it.
  • Other people then can either modify JSON directly or import the deck to their instance of Anki and then make some modifications to it.
  • Original JSON then can be updated the with the changes, these people made (merging several changes together if necessary).
  • After that original user (and other people) can import updated deck to integrate these new changes into their collection.

Export

To perform the export go to menu File > Export

Select the deck and the export format "CrowdAnki JSON representation". After pressing the Export button - select directory where the result should be stored.

Limitations:

  • CrowdAnki won't allow you to do export of "All decks", you should use CrowdAnki snapshot instead.
  • Export of a filtered deck is not supported, export the main deck instead and filter it again after importing. You don't have to delete existing filtered decks, as all cards are still part of the main deck. When exporting nested decks, filtered sub-decks are just ignored.

Import

To perform the import go to menu File > CrowdAnki: Import from disk and select the directory where the deck is stored.

Import from git

To get the deck from a git repository (such as GitHub) go to menu File > CrowdAnki: Import git repository and enter the repository's full URL.

So, for example, to get my git deck you would need to enter https://github.com/Stvad/Software_Engineering__git.

Things to note for the Import:

  • Automatic backup would be triggered prior to the import;
  • If note model for the note has changed, or if note model itself changed in a way that it's not easy to update it automatically: you would be prompted with the window, that will ask you to specify correspondence between old and new model;
  • If the note was moved to another deck in JSON file, on import all cards from that note (except the ones, that are in dynamic decks) will be moved to the specified deck.

Snapshots

CrowdAnki can help you preserve the history of edits for your decks.
It does this by exporting them in a specified location and creating a git commit each time you do a snapshot.

You can take snapshots manually via File > CrowdAnki: Snapshot menu action. Or you can enable automated snapshots in add-on configuration (see below) which will take a snapshot each time you open or close anki.

Configuration Settings

You can find the add-on's config page via Tools -> Add-ons, select CrowdAnki then hit Config. In here you can set a some config options, as well as a detailed explanation on what each does, with examples and default behaviour.

Here is a general summary of the currently available config options:

  • Snapshot Path: location of the snapshot will be exported to
  • Snapshot Root Decks: when a snapshot is taken a git repo will be generated for each of these decks
  • Automated Snapshot: whether the snapshot happens automatically
  • Do Not Move Existing Cards on Import: whether to move already existing cards on import or not
  • Deck Sort Methods: how to sort cards on export
  • Reverse Sort Order: whether to reverse the sorting of cards on export

crowdanki's People

Contributors

aplaice avatar dependabot[bot] avatar evandrocoan avatar evolverine avatar fredrikrab avatar friebetill avatar katrinleinweber avatar ohare93 avatar stvad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

crowdanki's Issues

Github security updates have broken crowdanki

When trying to import from my github anki deck I get the following notice:

Error while trying to get deck from Github: <urlopen error [Errno 1] _ssl.c:507: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version>

and error message:
\An error occurred in an add-on.
Please post on the add-on forum:
https://anki.tenderapp.com/discussions/add-ons

Traceback (most recent call last):
File "/Users/chris/Library/Application Support/Anki2/addons/crowd_anki/main.py", line 31, in
github_import_action.triggered.connect(lambda : GithubImporter.on_github_import_action(mw.col))
File "/Users/chris/Library/Application Support/Anki2/addons/crowd_anki/github/github_importer.py", line 29, in on_github_import_action
github_importer.import_from_github()
File "/Users/chris/Library/Application Support/Anki2/addons/crowd_anki/github/github_importer.py", line 44, in import_from_github
self.download_and_import(repo)
File "/Users/chris/Library/Application Support/Anki2/addons/crowd_anki/github/github_importer.py", line 48, in download_and_import
response = urllib2.urlopen(GITHUB_LINK.format(repo))
File "urllib2.pyc", line 127, in urlopen
File "urllib2.pyc", line 404, in open
File "urllib2.pyc", line 422, in _open
File "urllib2.pyc", line 382, in _call_chain
File "urllib2.pyc", line 1222, in https_open
File "urllib2.pyc", line 1184, in do_open
urllib2.URLError: <urlopen error [Errno 1] _ssl.c:507: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version>

This appears to be caused by a github update: https://githubengineering.com/crypto-removal-notice/

Snapshot <class 'OSError'>: [WinError 123] 文件名、目录名或卷标语法不正确

In my option, it results from the name of deck including '\n', but it is hard to find the '\n', because it is invisible. You can filter it when building the file.
I'm a chinese student, and my English is poor, so I paste the English Error code.

Error
An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed.
If the issue only occurs when add-ons are enabled, please use the Tools>Add-ons menu item to disable some add-ons and restart Anki, repeating until you discover the add-on that is causing the problem.
When you've discovered the add-on that is causing the problem, please report the issue on the add-ons section of our support site.
Debug info:
Anki 2.1.11 (3cf770c7) 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 "aqt\main.py", line 172, in onOpenProfile
File "aqt\main.py", line 263, in loadProfile
File "anki\hooks.py", line 29, in runHook
File "C:\Users\L.M.Sherlock\AppData\Roaming\Anki2\addons21\1788670778\history\archiver_vendor.py", line 42, in snapshot_on_sync
self.do_snapshot('CrowdAnki: Snapshot on sync')
File "C:\Users\L.M.Sherlock\AppData\Roaming\Anki2\addons21\1788670778\history\archiver_vendor.py", line 47, in do_snapshot
reason=reason)
File "C:\Users\L.M.Sherlock\AppData\Roaming\Anki2\addons21\1788670778\history\archiver.py", line 23, in archive
self.deck_archiver_supplier(deck).archive(reason=reason)
File "C:\Users\L.M.Sherlock\AppData\Roaming\Anki2\addons21\1788670778\history\anki_deck_archiver.py", line 19, in archive
deck_path = self.deck_exporter.export_to_directory(self.deck, self.output_directory)
File "C:\Users\L.M.Sherlock\AppData\Roaming\Anki2\addons21\1788670778\export\anki_exporter.py", line 26, in export_to_directory
deck_directory.mkdir(parents=True, exist_ok=True)
File "pathlib.py", line 1257, in mkdir
File "pathlib.py", line 1348, in is_dir
File "pathlib.py", line 1158, in stat
File "pathlib.py", line 387, in wrapped
<class 'OSError'>: [WinError 123] 文件名、目录名或卷标语法不正确。: 'C:\Users\L.M.Sherlock\AppData\Roaming\Anki2\addons21\1788670778\user_files\整合\3_生物组__1_必修一__1-5细胞的分化、衰老和凋亡__(2)细胞的全能性\n'

Snapshot/export will fail if there is a dynamic deck that is a sub-deck of the top level standard deck.

Error example:

Error 
An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed. 
If the issue only occurs when add-ons are enabled, please use the Tools>Add-ons menu item to disable some add-ons and restart Anki, repeating until you discover the add-on that is causing the problem. 
When you've discovered the add-on that is causing the problem, please report the issue on the add-ons section of our support site. 
Debug info:
Anki 2.1.11 (3cf770c7) Python 3.6.7 Qt 5.12.1 PyQt 5.11.3
Platform: Mac 10.14.3
Flags: frz=True ao=True sv=1
Add-ons possibly involved: 1788670778

Caught exception:
  File "/Users/sitalov/Library/Application Support/Anki2/addons21/1788670778/history/archiver_vendor.py", line 39, in do_manual_snapshot
    self.do_snapshot('CrowdAnki: Manual snapshot')
  File "/Users/sitalov/Library/Application Support/Anki2/addons21/1788670778/history/archiver_vendor.py", line 47, in do_snapshot
    reason=reason)
  File "/Users/sitalov/Library/Application Support/Anki2/addons21/1788670778/history/archiver.py", line 23, in archive
    self.deck_archiver_supplier(deck).archive(reason=reason)
  File "/Users/sitalov/Library/Application Support/Anki2/addons21/1788670778/history/anki_deck_archiver.py", line 19, in archive
    deck_path = self.deck_exporter.export_to_directory(self.deck, self.output_directory)
  File "/Users/sitalov/Library/Application Support/Anki2/addons21/1788670778/export/anki_exporter.py", line 28, in export_to_directory
    deck = deck_initializer.from_collection(self.collection, deck.name)
  File "/Users/sitalov/Library/Application Support/Anki2/addons21/1788670778/representation/deck_initializer.py", line 22, in from_collection
    for child_name in direct_children]
  File "/Users/sitalov/Library/Application Support/Anki2/addons21/1788670778/representation/deck_initializer.py", line 22, in <listcomp>
    for child_name in direct_children]
  File "/Users/sitalov/Library/Application Support/Anki2/addons21/1788670778/representation/deck_initializer.py", line 13, in from_collection
    deck._load_metadata()
  File "/Users/sitalov/Library/Application Support/Anki2/addons21/1788670778/representation/deck.py", line 77, in _load_metadata
    self._load_deck_config()
  File "/Users/sitalov/Library/Application Support/Anki2/addons21/1788670778/representation/deck.py", line 81, in _load_deck_config
    new_config = DeckConfig.from_collection(self.collection, self.anki_dict["conf"])
<class 'KeyError'>: 'conf'

Intorduce round-trip test

To minimize chances of things like #41, and give more gurantees for things like #34

This is made harder by the fact of relience on Anki runtime to do the actual work of getting info to/storing info from collection.

Some insight about Anki.

I didn't find your mail address so use ticket for this purpose.

Recently I decided to pull my personal dictionary to some SRS with requirement that subsequent updates can be merged with preserving learning progress. Among free SRS with mobile clients only Anki with AnkiDroid able to do that.

You may interested in my adventure:

My solution for preserving node.guid is based on hashing headword with mixing of file name and card type. Also model['id'] should be preserved and it is generated from file name. Details at http://hg.defun.work/gadict/file/tip/py/gadict_srs_anki.py

I think that JSON is not appropriate for unqualified users. You should consider FAQ format because of it verbosity. You may get idea from AnyMemo specification:

https://web.archive.org/web/20160309022328/http://anymemo.org/index.php?page=amc-guide1

I think line oriented format works the best, as illustration:

model-id: 123456789123456789 (8 byte integer is about 18 digit number)
model-css: ...

guid: xxx-xxx-yyy  (sqlite type text - any string sequence)
Q: Hello from Dnipro!
A: Привіт з Дніпра!
PRON: prɪvit z dniprɑ

May be YAML another good option instead of JSON. It verbose for ordinary users and keeps structure for programming access.

Re-importing a deck forces already-existing cards to be moved

How to reproduce:

  1. Import a .json deck.
  2. Move some of the imported cards into another Anki deck
  3. Re-import the same .json deck, which reverts step 2

Desired behaviour: Don't move already existing cards

There might be a more fundamental problem with this issue: If CrowdAnki is used by several people, then it's not possible for them to have different deck hierarchies. Once upon a time I programmed a similar (yet incomplete) collaboration plugin and I solved this problem by not exporting single decks, but rather entire note types and their notes. The advantage of this approach is that every individual person can have individual deck hierarchies. Would this correspond to your idea of how syncing/collaborating is supposed to work?

Incorrect JSON when exporting a deck containing cloned note types

Details:

Say there are two note types type1 and type2 and type1 was cloned (anki feature while creating new note types) to create type2. Now create a deck ABC which has notes based on the two note type1 and type2. If you export deck ABC using CrowdANKI, the resulting JSON representation will have only one note type or one NoteModel. As a result all the notes in the JSON which were exported from deck ABC will have the crowdanki_uuid of this NoteModel as the note_model_uuid. Importing this JSON representation to Anki will eventually result in a crash. For whatever reason, crowdanki is assuming a cloned note type and its parent to be identical (?)

Anki Version 2.1.5
Qt 5.9.2 PyQt 5.9
Platform: Windows 10

Deck won't round-trip.

Hi, I've got a deck that won't round-trip. It seems fine in Anki, but when I export it and then import it, it gives the error below:

I'm happy to help you debug it! What do you need?

Error
An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed.
If the issue only occurs when add-ons are enabled, please use the Tools>Add-ons menu item to disable some add-ons and restart Anki, repeating until you discover the add-on that is causing the problem.
When you've discovered the add-on that is causing the problem, please report the issue on the add-ons section of our support site.
Debug info:
Anki 2.1.11 (3cf770c7) Python 3.6.7 Qt 5.12.1 PyQt 5.11.3
Platform: Linux
Flags: frz=True ao=True sv=1
Add-ons possibly involved: CrowdAnki JSON exportimport Edit history Collaborate on deck creation

Caught exception:
File "/home/john/.local/share/Anki2/addons21/1788670778/anki/ui/action_vendor.py", line 29, in
lambda: AnkiJsonImporter.import_deck(self.window.col, self.directory_vendor))
File "/home/john/.local/share/Anki2/addons21/1788670778/importer/anki_importer.py", line 80, in import_deck
AnkiJsonImporter.import_deck_from_path(collection, Path(directory_path))
File "/home/john/.local/share/Anki2/addons21/1788670778/importer/anki_importer.py", line 69, in import_deck_from_path
importer.load_from_directory(directory_path, import_media)
File "/home/john/.local/share/Anki2/addons21/1788670778/importer/anki_importer.py", line 45, in load_from_directory
self.load_from_file(directory_path.joinpath(directory_path.name).with_suffix(DECK_FILE_EXTENSION))
File "/home/john/.local/share/Anki2/addons21/1788670778/importer/anki_importer.py", line 30, in load_from_file
deck.save_to_collection(self.collection)
File "/home/john/.local/share/Anki2/addons21/1788670778/representation/deck.py", line 141, in save_to_collection
name = self._save_deck(collection, parent_name)
File "/home/john/.local/share/Anki2/addons21/1788670778/representation/deck.py", line 171, in _save_deck
self.anki_dict["conf"] = self.metadata.deck_configs[self.deck_config_uuid].anki_dict["id"]
<class 'KeyError'>: 'c675e2b3-9a7b-11e9-9bae-342387e2ac49'

Save name of last used repository

When importing from GitHub it would be a nice feature to save the last repository used (which in my and many others' case would be the only repository), to save having to look up the name and copy paste it each time

Import deck from git repository link

Instead of just downloading the repository, collaboration on decks requires cloning repositories, in order to have the original remote configured, so that people can push their changes to github.

ImportError: No module named ntpath on Anki

I have Anki 2.0.36, Qt 4.8.2 PyQt 4.9.4, on OS X 10.11.6.

I've installed the AnkiHub add-on, and then CrowdAnki. I've removed all other add-ons and I'm sadly still getting the error.

An error occurred in an add-on.
Please post on the add-on forum:
https://anki.tenderapp.com/discussions/add-ons

Traceback (most recent call last):
  File "aqt/addons.pyc", line 41, in loadAddons
  File "/Users/andrei/Documents/Anki/addons/crowd_anki_importer.py", line 1, in <module>
  File "/Users/andrei/Documents/Anki/addons/crowd_anki/main.py", line 1, in <module>
  File "/Users/andrei/Documents/Anki/addons/crowd_anki/thirdparty/pathlib.py", line 1, in <module>
  File "/Users/andrei/Documents/Anki/addons/crowd_anki/thirdparty/pathlib2.py", line 5, in <module>
ImportError: No module named ntpath

This doesn't crash Anki, but only makes the CrowdAnki plugin unusable. Please do let me know if you need additional details.

UnicodeEncodeError: 'ascii' codec can't encode character u'\xfd' in position 18: ordinal not in range(128)

When exporting collection with texts with special national characters, such as: á é í ó ú č š ž Anki crowd runs into this exception

An

error occurred in an add-on.
Please post on the add-on forum:
https://anki.tenderapp.com/discussions/add-ons

Traceback (most recent call last):
File "aqt\exporting.py", line 116, in accept
File "C:\Users\USER\AppData\Roaming\Anki2\addons\crowd_anki\anki_exporter_wrapper.py", line 38, in exportInto
self.anki_json_exporter.export_deck_to_directory(deck_name, Path(directory_path).parent, self.includeMedia)
File "C:\Users\USER\AppData\Roaming\Anki2\addons\crowd_anki\anki_exporter.py", line 32, in export_deck_to_directory
deck_directory = output_dir.joinpath(deck_fsname)
File "C:\Users\USER\AppData\Roaming\Anki2\addons\crowd_anki\thirdparty\pathlib2.py", line 1008, in joinpath
return self._make_child(args)
File "C:\Users\USER\AppData\Roaming\Anki2\addons\crowd_anki\thirdparty\pathlib2.py", line 790, in _make_child
drv, root, parts = self._parse_args(args)
File "C:\Users\USER\AppData\Roaming\Anki2\addons\crowd_anki\thirdparty\pathlib2.py", line 748, in _parse_args
parts.append(str(a))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xfd' in position 18: ordinal not in range(128)

I found it as known issue in python: discussion 1
discussion 2

This is blocker, collection can't be exported at all.

I'm running Anki 2.0.44 and freshly installed plugin.

Automated committing of changes upon AnkiWeb synchronization

One thing that would immediately make this useful to me, is if it automatically executed git commit --allow-empty-message -m '' or similar every time AnkiWeb synchronization completed (and thus, most crucially, every time I launch or exit Anki.) I'd really like to only interact with this plugin only to merge changes pulled from GitHub or similar … not to export them in the first place, if that makes sense.

Is this do-able? I haven't looked at Anki's plugin-architecture, but I'd hope so …

Preserve Deck Edit history

The idea would be to do have the git repo (not sure if for the whole collection/top level deck/more granular - potentially can be configurable)
And on each edit (adding, removing notes, changing options, etc) - make an automated export and commit (and optionally push to origin).
Alternatively it can be performed on the regular intervals (e.g. every 5 min), but the change hook feels more meaningful to me (regular push to origin makes sense to me though).

Having git repo would open the route to further enhancements

Cannot import a deck with modified model

Tried to export a deck, modify template and import back.

Debug info:
Anki 2.1.0beta38 Python 3.6.2 Qt 5.9.3 PyQt 5.9.2
Platform: Linux
Flags: frz=False ao=True

Caught exception:
File "/home/qmax/.local/share/Anki2/addons21/1788670778/main.py", line 23, in on_import_action
AnkiJsonImporter.import_deck(aqt.mw.col, import_directory)
File "/home/qmax/.local/share/Anki2/addons21/1788670778/anki_importer.py", line 72, in import_deck
importer.load_from_directory(directory_path, import_media)
File "/home/qmax/.local/share/Anki2/addons21/1788670778/anki_importer.py", line 48, in load_from_directory
self.load_from_file(directory_path.joinpath(directory_path.name).with_suffix(DECK_FILE_EXTENSION))
File "/home/qmax/.local/share/Anki2/addons21/1788670778/anki_importer.py", line 33, in load_from_file
deck.save_to_collection(self.collection)
File "/home/qmax/.local/share/Anki2/addons21/1788670778/representation/deck.py", line 177, in save_to_collection
note_model.save_to_collection(collection)
File "/home/qmax/.local/share/Anki2/addons21/1788670778/representation/note_model.py", line 56, in save_to_collection
self.update_cards(collection, note_model_dict)
File "/home/qmax/.local/share/Anki2/addons21/1788670778/representation/note_model.py", line 77, in update_cards
ChangeModelDialog(collection, collection.models.nids(old_model), old_model).exec_()
<class 'NameError'>: name 'ChangeModelDialog' is not defined

GitHub integration

Export a deck to GitHub directly from Anki.

one deck = one GitHub repository. People want to fork one of your decks, not all of your decks.

After a pull request has been merged on GitHub, Anki detects that, and retrieve the changes automatically from GitHub (if detection is not feasible, at least retrieve the changes at the click of a button within Anki).

Anki 2.1

Couldn't install it on Anki 2.1 (from AnkiWeb)

Is the plugin compatible? Are there any plans for future?

Installing add-on from AnkiWeb does not work

Expectation: Installing the add-on from AnkiWeb like normal would result in the add-on being installed.

What happened: After installation there is no indication that the add-on was installed, no item in the Tools > Add-ons menu, and nothing has been added to the File menu or the Export formats dropdown.

Steps to reproduce:

  1. Using fresh Anki, no add-ons
  2. Tools > Add-ons > Browse & install...
  3. Paste 1788670778 and Install
  4. Restart Anki
  5. See no indication that the add-on was installed.

Anki Version: 2.0.47 Linux

Note: After install my add-ons directory ~/.local/share/Anki2/addons looked like this:

addons/
└─ crowd_anki/
   ├─ crowd_anki_importer.py
   └─ crowd_anki/
      └─ (package files)

I moved the files out of the top-level crowd_anki directory and restarted Anki, then the plugin worked as expected. For completeness, here is my add-ons directory after the change:

addons/
├─ crowd_anki_importer.py
└─ crowd_anki/
   └─ (package files)

How to add snapshot path

Hi,
Sorry for this noob question regarding snapshots in crowdanki. I want to use the snapshot feature of crowdanki to keep track of my deck edits. So, based on the guide I made an account on github and installed the desktop client. I tried to input the default github directory into the configuration file for the addon. However, I got the following error. Kindly help.

Invalid configuration: JSONDecodeError('InvaIid line 2 column 22 (char 23)',)

{
	"snapshot_path": "C:\Users\.....\Documents\GitHub"
    "automated_snapshot": false,
    "snapshot_root_decks": []
}

Error when deck name includes non-ASCII characters

An error occurred in an add-on.
Please post on the add-on forum:
https://anki.tenderapp.com/discussions/add-ons

Traceback (most recent call last):

  File "aqt\exporting.py", line 116, in accept
  File "C:\Users\evolverine\Documents\Anki\addons\crowd_anki\anki_exporter_wrapper.py", line 37, in exportInto
    self.anki_json_exporter.export_deck_to_directory(deck_name, Path(directory_path).parent, self.includeMedia)
  File "C:\Users\evolverine\Documents\Anki\addons\crowd_anki\anki_exporter.py", line 50, in export_deck_to_directory
    self._copy_media(deck, deck_directory)
  File "C:\Users\evolverine\Documents\Anki\addons\crowd_anki\anki_exporter.py", line 71, in _copy_media
    str(media_directory.resolve()))
  File "shutil.py", line 116, in copy
  File "ntpath.py", line 108, in join
    If the path contained a UNC path, the drive_or_unc will contain the host name
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position 67: ordinal not in range(128)

Large anki decks result in merge conflicts due to poor git diff

Steps to reproduce: Have two people independently edit the shared deck and attempt to commit. My deck size is ~7000 cards.
Expected result: Git should be able to merge without conflicts unless the same card/model/media has been edited by both people.
Actual result: Git has a lot of difficulty combining large JSON files, with a large number of merge conflicts that Git can't resolve automatically. This occurs even if two different cards are edited. I am not the first person to run into this issue (albeit in a different context), and it seems to be an issue with git not being able to diff large JSON files properly.
Proposed solution: Issue can be resolved if line breaks are added between objects in a JSON array as described in this Stack Overflow post. Suggest that when exporting using CrowdAnki add line breaks between objects in the notes array.

Port to Anki 2.1.0

Trying to install the plugin (1788670778) results in the following error with Anki 2.1.0a4:

An error occurred in an add-on.
Please post on the add-on forum:
https://anki.tenderapp.com/discussions/add-ons

Caught exception:
  File "aqt/addons.py", line 172, in accept
  File "aqt/addons.py", line 136, in install
<class 'TypeError'>: initial_value must be str or None, not bytes

The API has changed so plugins must be ported.
https://anki.tenderapp.com/discussions/beta-testing/180-anki-210-alpha-4

Require a license statement, and embed it in the JSON

Having a license lets people fork decks without worrying about legal trouble.
In case of share-alike licenses like CC-BY-SA or GNU-GPL, the license also prevents people from selling a derived deck without publishing it freely too.
So, better require everyone to specify a license, and embed this license in the JSON file.
The license question could be a very simple question when exporting:

- Should people who modify this deck make their modifications available to everyone? -> CC-BY-SA-3.0
- Can people do what they want with this deck, including selling a modified version of it? -> MIT
- Nobody is allowed to modify this deck? -> EULA

or something similar.

Feature Request - Ignore Field on Import/Export

I love the collaboration that this add-on allows, but there is one thing that is stopping me from being able to share my decks with others. I want to begin sharing some of my personal language learning decks with others, however I use images in my cards. Using images is wonderful for memory, there's nothing better. But when my deck is filled to the brim with copyrighted images simply taken from Google Images for personal use, this makes my decks completely unshareable. Of course it would be better if I had copyright free images (which I do for some), but finding that for thousands of notes, especially vague concepts, is incredibly challenging.

Potential Solution: The ability to flag any field(s) so that their value will not be exported/imported. This would allow each user to set their own picture, while still being able to import the deck when it is upgraded without their manually set "Picture" field being overwritten. Exporting without certain fields would be nice, but I will be using other deck managers like AnkiDM, so Importing really is the main issue.

I imagine this could be implemented for importing in many ways.

  1. State that the field should not import in the Note Model. The field should still be taken into account so you can match it to the correct Note Type, but it's value will not be put into the Note itself (thus leaving anything the user has set changed).
  "note_models": [
    {
      "__type__": "NoteModel",
      "crowdanki_uuid": "43e2586a-9a65-11e8-a777-a0481cc15658",
      "name": "Ultimate Geography",
      "flds": [
        {
        ...
        {
          "name": "Map",
          "ord": 7,
          "font": "Arial",
          "media": [],
          "rtl": false,
          "size": 20,
          "sticky": false
          "doNotImport": true        <-----------------------------
        }
      ],
  1. State that the specific card does not overwrite specific fields, with some type of generic flag which CrowdAnki reads on Import.
  "notes": [
    {
      "__type__": "Note",
      "data": "",
      "fields": [
        "England",
        "Constituent country of the United Kingdom.",
        "London",
        "",
        "Constituent country",
        "<img src=\"ug-flag-england.svg\" />",
        "",
        false                 <----------------------------------
      ],
      "flags": 0,
      "guid": "e+/O]%*qfk",
      "note_model_uuid": "43e2586a-9a65-11e8-a777-a0481cc15658",
      "tags": [
        "UG::Europe"
      ]
    },

This feature would be useful in a number of different ways, not just stopping the sharing of copyrighted images. In the Ultimate Geography deck, for instance, there could be a field "Personal Notes" with the users own memory or personal helpful tip on that country. Everyone surely has these personal thoughts which could aid them in recall, but in a shared deck like this it is impossible to add in your own, without the risk of losing them when you next upgrade. With this feature, no longer will you be stuck deciding one or the other!

Thanks again for your great work with this add-on, it's a real boon to the community! 👍

Feature request - json-schema to validate the anki json file

First of all, many many thanks for this. Rated on the add-in site with below comment-
"A big thumbs up!! Much more faster to update the decks in a text editor than application. Of course, it is for advanced users who are familiar with the data model. However, we need a schema file to validate the resultant anki json file to validate it so that we do not upload the corrupt json file. I am not sure schema exists, hence going to ask the developer for the same at the GitHub account."

IMHO, a baseline schema can be generated from the json file at "https://jsonschema.net/#/" and worked from there on. I use json-buddy json editor (http://www.json-buddy.com/json-schema-editor.htm) in which the schema can be referred and json can be validated for any semantic errors.

Unable to export deck as .json

I'm currently running Anki 2.0 on Win 10, and running into this exception when trying to export a single deck as JSON.

Edit: Removing the / from the deck name fixed this issue.

An error occurred in an add-on.
Please post on the add-on forum:
https://anki.tenderapp.com/discussions/add-ons

Traceback (most recent call last):
  File "aqt\exporting.py", line 116, in accept
  File "C:\Users\User\AppData\Roaming\Anki2\addons\crowd_anki\anki_exporter_wrapper.py", line 37, in exportInto
    self.anki_json_exporter.export_deck_to_directory(deck_name, Path(directory_path).parent, self.includeMedia)
  File "C:\Users\User\AppData\Roaming\Anki2\addons\crowd_anki\anki_exporter.py", line 40, in export_deck_to_directory
    with deck_filename.open(mode='w', encoding="utf8") as deck_file:
  File "C:\Users\User\AppData\Roaming\Anki2\addons\crowd_anki\thirdparty\pathlib2.py", line 1385, in open
    encoding, errors, newline)
IOError: [Errno 2] No such file or directory: 'C:\\Users\\User\\Desktop\\Core_2k\\6k_Optimized_Japanese_Vocabulary\\Core_2k\\6k_Optimized_Japanese_Vocabulary.json'

UUIDs differ

I've got anki running on two computers (and also two mobile phones) , all synced through ankiweb.

If I export my deck on my laptop, all is fine, but if I export it on the desktop computer I get a completely different set of uuids in the .json, which of course git thinks is a vast set of changes.

This seems to be a problem, what should I do? I can see that I could only use one computer for exporting/uploading changes, but won't any potential collaborators have the same issues?

Export error - character maps

"Species Taxonomy" deck


An error occurred in an add-on.
Please post on the add-on forum:
https://anki.tenderapp.com/discussions/add-ons

Traceback (most recent call last):
File "C:\cygwin\home\dae\win\build\pyi.win32\anki\outPYZ1.pyz/aqt.exporting", line 108, in accept
File "C:\Users\myuser\Documents\Anki\addons\crowd_anki\anki_exporter_wrapper.py", line 35, in exportInto
self.anki_json_exporter.export_deck_to_directory(deck_name, Path(directory_path).parent, self.includeMedia)
File "C:\Users\myuser\Documents\Anki\addons\crowd_anki\anki_exporter.py", line 26, in export_deck_to_directory
ensure_ascii=False)))
File "C:\cygwin\home\dae\win\build\pyi.win32\anki\outPYZ1.pyz/encodings.cp1252", line 19, in encode
UnicodeEncodeError: 'charmap' codec can't encode characters in position 3430-3433: character maps to


Export/import a deck without configuration

  1. Let's say I have a deck in Anki with configuration A = 10 new cards + 100 reviews / day.
  2. I export the deck with CrowdAnki.
  3. I switch the deck to configuration B = 5 new cards + 50 reviews / day.
  4. I re-import the deck.
  5. Deck has configuration A again instead of B.

This behaviour is problematic notably when users try to update a deck to a newer version. Is there any way exporting/importing a deck could not export/import the deck configuration? I tried removing keys deck_configurations and deck_config_uiid from the exported JSON before re-importing it, but I get an error 😢 :

Traceback (most recent call last):
  File "...\addons\crowd_anki\main.py", line 23, in on_import_action
    AnkiJsonImporter.import_deck(aqt.mw.col, import_directory)
  File "...\addons\crowd_anki\anki_importer.py", line 68, in import_deck
    importer.load_from_directory(directory_path, import_media)
  File "...\addons\crowd_anki\anki_importer.py", line 44, in load_from_directory
    self.load_from_file(directory_path.joinpath(directory_path.name).with_suffix(DECK_FILE_EXTENSION))
  File "...\addons\crowd_anki\anki_importer.py", line 27, in load_from_file
    deck = Deck.from_json(deck_json)
  File "...\addons\crowd_anki\representation\deck.py", line 154, in from_json
    deck.deck_config_uuid = json_dict["deck_config_uuid"]
KeyError: 'deck_config_uuid'

Make ‘respecting the movement of cards between decks’ optional

The documentation states that, if a card is in a different deck when a CrowdAnki deck is imported, that it will be moved in Anki as well.

This should be optional: decks should be able to be, optionally, ’virtual‘ — that is, a “Foo” deck with 24 cards is imported, but then those cards are moved by the user into another “Major” deck with hundreds of other cards, then re-importing “Foo” should simply update those notes/cards where they already exist: in the “Major” deck.

The issue here is scalability: Anki (as mentioned in the manual) doesn't handle large numbers of decks, well. It's pretty standard practice to distribute a subset of information in a “shared deck”, but usually, one merges many of those into a single deck per subject (or writes their own cards about that subject, that don't belong in the original shared deck, or … you get the idea.) Thus, it makes sense for (most) CrowdAnki decks to be ‘virtual’ like that: import them, merge them into your own subject-specific decks, and then merge upstream changes as they're offered.

(Really the only situation where one wants ‘concrete’ decks, ones that precisely match the CrowdAnki representation, and follow said representation when it's imported if it's changed, is when one is using CrowdAnki to backup/record one's entire collection — and that's currently not well-supported in other ways, so …)

Just some thoughts! (=

Imports that change note types cannot be cancelled

When importing from github where a remote change prompts a change of note type (eg changes cards and fields) the dialog box pops up as for changing note type for an individual card, and asks you what card and fields you want to be changed to. If you hit cancel at this point (eg if a remote change is incorrect and you don't want it) regardless crowdanki will force the note type change and the subsequent requirement for a full database sync. The correct behaviour should be to atomically abort a git import if the user hits cancel. This may require checking for changes to note types before the import is made.

Deck name vs. repository name

  • On export, CrowdAnki outputs a folder named after the deck - e.g. My Deck becomes My_Deck.
  • To import from GitHub, CrowdAnki requires the repository to be named after the deck - e.g. My_Deck.

I'm not very keen on having the name of my GitHub repo bound to the name of the deck. I think the add-on would really benefit from a bit more flexibility in this regard.

I can think of a couple of options:

  1. Include the name of the deck in the JSON and allow exporting the deck to any folder (i.e. the export doesn't create the folder).
    • Upside: nice separation of concern; during the import CrowdAnki can just look for the JSON file and the media folder at the root of the repo and parse the content of the file to get the name of the deck.
    • Downside: changing the format is not ideal... although for backward compatibility, if the JSON file doesn't contain the name of the deck, its filename could be used as fallback.
  2. Keep the export as is, but allow selecting a custom folder inside the git repository during the import.
    • Upside: probably more straightforward to implement; no change to the JSON format.
    • Downside: superfluous folder nesting; makes import more complex for end users.

media_files has different order on each export

media_files list seems to have a different sorting each time you exporte the deck. Which leads to a noise in git commits on snapshots and to potential git conflicts when collaborating on a deck. I believe I do sort keys on json serialization, but this probably is not sorted and comes from the original sorting of that list on the python side

Install with AnkiHub: HTTP Error 404

I saw the note AnkiHub can be used with this plugin. Thus I installed AnkiHub and tried to use it to install CrowdAnki. In the "Path" dialog, I entered Stvad/CrowdAnki. The result was this error:

An error occurred in an add-on.
Please post on the add-on forum:
https://anki.tenderapp.com/discussions/add-ons

Traceback (most recent call last):
File "/Users/cgorichanaz/Library/Application Support/Anki2/addons/___ankihub.py", line 271, in addRepository
update([repo],install=True)
File "/Users/cgorichanaz/Library/Application Support/Anki2/addons/___ankihub.py", line 235, in update
response = urllib2.urlopen("https://api.github.com/repos/{0}/releases/tags/{1}".format(path,minorTagName))
File "urllib2.pyc", line 127, in urlopen
File "urllib2.pyc", line 410, in open
File "urllib2.pyc", line 523, in http_response
File "urllib2.pyc", line 448, in error
File "urllib2.pyc", line 382, in _call_chain
File "urllib2.pyc", line 531, in http_error_default
urllib2.HTTPError: HTTP Error 404: Not Found

I am already hastily trying to wrap up a tangent off a tangent off a tangent of what I am really trying to work on, so instead of tracing this more (maybe I made a simple mistake), I've just installed CrowdAnki via the traditional numeric ID method.

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.