Ensure consistency between extension-categories, between torrent-player and torrent-poster.
Add additional audio-file-extensions.
This commit is contained in:
8
src/renderer/lib/media-extensions.js
Normal file
8
src/renderer/lib/media-extensions.js
Normal file
@@ -0,0 +1,8 @@
|
||||
const mediaExtensions = {
|
||||
audio: ['.aac', '.asf', '.flac', '.m2a', '.m4a', '.m4b', '.mp2', '.mp4', '.mp3', '.oga', '.ogg',
|
||||
'.opus', '.wma', '.wav', '.wv', '.wvp'],
|
||||
video: ['.avi', '.mp4', '.m4v', '.webm', '.mov', '.mkv', 'mpg', 'mpeg', '.ogv', '.webm', '.wmv'],
|
||||
image: ['.gif', '.jpg', '.jpeg', '.png']
|
||||
}
|
||||
|
||||
module.exports = mediaExtensions
|
||||
@@ -8,6 +8,8 @@ module.exports = {
|
||||
|
||||
const path = require('path')
|
||||
|
||||
const mediaExtensions = require('./media-extensions')
|
||||
|
||||
// Checks whether a fileSummary or file path is audio/video that we can play,
|
||||
// based on the file extension
|
||||
function isPlayable (file) {
|
||||
@@ -16,36 +18,12 @@ function isPlayable (file) {
|
||||
|
||||
// Checks whether a fileSummary or file path is playable video
|
||||
function isVideo (file) {
|
||||
return [
|
||||
'.avi',
|
||||
'.m4v',
|
||||
'.mkv',
|
||||
'.mov',
|
||||
'.mp4',
|
||||
'.mpg',
|
||||
'.ogv',
|
||||
'.webm',
|
||||
'.wmv'
|
||||
].includes(getFileExtension(file))
|
||||
return mediaExtensions.video.includes(getFileExtension(file))
|
||||
}
|
||||
|
||||
// Checks whether a fileSummary or file path is playable audio
|
||||
function isAudio (file) {
|
||||
return [
|
||||
'.aac',
|
||||
'.aiff',
|
||||
'.ape',
|
||||
'.ac3',
|
||||
'.flac',
|
||||
'.m4a',
|
||||
'.mp2',
|
||||
'.mp3',
|
||||
'.oga',
|
||||
'.ogg',
|
||||
'.opus',
|
||||
'.wav',
|
||||
'.wma'
|
||||
].includes(getFileExtension(file))
|
||||
return mediaExtensions.audio.includes(getFileExtension(file))
|
||||
}
|
||||
|
||||
// Checks if the argument is either:
|
||||
|
||||
@@ -3,12 +3,7 @@ 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']
|
||||
}
|
||||
const mediaExtensions = require('./media-extensions')
|
||||
|
||||
function torrentPoster (torrent, cb) {
|
||||
// First, try to use a poster image if available
|
||||
|
||||
Reference in New Issue
Block a user