Skip to content

Commit

Permalink
Better deal with live videos
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnmrs committed Dec 15, 2024
1 parent bbb2f98 commit 9d20340
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/Helpers/youtube_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ function youtube_get_duration($videoID)

if ($resultPage !== false && is_string($resultPage)) {
if (preg_match('/"lengthSeconds":"(\d+)"/', $resultPage, $matches)) {
return $matches[1];
if ($matches[1] > 0) {
return $matches[1];
}
}
}

Expand Down Expand Up @@ -186,6 +188,10 @@ function youtube_parse_meta(object $item)

$video['video_duration'] = youtube_get_duration($video['video_id']);

if (!$video['video_duration']) {
$video['video_duration'] = 0;
}

return $video;
}
}

0 comments on commit 9d20340

Please sign in to comment.