mirror of
https://github.com/algora-io/tv.git
synced 2024-11-16 00:58:59 +02:00
add Admin module
This commit is contained in:
parent
2eda2f433e
commit
0da97054ca
2
.iex.exs
2
.iex.exs
@ -1,7 +1,7 @@
|
||||
import Ecto.Query
|
||||
import Ecto.Changeset
|
||||
|
||||
alias Algora.{Accounts, Library, Repo, Storage, Cache, ML}
|
||||
alias Algora.{Admin, Accounts, Library, Repo, Storage, Cache, ML, Shows}
|
||||
|
||||
IEx.configure(inspect: [charlists: :as_lists])
|
||||
|
||||
|
24
lib/algora/admin.ex
Normal file
24
lib/algora/admin.ex
Normal file
@ -0,0 +1,24 @@
|
||||
alias Algora.{Accounts, Library}
|
||||
|
||||
defmodule Algora.Admin do
|
||||
def set_thumbnail!(id, path) do
|
||||
video = Library.get_video!(id)
|
||||
{:ok, _} = Library.store_thumbnail_from_file(video, path || "/tmp/#{id}.png")
|
||||
{:ok, _} = Library.store_og_image_from_file(video, path || "/tmp/#{id}.png")
|
||||
end
|
||||
|
||||
def set_title!(id, title) do
|
||||
video = Library.get_video!(id)
|
||||
user = Accounts.get_user!(video.user_id)
|
||||
{:ok, _} = Library.update_video(video, %{title: title})
|
||||
{:ok, _} = Accounts.update_settings(user, %{channel_tagline: title})
|
||||
end
|
||||
|
||||
def pipelines() do
|
||||
Node.list() |> Enum.flat_map(&Membrane.Pipeline.list_pipelines/1)
|
||||
end
|
||||
|
||||
def broadcasts() do
|
||||
pipelines() |> Enum.map(fn pid -> GenServer.call(pid, :get_video_id) end)
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user