mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
[scraper] move is-video function to a file
This commit is contained in:
@@ -4,11 +4,10 @@ const parseTorrent = require('parse-torrent');
|
|||||||
const async = require('async');
|
const async = require('async');
|
||||||
const decode = require('magnet-uri');
|
const decode = require('magnet-uri');
|
||||||
const { retrieveTorrentFiles } = require('./cache');
|
const { retrieveTorrentFiles } = require('./cache');
|
||||||
|
const isVideo = require('./video');
|
||||||
|
|
||||||
const MAX_PEER_CONNECTIONS = process.env.MAX_PEER_CONNECTIONS || 20;
|
const MAX_PEER_CONNECTIONS = process.env.MAX_PEER_CONNECTIONS || 20;
|
||||||
const SEEDS_CHECK_TIMEOUT = process.env.SEEDS_CHECK_TIMEOUT || 10 * 1000; // 10 secs
|
const SEEDS_CHECK_TIMEOUT = process.env.SEEDS_CHECK_TIMEOUT || 10 * 1000; // 10 secs
|
||||||
const EXTENSIONS = ["3g2", "3gp", "avi", "flv", "mkv", "mov", "mp2", "mp4", "mpe", "mpeg", "mpg", "mpv", "webm", "wmv",
|
|
||||||
"ogm"];
|
|
||||||
|
|
||||||
module.exports.updateCurrentSeeders = function (torrent) {
|
module.exports.updateCurrentSeeders = function (torrent) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
@@ -110,10 +109,7 @@ async function filesFromTorrentStream(torrent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function filterVideos(files) {
|
function filterVideos(files) {
|
||||||
return files.filter((file) => {
|
return files.filter((file) => isVideo(file.path));
|
||||||
const match = file.path.match(/\.(\w{2,4})$/);
|
|
||||||
return match && EXTENSIONS.includes(match[1].toLowerCase());
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function filterSamples(files) {
|
function filterSamples(files) {
|
||||||
|
|||||||
22
scraper/lib/video.js
Normal file
22
scraper/lib/video.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
const EXTENSIONS = [
|
||||||
|
"3g2",
|
||||||
|
"3gp",
|
||||||
|
"avi",
|
||||||
|
"flv",
|
||||||
|
"mkv",
|
||||||
|
"mov",
|
||||||
|
"mp2",
|
||||||
|
"mp4",
|
||||||
|
"mpe",
|
||||||
|
"mpeg",
|
||||||
|
"mpg",
|
||||||
|
"mpv",
|
||||||
|
"webm",
|
||||||
|
"wmv",
|
||||||
|
"ogm"
|
||||||
|
];
|
||||||
|
|
||||||
|
module.exports = (filename) => {
|
||||||
|
const extensionMatch = filename.match(/\.(\w{2,4})$/);
|
||||||
|
return extensionMatch && EXTENSIONS.includes(extensionMatch[1].toLowerCase());
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user