Add playlist functions
This commit is contained in:
@@ -41,8 +41,9 @@ sub initialize_context {
|
||||
}
|
||||
|
||||
sub get_visitor_id {
|
||||
my ($content) = @_;
|
||||
my @matches = $content =~ /ytcfg\.set\s*\(\s*({.+?})\s*\)\s*;/g;
|
||||
my ($response) = @_;
|
||||
my @matches =
|
||||
$response->decoded_content =~ /ytcfg\.set\s*\(\s*({.+?})\s*\)\s*;/g;
|
||||
my $visitor_id = "";
|
||||
|
||||
if (@matches) {
|
||||
@@ -89,11 +90,15 @@ sub to_int {
|
||||
sub sum_total_duration {
|
||||
my ($item) = @_;
|
||||
|
||||
return 0 unless exists $item->{tracks};
|
||||
return 0 unless exists $item->{"tracks"};
|
||||
|
||||
my $total_duration =
|
||||
sum( map { exists $_->{duration_seconds} ? $_->{duration_seconds} : 0 }
|
||||
@{ $item->{tracks} } );
|
||||
my $total_duration = 0;
|
||||
foreach my $track ( @{ $item->{"tracks"} } ) {
|
||||
$total_duration +=
|
||||
exists $track->{"duration_seconds"}
|
||||
? $track->{"duration_seconds"}
|
||||
: 0;
|
||||
}
|
||||
|
||||
return $total_duration;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user