From 6471718a3c9cb3fbd9ceadc7077f5cedcac86bbe Mon Sep 17 00:00:00 2001 From: Liam Date: Mon, 5 Aug 2024 08:22:11 -0400 Subject: [PATCH] Fixup --- lib/philomena/channels/channel.ex | 1 + lib/philomena_web/views/channel_view.ex | 24 ++---------------------- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/lib/philomena/channels/channel.ex b/lib/philomena/channels/channel.ex index 58d2942c..7f70351a 100644 --- a/lib/philomena/channels/channel.ex +++ b/lib/philomena/channels/channel.ex @@ -18,6 +18,7 @@ defmodule Philomena.Channels.Channel do field :last_fetched_at, :utc_datetime field :next_check_at, :utc_datetime field :last_live_at, :utc_datetime + field :thumbnail_url, :string, default: "" timestamps(inserted_at: :created_at, type: :utc_datetime) end diff --git a/lib/philomena_web/views/channel_view.ex b/lib/philomena_web/views/channel_view.ex index acb4880a..c8f1927c 100644 --- a/lib/philomena_web/views/channel_view.ex +++ b/lib/philomena_web/views/channel_view.ex @@ -1,27 +1,7 @@ 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) - - PhilomenaProxy.Camo.image_url( - "https://thumbnail.api.livestream.com/thumbnail?name=#{short_name}&rand=#{now}" - ) + def channel_image(%{thumbnail_url: thumbnail_url}) do + PhilomenaProxy.Camo.image_url(thumbnail_url || "https://picarto.tv/images/missingthumb.jpg") end - - def channel_image(%{type: "PicartoChannel", thumbnail_url: thumbnail_url}), - do: - PhilomenaProxy.Camo.image_url(thumbnail_url || "https://picarto.tv/images/missingthumb.jpg") - - 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" - ) - - def channel_image(%{type: "TwitchChannel", short_name: short_name}), - do: - PhilomenaProxy.Camo.image_url( - "https://static-cdn.jtvnw.net/previews-ttv/live_user_#{String.downcase(short_name)}-320x180.jpg" - ) end