Write a script that downloads the torrent The WIRED CD and displays all the files in the torrent, regardless of their file type. In addition to .mp3
files, this torrent also contains an album art image (a .jpg
file) and a readme file (a .md
file).
Let’s display all the files in the page, not just the .mp3
files!
Instead of selecting the .mp3
files, just loop over all the files in torrent.files
and display them all. Rather than give you the code for this one, we’re going to let you figure it out! If you get stuck, feel free to ask for help.
If it worked, you should see an <audio>
tag added to the page for each track in The WIRED CD. You should also see an image and a text file included, as well.
WebTorrent can even handle rendering images, .pdf
files, .html
files, .txt
files, and more. (If you’re curious, this magic is implemented in the render-media
package on npm.)
If you are stuck, read the solution.
When you are ready, go to the next exercise.