rm example upload broadcast
This commit is contained in:
parent
3d3130ac66
commit
ee8542e132
apps/bright
lib
bright
bright_web/controllers/torrent_html
test/bright/oban_workers
@ -53,7 +53,7 @@ defmodule Bright.ObanWorkers.CreateHlsPlaylist do
|
||||
|
||||
{:complete, vod} ->
|
||||
Streams.broadcast_processing_progressed!(stage, vod, 1)
|
||||
Streams.broadcast_processing_completed!(:upload, vod, vod.url)
|
||||
Streams.broadcast_processing_completed!(:hls_playlist, vod)
|
||||
{:ok, vod.url}
|
||||
|
||||
{:error, e, %Oban.Job{attempt: attempt, max_attempts: max_attempts}} ->
|
||||
|
64
apps/bright/lib/bright/oban_workers/scrape_x.ex
Normal file
64
apps/bright/lib/bright/oban_workers/scrape_x.ex
Normal file
@ -0,0 +1,64 @@
|
||||
# defmodule Bright.ObanWorkers.ScrapeX do
|
||||
# alias Bright.Vtubers.Vtuber
|
||||
# use Oban.Worker, queue: :default, max_attempts: 3
|
||||
|
||||
# alias Bright.Streams.Vod
|
||||
|
||||
# alias Bright.{
|
||||
# Repo,
|
||||
# Downloader,
|
||||
# B2,
|
||||
# Images
|
||||
# }
|
||||
|
||||
# require Logger
|
||||
|
||||
# @impl Oban.Worker
|
||||
# def perform(%Oban.Job{args: %{"vtuber_id" => vtuber_id}}) do
|
||||
# Logger.info(">>>> Scrape X is performing. with vtuber_id=#{vtuber_id}")
|
||||
|
||||
# # @todo get vtuber from db
|
||||
# # @todo get vtuber's X account
|
||||
# # @todo get nitter URL
|
||||
# # @todo get X posts
|
||||
# # @todo queue posts we haven't yet processed
|
||||
# # @todo parse posts in the queue to find CB/Fansly/OF invite links
|
||||
# # @todo for each post with an invite, create a stream in the db
|
||||
|
||||
# # case Repo.get(Vtuber, vtuber_id) do
|
||||
|
||||
# # nil ->
|
||||
# # Logger.error("Vtuber id #{vtuber_id} not found.")
|
||||
# # {:error, "Vtuber not found"}
|
||||
|
||||
# # %Vtuber{} = vtuber ->
|
||||
# # with {:ok, } <-
|
||||
|
||||
# # end
|
||||
|
||||
# case Repo.get(Vod, vod_id) do
|
||||
# nil ->
|
||||
# Logger.error("VOD ID #{vod_id} not found")
|
||||
# {:error, "VOD not found"}
|
||||
|
||||
# %Vod{origin_temp_input_url: origin_temp_input_url} = vod ->
|
||||
# with {:ok, local_filename} <- Downloader.get(origin_temp_input_url),
|
||||
# {:ok, thumbnail_filename} <- Images.create_thumbnail(local_filename),
|
||||
# {:ok, s3Asset} <- B2.put(thumbnail_filename) do
|
||||
# update_vod_with_thumbnail_url(vod, s3Asset.cdn_url)
|
||||
# else
|
||||
# {:error, reason} ->
|
||||
# Logger.error("Failed to create thumbnail for VOD ID #{vod_id}: #{inspect(reason)}")
|
||||
# {:error, reason}
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
# # defp generate_thumbnail_url(basename), do: "#{Application.get_env(:bright, :public_s3_endpoint)}/#{basename}"
|
||||
# defp update_vod_with_thumbnail_url(vod, thumbnail_url) do
|
||||
# case Repo.update(vod |> Ecto.Changeset.change(thumbnail_url: thumbnail_url)) do
|
||||
# {:ok, updated_vod} -> {:ok, updated_vod}
|
||||
# {:error, changeset} -> {:error, changeset}
|
||||
# end
|
||||
# end
|
||||
# end
|
22
apps/bright/lib/bright/platforms/x.ex
Normal file
22
apps/bright/lib/bright/platforms/x.ex
Normal file
@ -0,0 +1,22 @@
|
||||
defmodule Bright.Platforms.XPost do
|
||||
use Ecto.Schema
|
||||
import Ecto.Changeset
|
||||
|
||||
schema "x_posts" do
|
||||
field :raw, :string
|
||||
field :url, :string
|
||||
field :date, :utc_datetime
|
||||
field :is_invitation, :boolean
|
||||
|
||||
belongs_to :vtuber, Bright.Vtubers.Vtuber
|
||||
|
||||
timestamps(type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
def changeset(platform, attrs) do
|
||||
platform
|
||||
|> cast(attrs, [:raw, :url, :date])
|
||||
|> validate_required([:raw, :url, :date])
|
||||
end
|
||||
end
|
@ -539,8 +539,8 @@ defmodule Bright.Streams do
|
||||
broadcast!("backend", %Events.ProcessingProgressed{vod: vod, stage: stage, pct: pct})
|
||||
end
|
||||
|
||||
def broadcast_processing_completed!(action, vod, url) do
|
||||
broadcast!("backend", %Events.ProcessingCompleted{action: action, vod: vod, url: url})
|
||||
def broadcast_processing_completed!(action, vod) do
|
||||
broadcast!("backend", %Events.ProcessingCompleted{action: action, vod: vod})
|
||||
end
|
||||
|
||||
def broadcast_processing_failed!(vod, attempt, max_attempts) do
|
||||
|
@ -11,8 +11,17 @@
|
||||
<.list>
|
||||
<:item title="Info hash v1">{@torrent.info_hash_v1}</:item>
|
||||
<:item title="Info hash v2">{@torrent.info_hash_v2}</:item>
|
||||
<:item title="Cdn url">{@torrent.cdn_url}</:item>
|
||||
<:item title="Magnet">{@torrent.magnet}</:item>
|
||||
<:item title="Torrent (file)">
|
||||
<a target="_blank" href={@torrent.cdn_url}>
|
||||
{@torrent.cdn_url}
|
||||
</a>
|
||||
</:item>
|
||||
<:item title="Torrent (magnet)">
|
||||
<!-- we specifically do not use <.external_link> because that component can't handle the scheme -->
|
||||
<a target="_blank" href={@torrent.magnet}>
|
||||
{@torrent.magnet}
|
||||
</a>
|
||||
</:item>
|
||||
</.list>
|
||||
|
||||
<.back navigate={~p"/torrents"}>Back to torrent</.back>
|
||||
|
@ -9,8 +9,6 @@ defmodule Bright.CreateHlsPlaylistTest do
|
||||
alias Bright.Streams.Stream
|
||||
|
||||
describe "CreateHlsPlaylist" do
|
||||
import Bright.StreamsFixtures
|
||||
|
||||
@tag :integration
|
||||
test "sheduling upon vod creation" do
|
||||
example_video = "http://example.com/video.ts"
|
||||
|
Loading…
x
Reference in New Issue
Block a user