philomena/lib/philomena_web/views/channel_view.ex

28 lines
969 B
Elixir
Raw Normal View History

2019-11-30 07:30:45 +01:00
defmodule PhilomenaWeb.ChannelView do
use PhilomenaWeb, :view
def channel_image(%{type: "LivestreamChannel", short_name: short_name}) do
now = DateTime.utc_now() |> DateTime.to_unix(:microsecond)
2020-01-11 05:20:19 +01:00
PhilomenaProxy.Camo.image_url(
2020-01-11 05:20:19 +01:00
"https://thumbnail.api.livestream.com/thumbnail?name=#{short_name}&rand=#{now}"
)
2019-11-30 07:30:45 +01:00
end
def channel_image(%{type: "PicartoChannel", thumbnail_url: thumbnail_url}),
do:
PhilomenaProxy.Camo.image_url(thumbnail_url || "https://picarto.tv/images/missingthumb.jpg")
2019-11-30 07:30:45 +01:00
def channel_image(%{type: "PiczelChannel", remote_stream_id: remote_stream_id}),
do:
PhilomenaProxy.Camo.image_url(
"https://piczel.tv/api/thumbnail/stream_#{remote_stream_id}.jpg"
)
2020-01-11 05:20:19 +01:00
2019-11-30 07:30:45 +01:00
def channel_image(%{type: "TwitchChannel", short_name: short_name}),
2020-01-11 05:20:19 +01:00
do:
PhilomenaProxy.Camo.image_url(
2020-01-11 05:20:19 +01:00
"https://static-cdn.jtvnw.net/previews-ttv/live_user_#{String.downcase(short_name)}-320x180.jpg"
)
2019-11-30 07:30:45 +01:00
end