Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Pour valider des entités lorsque vous créez ou mettez à jour votre flux, utilisez les schémas JSON suivants. Les schémas sont basés sur la spécification du schéma JSON.
En ajoutant un test unitaire pour valider les entités que vous générez, vous pouvez détecter les problèmes qui affecteraient la qualité du flux. Vous pouvez également utiliser ces schémas lors du développement de votre flux pour éviter les erreurs courantes.
Le schéma de télévision en direct valide les entités BroadcastEvent, BroadcastService, CableOrSatelliteService, Movie, Organization, SportsEvent, TelevisionChannel, TVEpisode, TVSeason et TVSeries.
Le schéma Music valide les entités MusicAlbum, MusicGroup, MusicPlaylist et MusicRecording.
Le schéma Radio valide les entités RadioBroadcastService.
Utilisez la spécification de ce site comme source de vérité, car il est possible que toutes les fonctionnalités ne soient pas implémentées dans ces schémas.
Les schémas fournis sont rédigés en version préliminaire 7. L'implémentation que vous choisissez doit donc être compatible avec cette version pour fonctionner correctement.
Exemple de validation
L'exemple suivant montre comment valider toutes les entités présentes dans un fichier feed.json à l'aide du fichier de schéma schema.json et du module Python jsonschema. Les entités se trouvent dans la propriété dataFeedElement, comme indiqué dans la documentation sur l'enveloppe du flux de données.
importjsonfromjsonschemaimportvalidate# Loading the schema filewithopen("schema.json","r")asfp:schema=json.load(fp)# Opening the feedwithopen("feed.json","r")asfp:feed=json.load(fp)# Validating each entity in the feedforentityinfeed["dataFeedElement"]:try:validate(schema=schema,instance=entity)print("Entity validated successfully")exceptExceptionase:# e may contain an explanation as to why the entity wasn't validprint("Failed to validate the entity")
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
[null,null,[],[[["\u003cp\u003eJSON Schemas are provided to validate entities when creating or updating your data feed, ensuring data quality and consistency.\u003c/p\u003e\n"],["\u003cp\u003eChoose the appropriate Media Actions schema (VOD, Live TV, Music, or Radio) based on the type of entities in your feed.\u003c/p\u003e\n"],["\u003cp\u003eSelect a validator implementation that supports JSON Schema draft 7 and integrate it into your workflow for automated validation.\u003c/p\u003e\n"],["\u003cp\u003eRefer to the specification on this site as the primary source of truth for entity requirements, as schemas may not include all features.\u003c/p\u003e\n"],["\u003cp\u003eUtilize the provided example code snippet to validate entities within your feed using the chosen schema and a compatible validator.\u003c/p\u003e\n"]]],["To validate feed entities, use the provided JSON Schemas, based on the JSON Schema specification, for different media types: Video On Demand, Live TV, Music, and Radio. Add unit tests for validation to detect issues and avoid errors during feed development. Choose a validator implementation supporting draft 7, such as the `jsonschema` python module. Validate entities by loading the schema and feed, then iterating through entities in the `dataFeedElement` property and testing with the selected implementation, printing the results.\n"],null,["# Validate entities with JSON schemas\n\nTo validate entities when you're creating or updating your feed, use the following JSON\nSchemas. The schemas are based on the [JSON Schema specification](https://json-schema.org).\nBy adding a unit test to validate the entities you generate, you can detect\nissues that would impact the feed quality. You can also use these schemas during\nthe development of your feed to avoid common errors.\n\nSelect a Media Actions schema\n-----------------------------\n\n- [Video On Demand Schema](./schema_vod.json) validates `Movie`, `TVEpisode`, `TVSeries` and `TVSeason` entities.\n- [Live TV Schema](./schema_livetv.json) validates `BroadcastEvent`, `BroadcastService`, `CableOrSatelliteService`, `Movie`, `Organization`, `SportsEvent`, `TelevisionChannel`, `TVEpisode`, `TVSeason` and `TVSeries` entities.\n- [Music Schema](./schema_music.json) validates `MusicAlbum`, `MusicGroup`, `MusicPlaylist` and `MusicRecording` entities.\n- [Radio Schema](./schema_radio.json) validates `RadioBroadcastService` entities.\n\n| **Warning:** The `TVSeries`, `TVSeason`, `TVEpisode` and `Movie` specifications differ between VOD and Live TV. Use the schema that corresponds to the intended use of the entity or use the VOD schema if the entity is used as VOD and Live TV.\n\nUse the specification on this site as the source of truth, since these schemas may not have all the features implemented.\n\nChoose a validator\n------------------\n\nYou can find the list of [validator implementations](https://json-schema.org/implementations.html#validators) on [json-schema.org](https://json-schema.org/).\n\nThe schemas provided are written in [draft 7](https://json-schema.org/specification.html), so the implementation you choose needs to support this version to work properly.\n| **Warning:** We can't endorse any implementation. It's your responsibility to choose from existing implementations, and to make sure it runs safely within your process.\n\nExample of validation\n---------------------\n\nThe following example show how to validate all entities present in a file\n`feed.json` using the schema file `schema.json` and the [jsonschema](https://github.com/Julian/jsonschema) python module. The entities are in the\nproperty `dataFeedElement` as specified in the [data feed envelope](../reference#data_feed_envelope) documentation. \n\n\n import json\n from jsonschema import validate\n\n # Loading the schema file\n with open(\"schema.json\", \"r\") as fp:\n schema = json.load(fp)\n\n # Opening the feed\n with open(\"feed.json\", \"r\") as fp:\n feed = json.load(fp)\n\n # Validating each entity in the feed\n for entity in feed[\"dataFeedElement\"] :\n try:\n validate(schema=schema, instance=entity)\n print(\"Entity validated successfully\")\n except Exception as e:\n # e may contain an explanation as to why the entity wasn't valid\n print(\"Failed to validate the entity\")"]]