Change Channel to Source (#12)
* Ensure channel detail lookup doesn't download the video - oops * Ran the needful migrations for replacing channels with sources * got media source test back working * channel tasks test * Media indexing worker test * media tests * Got all tests working except controller tests * got all tests working * Renamed Channel struct to Source * renamed ChannelTasks * More renaming; renamed channel details module * Removed Channel yt-dlp module, instead throwing things in the VideoCollection module * Renamed what looks like the last of the outstanding data
This commit is contained in:
@@ -1,75 +0,0 @@
|
||||
defmodule PinchflatWeb.MediaSources.ChannelController do
|
||||
use PinchflatWeb, :controller
|
||||
|
||||
alias Pinchflat.Profiles
|
||||
alias Pinchflat.MediaSource
|
||||
alias Pinchflat.MediaSource.Channel
|
||||
|
||||
def index(conn, _params) do
|
||||
channels = MediaSource.list_channels()
|
||||
|
||||
render(conn, :index, channels: channels)
|
||||
end
|
||||
|
||||
def new(conn, _params) do
|
||||
changeset = MediaSource.change_channel(%Channel{})
|
||||
|
||||
render(conn, :new, changeset: changeset, media_profiles: media_profiles())
|
||||
end
|
||||
|
||||
def create(conn, %{"channel" => channel_params}) do
|
||||
case MediaSource.create_channel(channel_params) do
|
||||
{:ok, channel} ->
|
||||
conn
|
||||
|> put_flash(:info, "Channel created successfully.")
|
||||
|> redirect(to: ~p"/media_sources/channels/#{channel}")
|
||||
|
||||
{:error, %Ecto.Changeset{} = changeset} ->
|
||||
render(conn, :new, changeset: changeset, media_profiles: media_profiles())
|
||||
end
|
||||
end
|
||||
|
||||
def show(conn, %{"id" => id}) do
|
||||
channel = MediaSource.get_channel!(id)
|
||||
|
||||
render(conn, :show, channel: channel)
|
||||
end
|
||||
|
||||
def edit(conn, %{"id" => id}) do
|
||||
channel = MediaSource.get_channel!(id)
|
||||
changeset = MediaSource.change_channel(channel)
|
||||
|
||||
render(conn, :edit, channel: channel, changeset: changeset, media_profiles: media_profiles())
|
||||
end
|
||||
|
||||
def update(conn, %{"id" => id, "channel" => channel_params}) do
|
||||
channel = MediaSource.get_channel!(id)
|
||||
|
||||
case MediaSource.update_channel(channel, channel_params) do
|
||||
{:ok, channel} ->
|
||||
conn
|
||||
|> put_flash(:info, "Channel updated successfully.")
|
||||
|> redirect(to: ~p"/media_sources/channels/#{channel}")
|
||||
|
||||
{:error, %Ecto.Changeset{} = changeset} ->
|
||||
render(conn, :edit,
|
||||
channel: channel,
|
||||
changeset: changeset,
|
||||
media_profiles: media_profiles()
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def delete(conn, %{"id" => id}) do
|
||||
channel = MediaSource.get_channel!(id)
|
||||
{:ok, _channel} = MediaSource.delete_channel(channel)
|
||||
|
||||
conn
|
||||
|> put_flash(:info, "Channel deleted successfully.")
|
||||
|> redirect(to: ~p"/media_sources/channels")
|
||||
end
|
||||
|
||||
defp media_profiles do
|
||||
Profiles.list_media_profiles()
|
||||
end
|
||||
end
|
||||
@@ -1,12 +0,0 @@
|
||||
<.header>
|
||||
Edit Channel <%= @channel.id %>
|
||||
<:subtitle>Use this form to manage channel records in your database.</:subtitle>
|
||||
</.header>
|
||||
|
||||
<.channel_form
|
||||
changeset={@changeset}
|
||||
media_profiles={@media_profiles}
|
||||
action={~p"/media_sources/channels/#{@channel}"}
|
||||
/>
|
||||
|
||||
<.back navigate={~p"/media_sources/channels"}>Back to channels</.back>
|
||||
@@ -1,28 +0,0 @@
|
||||
<.header>
|
||||
Listing Channels
|
||||
<:actions>
|
||||
<.link href={~p"/media_sources/channels/new"}>
|
||||
<.button>New Channel</.button>
|
||||
</.link>
|
||||
</:actions>
|
||||
</.header>
|
||||
|
||||
<.table id="channels" rows={@channels} row_click={&JS.navigate(~p"/media_sources/channels/#{&1}")}>
|
||||
<:col :let={channel} label="Name"><%= channel.name %></:col>
|
||||
<:col :let={channel} label="Channel"><%= channel.channel_id %></:col>
|
||||
<:action :let={channel}>
|
||||
<div class="sr-only">
|
||||
<.link navigate={~p"/media_sources/channels/#{channel}"}>Show</.link>
|
||||
</div>
|
||||
<.link navigate={~p"/media_sources/channels/#{channel}/edit"}>Edit</.link>
|
||||
</:action>
|
||||
<:action :let={channel}>
|
||||
<.link
|
||||
href={~p"/media_sources/channels/#{channel}"}
|
||||
method="delete"
|
||||
data-confirm="Are you sure?"
|
||||
>
|
||||
Delete
|
||||
</.link>
|
||||
</:action>
|
||||
</.table>
|
||||
@@ -1,12 +0,0 @@
|
||||
<.header>
|
||||
New Channel
|
||||
<:subtitle>Use this form to manage channel records in your database.</:subtitle>
|
||||
</.header>
|
||||
|
||||
<.channel_form
|
||||
changeset={@changeset}
|
||||
media_profiles={@media_profiles}
|
||||
action={~p"/media_sources/channels"}
|
||||
/>
|
||||
|
||||
<.back navigate={~p"/media_sources/channels"}>Back to channels</.back>
|
||||
@@ -1,17 +0,0 @@
|
||||
<.header>
|
||||
Channel <%= @channel.id %>
|
||||
<:subtitle>This is a channel record from your database.</:subtitle>
|
||||
<:actions>
|
||||
<.link href={~p"/media_sources/channels/#{@channel}/edit"}>
|
||||
<.button>Edit channel</.button>
|
||||
</.link>
|
||||
</:actions>
|
||||
</.header>
|
||||
|
||||
<.list>
|
||||
<:item title="Channel Name"><%= @channel.name %></:item>
|
||||
<:item title="Channel ID"><%= @channel.channel_id %></:item>
|
||||
<:item title="Original URL"><%= @channel.original_url %></:item>
|
||||
</.list>
|
||||
|
||||
<.back navigate={~p"/media_sources/channels"}>Back to channels</.back>
|
||||
@@ -0,0 +1,75 @@
|
||||
defmodule PinchflatWeb.MediaSources.SourceController do
|
||||
use PinchflatWeb, :controller
|
||||
|
||||
alias Pinchflat.Profiles
|
||||
alias Pinchflat.MediaSource
|
||||
alias Pinchflat.MediaSource.Source
|
||||
|
||||
def index(conn, _params) do
|
||||
sources = MediaSource.list_sources()
|
||||
|
||||
render(conn, :index, sources: sources)
|
||||
end
|
||||
|
||||
def new(conn, _params) do
|
||||
changeset = MediaSource.change_source(%Source{})
|
||||
|
||||
render(conn, :new, changeset: changeset, media_profiles: media_profiles())
|
||||
end
|
||||
|
||||
def create(conn, %{"source" => source_params}) do
|
||||
case MediaSource.create_source(source_params) do
|
||||
{:ok, source} ->
|
||||
conn
|
||||
|> put_flash(:info, "Source created successfully.")
|
||||
|> redirect(to: ~p"/media_sources/sources/#{source}")
|
||||
|
||||
{:error, %Ecto.Changeset{} = changeset} ->
|
||||
render(conn, :new, changeset: changeset, media_profiles: media_profiles())
|
||||
end
|
||||
end
|
||||
|
||||
def show(conn, %{"id" => id}) do
|
||||
source = MediaSource.get_source!(id)
|
||||
|
||||
render(conn, :show, source: source)
|
||||
end
|
||||
|
||||
def edit(conn, %{"id" => id}) do
|
||||
source = MediaSource.get_source!(id)
|
||||
changeset = MediaSource.change_source(source)
|
||||
|
||||
render(conn, :edit, source: source, changeset: changeset, media_profiles: media_profiles())
|
||||
end
|
||||
|
||||
def update(conn, %{"id" => id, "source" => source_params}) do
|
||||
source = MediaSource.get_source!(id)
|
||||
|
||||
case MediaSource.update_source(source, source_params) do
|
||||
{:ok, source} ->
|
||||
conn
|
||||
|> put_flash(:info, "Source updated successfully.")
|
||||
|> redirect(to: ~p"/media_sources/sources/#{source}")
|
||||
|
||||
{:error, %Ecto.Changeset{} = changeset} ->
|
||||
render(conn, :edit,
|
||||
source: source,
|
||||
changeset: changeset,
|
||||
media_profiles: media_profiles()
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def delete(conn, %{"id" => id}) do
|
||||
source = MediaSource.get_source!(id)
|
||||
{:ok, _source} = MediaSource.delete_source(source)
|
||||
|
||||
conn
|
||||
|> put_flash(:info, "Source deleted successfully.")
|
||||
|> redirect(to: ~p"/media_sources/sources")
|
||||
end
|
||||
|
||||
defp media_profiles do
|
||||
Profiles.list_media_profiles()
|
||||
end
|
||||
end
|
||||
+4
-4
@@ -1,16 +1,16 @@
|
||||
defmodule PinchflatWeb.MediaSources.ChannelHTML do
|
||||
defmodule PinchflatWeb.MediaSources.SourceHTML do
|
||||
use PinchflatWeb, :html
|
||||
|
||||
embed_templates "channel_html/*"
|
||||
embed_templates "source_html/*"
|
||||
|
||||
@doc """
|
||||
Renders a channel form.
|
||||
Renders a source form.
|
||||
"""
|
||||
attr :changeset, Ecto.Changeset, required: true
|
||||
attr :action, :string, required: true
|
||||
attr :media_profiles, :list, required: true
|
||||
|
||||
def channel_form(assigns)
|
||||
def source_form(assigns)
|
||||
|
||||
def friendly_index_frequencies do
|
||||
[
|
||||
@@ -0,0 +1,12 @@
|
||||
<.header>
|
||||
Edit Source <%= @source.id %>
|
||||
<:subtitle>Use this form to manage source records in your database.</:subtitle>
|
||||
</.header>
|
||||
|
||||
<.source_form
|
||||
changeset={@changeset}
|
||||
media_profiles={@media_profiles}
|
||||
action={~p"/media_sources/sources/#{@source}"}
|
||||
/>
|
||||
|
||||
<.back navigate={~p"/media_sources/sources"}>Back to sources</.back>
|
||||
@@ -0,0 +1,24 @@
|
||||
<.header>
|
||||
Listing Sources
|
||||
<:actions>
|
||||
<.link href={~p"/media_sources/sources/new"}>
|
||||
<.button>New Source</.button>
|
||||
</.link>
|
||||
</:actions>
|
||||
</.header>
|
||||
|
||||
<.table id="sources" rows={@sources} row_click={&JS.navigate(~p"/media_sources/sources/#{&1}")}>
|
||||
<:col :let={source} label="Name"><%= source.name %></:col>
|
||||
<:col :let={source} label="Source"><%= source.collection_id %></:col>
|
||||
<:action :let={source}>
|
||||
<div class="sr-only">
|
||||
<.link navigate={~p"/media_sources/sources/#{source}"}>Show</.link>
|
||||
</div>
|
||||
<.link navigate={~p"/media_sources/sources/#{source}/edit"}>Edit</.link>
|
||||
</:action>
|
||||
<:action :let={source}>
|
||||
<.link href={~p"/media_sources/sources/#{source}"} method="delete" data-confirm="Are you sure?">
|
||||
Delete
|
||||
</.link>
|
||||
</:action>
|
||||
</.table>
|
||||
@@ -0,0 +1,12 @@
|
||||
<.header>
|
||||
New Source
|
||||
<:subtitle>Use this form to manage source records in your database.</:subtitle>
|
||||
</.header>
|
||||
|
||||
<.source_form
|
||||
changeset={@changeset}
|
||||
media_profiles={@media_profiles}
|
||||
action={~p"/media_sources/sources"}
|
||||
/>
|
||||
|
||||
<.back navigate={~p"/media_sources/sources"}>Back to sources</.back>
|
||||
@@ -0,0 +1,17 @@
|
||||
<.header>
|
||||
Source <%= @source.id %>
|
||||
<:subtitle>This is a source record from your database.</:subtitle>
|
||||
<:actions>
|
||||
<.link href={~p"/media_sources/sources/#{@source}/edit"}>
|
||||
<.button>Edit source</.button>
|
||||
</.link>
|
||||
</:actions>
|
||||
</.header>
|
||||
|
||||
<.list>
|
||||
<:item title="Source Name"><%= @source.name %></:item>
|
||||
<:item title="Source ID"><%= @source.collection_id %></:item>
|
||||
<:item title="Original URL"><%= @source.original_url %></:item>
|
||||
</.list>
|
||||
|
||||
<.back navigate={~p"/media_sources/sources"}>Back to sources</.back>
|
||||
+3
-2
@@ -10,7 +10,8 @@
|
||||
label="Media Profile"
|
||||
/>
|
||||
|
||||
<.input field={f[:original_url]} type="text" label="Channel URL" />
|
||||
<.input field={f[:collection_type]} type="text" label="Collection Type" />
|
||||
<.input field={f[:original_url]} type="text" label="Source URL" />
|
||||
|
||||
<.input
|
||||
field={f[:index_frequency_minutes]}
|
||||
@@ -20,6 +21,6 @@
|
||||
/>
|
||||
|
||||
<:actions>
|
||||
<.button>Save Channel</.button>
|
||||
<.button>Save Source</.button>
|
||||
</:actions>
|
||||
</.simple_form>
|
||||
Reference in New Issue
Block a user