Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upsimplifying installation? #65
Closed
Comments
|
For reference the patch would just be something as simple as: commit 2c6be2df691113298d7438bda8379157ab86ae84
Author: Aleksa Sarai <cyphar@cyphar.com>
Date: Wed Aug 26 01:16:58 2020 +1000
main: download accentAudio on startup
This avoids forcing users to go through annoying steps to download the
accentAudio, and makes the installation experience much nicer.
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
diff --git a/src/main.py b/src/main.py
index 5fa7f5ce3041..1a607909008f 100644
--- a/src/main.py
+++ b/src/main.py
@@ -4,8 +4,10 @@ from anki import models
from os.path import dirname, join
import sys, os, platform, re, subprocess, aqt.utils
from anki.utils import stripHTML, isWin, isMac
-from . import reading
-import re
+from . import reading
+import requests
+import tempfile
+import zipfile
import unicodedata
import urllib.parse
from anki.hooks import addHook, wrap, runHook, runFilter
@@ -355,7 +357,23 @@ def fetchAudioFromDict(word, yomi, idx):
return grabAudioForMultiReadingWord(word, yomi)
else:
return grabAudioForMultiPitchWord(word, yomi, idx)
-
+
+
+def setupAccentAudio():
+ # XXX: This needs to be changed to a proper URL.
+ ACCENT_URL = "http://download31.mediafire.com/mcg2h1l0skdg/ec0i8omoayfuc75/accentAudio.zip"
+ userFiles = join(addon_path, "user_files")
+ audioDir = join(userFiles, "accentAudio")
+ # If we don't have accent audio, download it.
+ if not exists(audioDir):
+ with tempfile.TemporaryFile(mode="w+b") as tmp:
+ with requests.get(ACCENT_URL, stream=True) as req:
+ for chunk in req.iter_content(chunk_size=16*1024):
+ tmpzip.write(chunk)
+ with zipfile.Zipfile(tmp) as tmpzip:
+ tmpzip.extractall(path=userFiles)
+
+setupAccentAudio()
def clickPlayAudio(cmd):
|
|
The reason that audio is hosted the way it is is because it is copyrighted content. Be on the lookout because I have some things planned that will change this in the near future though. |
|
Ah, that makes much more sense. Thanks, and I look forward to whatever you come up with. :D |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Type:
Environment:
I'm going to open a PR to resolve the issue:
Description:
The installation instructions on the Anki add-on page indicate that we need to download and extract a file from MediaFire in order to get this add-on to work (because the file is too large to embed into the bundled data for the add-on on AnkiWeb). That's all fine and good -- but is there a reason that the add-on doesn't just download and extract this file for users? It would make installation much simpler and less error-prone.
As an aside, the file being hosted on MediaFire seems a little bit odd to me when you could just as easily host it on GitHub (as a release artefact) where it'd be much more safe IMHO to store long-term (you could even commit it to the repository in a separate branch -- which would be a more extreme solution).
I'd be happy to send a patch to fix all of this (it'd be fairly simple to do -- though we probably couldn't use
requests), but I wanted to check whether this is something that you'd be interested in being fixed?