From f7b46336fdc9a266096f13000e65edcef3832929 Mon Sep 17 00:00:00 2001 From: Benjamin Tan Date: Sun, 22 May 2016 17:14:48 +0800 Subject: [PATCH] Use `poster.jpg` file as the poster image if available. (#558) Closes #501. --- renderer/lib/torrent-poster.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/renderer/lib/torrent-poster.js b/renderer/lib/torrent-poster.js index 7f1a2e8a..8274a7fa 100644 --- a/renderer/lib/torrent-poster.js +++ b/renderer/lib/torrent-poster.js @@ -4,12 +4,18 @@ var captureVideoFrame = require('./capture-video-frame') var path = require('path') function torrentPoster (torrent, cb) { - // First, try to use the largest video file + // First, try to use a poster image if available + var posterFile = torrent.files.filter(function (file) { + return /^poster\.(jpg|png|gif)$/.test(file.name) + })[0] + if (posterFile) return torrentPosterFromImage(posterFile, torrent, cb) + + // Second, try to use the largest video file // Filter out file formats that the