Describe the bug
FormatException is thrown when trying to get duration of SHORTS videos. This happens when a channel contains a short videos. The method to convert string to duration failed to parse int.
To Reproduce
/// Format: HH:MM:SS
Duration? toDuration() {
if (/*string == null ||*/ trim().isEmpty) {
return null;
}
// Normal Videos will have a HH:MM:SS as string
// SHORTS video will have a SHORTS string
var parts = split(':');
assert(parts.length <= 3);
// SHORTS VIDEOS => parts = [SHORTS]
if (parts.length == 1) {
// Here where exception is raised. It tries to parse string "SHORTS" to int
return Duration(seconds: int.parse(parts.first));
}
if (parts.length == 2) {
return Duration(
minutes: int.parse(parts[0]), seconds: int.parse(parts[1]));
}
if (parts.length == 3) {
return Duration(
hours: int.parse(parts[0]),
minutes: int.parse(parts[1]),
seconds: int.parse(parts[2]));
}
// Shouldn't reach here.
throw Error();
}
Describe the bug FormatException is thrown when trying to get duration of SHORTS videos. This happens when a channel contains a short videos. The method to convert string to duration failed to parse int.
To Reproduce