[Enhancement] Delete media after "x" days (#160)

* [Enhancement] Adds ability to stop media from re-downloading (#159)

* Added column

* Added methods for ignoring media items from future download

* Added new deletion options to controller and UI

* Added controller actions and UI for editing a media item

* Added column to sources

* Added retention period to form

* [WIP] getting retention methods in place

* Hooked up retention worker

* Added column and UI to prevent automatic deletion

* Docs

* Removed unused backfill worker

* Added edit links to media item tabs on source view

* Clarified form wording

* Form wording (again)
This commit is contained in:
Kieran authored and GitHub committed 2024-04-03 10:44:11 -07:00
1 parent f9c2f7b8f2
commit 79c61bca4f
25 files changed
+576 -171

No files matched your search

+20 -2
View File
@@ -30,7 +30,11 @@ defmodule Pinchflat.Media.MediaItem do
:subtitle_filepaths,
:thumbnail_filepath,
:metadata_filepath,
:nfo_filepath
:nfo_filepath,
# These are user or system controlled fields
:prevent_download,
:prevent_culling,
:culled_at
]
# Pretty much all the fields captured at index are required.
@required_fields ~w(
@@ -42,7 +46,7 @@ defmodule Pinchflat.Media.MediaItem do
source_id
upload_date
short_form_content
)a
)a
schema "media_items" do
# This is _not_ used as the primary key or internally in the database
@@ -70,6 +74,10 @@ defmodule Pinchflat.Media.MediaItem do
# Will very likely revisit because I can't leave well-enough alone.
field :subtitle_filepaths, {:array, {:array, :string}}, default: []
field :prevent_download, :boolean, default: false
field :prevent_culling, :boolean, default: false
field :culled_at, :utc_datetime
field :matching_search_term, :string, virtual: true
belongs_to :source, Source
@@ -96,4 +104,14 @@ defmodule Pinchflat.Media.MediaItem do
def filepath_attributes do
~w(media_filepath thumbnail_filepath metadata_filepath subtitle_filepaths nfo_filepath)a
end
@doc false
def filepath_attribute_defaults do
filepath_attributes()
|> Enum.map(fn
:subtitle_filepaths -> {:subtitle_filepaths, []}
field -> {field, nil}
end)
|> Enum.into(%{})
end
end