Rename video-related modules to be media-related (#50)

* Added test from before that I forgor

* Renamed video-related modules to media
This commit is contained in:
Kieran
2024-03-04 17:46:33 -08:00
committed by GitHub
parent f55cdc80dd
commit 90a0022d85
21 changed files with 128 additions and 109 deletions
@@ -1,10 +1,10 @@
defmodule Pinchflat.MediaClient.Backends.YtDlp.Video do
defmodule Pinchflat.MediaClient.Backends.YtDlp.Media do
@moduledoc """
Contains utilities for working with singular videos
Contains utilities for working with singular pieces of media
"""
@doc """
Downloads a single video (and possibly its metadata) directly to its
Downloads a single piece of media (and possibly its metadata) directly to its
final destination. Returns the parsed JSON output from yt-dlp.
Returns {:ok, map()} | {:error, any, ...}.
@@ -1,7 +1,7 @@
defmodule Pinchflat.MediaClient.Backends.YtDlp.VideoCollection do
defmodule Pinchflat.MediaClient.Backends.YtDlp.MediaCollection do
@moduledoc """
Contains utilities for working with collections of
videos (aka: a source [ie: channels, playlists]).
media (aka: a source [ie: channels, playlists]).
"""
require Logger
@@ -10,7 +10,7 @@ defmodule Pinchflat.MediaClient.Backends.YtDlp.VideoCollection do
alias Pinchflat.Utils.FilesystemUtils
@doc """
Returns a list of maps representing the videos in the collection.
Returns a list of maps representing the media in the collection.
Options:
- :file_listener_handler - a function that will be called with the path to the
@@ -4,7 +4,7 @@ defmodule Pinchflat.MediaClient.Backends.YtDlp.MetadataFileHelpers do
out-of-band of the normal yt-dlp backend process.
The idea is that I don't want to craft a complicated yt-dlp command,
instead focusing on downloading the video as the user wants it then
instead focusing on downloading the media as the user wants it then
I can use the result of that here to grab the additional information
needed
"""
@@ -1,8 +1,8 @@
defmodule Pinchflat.MediaClient.VideoDownloader do
defmodule Pinchflat.MediaClient.MediaDownloader do
@moduledoc """
This is the integration layer for actually downloading videos.
This is the integration layer for actually downloading medias.
It takes into account the media profile's settings in order
to download the video with the desired options.
to download the media with the desired options.
Technically hardcodes the yt-dlp backend for now, but should leave
it open-ish for future expansion (just in case).
@@ -12,13 +12,13 @@ defmodule Pinchflat.MediaClient.VideoDownloader do
alias Pinchflat.Media
alias Pinchflat.Media.MediaItem
alias Pinchflat.MediaClient.Backends.YtDlp.Video, as: YtDlpVideo
alias Pinchflat.MediaClient.Backends.YtDlp.Media, as: YtDlpMedia
alias Pinchflat.Profiles.Options.YtDlp.DownloadOptionBuilder, as: YtDlpDownloadOptionBuilder
alias Pinchflat.MediaClient.Backends.YtDlp.MetadataParser, as: YtDlpMetadataParser
alias Pinchflat.MediaClient.Backends.YtDlp.MetadataFileHelpers, as: YtDlpMetadataHelpers
@doc """
Downloads a video for a media item, updating the media item based on the metadata
Downloads media for a media item, updating the media item based on the metadata
returned by the backend. Also saves the entire metadata response to the associated
media_metadata record.
@@ -57,10 +57,10 @@ defmodule Pinchflat.MediaClient.VideoDownloader do
defp download_with_options(url, item_with_preloads, backend) do
option_builder = option_builder(backend)
video_backend = video_backend(backend)
media_backend = media_backend(backend)
{:ok, options} = option_builder.build(item_with_preloads)
video_backend.download(url, options)
media_backend.download(url, options)
end
defp option_builder(backend) do
@@ -69,9 +69,9 @@ defmodule Pinchflat.MediaClient.VideoDownloader do
end
end
defp video_backend(backend) do
defp media_backend(backend) do
case backend do
:yt_dlp -> YtDlpVideo
:yt_dlp -> YtDlpMedia
end
end
+2 -2
View File
@@ -7,7 +7,7 @@ defmodule Pinchflat.MediaClient.SourceDetails do
"""
alias Pinchflat.Sources.Source
alias Pinchflat.MediaClient.Backends.YtDlp.VideoCollection, as: YtDlpSource
alias Pinchflat.MediaClient.Backends.YtDlp.MediaCollection, as: YtDlpSource
@doc """
Gets a source's ID and name from its URL using the given backend.
@@ -19,7 +19,7 @@ defmodule Pinchflat.MediaClient.SourceDetails do
end
@doc """
Returns a list of basic video data mapsfor the given source URL OR
Returns a list of basic media data maps for the given source URL OR
source record using the given backend.
Options:
+2 -2
View File
@@ -44,10 +44,10 @@ defmodule Pinchflat.Profiles.MediaProfile do
field :embed_metadata, :boolean, default: true
# NOTE: these do NOT speed up indexing - the indexer still has to go
# through the entire collection to determine if a video is a short or
# through the entire collection to determine if a media is a short or
# a livestream.
# NOTE: these can BOTH be set to :only which will download shorts and
# livestreams _only_ and ignore regular videos. The redundant case
# livestreams _only_ and ignore regular media. The redundant case
# is when one is set to :only and the other is set to :exclude.
# See `build_format_clauses` in the Media context for more.
field :shorts_behaviour, Ecto.Enum, values: ~w(include exclude only)a, default: :include
+4 -4
View File
@@ -15,7 +15,7 @@ defmodule Pinchflat.Tasks.SourceTasks do
alias Pinchflat.Media.MediaItem
alias Pinchflat.MediaClient.SourceDetails
alias Pinchflat.Workers.MediaIndexingWorker
alias Pinchflat.Workers.VideoDownloadWorker
alias Pinchflat.Workers.MediaDownloadWorker
alias Pinchflat.Utils.FilesystemUtils.FileFollowerServer
@doc """
@@ -75,7 +75,7 @@ defmodule Pinchflat.Tasks.SourceTasks do
end
@doc """
Starts tasks for downloading videos for any of a sources _pending_ media items.
Starts tasks for downloading media for any of a sources _pending_ media items.
Jobs are not enqueued if the source is set to not download media. This will return :ok.
NOTE: this starts a download for each media item that is pending,
@@ -91,7 +91,7 @@ defmodule Pinchflat.Tasks.SourceTasks do
|> Enum.each(fn media_item ->
media_item
|> Map.take([:id])
|> VideoDownloadWorker.new()
|> MediaDownloadWorker.new()
|> Tasks.create_job_with_task(media_item)
end)
end
@@ -161,7 +161,7 @@ defmodule Pinchflat.Tasks.SourceTasks do
media_item
|> Map.take([:id])
|> VideoDownloadWorker.new()
|> MediaDownloadWorker.new()
|> Tasks.create_job_with_task(media_item)
end
@@ -1,4 +1,4 @@
defmodule Pinchflat.Workers.VideoDownloadWorker do
defmodule Pinchflat.Workers.MediaDownloadWorker do
@moduledoc false
use Oban.Worker,
@@ -9,7 +9,7 @@ defmodule Pinchflat.Workers.VideoDownloadWorker do
alias Pinchflat.Repo
alias Pinchflat.Media
alias Pinchflat.Tasks
alias Pinchflat.MediaClient.VideoDownloader
alias Pinchflat.MediaClient.MediaDownloader
alias Pinchflat.Workers.FilesystemDataWorker
@impl Oban.Worker
@@ -34,7 +34,7 @@ defmodule Pinchflat.Workers.VideoDownloadWorker do
end
defp download_media_and_schedule_jobs(media_item) do
case VideoDownloader.download_for_media_item(media_item) do
case MediaDownloader.download_for_media_item(media_item) do
{:ok, _} ->
schedule_filesystem_data_worker(media_item)
{:ok, media_item}