kamui-fin / yt-to-anki

Simple anki addon to generate decks from youtube videos
https://ankiweb.net/shared/info/964531817
GNU General Public License v3.0
24 stars 4 forks source link

Anki does not show the plugin anymore after the "Refactoring of the root module" commit #25

Closed stanislaw closed 1 year ago

stanislaw commented 1 year ago

This commit e2264d2, refactor: root ytsrs module seems to have broken some Anki convention: I no longer see the yt2srs in the Extras menu.

Does this have to do with a root __init__.py that is no longer there? How did you test this to work?

kamui-fin commented 1 year ago

Have you tried using the newly added dev task? Be sure to also create a symbolic link between the dist and the addon directory.

stanislaw commented 1 year ago

I have tried it like you recommended and I am getting this:

Fehler
Eine der installierten Erweiterungen konnte nicht geladen werden. Wenn das Problem weiter besteht, bitte über den Menüpunkt Extras → Erweiterungen die Erweiterungen deaktivieren oder deinstallieren

Beim Laden von '⁨964531817⁩':
⁨Traceback (most recent call last):
  File "/Users/stanislaw/.pyenv/versions/3.11.1/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/aqt/addons.py", line 247, in loadAddons
  __import__(addon.dir_name)
  File "/Users/stanislaw/Library/Application Support/Anki2/addons21/964531817/__init__.py", line 10, in <module>
  from .main import launch
  File "/Users/stanislaw/Library/Application Support/Anki2/addons21/964531817/main.py", line 8, in <module>
  from . import worker
  File "/Users/stanislaw/Library/Application Support/Anki2/addons21/964531817/worker.py", line 12, in <module>
  from .client_youtube import SubtitleRange, YouTubeClient, YouTubeDownloadResult
  File "/Users/stanislaw/Library/Application Support/Anki2/addons21/964531817/client_youtube.py", line 7, in <module>
  import youtube_dl
ModuleNotFoundError: No module named 'youtube_dl'

Does it mean that you recommend now to install youtube_dl from pip?

kamui-fin commented 1 year ago

Is there a lib directory that was generated in dist/ with the youtube_dl library bundled? And is the poetry environment activated? Make sure to run poetry install before running the dev task.

stanislaw commented 1 year ago

It would be great if you'd put together a small README section for how this should work. The invoke dev produces this result:

code/yt2srs (master) $ git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean
code/yt2srs (master) $ invoke dev
Traceback (most recent call last):
  File "/Users/stanislaw/.pyenv/versions/3.11.1/bin/invoke", line 8, in <module>
    sys.exit(program.run())
             ^^^^^^^^^^^^^
  File "/Users/stanislaw/.pyenv/versions/3.11.1/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/invoke/program.py", line 380, in run
    self.execute()
  File "/Users/stanislaw/.pyenv/versions/3.11.1/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/invoke/program.py", line 565, in execute
    executor.execute(*self.tasks)
  File "/Users/stanislaw/.pyenv/versions/3.11.1/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/invoke/executor.py", line 127, in execute
    result = call.task(*args, **call.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/stanislaw/.pyenv/versions/3.11.1/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/invoke/tasks.py", line 115, in __call__
    result = self.body(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/stanislaw/workspace/projects/code/yt2srs/tasks.py", line 140, in dev
    package_dev(context)
  File "/Users/stanislaw/.pyenv/versions/3.11.1/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/invoke/tasks.py", line 115, in __call__
    result = self.body(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/stanislaw/workspace/projects/code/yt2srs/tasks.py", line 132, in package_dev
    bundle_ffmpeg(context)
  File "/Users/stanislaw/.pyenv/versions/3.11.1/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/invoke/tasks.py", line 115, in __call__
    result = self.body(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/stanislaw/workspace/projects/code/yt2srs/tasks.py", line 124, in bundle_ffmpeg
    copytree("ffmpeg", "dist", dirs_exist_ok=True)
  File "/Users/stanislaw/.pyenv/versions/3.11.1/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/shutil.py", line 559, in copytree
    with os.scandir(src) as itr:
         ^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg'
kamui-fin commented 1 year ago

I will compile the development workflow information into the README. As far as the ffmpeg error goes, it assumes that you have a directory called ffmpeg/ with the executable ffmpeg.exe inside.

stanislaw commented 1 year ago

As far as the ffmpeg error goes, it assumes that you have a directory called ffmpeg/ with the executable ffmpeg.exe inside.

This I understand but where am I supposed to get these ffmpeg files?

Previously, I could get them by installing your extension via Anki and then replacing the code files with those from my repo. How do you obtain the ffmpeg.exe?

kamui-fin commented 1 year ago

You can find windows builds here: https://github.com/BtbN/FFmpeg-Builds/releases

stanislaw commented 1 year ago

Ok, the FFmpeg is ok but I am still missing some info.

Does it mean that with your new setup, I have to run invoke dev every time I make a change in the Python code?

Could we adjust this setup a little that during the development, I could symlink directly to the root of this repository? Would a root-level __init__ pointing to the ytsrs/__init__.py solve the problem?

stanislaw commented 1 year ago

Now I see: I was running Anki from its source and you are calling Anki via its Python interface. Now that I understand how this works, the approach of continuously running invoke dev makes sense.

@task()
def anki(context):
    import aqt

    aqt.run()

I found some problems with has_ffmpeg on macOS, I will send a PR now. It would be great to have this merged first because it contains a bug with a home directory variable: https://github.com/kamui-fin/yt2srs/pull/26.