Skip to content

Commit

Permalink
initial namespace for A177r7, constrain MinimumAge to 4~18 according …
Browse files Browse the repository at this point in the history
…to the parental_rating_descriptor
  • Loading branch information
paulhiggs committed Sep 18, 2024
1 parent 22fbcac commit 748d774
Show file tree
Hide file tree
Showing 14 changed files with 98 additions and 83 deletions.
5 changes: 2 additions & 3 deletions DVB-I_definitions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* DVB-I_defintions.js
*
*
* Defintions made in DVB A177 Bluebooks
*/
import { tva, tvaEA, tvaEC, TVA_CSmetadata } from "./TVA_definitions.js";
Expand All @@ -9,7 +9,6 @@ const DVB_metadata = "urn:dvb:metadata";
const DVB_CSmetadata = `${DVB_metadata}:cs`,
FVC_CSmetadata = "urn:fvc:metadata:cs";


const PaginationPrefix = `${FVC_CSmetadata}:HowRelatedCS:2015-12:pagination`,
NowNextCRIDPrefix = "crid://dvb.org/metadata/schedules/now-next";

Expand Down Expand Up @@ -43,7 +42,7 @@ export const dvbi = {
A177r4_Namespace: `${DVB_metadata}:servicediscovery:2022b`,
A177r5_Namespace: `${DVB_metadata}:servicediscovery:2023`,
A177r6_Namespace: `${DVB_metadata}:servicediscovery:2024`,
A177r7_Namespace: `${DVB_metadata}:servicediscovery:2024x`,
A177r7_Namespace: `${DVB_metadata}:servicediscovery:2025`,

ApplicationStandards: [
`${HbbTVStandardPrefix}:1.2.1`,
Expand Down
2 changes: 1 addition & 1 deletion IANA_languages.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import chalk from "chalk";

import { datatypeIs } from "./phlib/phlib.js";

import { handleErrors } from "./fetch_err_handler.js";
import handleErrors from "./fetch_err_handler.js";
import { isIn, isIni } from "./utils.js";
import { isHTTPURL } from "./pattern_checks.js";
import fetchS from "sync-fetch";
Expand Down
33 changes: 16 additions & 17 deletions ISO_countries.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/**
/**
* ISO_countries.js
*
*
* Load and check country codes
*/
import { readFile, readFileSync } from "fs";

import chalk from "chalk";
import fetchS from "sync-fetch";

import { handleErrors } from "./fetch_err_handler.js";
import handleErrors from "./fetch_err_handler.js";
import { isHTTPURL } from "./pattern_checks.js";

/**
Expand Down Expand Up @@ -67,7 +67,7 @@ export default class ISOcountries {
}.bind(this)
);
else {
let langs = readFileSync(countriesFile, { encoding: "utf-8" } ).toString();
let langs = readFileSync(countriesFile, { encoding: "utf-8" }).toString();
this.#countriesList = loadCountryData(langs);
}
}
Expand All @@ -90,22 +90,21 @@ export default class ISOcountries {
.then((response) => response.text())
.then((responseText) => (this.#countriesList = loadCountryData(responseText)))
.catch((error) => console.log(chalk.red(`error (${error}) retrieving ${countriesURL}`)));
else {
let resp = null;
try {
resp = fetchS(countriesURL);
} catch (error) {
console.log(chalk.red(error.message));
}
if (resp) {
if (resp.ok)
this.#countriesList = loadCountryData(response.text)
else console.log(chalk.red(`error (${error}) retrieving ${languagesURL}`));
}
else {
let resp = null;
try {
resp = fetchS(countriesURL);
} catch (error) {
console.log(chalk.red(error.message));
}
if (resp) {
if (resp.ok) this.#countriesList = loadCountryData(response.text);
else console.log(chalk.red(`error (${error}) retrieving ${languagesURL}`));
}
}
}

loadCountries(options, async=true) {
loadCountries(options, async = true) {
if (!options) options = {};
if (!options.purge) options.purge = true;

Expand Down
2 changes: 1 addition & 1 deletion accessibility_attributes_checks.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { CS_URI_DELIMITER } from "./classification_scheme.js";

import { DumpString } from "./utils.js";

export function CheckAccessibilityAttributes(AccessibilityAttributes, cs, errs, errCode) {
export default function CheckAccessibilityAttributes(AccessibilityAttributes, cs, errs, errCode) {
const ACCESSIBILITY_CHECK_KEY = "accessibility attributes";

if (!AccessibilityAttributes) {
Expand Down
32 changes: 16 additions & 16 deletions cg_check.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { ValidatePromotionalStillImage } from "./related_material_checks.js";
import { cg_InvalidHrefValue, NoChildElement, keys } from "./common_errors.js";
import { checkAttributes, checkTopElementsAndCardinality, hasChild, SchemaCheck, SchemaLoad, SchemaVersionCheck } from "./schema_checks.js";
import { checkLanguage, GetNodeLanguage, checkXMLLangs } from "./multilingual_element.js";
import { writeOut } from "./logger.js";
import writeOut from "./logger.js";
import { CURRENT, OLD } from "./globals.js";
import {
LoadGenres,
Expand All @@ -42,7 +42,7 @@ import {
LoadCountries,
} from "./classification_scheme_loaders.js";
import { LoadCredits } from "./role_loader.js";
import { CheckAccessibilityAttributes } from "./accessibility_attributes_checks.js";
import CheckAccessibilityAttributes from "./accessibility_attributes_checks.js";

// convenience/readability values
const DEFAULT_LANGUAGE = "***";
Expand Down Expand Up @@ -664,7 +664,7 @@ export default class ContentGuideCheck {
case tva.e_MinimumAge:
checkAttributes(pgChild, [], [], tvaEA.MinimumAge, errs, `${errCode}-10`);
if (thisCountry.MinimumAge) {
// only one minimum age value is premitted per country
// only one minimum age value is permitted per country
errs.addError({
code: `${errCode}-11`,
key: keys.k_ParentalGuidance,
Expand All @@ -675,6 +675,14 @@ export default class ContentGuideCheck {
});
}
thisCountry.MinimumAge = pgChild;
let age = pgChild.text().parseInt();
if ((age < 4 || age > 18) && age != 255)
errs.addError({
code: `${errCode}-12`,
key: keys.k_ParentalGuidance,
message: `value of ${tva.e_MinimumAge.elementize()} must be between 4 and 18 (to align with parental_rating_descriptor) or be 255`,
fragment: pgChild,
});
break;
case tva.e_ParentalRating:
checkAttributes(pgChild, [tva.a_href], [], tvaEA.ParentalRating, errs, `${errCode}-20`);
Expand Down Expand Up @@ -2723,15 +2731,7 @@ export default class ContentGuideCheck {
errs.addError({ type: APPLICATION, code: "PA000a", message: "CheckPlayerApplication() called with node==null" });
return;
}
if (!Array.isArray(allowedContentTypes)) {
errs.addError({
type: APPLICATION,
code: "PA000b",
message: "CheckPlayerApplication() called with incorrect type for allowedContentTypes",
});
return;
}

let allowedTypes = Array.isArray(allowedContentTypes) ? allowedContentTypes : [].concat(allowedContentTypes);
if (!node.attr(tva.a_contentType)) {
errs.addError({
code: `${errcode}-1`,
Expand All @@ -2742,20 +2742,20 @@ export default class ContentGuideCheck {
return;
}

if (allowedContentTypes.includes(node.attr(tva.a_contentType).value())) {
if (allowedTypes.includes(node.attr(tva.a_contentType).value())) {
switch (node.attr(tva.a_contentType).value()) {
case dvbi.XML_AIT_CONTENT_TYPE:
if (!isHTTPURL(node.text()))
errs.addError({
code: `${errcode}-2`,
message: `${node.name().elementize()}=${node.text().quote()} is not a valid AIT URL`,
message: `${node.name().elementize()}=${node.text().quote()} is not a valid HTTP or HTTP URL`,
key: keys.k_InvalidURL,
fragment: node,
});
break;
/* case dvbi.HTML5_APP:
case dvbi.XHTML_APP:
if (!patterns.isHTTPURL(node.text()))
if (!isHTTPURL(node.text()))
errs.addError({code:`${errcode}-3`, message:`${node.name().elementize()}=${node.text().quote()} is not a valid URL`, key:"invalid URL", fragment:node});
break;
*/
Expand Down Expand Up @@ -2890,7 +2890,7 @@ export default class ContentGuideCheck {

// <ProgramURL>
let ProgramURL = OnDemandProgram.get(xPath(props.prefix, tva.e_ProgramURL), props.schema);
if (ProgramURL) this.#CheckPlayerApplication(ProgramURL, [dvbi.XML_AIT_CONTENT_TYPE], errs, "OD020");
if (ProgramURL) this.#CheckPlayerApplication(ProgramURL, dvbi.XML_AIT_CONTENT_TYPE, errs, "OD020");

// <AuxiliaryURL>
let AuxiliaryURL = OnDemandProgram.get(xPath(props.prefix, tva.e_AuxiliaryURL), props.schema);
Expand Down
12 changes: 5 additions & 7 deletions classification_scheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { parseXmlString } from "libxmljs2";
import fetchS from "sync-fetch";

import { dvb } from "./DVB_definitions.js";
import { handleErrors } from "./fetch_err_handler.js";
import handleErrors from "./fetch_err_handler.js";
import { hasChild } from "./schema_checks.js";
import { isHTTPURL } from "./pattern_checks.js";

Expand Down Expand Up @@ -89,7 +89,7 @@ export default class ClassificationScheme {
* @param {String} csURL URL to the classification scheme
*/
#loadFromURL(csURL, async=true) {
#loadFromURL(csURL, async = true) {
const isHTTPurl = isHTTPURL(csURL);
console.log(chalk.yellow(`${isHTTPurl ? "" : "--> NOT "}retrieving CS (${this.#leafsOnly ? "leaf" : "all"} nodes) from ${csURL} via fetch()`));
if (!isHTTPurl) return;
Expand Down Expand Up @@ -120,8 +120,7 @@ export default class ClassificationScheme {
this.insertValue(e, true);
});
this.#schemes.push(CStext.uri);
}
else console.log(chalk.red(`error (${resp.status}:${resp.statusText}) handling ${ref}`));
} else console.log(chalk.red(`error (${resp.status}:${resp.statusText}) handling ${ref}`));
}
}
}
Expand All @@ -131,7 +130,7 @@ export default class ClassificationScheme {
*
* @param {String} classificationScheme the filename of the classification scheme
*/
#loadFromFile(classificationScheme, async=true) {
#loadFromFile(classificationScheme, async = true) {
console.log(chalk.yellow(`reading CS (${this.#leafsOnly ? "leaf" : "all"} nodes) from ${classificationScheme}`));

if (async)
Expand All @@ -155,7 +154,7 @@ export default class ClassificationScheme {
}
}

loadCS(options, async=true) {
loadCS(options, async = true) {
if (!options) options = {};
if (!Object.prototype.hasOwnProperty.call(options, "leafNodesOnly")) options.leafNodesOnly = false;
this.#leafsOnly = options.leafNodesOnly;
Expand Down Expand Up @@ -193,5 +192,4 @@ export default class ClassificationScheme {
if (prefix == "" || node.getValue().beginsWith(prefix)) console.log(node.getValue());
});
}

}
34 changes: 22 additions & 12 deletions dvbi_v7.0-with-hls-hbbtv.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<!ENTITY Hex16 "&HexDigit;{1,4}">
<!ENTITY Hex8 "&HexDigit;{1,2}">
]>
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:dvbisd="urn:dvb:metadata:servicediscovery:2024x" xmlns:dvbi-types="urn:dvb:metadata:servicediscovery-types:2023" xmlns:mpeg7="urn:tva:mpeg7:2008" xmlns:tva="urn:tva:metadata:2024" targetNamespace="urn:dvb:metadata:servicediscovery:2024x" elementFormDefault="qualified" attributeFormDefault="unqualified">
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:dvbisd="urn:dvb:metadata:servicediscovery:2025" xmlns:dvbi-types="urn:dvb:metadata:servicediscovery-types:2023" xmlns:mpeg7="urn:tva:mpeg7:2008" xmlns:tva="urn:tva:metadata:2024" targetNamespace="urn:dvb:metadata:servicediscovery:2025" elementFormDefault="qualified" attributeFormDefault="unqualified">
<import namespace="urn:dvb:metadata:servicediscovery-types:2023" schemaLocation="dvbi_types_v1.0.xsd"/>
<import namespace="urn:tva:metadata:2024" schemaLocation="tva_metadata_3-1_2024.xsd"/>
<import namespace="urn:tva:mpeg7:2008" schemaLocation="tva_mpeg7.xsd"/>
Expand Down Expand Up @@ -226,18 +226,28 @@
</simpleContent>
</complexType>
<complexType name="ParentalRatingType">
<sequence>
<element name="MinimumAge" maxOccurs="unbounded">
<complexType>
<simpleContent>
<extension base="nonNegativeInteger">
<attribute name="countryCodes" type="tva:ISO-3166-List" use="optional"/>
</extension>
</simpleContent>
</complexType>
</element>
</sequence>
<sequence>
<element name="MinimumAge" maxOccurs="unbounded">
<complexType>
<simpleContent>
<extension base="dvbisd:RatingConstrainedAgeType">
<attribute name="countryCodes" type="tva:ISO-3166-List" use="optional"/>
</extension>
</simpleContent>
</complexType>
</element>
</sequence>
</complexType>
<simpleType name="RatingConstrainedAgeType">
<annotation><documentation>
Representation of the minimum age rating values specifed in DVB-SI
0x01 = 4, 0xF = 18
</documentation></annotation>
<restriction base="nonNegativeInteger">
<minExclusive value="3"/>
<maxInclusive value="18"/>
</restriction>
</simpleType>
<complexType name="DVBTDeliveryParametersType">
<sequence>
<element name="DVBTriplet" type="dvbi-types:DVBTripletType"/>
Expand Down
34 changes: 22 additions & 12 deletions dvbi_v7.0.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<!ENTITY Hex16 "&HexDigit;{1,4}">
<!ENTITY Hex8 "&HexDigit;{1,2}">
]>
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:dvbisd="urn:dvb:metadata:servicediscovery:2024x" xmlns:dvbi-types="urn:dvb:metadata:servicediscovery-types:2023" xmlns:mpeg7="urn:tva:mpeg7:2008" xmlns:tva="urn:tva:metadata:2024" targetNamespace="urn:dvb:metadata:servicediscovery:2024x" elementFormDefault="qualified" attributeFormDefault="unqualified">
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:dvbisd="urn:dvb:metadata:servicediscovery:2025" xmlns:dvbi-types="urn:dvb:metadata:servicediscovery-types:2023" xmlns:mpeg7="urn:tva:mpeg7:2008" xmlns:tva="urn:tva:metadata:2024" targetNamespace="urn:dvb:metadata:servicediscovery:2025" elementFormDefault="qualified" attributeFormDefault="unqualified">
<import namespace="urn:dvb:metadata:servicediscovery-types:2023" schemaLocation="dvbi_types_v1.0.xsd"/>
<import namespace="urn:tva:metadata:2024" schemaLocation="tva_metadata_3-1_2024.xsd"/>
<import namespace="urn:tva:mpeg7:2008" schemaLocation="tva_mpeg7.xsd"/>
Expand Down Expand Up @@ -224,18 +224,28 @@
</simpleContent>
</complexType>
<complexType name="ParentalRatingType">
<sequence>
<element name="MinimumAge" maxOccurs="unbounded">
<complexType>
<simpleContent>
<extension base="nonNegativeInteger">
<attribute name="countryCodes" type="tva:ISO-3166-List" use="optional"/>
</extension>
</simpleContent>
</complexType>
</element>
</sequence>
<sequence>
<element name="MinimumAge" maxOccurs="unbounded">
<complexType>
<simpleContent>
<extension base="dvbisd:RatingConstrainedAgeType">
<attribute name="countryCodes" type="tva:ISO-3166-List" use="optional"/>
</extension>
</simpleContent>
</complexType>
</element>
</sequence>
</complexType>
<simpleType name="RatingConstrainedAgeType">
<annotation><documentation>
Representation of the minimum age rating values specifed in DVB-SI
0x01 = 4, 0xF = 18
</documentation></annotation>
<restriction base="nonNegativeInteger">
<minExclusive value="3"/>
<maxInclusive value="18"/>
</restriction>
</simpleType>
<complexType name="DVBTDeliveryParametersType">
<sequence>
<element name="DVBTriplet" type="dvbi-types:DVBTripletType"/>
Expand Down
6 changes: 3 additions & 3 deletions fetch_err_handler.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* fetch_error_handler.js
*
* fetch_err_handler.js
*
* Throw a nice error is there is a problem fetching the information
*
* @param {*} response
* @returns
*/
export function handleErrors(response) {
export default function handleErrors(response) {
if (response && !response.ok) throw Error(`fetch() returned (${response.status}) "${response.statusText}"`);
return response;
}
2 changes: 1 addition & 1 deletion logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function createPrefix(req) {
return `${logDir}${sep}${getDate(new Date())} (${req.body.testtype == MODE_SL ? "SL" : req.body.requestType}) ${fname.replace(/[/\\?%*:|"<>]/g, "-")}`;
}

export function writeOut(errs, filebase, markup, req = null) {
export default function writeOut(errs, filebase, markup, req = null) {
if (!filebase || errs.markupXML?.length == 0) return;

let outputLines = [];
Expand Down
4 changes: 2 additions & 2 deletions role.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* role.js
*
*
* Manages Classification Scheme checking based in a flat list of roles
*/
import chalk from "chalk";
import { readFile } from "fs";

import { handleErrors } from "./fetch_err_handler.js";
import handleErrors from "./fetch_err_handler.js";
import { isHTTPURL } from "./pattern_checks.js";

import ClassificationScheme from "./classification_scheme.js";
Expand Down
Loading

0 comments on commit 748d774

Please sign in to comment.