Last active
September 15, 2016 12:44
-
-
Save ranyefet/dc4c4aca8c3d1953d8a5bc95243b824f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function buildStreamUrl(assetIds = [], format = 'applehttp') { | |
const baseUrl = `${cdn}/p/${partner}/sp/${partner}00/playManifest/entryId/{entryId}`; | |
if (format === 'applehttp') { | |
if (assetsIds.length === 0) { | |
return baseUrl + `/format/applehttp/protocol/https/a.m3u8`; | |
} else { | |
return baseUrl + `/flavorIds/{assetIds.join(',')}format/applehttp/protocol/https/a.m3u8`; | |
} | |
} | |
if (format === 'url') { | |
return baseUrl + `/flavorId/{assetIds[0]}/format/url/protocol/https/a.mp4`; | |
} | |
} | |
function getPlayManifestFromAssets(assets) { | |
const adaptiveFlavors = []; | |
assets.each(asset => { | |
// asset transcoding, skip | |
if (asset.status !=2) continue; | |
if (assetHasTag(asset, 'applembr')) { | |
// exit loop return url | |
return buildStreamUrl(); | |
} | |
if (entry.duration < 10 && assetHasTag(asset, 'iphone')) { | |
// return mp4 for short entries | |
return buildStreamUrl([asset.id], 'url'); | |
} | |
if (assetHasTag(asset, 'iphonenew')) { | |
adaptiveFlavors.push(asset.id); | |
} | |
}); | |
return buildStreamUrl(adaptiveFlavors); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment