Add playlist functions

This commit is contained in:
mschuepbach
2024-03-24 23:34:26 +01:00
parent fe4a7dc49e
commit e3a184aa63
7 changed files with 784 additions and 28 deletions

View File

@@ -107,11 +107,12 @@ sub parse_duration {
my ($duration) = @_;
return $duration unless defined $duration;
my @mapped_increments = ( [ 1, 60, 3600 ], reverse split /:/, $duration );
my $seconds = 0;
my @times = reverse split /:/, $duration;
my @multipliers = ( 1, 60, 3600 );
my $seconds = 0;
while ( my ( $multiplier, $time ) = splice( @mapped_increments, 0, 2 ) ) {
$seconds += $multiplier * $time;
for ( my $i = 0 ; $i < @times ; $i++ ) {
$seconds += $multipliers[$i] * $times[$i] if defined $times[$i];
}
return $seconds;
@@ -128,13 +129,13 @@ sub parse_id_name {
}
our @EXPORT = qw(
parse_menu_playlists
get_item_text
get_flex_column_item
get_fixed_column_item
get_dot_separator_index
parse_duration
parse_id_name
parse_menu_playlists
get_item_text
get_flex_column_item
get_fixed_column_item
get_dot_separator_index
parse_duration
parse_id_name
);
1;