* Add media streaming (#108) * [WIP] set up streaming route * Added UUID to sources and media items * Added media preview to MI show page * Added plug to strip file extensions * [VERY WIP] basic podcast RSS setup * [WIP] got basic podcast RSS working * [WIP] more expanding on RSS * Comment * [WIP] Working on refactoring feed * Added UUID backfill to a migration * [WIP] Moar refactoring * [WIP] Adding UI for getting RSS feed * Many tests * Added conditional routing for feed URLs * Removed the need for url_base to be set * Updated preset name * Rendered certain fields HTML-safe; Added logging to confirm range request support * Fixed incorrect scheme issue * Updated env var * Updated other UI to use dropdown * removed commented code * Generate rss feeds (#123) * Added plug to strip file extensions * [VERY WIP] basic podcast RSS setup * [WIP] got basic podcast RSS working * [WIP] more expanding on RSS * [WIP] Working on refactoring feed * Added UUID backfill to a migration * [WIP] Moar refactoring * [WIP] Adding UI for getting RSS feed * Many tests * Added conditional routing for feed URLs * Removed the need for url_base to be set * Updated preset name * Rendered certain fields HTML-safe; Added logging to confirm range request support * Fixed incorrect scheme issue * Updated env var * Updated other UI to use dropdown * removed commented code * docs * Added unique index to UUID fields
38 lines
1.2 KiB
Elixir
38 lines
1.2 KiB
Elixir
defmodule PinchflatWeb.Podcasts.PodcastController do
|
|
use PinchflatWeb, :controller
|
|
|
|
alias Pinchflat.Repo
|
|
alias Pinchflat.Media
|
|
alias Pinchflat.Sources.Source
|
|
alias Pinchflat.Podcasts.RssFeedBuilder
|
|
alias Pinchflat.Podcasts.PodcastHelpers
|
|
|
|
def rss_feed(conn, %{"uuid" => uuid}) do
|
|
source = Repo.get_by!(Source, uuid: uuid)
|
|
url_base = url(conn, ~p"/")
|
|
xml = RssFeedBuilder.build(source, limit: 300, url_base: url_base)
|
|
|
|
conn
|
|
|> put_resp_content_type("application/rss+xml")
|
|
|> put_resp_header("content-disposition", "inline")
|
|
|> send_resp(200, xml)
|
|
end
|
|
|
|
def feed_image(conn, %{"uuid" => uuid}) do
|
|
source = Repo.get_by!(Source, uuid: uuid)
|
|
# This provides a fallback image if the source has none.
|
|
# We only need one since we're using the internal metadata image which
|
|
# we know exists.
|
|
media_items = Media.list_downloaded_media_items_for(source, limit: 1)
|
|
|
|
case PodcastHelpers.select_cover_image(source, media_items) do
|
|
{:error, _} ->
|
|
send_resp(conn, 404, "Image not found")
|
|
|
|
{:ok, filepath} ->
|
|
conn
|
|
|> put_resp_content_type(MIME.from_path(filepath))
|
|
|> send_file(200, filepath)
|
|
end
|
|
end
|
|
end
|