question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Media files are not being extracted

See original GitHub issue

I am not sure if i am doing something wrong but if i use the package.media_files as shown in the description, the resulted apkg archive contains all necessary files inside and they have correct values.

However i have checked %appdata%\Anki2\<profile_name>\collection.media and this folder remains empty after i install the apkg file.

If i manually drag all my media files there, then everything works as expected.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
redsigmacommented, Dec 30, 2021

@konhi I ran the code above as well and it seems that it is working and the .mp3 file gets copied to %appdata%Anki2\<profile>\collection.media\

The mistake which i was doing using images was this:

note = genanki.Note(MODEL, fields=['das', 'ten', 'test_meh.jpg'])  # test_meh.jpg won't be extracted
deck.add_note(note)
package = genanki.Package(deck, ['data/images/test_meh.jpg'])

The correct syntax is:

note = genanki.Note(MODEL, fields=['das', 'ten', '<img src=test_meh.jpg>'])  # test_meh.jpg gets extracted correctly
deck.add_note(note)
package = genanki.Package(deck, ['data/images/test_meh.jpg'])

I was under the impression that i could add the <img src="./{{Answer}}"> text inside the model and only mention the name of the files in the genanki.Note.

1reaction
redsigmacommented, Dec 28, 2021

No i couldn’t fix the problem. Currently i am manually copying the images and audio files to the collection.media folder. (for example %appdata%/Anki2/collection.media/data_deck1/<files>) and i am adding them by the relative path (./data_deck1/file) which seems to point to the collection.media folder.

So the answer is that package.media_files either does nothing or does not work

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tips to Fix Windows Cannot Complete the Extraction
Try different locations and if you can completely extract the files, then it goes without saying that the issue is the zip file...
Read more >
Fix Exracted Files or Files Not Showing in Folder Windows 10
Here are four solutions for files not showing in folder or extracted files not showing up in Windows 10. Try it to retrieve...
Read more >
How To Fix 'Windows Cannot Complete The Extraction' Error
More often than not, a lot of computer related problems can be solved with a restart. Click the Start menu; Click the power...
Read more >
SOLVED: “Windows Cannot Complete The Extraction” Error ...
... complete the extraction " when they try to open a zipped file they downloaded using Windows ... ... Your browser can't play...
Read more >
Extract files or objects from a PowerPoint file - Microsoft Support
You can extract files and objects, such as videos, photos or documents, from PowerPoint ... The following procedure works on Windows, but not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found