add thumbnail_url to video

This commit is contained in:
zafer
2024-03-06 19:51:58 +03:00
parent 0b3b94faa4
commit 1b2c7d6f5a
2 changed files with 20 additions and 0 deletions
+1
View File
@@ -13,6 +13,7 @@ defmodule Algora.Library.Video do
field :type, Ecto.Enum, values: [vod: 1, livestream: 2]
field :is_live, :boolean, default: false
field :thumbnails_ready, :boolean, default: false
field :thumbnail_url, :string
field :url, :string
field :url_root, :string
field :uuid, :string
@@ -0,0 +1,19 @@
defmodule Algora.Repo.Migrations.AddThumbnailUrlToVideo do
use Ecto.Migration
def up do
alter table("videos") do
add :thumbnail_url, :string
end
execute "update videos set thumbnail_url = format('%s/index.jpeg', url_root) where url_root is not null and thumbnails_ready = 't'"
execute "update videos set thumbnail_url = format('https://i.ytimg.com/vi/%s/hqdefault.jpg', substr(url,29)) where url like 'https://youtube.com/watch?v=%'"
end
def down do
alter table("videos") do
remove :thumbnail_url, :string
end
end
end