From 2d17cfa7e15fee53482a5237c32b01acb51b0780 Mon Sep 17 00:00:00 2001 From: Borewit Date: Sun, 4 Mar 2018 18:43:12 +0100 Subject: [PATCH] #1332: Fix selection of poster.jpg|png|gif image --- src/renderer/lib/torrent-poster.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/renderer/lib/torrent-poster.js b/src/renderer/lib/torrent-poster.js index d4d2e601..c9b405d4 100644 --- a/src/renderer/lib/torrent-poster.js +++ b/src/renderer/lib/torrent-poster.js @@ -15,7 +15,7 @@ function torrentPoster (torrent, cb) { const posterFile = torrent.files.filter(function (file) { return /^poster\.(jpg|png|gif)$/.test(file.name) })[0] - if (posterFile) return torrentPosterFromImage(posterFile, torrent, cb) + if (posterFile) return extractPoster(posterFile, cb) // 'score' each media type based on total size present in torrent const bestScore = ['audio', 'video', 'image'].map(mediaType => { @@ -159,7 +159,10 @@ function torrentPosterFromVideo (torrent, cb) { function torrentPosterFromImage (torrent, cb) { const file = getLargestFileByExtension(torrent, mediaExtensions.image) - - const extname = path.extname(file.name) - file.getBuffer((err, buf) => cb(err, buf, extname)) + extractPoster(file, cb) +} + +function extractPoster (file, cb) { + const extname = path.extname(file.name) + file.getBuffer((err, buf) => { return cb(err, buf, extname) }) }