diff --git a/anki/importing/__init__.py b/anki/importing/__init__.py index 4ac509448..a640f8b89 100644 --- a/anki/importing/__init__.py +++ b/anki/importing/__init__.py @@ -13,7 +13,7 @@ from anki.lang import _ Importers = ( (_("Text separated by tabs or semicolons (*)"), TextImporter), - (_("Packaged Anki Deck (*.apkg)"), AnkiPackageImporter), + (_("Packaged Anki Deck (*.apkg *.zip)"), AnkiPackageImporter), (_("Anki 1.2 Deck (*.anki)"), Anki1Importer), (_("Mnemosyne 2.0 Deck (*.db)"), MnemosyneImporter), (_("Supermemo XML export (*.xml)"), SupermemoXmlImporter), diff --git a/aqt/importing.py b/aqt/importing.py index a87890d9b..f30b55136 100644 --- a/aqt/importing.py +++ b/aqt/importing.py @@ -300,8 +300,15 @@ backup, please see the 'Backups' section of the user manual.""")) mw.progress.finish() diag = ImportDialog(mw, importer) else: - # if it's an apkg, we need to ask whether to import/replace + # if it's an apkg/zip, first test it's a valid file if importer.__class__.__name__ == "AnkiPackageImporter": + z = zipfile.ZipFile(importer.file) + try: + z.getinfo("collection.anki2") + except: + showWarning(_("The provided file is not a valid .apkg file.")) + return + # we need to ask whether to import/replace if not setupApkgImport(mw, importer): return mw.progress.start(immediate=True)