Download video(s) (first iteration) (#5)
* Updated package.json (and made an excuse to make a branch) * Video filepath parser (#6) * Restructured files; Added parser placeholder * More restructuring * Added basic parser for hydrating template strings * Improved docs * More docs * Initial implementation of media profiles (#7) * [WIP] Added basic video download method * [WIP] Very-WIP first steps at parsing options and downloading * Made my options safe by default and removed special safe versions * Ran html generator for mediaprofile model - leaving as-is for now * Addressed a bunch of TODO comments * Add "channel" type Media Source (#8) * [WIP] Working on fetching channel metadata in yt-dlp backend * Finished first draft of methods to do with querying channels * Renamed CommandRunnerMock to have a more descriptive name * Ran the phx generator for the channel model * Renamed Downloader namespace to MediaClient * [WIP] saving before attempting LiveView * LiveView did not work out but here's a working controller how about * Index a channel (#9) * Ran a MediaItem generator; Reformatted to my liking * [WIP] added basic index function * setup oban * Added basic Oban job for indexing * Added in workers for indexing; hooked them into record creation flow * Added a task model with a phx generator * Tied together tasks with jobs and channels * Download indexed videos (#10) * Clarified documentation * more comments * [WIP] hooked up basic video downloading; starting work on metadata * Added metadata model and parsing Adding the metadata model made me realize that, in many cases, yt-dlp returns undesired input in stdout, breaking parsing. In order to get the metadata model working, I had to change the way in which the app interacts with yt-dlp. Now, output is written as a file to disk which is immediately re-read and returned. * Added tests for video download worker * Hooked up video downloading to the channel indexing pipeline * Adds tasks for media items * Updated video metadata parser to extract the title * Ran linting
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
defmodule Pinchflat.Repo.Migrations.CreateMediaProfiles do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:media_profiles) do
|
||||
add :name, :string, null: false
|
||||
add :output_path_template, :string, null: false
|
||||
|
||||
timestamps(type: :utc_datetime)
|
||||
end
|
||||
|
||||
create unique_index(:media_profiles, [:name])
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,17 @@
|
||||
defmodule Pinchflat.Repo.Migrations.CreateChannels do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:channels) do
|
||||
add :name, :string, null: false
|
||||
add :channel_id, :string, null: false
|
||||
add :original_url, :string, null: false
|
||||
add :media_profile_id, references(:media_profiles, on_delete: :restrict), null: false
|
||||
|
||||
timestamps(type: :utc_datetime)
|
||||
end
|
||||
|
||||
create index(:channels, [:media_profile_id])
|
||||
create unique_index(:channels, [:channel_id, :media_profile_id])
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,17 @@
|
||||
defmodule Pinchflat.Repo.Migrations.CreateMediaItems do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:media_items) do
|
||||
add :media_id, :string, null: false
|
||||
add :title, :string
|
||||
add :video_filepath, :string
|
||||
add :channel_id, references(:channels, on_delete: :restrict), null: false
|
||||
|
||||
timestamps(type: :utc_datetime)
|
||||
end
|
||||
|
||||
create index(:media_items, [:channel_id])
|
||||
create unique_index(:media_items, [:media_id, :channel_id])
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,13 @@
|
||||
defmodule Pinchflat.Repo.Migrations.AddObanJobsTable do
|
||||
use Ecto.Migration
|
||||
|
||||
def up do
|
||||
Oban.Migration.up(version: 11)
|
||||
end
|
||||
|
||||
# We specify `version: 1` in `down`, ensuring that we'll roll all the way back down if
|
||||
# necessary, regardless of which version we've migrated `up` to.
|
||||
def down do
|
||||
Oban.Migration.down(version: 1)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
defmodule Pinchflat.Repo.Migrations.AddIndexFrequencyToChannels do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
alter table(:channels) do
|
||||
add :index_frequency_minutes, :integer, default: 60 * 24, null: false
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,16 @@
|
||||
defmodule Pinchflat.Repo.Migrations.CreateTasks do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:tasks) do
|
||||
add :job_id, references(:oban_jobs, on_delete: :delete_all), null: false
|
||||
# `restrict` because we need to be sure to delete pending tasks when a channel is deleted
|
||||
add :channel_id, references(:channels, on_delete: :restrict), null: true
|
||||
|
||||
timestamps(type: :utc_datetime)
|
||||
end
|
||||
|
||||
create index(:tasks, [:job_id])
|
||||
create index(:tasks, [:channel_id])
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,15 @@
|
||||
defmodule Pinchflat.Repo.Migrations.CreateMediaMetadata do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:media_metadata) do
|
||||
add :client_response, :jsonb, null: false
|
||||
add :media_item_id, references(:media_items, on_delete: :delete_all), null: false
|
||||
|
||||
timestamps(type: :utc_datetime)
|
||||
end
|
||||
|
||||
create unique_index(:media_metadata, [:media_item_id])
|
||||
create index(:media_metadata, [:client_response], using: :gin)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,12 @@
|
||||
defmodule Pinchflat.Repo.Migrations.AddMediaItemToTasks do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
alter table(:tasks) do
|
||||
# `restrict` because we need to be sure to delete pending tasks when a channel is deleted
|
||||
add :media_item_id, references(:media_items, on_delete: :restrict), null: true
|
||||
end
|
||||
|
||||
create index(:tasks, [:media_item_id])
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user