Skip to content

Commit e720111

Browse files
committed
core: keep stream source badges evidence-only
1 parent 7c7217e commit e720111

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

engine_v2/src/stream-presentation.mjs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ export function presentStreamCandidate(stream = {}, metadata = {}, provider = {}
1616
descriptionParts.push(originalDescription);
1717
}
1818

19+
// TMDB (or another shared factual metadata resolver) fills sparse/Unknown provider
20+
// descriptions. It supplements facts only; it never invents stream provenance.
1921
const tmdbTitle = useful(metadata.title ?? metadata.name ?? metadata.originalTitle ?? metadata.original_name);
2022
const tmdbYear = positiveInt(metadata.year ?? yearFromDate(metadata.releaseDate ?? metadata.release_date ?? metadata.firstAirDate ?? metadata.first_air_date));
21-
if (!descriptionParts.length && (tmdbTitle || tmdbYear)) {
23+
if (!originalDescription && (tmdbTitle || tmdbYear)) {
2224
descriptionParts.push([tmdbTitle, tmdbYear].filter(Boolean).join(" • "));
2325
}
2426

@@ -92,8 +94,10 @@ export function normalizeSourceType(value) {
9294
if (/WEB-?RIP/.test(compact)) return "WEBRIP";
9395
if (/HDTV/.test(compact)) return "HDTV";
9496
if (/DVDRIP|DVD/.test(compact)) return "DVD";
95-
if (/CAM|TS|TELESYNC/.test(compact)) return "CAM";
96-
return text.toUpperCase();
97+
if (/(?:^|-)CAM(?:-|$)|TELESYNC/.test(compact)) return "CAM";
98+
// Unknown strings are not provenance. In particular, a quality such as 1080p
99+
// must never be converted into a source badge or used to imply Blu-ray/Web-DL.
100+
return null;
97101
}
98102

99103
export function normalizeCodec(value) {
@@ -140,7 +144,7 @@ export function normalizeAgeRating(value) {
140144
const upper = text.toUpperCase();
141145
const france = upper.match(/(?:-|INTERDIT\s+MOINS\s+DE\s+)(10|12|16|18)\b/);
142146
if (france) return `-${france[1]}`;
143-
const plus = upper.match(/\b(7|10|12|13|14|15|16|17|18)\+\b/);
147+
const plus = upper.match(/(?:^|\b)(7|10|12|13|14|15|16|17|18)\+(?:$|\s)/);
144148
if (plus) return `${plus[1]}+`;
145149
if (/^(?:U|G|PG|PG-13|R|NC-17|TV-Y|TV-Y7|TV-G|TV-PG|TV-14|TV-MA)$/i.test(text)) return upper;
146150
return text;

0 commit comments

Comments
 (0)