jam乐队/涟漪

从URL获取曲目/专辑信息。

v0.16.1 2023-11-27 10:56 UTC

README

Build Status Latest Stable Version Total Downloads

从URL获取曲目/专辑信息。

要求

PHP 8.0 或更高版本

安装

composer require jamband/ripple

使用

// basic
$ripple = new Jamband\Ripple\Ripple();
$ripple->request('https://example.bandcamp.com/track/title');
$ripple->provider(); // Bandcamp
$ripple->url(); // https://example.bandcamp.com/track/title
$ripple->id(); // 123
$ripple->title(); // Title, by Artist
$ripple->image(); // https://img.example.com/img/123.jpg
// embed
$ripple = new Jamband\Ripple\Ripple();
$ripple->options(['embed' => ['Bandcamp' => 'size=large/']]);
$ripple->request('https://example.bandcamp.com/track/title');
$embed = $ripple->embed(); // https://bandcamp.com/EmbeddedPlayer/track=123/size=large/
?>
<iframe width="300" height="300" src="<?= $embed ?>" allow="fullscreen"></iframe>
// custom curl options
$ripple = new Jamband\Ripple\Ripple();
$ripple->options(['curl' => [
    // CURLOPT_TIMEOUT => 8,
    // CURLOPT_USERAGENT => '...',
    // ...
]]);
$ripple->request('https://example.bandcamp.com/track/title');
// mock response
$ripple = new Jamband\Ripple\Ripple();
$ripple->options(['response' => '...']);
$ripple->request('https://example.bandcamp.com/track/title');

有效URL

Bandcamp:
https://{subdomain}.bandcamp.com/track/{title}
https://{subdomain}.bandcamp.com/album/{title}
https://{subdomain}.bandcamp.com/releases
https?://{domain}/track/{title}
https?://{domain}/album/{title}
https?://{domain}/releases

SoundCloud:
https://soundcloud.com/{account}/{title}
https://soundcloud.com/{account}/sets/{title}

Vimeo:
https://vimeo.com/{id}

YouTube:
https://www.youtube.com/watch?v={id}
https://www.youtube.com/playlist?list={id}
https://youtu.be/{id}

支持的服务提供者

  • Bandcamp
  • SoundCloud
  • Vimeo
  • YouTube

许可证

涟漪采用MIT许可证。