Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
liamwhite committed Aug 5, 2024
2 parents 87e8b82 + 6471718 commit 549a810
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
1 change: 1 addition & 0 deletions lib/philomena/channels/channel.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 2 additions & 22 deletions lib/philomena_web/views/channel_view.ex
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 549a810

Please sign in to comment.