From b89a74e6e90c5e348f1eb7d141befa407cd644d1 Mon Sep 17 00:00:00 2001 From: Borewit Date: Sun, 4 Mar 2018 13:48:07 +0100 Subject: [PATCH 01/10] #1332: Improve the poster selection for audio/music based torrent, aiming to get the cover-art selected as the torrent poster. --- src/renderer/lib/torrent-poster.js | 104 ++++++++++++++++++++++++----- 1 file changed, 88 insertions(+), 16 deletions(-) diff --git a/src/renderer/lib/torrent-poster.js b/src/renderer/lib/torrent-poster.js index f05d1bb58b..d90d6b8720 100644 --- a/src/renderer/lib/torrent-poster.js +++ b/src/renderer/lib/torrent-poster.js @@ -3,6 +3,13 @@ module.exports = torrentPoster const captureFrame = require('capture-frame') const path = require('path') +const mediaExtensions = { + audio: ['.aac', '.asf', '.flac', '.m2a', '.m4a', '.mp2', '.mp4', '.mp3', '.oga', '.ogg', '.opus', + '.wma', '.wav', '.wv', '.wvp'], + video: ['.mp4', '.m4v', '.webm', '.mov', '.mkv'], + image: ['.gif', '.jpg', '.jpeg', '.png'] +} + function torrentPoster (torrent, cb) { // First, try to use a poster image if available const posterFile = torrent.files.filter(function (file) { @@ -10,32 +17,95 @@ function torrentPoster (torrent, cb) { })[0] if (posterFile) return torrentPosterFromImage(posterFile, torrent, cb) - // Second, try to use the largest video file - // Filter out file formats that the