forked from matiassingers/scene-release
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
53 lines (45 loc) · 1.88 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"use strict";
var match = require("string-match");
module.exports = function (name) {
// prettier-ignore
var data = {
episode: match(name, /(?<=\.)(((s|e|season|part)\.?\d+)(e\d+)?|\d+x\d+)/i),
date: match(name, /\d{4}((\.|-)\d{2}){2}/),
year: match(name, /(?!^)(?!1080|2160)[1,2]\d{3}/),
resolution: match(name, /\d{3,4}p/i),
format: match(name, /HEVC/i),
type: match(name, /(?<=\.)(CAM|TS(?!C)|TELESYNC|(DVD|BD)SCR|SCR|DDC|R5[\.\s]LINE|R5|(DVD|HD(TV)*|BR|BD|WEB)Rip|DVDR|(HD|PD)TV|WEB-DL|WEBDL|WEB|BluRay)(?=\.)/i),
source: match(name, /(?<=\.)(NETFLIX|AMZN|HULU|COOK|PBS|HMAX|iP|DL|DVD)(?=\.)/),
video: match(name, /(?<=\.)(NTSC|PAL|[xh][\.\s]?26(4|5)|XVID|Divx|REMUX(\.AVC)?)(?=\.)?/i),
audio: match(name, /(?<=\.)(DUBBED|AAC2[\.\s]0|AAC|AC3(D|.Dubbed)*|DTS(-HD)?|(DD|MA)\S?(5|2)\.(1|0))/i),
language: match(name, /(?<=\.)(MULTiSUBS|MULTi|NORDiC|DANiSH|SWEDiSH|NORWEGiAN|GERMAN|iTALiAN|FRENCH|SPANiSH)(?=\.)/i),
edition: match(name, /(?<=\.)(U*HDR*|UN(RATED|CUT)|DC|(Directors|EXTENDED)[\.\s](CUT|EDITION)|EXTENDED|REMASTERED|3D|2D|\bNF\b)(?=\.)/i),
tags: match(name, /COMPLETE(\.COLLECTiON)?|LiMiTED|iNTERNAL|DOKU|DOCU|REAL/i),
release: match(name, /REAL[\.\s]PROPER|PROPER|REPACK|READNFO|READ[\.\s]NFO|DiRFiX|NFOFiX|RERiP/i),
group: match(name, /[A-Za-z0-9]+$/),
};
var matches = "";
for (var key in data) {
var value = data[key];
if (!value) continue;
matches += value + "|";
}
data.title = name
.replace(RegExp(matches + "-", "g"), " ")
.replace(/\./g, " ")
.replace(/\(/g, " ")
.replace(/\)/g, " ")
.replace(/\s{2,}/g, " ")
.trim();
data.original = name;
Object.keys(data).forEach(function (key) {
if (!data[key]) {
delete data[key];
return;
}
if (key === "edition" || key === "release") {
data[key] = data[key].replace(/\./g, " ").trim();
}
});
return data;
};