diff --git a/src/renderer/webtorrent.js b/src/renderer/webtorrent.js index e47d8ca7..97a7737b 100644 --- a/src/renderer/webtorrent.js +++ b/src/renderer/webtorrent.js @@ -339,8 +339,15 @@ console.log('Initializing...') function getAudioMetadata (infoHash, index) { const torrent = client.get(infoHash) const file = torrent.files[index] - mm.parseStream(file.createReadStream(), file.name, - {native: false, skipCovers: true}) + + const options = {native: false, skipCovers: true} + const onMetaData = file.done + // If completed; use direct file access + ? mm.parseFile(path.join(torrent.path, file.path), options) + // otherwise stream + : mm.parseStream(file.createReadStream(), file.name, options) + + onMetaData .then(function (metadata) { console.log('got audio metadata for %s: %o', file.name, metadata) ipc.send('wt-audio-metadata', infoHash, index, metadata)