This commit is contained in:
Cody Cook 2024-05-19 20:01:13 -07:00
commit 70c8a87e15
25 changed files with 508 additions and 187 deletions

View file

@ -76,19 +76,8 @@ class Mix
$this->name = $mix['title'];
$this->slug = $mix['slug'];
$this->description = $mix['description'];
if (isset($mix['cover'])) {
// is this legacy code?
// the code is legacy if it starts with /dj/,
// if it does, prefix with https://www.utahsdjs.com
if (substr($mix['cover'], 0, 5) == "/djs/") {
$mix['cover'] = substr($mix['cover'], 4);
$this->cover = "https://cdn.utahsdjs.com" . $mix['cover'];
} else {
$this->cover = $mix['cover'];
}
}
$this->url = $mix['url'];
$this->cover = $this->legacyFix($mix['cover']);
$this->url = $this->legacyFix($mix['url']);
$this->seconds = $mix['seconds'];
$this->duration = $this->configure_duration();
$this->download_only = $mix['mediaplayer'];
@ -114,6 +103,15 @@ class Mix
return true;
}
private function legacyFix(mixed $item)
{
if (str_starts_with($item, "/djs/")) {
return "https://cdn.utahsdjs.com" . substr($item, 4);
} else {
return $item;
}
}
private function configure_duration(): array
{
$seconds = $this->seconds;
@ -201,14 +199,18 @@ class Mix
private function load_by_slug(): bool
{
$mix = $this->get_mix_by_slug();
if ($mix['title'] != "") {
return $this->build_mix($mix);
if ($mix) {
if ($mix['title'] != "") {
return $this->build_mix($mix);
} else {
return false;
}
} else {
return false;
}
}
private function get_mix_by_slug()
{
$stmt = $this->db->prepare("SELECT * FROM mix WHERE slug = ?");
@ -235,7 +237,7 @@ class Mix
return $this->updated;
}
public function get_img(): string
public function get_img()
{
return $this->cover;
}
@ -275,7 +277,7 @@ class Mix
return $this->url;
}
public function get_cover(): string
public function get_cover()
{
return $this->cover;
}
@ -316,5 +318,3 @@ class Mix
}
}