create static method
Implementation
static List<TextComponentDetail> create(List<Map<String, dynamic>> runs) {
List<TextComponentDetail> tcds = [];
for (var i = 0; i < runs.length; i++) {
TextComponentDetail tcd = TextComponentDetail(text: "");
final run = runs[i];
tcd.text = run['text'];
final navigationEndpoint = run['navigationEndpoint'];
if (navigationEndpoint != null) {
final watchEndpoint = navigationEndpoint['watchEndpoint'];
final browseEndpoint = navigationEndpoint['browseEndpoint'];
if (watchEndpoint != null) {
tcd.type = 'watch';
}
if (browseEndpoint != null) {
final pageType = browseEndpoint['browseEndpointContextSupportedConfigs']['browseEndpointContextMusicConfig']['pageType'] as String?;
if (pageType != null) {
tcd.type = pageType.replaceAll("MUSIC_PAGE_TYPE_", "").toLowerCase();
}
}
tcd.id = watchEndpoint != null
? watchEndpoint['videoId']
: browseEndpoint != null
? browseEndpoint['browseId']
: null;
if (tcd.type == 'playlist' && tcd.id != null) {
tcd.id = (tcd.id ?? '').replaceFirst('VL', '').replaceFirst('MPSP', '');
}
}
tcds.add(tcd);
}
return tcds;
}