Skip to content
Permalink
Browse files

Youtube playlist changed

  • Loading branch information...
Thoulah committed Apr 11, 2019
1 parent 21cfc5f commit 791cb4d4ee8f9eef9d4db8cc2f4515695d6e0856

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -10,7 +10,7 @@ public function cleanInput(string $data, string $markdown = 'original', bool $al
$data = $allowHtml ? Yii::$app->formatter->asRaw(trim($data)) : Yii::$app->formatter->asHtml(trim($data), ['HTML.Allowed' => '']);
$data = preg_replace_callback_array([
'/(vimeo):(()?[[:digit:]]+):(21by9|16by9|4by3|1by1)/U' => [$this, 'getVideo'],
'/(youtube):((PL)?[[:ascii:]]{11,32}):(21by9|16by9|4by3|1by1)/U' => [$this, 'getVideo'],
'/(youtube):((OL|PL){0,1}?[[:ascii:]]+):(21by9|16by9|4by3|1by1)/U' => [$this, 'getVideo'],
], $data);
if ($markdown)
$data = Markdown::process($data, $markdown);
@@ -43,6 +43,6 @@ private function addImageResponsiveClass(string $html): string {
}
private function getVideo(array $match): string {
return Video::getEmbed($match[1], $match[2], $match[4], $match[3] === 'PL' ? true : $match[3]);
return Video::getEmbed($match[1], $match[2], $match[4], boolval($match[3]));
}
}
@@ -110,9 +110,7 @@ public function belongsToViewer(): bool {
}
public static function getLastModified(): int {
$data = self::find()
->max('updated');
return $data;
return $self::find()->max('updated');
}
public function getAuthor() {
@@ -18,7 +18,6 @@ public static function tableName(): string {
public function afterFind(): void {
parent::afterFind();
$this->url = $this->url ?? $this->name;
$this->playlist_id = $this->playlist_id ? 'PL'.$this->playlist_id : null;
$this->playlist_embed = $this->playlist_id && $this->playlist_ratio ? Video::getEmbed('youtube', $this->playlist_id, $this->playlist_ratio, true) : null;
$this->playlist_url = $this->playlist_id ? Video::getUrl('youtube', $this->playlist_id, true) : null;
$this->updated = Yii::$app->formatter->asTimestamp($this->updated);
@@ -28,7 +27,6 @@ public function afterFind(): void {
public function beforeSave($insert): bool {
if (parent::beforeSave($insert)) :
$this->url = $this->name === $this->url ? null : $this->url;
$this->playlist_id = $this->playlist_id ? substr($this->playlist_id, 2) : null;
$this->active = $this->active ? 1 : 0;
return true;
endif;

0 comments on commit 791cb4d

Please sign in to comment.
You can’t perform that action at this time.