-
Notifications
You must be signed in to change notification settings - Fork 6k
Closed
Labels
Description
[REQUIRED] Use case description
Add ability to extract metadata from ICY on the client implementation.
Currently it's impossible to extract additional information from ICY metadata except title and url. It would be better if you would just pass rawMetadata as additional parameter to IcyInfo, so client will handle extraction on it's own if needed.
Use case is that we are using ads info that is passed along with title, but it's not in "title=", instead it's like adw_ad= or ad|main
Example that we are using:
[StreamTitle='';StreamUrl='';metadata='adswizzContext=fGg6M158cDo2MTkzI3U6ODU3MA%3D%3D';adw_ad='true';durationMilliseconds='30511';adId='54691';insertionType='midroll';]
Proposed solution
@Nullable
@VisibleForTesting
/* package */ Metadata decode(String metadata) {
String name = null;
String url = null;
int index = 0;
Matcher matcher = METADATA_ELEMENT.matcher(metadata);
while (matcher.find(index)) {
String key = Util.toLowerInvariant(matcher.group(1));
String value = matcher.group(2);
switch (key) {
case STREAM_KEY_NAME:
name = value;
break;
case STREAM_KEY_URL:
url = value;
break;
default:
Log.w(TAG, "Unrecognized ICY tag: " + name);
break;
}
index = matcher.end();
}
return (name != null || url != null) ? new Metadata(new IcyInfo(name, url, metadata)) : null;
}
and
....
@Nullable public final String rawMetadata;
....
public IcyInfo(@Nullable String title, @Nullable String url, @Nullable String rawMetadata) {
....
this.rawMetadata = rawMetadata;
Alternatives considered
I know you were thinking about other possible use-cases whether to provide key-value pair, but I think providing just raw String would be sufficient.
Reactions are currently unavailable