diff --git a/.iex.exs b/.iex.exs index 59d1755..536ad2e 100644 --- a/.iex.exs +++ b/.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]) diff --git a/lib/algora/admin.ex b/lib/algora/admin.ex new file mode 100644 index 0000000..ecc11ca --- /dev/null +++ b/lib/algora/admin.ex @@ -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