2024-05-08 21:08:47 +00:00
|
|
|
"use strict";
|
|
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
|
|
};
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
exports.Files = void 0;
|
|
|
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
|
|
const hash_1 = require("../hash");
|
|
|
|
const path_1 = require("path");
|
2024-05-15 21:29:59 +00:00
|
|
|
const fileExtensions = [
|
2024-05-15 18:34:24 +00:00
|
|
|
'.mp4',
|
|
|
|
'.mkv',
|
|
|
|
'.mov'
|
|
|
|
];
|
2024-05-08 21:08:47 +00:00
|
|
|
class Files {
|
|
|
|
static async exists(path) {
|
|
|
|
try {
|
|
|
|
await promises_1.default.access(path);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
catch {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static async enumerateSequences(path) {
|
|
|
|
const dirs = [];
|
|
|
|
let all;
|
|
|
|
let stats;
|
|
|
|
try {
|
|
|
|
all = await promises_1.default.readdir(path);
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
for (let elem of all) {
|
|
|
|
try {
|
|
|
|
stats = await promises_1.default.lstat(elem);
|
|
|
|
if (stats.isDirectory()) {
|
|
|
|
dirs.push({
|
|
|
|
path: elem,
|
|
|
|
hash: hash_1.Hashes.stringHash(elem),
|
|
|
|
name: (0, path_1.basename)(elem)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
//
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return dirs;
|
|
|
|
}
|
2024-05-15 18:34:24 +00:00
|
|
|
static async enumerateVideos(path) {
|
|
|
|
const videos = [];
|
|
|
|
let all;
|
|
|
|
let stats;
|
2024-05-15 21:29:59 +00:00
|
|
|
try {
|
|
|
|
all = await promises_1.default.readdir(path);
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
for (let elem of all) {
|
|
|
|
try {
|
|
|
|
stats = await promises_1.default.lstat(elem);
|
|
|
|
if (stats.isFile() && fileExtensions.indexOf((0, path_1.extname)((0, path_1.basename)(elem))) !== -1) {
|
|
|
|
videos.push({
|
|
|
|
path: elem,
|
|
|
|
hash: hash_1.Hashes.stringHash(elem),
|
|
|
|
name: (0, path_1.basename)(elem)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
//
|
|
|
|
}
|
|
|
|
}
|
2024-05-15 18:34:24 +00:00
|
|
|
return videos;
|
|
|
|
}
|
2024-05-08 21:08:47 +00:00
|
|
|
}
|
|
|
|
exports.Files = Files;
|
|
|
|
module.exports = { Files };
|
|
|
|
//# sourceMappingURL=index.js.map
|