mirror of
https://github.com/algora-io/tv.git
synced 2026-06-13 16:06:03 +02:00
add thumbnail_url to video
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user