migrate to esm structure
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
const cacheManager = require('cache-manager');
|
||||
const mangodbStore = require('cache-manager-mongodb');
|
||||
const { isStaticUrl } = require('../moch/static')
|
||||
import cacheManager from 'cache-manager';
|
||||
import mangodbStore from 'cache-manager-mongodb';
|
||||
import { isStaticUrl } from '../moch/static.js';
|
||||
|
||||
const GLOBAL_KEY_PREFIX = 'torrentio-addon';
|
||||
const STREAM_KEY_PREFIX = `${GLOBAL_KEY_PREFIX}|stream`;
|
||||
@@ -60,19 +60,19 @@ function cacheWrap(cache, key, method, options) {
|
||||
return cache.wrap(key, method, options);
|
||||
}
|
||||
|
||||
function cacheWrapStream(id, method) {
|
||||
export function cacheWrapStream(id, method) {
|
||||
return cacheWrap(remoteCache, `${STREAM_KEY_PREFIX}:${id}`, method, {
|
||||
ttl: (streams) => streams.length ? STREAM_TTL : STREAM_EMPTY_TTL
|
||||
});
|
||||
}
|
||||
|
||||
function cacheWrapResolvedUrl(id, method) {
|
||||
export function cacheWrapResolvedUrl(id, method) {
|
||||
return cacheWrap(memoryCache, `${RESOLVED_URL_KEY_PREFIX}:${id}`, method, {
|
||||
ttl: (url) => isStaticUrl(url) ? MESSAGE_VIDEO_URL_TTL : STREAM_TTL
|
||||
});
|
||||
}
|
||||
|
||||
function cacheAvailabilityResults(results) {
|
||||
export function cacheAvailabilityResults(results) {
|
||||
Object.keys(results)
|
||||
.forEach(infoHash => {
|
||||
const key = `${AVAILABILITY_KEY_PREFIX}:${infoHash}`;
|
||||
@@ -83,7 +83,7 @@ function cacheAvailabilityResults(results) {
|
||||
return results;
|
||||
}
|
||||
|
||||
function getCachedAvailabilityResults(infoHashes) {
|
||||
export function getCachedAvailabilityResults(infoHashes) {
|
||||
const keys = infoHashes.map(infoHash => `${AVAILABILITY_KEY_PREFIX}:${infoHash}`)
|
||||
return new Promise(resolve => {
|
||||
memoryCache.mget(...keys, (error, result) => {
|
||||
@@ -101,6 +101,3 @@ function getCachedAvailabilityResults(infoHashes) {
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = { cacheWrapStream, cacheWrapResolvedUrl, cacheAvailabilityResults, getCachedAvailabilityResults };
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
const { DebridOptions } = require('../moch/options');
|
||||
const { QualityFilter, Providers, SizeFilter } = require('./filter');
|
||||
const { LanguageOptions } = require('./languages');
|
||||
import { DebridOptions } from '../moch/options.js';
|
||||
import { QualityFilter, Providers, SizeFilter } from './filter.js';
|
||||
import { LanguageOptions } from './languages.js';
|
||||
|
||||
const PRE_CONFIGURATIONS = {
|
||||
export const PreConfigurations = {
|
||||
lite: {
|
||||
config: liteConfig(),
|
||||
serialized: configValue(liteConfig()),
|
||||
@@ -29,9 +29,9 @@ const PRE_CONFIGURATIONS = {
|
||||
const keysToSplit = [Providers.key, LanguageOptions.key, QualityFilter.key, SizeFilter.key, DebridOptions.key];
|
||||
const keyToUppercase = [SizeFilter.key];
|
||||
|
||||
function parseConfiguration(configuration) {
|
||||
if (PRE_CONFIGURATIONS[configuration]) {
|
||||
return PRE_CONFIGURATIONS[configuration].config;
|
||||
export function parseConfiguration(configuration) {
|
||||
if (PreConfigurations[configuration]) {
|
||||
return PreConfigurations[configuration].config;
|
||||
}
|
||||
const configValues = configuration.split('|')
|
||||
.reduce((map, next) => {
|
||||
@@ -73,11 +73,7 @@ function configValue(config) {
|
||||
.join('|');
|
||||
}
|
||||
|
||||
function getManifestOverride(config) {
|
||||
const preConfig = Object.values(PRE_CONFIGURATIONS).find(pre => pre.config === config);
|
||||
export function getManifestOverride(config) {
|
||||
const preConfig = Object.values(PreConfigurations).find(pre => pre.config === config);
|
||||
return preConfig ? preConfig.manifest : {};
|
||||
}
|
||||
|
||||
module.exports.PreConfigurations = PRE_CONFIGURATIONS;
|
||||
module.exports.parseConfiguration = parseConfiguration;
|
||||
module.exports.getManifestOverride = getManifestOverride;
|
||||
}
|
||||
@@ -50,25 +50,23 @@ const ARCHIVE_EXTENSIONS = [
|
||||
"zip"
|
||||
]
|
||||
|
||||
function isVideo(filename) {
|
||||
export function isVideo(filename) {
|
||||
return isExtension(filename, VIDEO_EXTENSIONS);
|
||||
}
|
||||
|
||||
function isSubtitle(filename) {
|
||||
export function isSubtitle(filename) {
|
||||
return isExtension(filename, SUBTITLE_EXTENSIONS);
|
||||
}
|
||||
|
||||
function isDisk(filename) {
|
||||
export function isDisk(filename) {
|
||||
return isExtension(filename, DISK_EXTENSIONS);
|
||||
}
|
||||
|
||||
function isArchive(filename) {
|
||||
export function isArchive(filename) {
|
||||
return isExtension(filename, ARCHIVE_EXTENSIONS);
|
||||
}
|
||||
|
||||
function isExtension(filename, extensions) {
|
||||
const extensionMatch = filename && filename.match(/\.(\w{2,4})$/);
|
||||
export function isExtension(filename, extensions) {
|
||||
const extensionMatch = filename?.match(/\.(\w{2,4})$/);
|
||||
return extensionMatch && extensions.includes(extensionMatch[1].toLowerCase());
|
||||
}
|
||||
|
||||
module.exports = { isVideo, isSubtitle, isDisk, isArchive, isExtension }
|
||||
@@ -1,6 +1,6 @@
|
||||
const { extractProvider, parseSize, extractSize } = require("./titleHelper");
|
||||
const { Type } = require("./types");
|
||||
const Providers = {
|
||||
import { extractProvider, parseSize, extractSize } from './titleHelper.js';
|
||||
import { Type } from './types.js';
|
||||
export const Providers = {
|
||||
key: 'providers',
|
||||
options: [
|
||||
{
|
||||
@@ -82,7 +82,7 @@ const Providers = {
|
||||
},
|
||||
]
|
||||
};
|
||||
const QualityFilter = {
|
||||
export const QualityFilter = {
|
||||
key: 'qualityfilter',
|
||||
options: [
|
||||
{
|
||||
@@ -175,12 +175,12 @@ const QualityFilter = {
|
||||
}
|
||||
]
|
||||
};
|
||||
const SizeFilter = {
|
||||
export const SizeFilter = {
|
||||
key: 'sizefilter'
|
||||
}
|
||||
const defaultProviderKeys = Providers.options.map(provider => provider.key);
|
||||
|
||||
function applyFilters(streams, config) {
|
||||
export default function applyFilters(streams, config) {
|
||||
return [
|
||||
filterByProvider,
|
||||
filterByQuality,
|
||||
@@ -223,8 +223,3 @@ function filterBySize(streams, config) {
|
||||
return size <= sizeLimit;
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = applyFilters;
|
||||
module.exports.Providers = Providers;
|
||||
module.exports.QualityFilter = QualityFilter;
|
||||
module.exports.SizeFilter = SizeFilter;
|
||||
|
||||
@@ -184,16 +184,15 @@ a.install-link {
|
||||
box-shadow: 0 0 0 2pt rgb(30, 144, 255, 0.7);
|
||||
}
|
||||
`;
|
||||
const { Providers } = require('./filter');
|
||||
const { SortOptions } = require('./sort');
|
||||
const { LanguageOptions } = require('./languages');
|
||||
const { QualityFilter, SizeFilter } = require('./filter');
|
||||
const { DebridOptions } = require('../moch/options');
|
||||
const { MochOptions } = require('../moch/moch');
|
||||
const { PreConfigurations } = require('../lib/configuration');
|
||||
import { Providers, QualityFilter, SizeFilter } from './filter.js';
|
||||
import { SortOptions } from './sort.js';
|
||||
import { LanguageOptions } from './languages.js';
|
||||
import { DebridOptions } from '../moch/options.js';
|
||||
import { MochOptions } from '../moch/moch.js';
|
||||
import { PreConfigurations } from './configuration.js';
|
||||
|
||||
function landingTemplate(manifest, config = {}) {
|
||||
const providers = config.providers || Providers.options.map(provider => provider.key);
|
||||
export default function landingTemplate(manifest, config = {}) {
|
||||
const providers = config[Providers.key] || Providers.options.map(provider => provider.key);
|
||||
const sort = config[SortOptions.key] || SortOptions.options.qualitySeeders.key;
|
||||
const languages = config[LanguageOptions.key] || [];
|
||||
const qualityFilters = config[QualityFilter.key] || [];
|
||||
@@ -491,5 +490,3 @@ function landingTemplate(manifest, config = {}) {
|
||||
|
||||
</html>`
|
||||
}
|
||||
|
||||
module.exports = landingTemplate;
|
||||
@@ -47,7 +47,7 @@ const languageMapping = {
|
||||
'thai': '🇹🇭'
|
||||
}
|
||||
|
||||
const LanguageOptions = {
|
||||
export const LanguageOptions = {
|
||||
key: 'language',
|
||||
options: Object.keys(languageMapping).slice(5).map(lang => ({
|
||||
key: lang,
|
||||
@@ -55,7 +55,7 @@ const LanguageOptions = {
|
||||
}))
|
||||
}
|
||||
|
||||
function mapLanguages(languages) {
|
||||
export function mapLanguages(languages) {
|
||||
const mapped = languages
|
||||
.map(language => languageMapping[language])
|
||||
.filter(language => language)
|
||||
@@ -66,13 +66,11 @@ function mapLanguages(languages) {
|
||||
return [...new Set([].concat(mapped).concat(unmapped))];
|
||||
}
|
||||
|
||||
function containsLanguage(stream, languages) {
|
||||
export function containsLanguage(stream, languages) {
|
||||
return languages.map(lang => languageMapping[lang]).some(lang => stream.title.includes(lang));
|
||||
}
|
||||
|
||||
function languageFromCode(code) {
|
||||
export function languageFromCode(code) {
|
||||
const entry = Object.entries(languageMapping).find(entry => entry[1] === code);
|
||||
return entry && entry[0];
|
||||
return entry?.[0];
|
||||
}
|
||||
|
||||
module.exports = { mapLanguages, containsLanguage, languageFromCode, LanguageOptions }
|
||||
@@ -1,8 +1,9 @@
|
||||
const axios = require('axios');
|
||||
const magnet = require('magnet-uri');
|
||||
const { getRandomUserAgent } = require('../lib/requestHelper');
|
||||
const { getTorrent } = require('../lib/repository');
|
||||
const { Type } = require('../lib/types');
|
||||
import axios from 'axios';
|
||||
import magnet from 'magnet-uri';
|
||||
import { getRandomUserAgent } from './requestHelper.js';
|
||||
import { getTorrent } from './repository.js';
|
||||
import { Type } from './types.js';
|
||||
import { extractProvider } from "./titleHelper.js";
|
||||
|
||||
const TRACKERS_URL = 'https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_best.txt';
|
||||
const DEFAULT_TRACKERS = [
|
||||
@@ -61,9 +62,9 @@ let BEST_TRACKERS = [];
|
||||
let ALL_ANIME_TRACKERS = [];
|
||||
let ALL_RUSSIAN_TRACKERS = [];
|
||||
|
||||
async function getMagnetLink(infoHash) {
|
||||
export async function getMagnetLink(infoHash) {
|
||||
const torrent = await getTorrent(infoHash).catch(() => ({ infoHash }));
|
||||
const torrentTrackers = torrent.trackers && torrent.trackers.split(',');
|
||||
const torrentTrackers = torrent?.trackers?.split(',');
|
||||
const animeTrackers = torrent.type === Type.ANIME ? ALL_ANIME_TRACKERS : undefined;
|
||||
const providerTrackers = RUSSIAN_PROVIDERS.includes(torrent.provider) && ALL_RUSSIAN_TRACKERS;
|
||||
const trackers = unique([].concat(torrentTrackers).concat(animeTrackers).concat(providerTrackers));
|
||||
@@ -73,7 +74,7 @@ async function getMagnetLink(infoHash) {
|
||||
: magnet.encode({ infoHash: infoHash });
|
||||
}
|
||||
|
||||
async function initBestTrackers() {
|
||||
export async function initBestTrackers() {
|
||||
BEST_TRACKERS = await getBestTrackers();
|
||||
ALL_ANIME_TRACKERS = unique(BEST_TRACKERS.concat(DEFAULT_TRACKERS).concat(ANIME_TRACKERS));
|
||||
ALL_RUSSIAN_TRACKERS = unique(BEST_TRACKERS.concat(DEFAULT_TRACKERS).concat(RUSSIAN_TRACKERS));
|
||||
@@ -94,7 +95,7 @@ async function getBestTrackers(retry = 2) {
|
||||
});
|
||||
}
|
||||
|
||||
function getSources(trackersInput, infoHash) {
|
||||
export function getSources(trackersInput, infoHash) {
|
||||
if (!trackersInput) {
|
||||
return null;
|
||||
}
|
||||
@@ -102,9 +103,8 @@ function getSources(trackersInput, infoHash) {
|
||||
return trackers.map(tracker => `tracker:${tracker}`).concat(`dht:${infoHash}`);
|
||||
}
|
||||
|
||||
function enrichStreamSources(stream) {
|
||||
const match = stream.title.match(/⚙.* ([^ \n]+)/);
|
||||
const provider = match && match[1];
|
||||
export function enrichStreamSources(stream) {
|
||||
const provider = extractProvider(stream.title);
|
||||
if (ANIME_PROVIDERS.includes(provider)) {
|
||||
const sources = getSources(ALL_ANIME_TRACKERS, stream.infoHash);
|
||||
return { ...stream, sources };
|
||||
@@ -118,6 +118,4 @@ function enrichStreamSources(stream) {
|
||||
|
||||
function unique(array) {
|
||||
return Array.from(new Set(array));
|
||||
}
|
||||
|
||||
module.exports = { initBestTrackers, getMagnetLink, getSources, enrichStreamSources };
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
const { MochOptions } = require('../moch/moch');
|
||||
const { Providers } = require('./filter');
|
||||
const { showDebridCatalog } = require('../moch/options');
|
||||
const { getManifestOverride } = require('./configuration');
|
||||
const { Type } = require('./types');
|
||||
import { MochOptions } from '../moch/moch.js';
|
||||
import { Providers } from './filter.js';
|
||||
import { showDebridCatalog } from '../moch/options.js';
|
||||
import { getManifestOverride } from './configuration.js';
|
||||
import { Type } from './types.js';
|
||||
|
||||
const DefaultProviders = Providers.options.map(provider => provider.key);
|
||||
const CatalogMochs = Object.values(MochOptions).filter(moch => moch.catalog);
|
||||
|
||||
function manifest(config = {}) {
|
||||
export function manifest(config = {}) {
|
||||
const defaultManifest = {
|
||||
id: 'com.stremio.torrentio.addon',
|
||||
version: '0.0.13',
|
||||
@@ -27,7 +27,7 @@ function manifest(config = {}) {
|
||||
return Object.assign(defaultManifest, overrideManifest);
|
||||
}
|
||||
|
||||
function dummyManifest() {
|
||||
export function dummyManifest() {
|
||||
const manifestDefault = manifest();
|
||||
manifestDefault.catalogs = [{ id: 'dummy', type: Type.OTHER }];
|
||||
manifestDefault.resources = ['stream', 'meta'];
|
||||
@@ -35,7 +35,7 @@ function dummyManifest() {
|
||||
}
|
||||
|
||||
function getDescription(config) {
|
||||
const providersList = config.providers || DefaultProviders;
|
||||
const providersList = config[Providers.key] || DefaultProviders;
|
||||
const enabledProvidersDesc = Providers.options
|
||||
.map(provider => `${provider.label}${providersList.includes(provider.key) ? '(+)' : '(-)'}`)
|
||||
.join(', ')
|
||||
@@ -76,5 +76,3 @@ function getResources(config) {
|
||||
}
|
||||
return [streamResource];
|
||||
}
|
||||
|
||||
module.exports = { manifest, dummyManifest };
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Delay promise
|
||||
*/
|
||||
async function delay(duration) {
|
||||
export async function delay(duration) {
|
||||
return new Promise((resolve) => setTimeout(resolve, duration));
|
||||
}
|
||||
|
||||
/**
|
||||
* Timeout promise after a set time in ms
|
||||
*/
|
||||
async function timeout(timeoutMs, promise, message = 'Timed out') {
|
||||
export async function timeout(timeoutMs, promise, message = 'Timed out') {
|
||||
return Promise.race([
|
||||
promise,
|
||||
new Promise(function (resolve, reject) {
|
||||
@@ -18,5 +18,3 @@ async function timeout(timeoutMs, promise, message = 'Timed out') {
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
||||
module.exports = { delay, timeout };
|
||||
@@ -1,4 +1,4 @@
|
||||
const { Sequelize } = require('sequelize');
|
||||
import { Sequelize } from 'sequelize';
|
||||
const Op = Sequelize.Op;
|
||||
|
||||
const DATABASE_URI = process.env.DATABASE_URI;
|
||||
@@ -67,15 +67,15 @@ File.belongsTo(Torrent, { foreignKey: 'infoHash', constraints: false });
|
||||
File.hasMany(Subtitle, { foreignKey: 'fileId', constraints: false });
|
||||
Subtitle.belongsTo(File, { foreignKey: 'fileId', constraints: false });
|
||||
|
||||
function getTorrent(infoHash) {
|
||||
export function getTorrent(infoHash) {
|
||||
return Torrent.findOne({ where: { infoHash: infoHash } });
|
||||
}
|
||||
|
||||
function getFiles(infoHashes) {
|
||||
export function getFiles(infoHashes) {
|
||||
return File.findAll({ where: { infoHash: { [Op.in]: infoHashes} } });
|
||||
}
|
||||
|
||||
function getImdbIdMovieEntries(imdbId) {
|
||||
export function getImdbIdMovieEntries(imdbId) {
|
||||
return File.findAll({
|
||||
where: {
|
||||
imdbId: { [Op.eq]: imdbId }
|
||||
@@ -88,7 +88,7 @@ function getImdbIdMovieEntries(imdbId) {
|
||||
});
|
||||
}
|
||||
|
||||
function getImdbIdSeriesEntries(imdbId, season, episode) {
|
||||
export function getImdbIdSeriesEntries(imdbId, season, episode) {
|
||||
return File.findAll({
|
||||
where: {
|
||||
imdbId: { [Op.eq]: imdbId },
|
||||
@@ -103,7 +103,7 @@ function getImdbIdSeriesEntries(imdbId, season, episode) {
|
||||
});
|
||||
}
|
||||
|
||||
function getKitsuIdMovieEntries(kitsuId) {
|
||||
export function getKitsuIdMovieEntries(kitsuId) {
|
||||
return File.findAll({
|
||||
where: {
|
||||
kitsuId: { [Op.eq]: kitsuId }
|
||||
@@ -116,7 +116,7 @@ function getKitsuIdMovieEntries(kitsuId) {
|
||||
});
|
||||
}
|
||||
|
||||
function getKitsuIdSeriesEntries(kitsuId, episode) {
|
||||
export function getKitsuIdSeriesEntries(kitsuId, episode) {
|
||||
return File.findAll({
|
||||
where: {
|
||||
kitsuId: { [Op.eq]: kitsuId },
|
||||
@@ -129,12 +129,3 @@ function getKitsuIdSeriesEntries(kitsuId, episode) {
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getTorrent,
|
||||
getFiles,
|
||||
getImdbIdMovieEntries,
|
||||
getImdbIdSeriesEntries,
|
||||
getKitsuIdMovieEntries,
|
||||
getKitsuIdSeriesEntries
|
||||
};
|
||||
@@ -1,8 +1,6 @@
|
||||
const UserAgent = require('user-agents');
|
||||
import UserAgent from 'user-agents';
|
||||
const userAgent = new UserAgent();
|
||||
|
||||
function getRandomUserAgent() {
|
||||
export function getRandomUserAgent() {
|
||||
return userAgent.random().toString();
|
||||
}
|
||||
|
||||
module.exports = { getRandomUserAgent };
|
||||
@@ -1,8 +1,8 @@
|
||||
const { QualityFilter } = require('./filter');
|
||||
const { containsLanguage, LanguageOptions } = require('./languages');
|
||||
const { Type } = require("./types");
|
||||
const { hasMochConfigured } = require("../moch/moch");
|
||||
const { extractSeeders, extractSize } = require("./titleHelper");
|
||||
import { QualityFilter } from './filter.js';
|
||||
import { containsLanguage, LanguageOptions } from './languages.js';
|
||||
import { Type } from './types.js';
|
||||
import { hasMochConfigured } from '../moch/moch.js';
|
||||
import { extractSeeders, extractSize } from './titleHelper.js';
|
||||
|
||||
const OTHER_QUALITIES = QualityFilter.options.find(option => option.key === 'other');
|
||||
const CAM_QUALITIES = QualityFilter.options.find(option => option.key === 'cam');
|
||||
@@ -11,7 +11,7 @@ const SEEDED_SEEDERS = 1;
|
||||
const MIN_HEALTHY_COUNT = 50;
|
||||
const MAX_UNHEALTHY_COUNT = 5;
|
||||
|
||||
const SortOptions = {
|
||||
export const SortOptions = {
|
||||
key: 'sort',
|
||||
options: {
|
||||
qualitySeeders: {
|
||||
@@ -33,7 +33,7 @@ const SortOptions = {
|
||||
}
|
||||
}
|
||||
|
||||
function sortStreams(streams, config, type) {
|
||||
export default function sortStreams(streams, config, type) {
|
||||
const languages = config[LanguageOptions.key];
|
||||
if (languages?.length && languages[0] !== 'english') {
|
||||
// No need to filter english since it's hard to predict which entries are english
|
||||
@@ -126,6 +126,3 @@ function extractQuality(title) {
|
||||
}
|
||||
return qualityDesc;
|
||||
}
|
||||
|
||||
module.exports = sortStreams;
|
||||
module.exports.SortOptions = SortOptions;
|
||||
@@ -1,15 +1,15 @@
|
||||
const titleParser = require('parse-torrent-title');
|
||||
const { Type } = require('./types');
|
||||
const { mapLanguages } = require('./languages');
|
||||
const { enrichStreamSources, getSources } = require('./magnetHelper');
|
||||
const { getSubtitles } = require("./subtitles");
|
||||
import titleParser from 'parse-torrent-title';
|
||||
import { Type } from './types.js';
|
||||
import { mapLanguages } from './languages.js';
|
||||
import { enrichStreamSources, getSources } from './magnetHelper.js';
|
||||
import { getSubtitles } from './subtitles.js';
|
||||
|
||||
const ADDON_NAME = 'Torrentio';
|
||||
const SIZE_DELTA = 0.02;
|
||||
const UNKNOWN_SIZE = 300000000;
|
||||
const CAM_SOURCES = ['CAM', 'TeleSync', 'TeleCine', 'SCR'];
|
||||
|
||||
function toStreamInfo(record) {
|
||||
export function toStreamInfo(record) {
|
||||
const torrentInfo = titleParser.parse(record.torrent.title);
|
||||
const fileInfo = titleParser.parse(record.title);
|
||||
const sameInfo = !Number.isInteger(record.fileIndex)
|
||||
@@ -105,7 +105,7 @@ function formatSize(size) {
|
||||
return Number((size / Math.pow(1024, i)).toFixed(2)) + ' ' + ['B', 'kB', 'MB', 'GB', 'TB'][i];
|
||||
}
|
||||
|
||||
function applyStaticInfo(streams) {
|
||||
export function applyStaticInfo(streams) {
|
||||
return streams.map(stream => enrichStaticInfo(stream));
|
||||
}
|
||||
|
||||
@@ -148,5 +148,3 @@ function getBingeGroupParts(record, sameInfo, quality, torrentInfo, fileInfo) {
|
||||
function cleanOutputObject(object) {
|
||||
return Object.fromEntries(Object.entries(object).filter(([_, v]) => v != null));
|
||||
}
|
||||
|
||||
module.exports = { toStreamInfo, applyStaticInfo };
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const { parse } = require('parse-torrent-title');
|
||||
const { isExtension } = require("./extension");
|
||||
const { Providers } = require("./filter");
|
||||
const { languageFromCode } = require("./languages");
|
||||
import { parse } from 'parse-torrent-title';
|
||||
import { isExtension } from './extension.js';
|
||||
import { Providers } from './filter.js';
|
||||
import { languageFromCode } from './languages.js';
|
||||
|
||||
const languageMapping = {
|
||||
'english': 'eng',
|
||||
@@ -50,8 +50,8 @@ const languageMapping = {
|
||||
const ignoreSet = new Set(['dubbed', 'multi audio', 'multi subs', 'dual audio']);
|
||||
const allowedExtensions = ['srt', 'vtt', 'ass', 'ssa'];
|
||||
|
||||
function getSubtitles(record) {
|
||||
if (!record.subtitles || !record.subtitles.length) {
|
||||
export function getSubtitles(record) {
|
||||
if (!record?.subtitles?.length) {
|
||||
return null;
|
||||
}
|
||||
return record.subtitles
|
||||
@@ -95,7 +95,5 @@ function getSingleLanguage(title) {
|
||||
|
||||
function getFileNameLanguageCode(fileName) {
|
||||
const match = fileName.match(/(?:(?:^|[._ ])([A-Za-z][a-z]{1,2})|\[([a-z]{2,3})])\.\w{3,4}$/);
|
||||
return match && match[1].toLowerCase();
|
||||
return match?.[1]?.toLowerCase();
|
||||
}
|
||||
|
||||
module.exports = { getSubtitles }
|
||||
@@ -1,19 +1,19 @@
|
||||
function extractSeeders(title) {
|
||||
export function extractSeeders(title) {
|
||||
const seedersMatch = title.match(/👤 (\d+)/);
|
||||
return seedersMatch && parseInt(seedersMatch[1]) || 0;
|
||||
}
|
||||
|
||||
function extractSize(title) {
|
||||
export function extractSize(title) {
|
||||
const seedersMatch = title.match(/💾 ([\d.]+ \w+)/);
|
||||
return seedersMatch && parseSize(seedersMatch[1]) || 0;
|
||||
}
|
||||
|
||||
function extractProvider(title) {
|
||||
export function extractProvider(title) {
|
||||
const match = title.match(/⚙.* ([^ \n]+)/);
|
||||
return match?.[1]?.toLowerCase();
|
||||
}
|
||||
|
||||
function parseSize(sizeText) {
|
||||
export function parseSize(sizeText) {
|
||||
if (!sizeText) {
|
||||
return 0;
|
||||
}
|
||||
@@ -29,5 +29,3 @@ function parseSize(sizeText) {
|
||||
}
|
||||
return Math.floor(parseFloat(sizeText.replace(/,/g, '')) * scale);
|
||||
}
|
||||
|
||||
module.exports = { extractSeeders, extractSize, extractProvider, parseSize }
|
||||
@@ -1,4 +1,4 @@
|
||||
exports.Type = {
|
||||
export const Type = {
|
||||
MOVIE: 'movie',
|
||||
SERIES: 'series',
|
||||
ANIME: 'anime',
|
||||
|
||||
Reference in New Issue
Block a user