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 path = require('path')
|
||||||
|
|
||||||
|
const mediaExtensions = require('./media-extensions')
|
||||||
|
|
||||||
// Checks whether a fileSummary or file path is audio/video that we can play,
|
// Checks whether a fileSummary or file path is audio/video that we can play,
|
||||||
// based on the file extension
|
// based on the file extension
|
||||||
function isPlayable (file) {
|
function isPlayable (file) {
|
||||||
@@ -16,36 +18,12 @@ function isPlayable (file) {
|
|||||||
|
|
||||||
// Checks whether a fileSummary or file path is playable video
|
// Checks whether a fileSummary or file path is playable video
|
||||||
function isVideo (file) {
|
function isVideo (file) {
|
||||||
return [
|
return mediaExtensions.video.includes(getFileExtension(file))
|
||||||
'.avi',
|
|
||||||
'.m4v',
|
|
||||||
'.mkv',
|
|
||||||
'.mov',
|
|
||||||
'.mp4',
|
|
||||||
'.mpg',
|
|
||||||
'.ogv',
|
|
||||||
'.webm',
|
|
||||||
'.wmv'
|
|
||||||
].includes(getFileExtension(file))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks whether a fileSummary or file path is playable audio
|
// Checks whether a fileSummary or file path is playable audio
|
||||||
function isAudio (file) {
|
function isAudio (file) {
|
||||||
return [
|
return mediaExtensions.audio.includes(getFileExtension(file))
|
||||||
'.aac',
|
|
||||||
'.aiff',
|
|
||||||
'.ape',
|
|
||||||
'.ac3',
|
|
||||||
'.flac',
|
|
||||||
'.m4a',
|
|
||||||
'.mp2',
|
|
||||||
'.mp3',
|
|
||||||
'.oga',
|
|
||||||
'.ogg',
|
|
||||||
'.opus',
|
|
||||||
'.wav',
|
|
||||||
'.wma'
|
|
||||||
].includes(getFileExtension(file))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks if the argument is either:
|
// Checks if the argument is either:
|
||||||
|
|||||||
@@ -3,12 +3,7 @@ module.exports = torrentPoster
|
|||||||
const captureFrame = require('capture-frame')
|
const captureFrame = require('capture-frame')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
|
||||||
const mediaExtensions = {
|
const mediaExtensions = require('./media-extensions')
|
||||||
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) {
|
function torrentPoster (torrent, cb) {
|
||||||
// First, try to use a poster image if available
|
// First, try to use a poster image if available
|
||||||
|
|||||||
Reference in New Issue
Block a user