[WIP] more expanding on RSS
This commit is contained in:
parent
1413aa153a
commit
e365f264ef
3 changed files with 38 additions and 3 deletions
|
|
@ -33,17 +33,17 @@ defmodule Pinchflat.Podcasts.RssFeedBuilder do
|
|||
<lastBuildDate>#{Calendar.strftime(DateTime.utc_now(), @datetime_format)}</lastBuildDate>
|
||||
<pubDate>#{Calendar.strftime(source.inserted_at, @datetime_format)}</pubDate>
|
||||
<atom:link href="#{generate_self_link(source)}" rel="self" type="application/rss+xml" />
|
||||
<podcast:locked>false</podcast:locked>
|
||||
<podcast:locked>yes</podcast:locked>
|
||||
<podcast:guid>#{source.uuid}</podcast:guid>
|
||||
<image>
|
||||
<url>https://raw.githubusercontent.com/kieraneglin/pinchflat/master/priv/static/images/originals/logo.png</url>
|
||||
<url>#{generate_source_image_path(source)}</url>
|
||||
<title>#{source.custom_name}</title>
|
||||
<link>#{source.original_url}</link>
|
||||
</image>
|
||||
<itunes:author>#{source.custom_name}</itunes:author>
|
||||
<itunes:subtitle>#{source.custom_name}</itunes:subtitle>
|
||||
<itunes:block>yes</itunes:block>
|
||||
<itunes:image href="https://raw.githubusercontent.com/kieraneglin/pinchflat/master/priv/static/images/originals/logo.png"></itunes:image>
|
||||
<itunes:image href="#{generate_source_image_path(source)}"></itunes:image>
|
||||
<itunes:explicit>false</itunes:explicit>
|
||||
<itunes:category text="TV & Film"></itunes:category>
|
||||
|
||||
|
|
@ -85,6 +85,11 @@ defmodule Pinchflat.Podcasts.RssFeedBuilder do
|
|||
"#{url_base()}/media/#{media_item.uuid}/stream#{extension}"
|
||||
end
|
||||
|
||||
# TODO: add extension maybe. maybe refactor controller to handle this
|
||||
defp generate_source_image_path(source) do
|
||||
"#{url_base()}/sources/#{source.uuid}/feed_image"
|
||||
end
|
||||
|
||||
defp generate_upload_date(media_item) do
|
||||
media_item.upload_date
|
||||
|> Date.to_gregorian_days()
|
||||
|
|
|
|||
|
|
@ -59,6 +59,8 @@ defmodule PinchflatWeb.Sources.SourceController do
|
|||
)
|
||||
end
|
||||
|
||||
# TODO: test
|
||||
# TODO: maybe move both of these to a separate controller
|
||||
def feed(conn, %{"id" => uuid}) do
|
||||
# TODO: change this to UUID
|
||||
source = Repo.get_by!(Source, id: uuid)
|
||||
|
|
@ -72,6 +74,32 @@ defmodule PinchflatWeb.Sources.SourceController do
|
|||
|> send_resp(200, xml)
|
||||
end
|
||||
|
||||
# TODO: test
|
||||
# TODO: look into media_items having a thumbnail path when the image is embedded but not on disk
|
||||
# TODO: pull these images from the internal metadata instead. this implies I'll have to hook up
|
||||
# metadata images for sources
|
||||
def feed_image(conn, %{"id" => uuid}) do
|
||||
source = Repo.get_by!(Source, uuid: uuid)
|
||||
media_item = Media.list_downloaded_media_items_for(source, limit: 1)
|
||||
|
||||
filepath =
|
||||
case {source.poster_filepath, media_item} do
|
||||
{poster, _} when poster != nil -> poster
|
||||
{nil, [media_item]} -> media_item.thumbnail_filepath
|
||||
_ -> nil
|
||||
end
|
||||
|
||||
IO.inspect(filepath)
|
||||
|
||||
if filepath && File.exists?(filepath) do
|
||||
conn
|
||||
|> put_resp_content_type(MIME.from_path(filepath))
|
||||
|> send_file(200, filepath)
|
||||
else
|
||||
send_resp(conn, 404, "File not found")
|
||||
end
|
||||
end
|
||||
|
||||
def edit(conn, %{"id" => id}) do
|
||||
source = Sources.get_source!(id)
|
||||
changeset = Sources.change_source(source)
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ defmodule PinchflatWeb.Router do
|
|||
# so people that want RSS feeds to work can enable it.
|
||||
scope "/", PinchflatWeb do
|
||||
get "/sources/:id/feed", Sources.SourceController, :feed
|
||||
get "/sources/:id/feed_image", Sources.SourceController, :feed_image
|
||||
|
||||
get "/media/:id/stream", MediaItems.MediaItemController, :stream
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue