酷狗
最近在进行一次对酷狗音乐歌词采集时发现酷狗音乐的歌词直接浏览都是“乱码”,自己平时所见的歌词都是lrc格式的文本,这种酷狗专用的krc格式的显然是经过特别处理过的,平时用酷狗听音乐也没仔细看他的歌词有什么不同,只是与天天静听等不同的是可以逐字高亮显示歌词。
对酷狗的flash播放器进行反编译,发现这段krc解密的ActionScript代码:
public function loaderCompleteHandler(param1:ByteArray) : void{ this.newkeyBytes = [64, 71, 97, 119, 94, 50, 116, 71, 81, 54, 49, 45, 206, 210, 110, 105]; var result:* = param1; var krcBytes:* = new ByteArray(); result.position = 4; result.readBytes(krcBytes); var l:* = krcBytes.length; var i:int; while (i < l) { krcBytes[i] = krcBytes[i] ^ this.newkeyBytes[i % this.newkeyBytes.length]; i = (i + 1); } try { krcBytes.uncompress(); } catch (error:SecurityError) { errorfun("uncompressError"); return; } krcBytes.position = 0; this.myLyric.dataStr = krcBytes.readUTFBytes(krcBytes.length); this.successfun(); return; }
根据这段代码可以很快转换成php解析代码:
$enKey = array(64, 71, 97, 119, 94, 50, 116, 71, 81, 54, 49, 45, 206, 210, 110, 105); $krc_content = substr($krc_content,4); $len = strlen($krc_content); $krc_compress = ''; for ($k = 0; $k < $len; $k++){ $krc_compress .= chr(ord($krc_content[$k]) ^ $enKey[$k % 16]); } $krc_text = gzuncompress($krc_compress);
上面的$krc_content为krc歌词压缩加密的文本内容,得到了解析后的krc明文文本歌词$krc_text,然后就可以很容易的转换成lrc歌词了,如下:
function krc2lrc($krc_content,$glue = "n"){ $enKey = array(64, 71, 97, 119, 94, 50, 116, 71, 81, 54, 49, 45, 206, 210, 110, 105); $krc_content = substr($krc_content,4); $len = strlen($krc_content); $krc_compress = ''; for ($k = 0; $k < $len; $k++){ $krc_compress .= chr(ord($krc_content[$k]) ^ $enKey[$k % 16]); } $krc_text = gzuncompress($krc_compress); preg_match_all("/[(ar|ti|offset):(.+)]/",$krc_text,$matches); $lrc_text = implode($glue,$matches[0]).$glue; preg_match_all("/[(d{0,8}),(d{0,8})](.+)/",$krc_text,$matches); unset($krc_text,$krc_compress,$krc_content,$enKey); if(!empty($matches[1])){ foreach($matches[1] as $k=>$v){ list($seconds, $millis) = explode('.', $v / 1000); $lrc_time = date('i:s',1388534400 + $seconds).'.'.substr($millis,0,2); $lrc_cont = preg_replace("/<d{1,8},d{1,8},d{1,8}>/",'',$matches[3][$k]); $lrc_text .= "[{$lrc_time}]{$lrc_cont}{$glue}"; } } return $lrc_text; }
简单示例如下:
$content = file_get_contents('1.krc'); echo krc2lrc($content,'<br/>');

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

In this article, we're going to explore the notification system in the Laravel web framework. The notification system in Laravel allows you to send notifications to users over different channels. Today, we'll discuss how you can send notifications ov

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

PHP logging is essential for monitoring and debugging web applications, as well as capturing critical events, errors, and runtime behavior. It provides valuable insights into system performance, helps identify issues, and supports faster troubleshoot


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Atom editor mac version download
The most popular open source editor

Notepad++7.3.1
Easy-to-use and free code editor
