Skip to content

Commit

Permalink
fix(FEC-8096): some of OTT metadata is getting overriden (#50)
Browse files Browse the repository at this point in the history
change the current structure of the metadata.
  • Loading branch information
odedhutzler authored and Dan Ziv committed Apr 17, 2018
1 parent 43b7e66 commit 30a7553
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 69 deletions.
32 changes: 29 additions & 3 deletions src/k-provider/ott/provider-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,9 @@ export default class OTTProviderParser extends BaseProviderParser {
const playbackContext = assetResponse.playBackContextResult;
const mediaAsset = assetResponse.mediaDataResult;
const kalturaSources = playbackContext.sources;
const metaData = {};
const metaData = OTTProviderParser.reconstructMetadata(mediaAsset);
metaData.description = mediaAsset.description;
metaData.poster = OTTProviderParser._getPoster(mediaAsset.pictures);
Object.assign(metaData, mediaAsset.metas);
Object.assign(metaData, mediaAsset.tags);
mediaEntry.name = mediaAsset.name;
mediaEntry.id = mediaAsset.id;
mediaEntry.metadata = metaData;
Expand All @@ -66,6 +64,34 @@ export default class OTTProviderParser extends BaseProviderParser {
return mediaEntry;
}

/**
* reconstruct the metadata
* @param {Object} mediaAsset the mediaAsset that contains the response with the metadata.
* @returns {Object} reconstructed metadata object
*/
static reconstructMetadata(mediaAsset: Object): Object {
const metadata = {
metas: OTTProviderParser.addToMetaObject(mediaAsset.metas),
tags: OTTProviderParser.addToMetaObject(mediaAsset.tags)
}
return metadata;
}

/**
* transform an array of [{key: value},{key: value}...] to an object
* @param {Array<Object>} list a list of objects
* @returns {Object} an mapped object of the arrayed list.
*/
static addToMetaObject(list: Array<Object>): Object {
let categoryObj = {};
if (list) {
list.forEach(item => {
categoryObj[item.key] = item.value;
})
}
return categoryObj;
}

/**
* Gets the poster url without width and height.
* @param {Array<Object>} pictures - Media pictures.
Expand Down
126 changes: 60 additions & 66 deletions test/src/k-provider/ott/media-config-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,28 @@ const NoPluginsWithDrm = {
"type": "Vod",
"dvr": false,
"metadata": {
"0": {"key": "Free", "value": "nirit|nirit|nirit|"},
"1": {"key": "Genre", "value": "Comedy|Comedy|Comedy|Drama|Kids|Kids|Kids|"},
"2": {
"key": "Main cast",
"value": "Anna Kendrick|Anna Kendrick|Anna Kendrick|Justin Timberlake|Justin Timberlake|Justin Timberlake|"
"metas": {
"App Link": "",
"Catchup allowed": false,
"Catchup logo URL": "",
"Country": "",
"Epg ID": "",
"QUALITY": "",
"Release year": 2017,
"Runtime": "92",
"Short title": "",
"synopsis": ""
},
"tags": {
"Country": "USA|USA|USA|",
"Director": "Walt Dohrn|Walt Dohrn|Walt Dohrn|",
"Free": "nirit|nirit|nirit|",
"Genre": "Comedy|Comedy|Comedy|Drama|Kids|Kids|Kids|",
"Main cast": "Anna Kendrick|Anna Kendrick|Anna Kendrick|Justin Timberlake|Justin Timberlake|Justin Timberlake|",
"Parental Rating": "PG|Parental - 8|",
"QUALITY": "hd|hd|hd|",
"Studio": "Pixar|Pixar|Pixar|"
},
"3": {"key": "Director", "value": "Walt Dohrn|Walt Dohrn|Walt Dohrn|"},
"4": {"key": "Parental Rating", "value": "PG|Parental - 8|"},
"5": {"key": "Studio", "value": "Pixar|Pixar|Pixar|"},
"6": {"key": "Country", "value": "USA|USA|USA|"},
"7": {"key": "QUALITY", "value": "hd|hd|hd|"},
"8": {"key": "Release year", "value": 2017},
"9": {"key": "Catchup allowed", "value": false},
"description": "After the Bergens invade Troll Village, Poppy, the happiest Troll ever born, and the curmudgeonly Branch set off on a journey to rescue her friends. DreamWorks Animation's TROLLS is an irreverent comedy extravaganza with incredible music! From the genius creators of SHREK, TROLLS stars Anna Kendrick as Poppy, the optimistic leader of the Trolls, and her polar opposite, Branch, played by Justin Timberlake. Together, this unlikely pair of Trolls must embark on an adventure that takes them far beyond the only world they've ever known.",
"poster": [
{
Expand Down Expand Up @@ -247,19 +256,28 @@ const FilteredSourcesByDeviceType = {
"type": "Vod",
"dvr": false,
"metadata": {
"0": {"key": "Free", "value": "nirit|nirit|nirit|"},
"1": {"key": "Genre", "value": "Comedy|Comedy|Comedy|Drama|Kids|Kids|Kids|"},
"2": {
"key": "Main cast",
"value": "Anna Kendrick|Anna Kendrick|Anna Kendrick|Justin Timberlake|Justin Timberlake|Justin Timberlake|"
"metas": {
"App Link": "",
"Catchup allowed": false,
"Catchup logo URL": "",
"Country": "",
"Epg ID": "",
"QUALITY": "",
"Release year": 2017,
"Runtime": "92",
"Short title": "",
"synopsis": ""
},
"tags": {
"Country": "USA|USA|USA|",
"Director": "Walt Dohrn|Walt Dohrn|Walt Dohrn|",
"Free": "nirit|nirit|nirit|",
"Genre": "Comedy|Comedy|Comedy|Drama|Kids|Kids|Kids|",
"Main cast": "Anna Kendrick|Anna Kendrick|Anna Kendrick|Justin Timberlake|Justin Timberlake|Justin Timberlake|",
"Parental Rating": "PG|Parental - 8|",
"QUALITY": "hd|hd|hd|",
"Studio": "Pixar|Pixar|Pixar|"
},
"3": {"key": "Director", "value": "Walt Dohrn|Walt Dohrn|Walt Dohrn|"},
"4": {"key": "Parental Rating", "value": "PG|Parental - 8|"},
"5": {"key": "Studio", "value": "Pixar|Pixar|Pixar|"},
"6": {"key": "Country", "value": "USA|USA|USA|"},
"7": {"key": "QUALITY", "value": "hd|hd|hd|"},
"8": {"key": "Release year", "value": 2017},
"9": {"key": "Catchup allowed", "value": false},
"description": "After the Bergens invade Troll Village, Poppy, the happiest Troll ever born, and the curmudgeonly Branch set off on a journey to rescue her friends. DreamWorks Animation's TROLLS is an irreverent comedy extravaganza with incredible music! From the genius creators of SHREK, TROLLS stars Anna Kendrick as Poppy, the optimistic leader of the Trolls, and her polar opposite, Branch, played by Justin Timberlake. Together, this unlikely pair of Trolls must embark on an adventure that takes them far beyond the only world they've ever known.",
"poster": [
{
Expand Down Expand Up @@ -408,49 +426,25 @@ const LiveEntryNoDrm = {
"type": "Live",
"dvr": false,
"metadata": {
"0": {
"key": "Free",
"value": "yes|no|"
},
"1": {
"key": "Genre",
"value": "History|"
},
"2": {
"key": "Parental Rating",
"value": "PG|"
},
"3": {
"key": "QUALITY",
"value": "hd|"
},
"4": {
"key": "Source",
"value": "Web3|"
},
"5": {
"key": "Country",
"value": ""
},
"6": {
"key": "QUALITY",
"value": ""
},
"7": {
"key": "Epg ID",
"value": "1073"
},
"8": {
"key": "Channel number",
"value": 19
},
"9": {
"key": "Epg guid ID",
"value": 1073
"metas": {
"App Link": "",
"Catchup allowed": false,
"Catchup logo URL": "",
"Channel number": 19,
"Country": "",
"Epg ID": "1073",
"Epg guid ID": 1073,
"QUALITY": "",
"Runtime": "220",
"Short title": "",
"synopsis": ""
},
"10": {
"key": "Catchup allowed",
"value": false
"tags": {
"Free": "yes|no|",
"Genre": "History|",
"Parental Rating": "PG|",
"QUALITY": "hd|",
"Source": "Web3|"
},
"description": "***nadya_aes***",
"poster": [
Expand Down

0 comments on commit 30a7553

Please sign in to comment.