Большое обновление
- проект переписан на flight + twig, laravel-like хелперы - docker-окружение - новая страница с подробностями о плейлисте - улучшен json о плейлисте - нормальный роутинг - нормальная статусная система - попытка перекодировки при не utf-8 + предупреждение об этом - дополнены FAQ + README
This commit is contained in:
45
src/app/Core/Playlist.php
Normal file
45
src/app/Core/Playlist.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace App\Core;
|
||||
|
||||
class Playlist extends BasicPlaylist
|
||||
{
|
||||
public ?string $name;
|
||||
|
||||
public ?string $desc;
|
||||
|
||||
public string $pls;
|
||||
|
||||
public ?string $src;
|
||||
|
||||
public string $url;
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct(public string $id, array $params)
|
||||
{
|
||||
empty($params['pls']) && throw new \Exception(
|
||||
"Плейлист с ID=$id обязан иметь параметр pls или redirect"
|
||||
);
|
||||
$this->url = str_replace(['http://', 'https://'], '', base_url($id));
|
||||
$this->name = $params['name'] ?? "Плейлист #$id";
|
||||
$this->desc = $params['desc'] ?? null;
|
||||
$this->pls = $params['pls'];
|
||||
$this->src = $params['src'] ?? null;
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'url' => $this->url,
|
||||
'name' => $this->name,
|
||||
'desc' => $this->desc,
|
||||
'pls' => $this->pls,
|
||||
'src' => $this->src,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user