Files
plugins/MyPlayer/api/lyric.php
chorblack e75f275ef4
Some checks failed
定时更新GitHub源插件 / 自动更新GitHub插件 (push) Has been cancelled
Initial commit
2026-03-07 11:19:25 +08:00

32 lines
921 B
PHP

<?php
/*
* 歌词文件
*/
class lyric extends API{
protected function LoadRemote( ) {
if( TryGetParam( 'url', $url ) ) {
$source = GetUrlContent( $url );
$this->data['source'] = $source;
//$this->data['json'] = $this->GetJson($source);
}
}
function GetJson($lyric){
$lrc = array();
$preg = '/^(.*?)$/m';
$count = preg_match_all( $preg, $lyric, $match );
foreach( $match[1] as $line ) {
$preg = '/\[(\d{2}:.*?)\]/s';
preg_match_all( $preg, $line, $m );
$text = implode( '', $m[0] );
$text = str_replace( $text, '' ,$line );
foreach( $m[1] as $t ) {
$i = explode( ':', $t );
$time = $i[0] * 60 + $i[1];
$lrc[] = array( $time, $text );
}
}
sort( $lrc );
return $lrc;
}
}