diff --git a/lib/pinchflat/media/media.ex b/lib/pinchflat/media/media.ex index b8a35fa..191b28f 100644 --- a/lib/pinchflat/media/media.ex +++ b/lib/pinchflat/media/media.ex @@ -41,9 +41,10 @@ defmodule Pinchflat.Media do Returns a list of media_items that are redownloadable based on the redownload delay of the media_profile their source belongs to. - The logic is that a media_item is past_redownload_delay if the media_item's - upload_date is at least redownload_delay_days ago AND - `media_downloaded_at` - `redownload_delay_days` is before the media_item's `upload_date`. + The logic is that a media_item is past_redownload_delay if the media_item's uploaded_at is + at least redownload_delay_days ago AND `media_downloaded_at` - `redownload_delay_days` + is before the media_item's `uploaded_at`. + This logic grabs media that we've recently downloaded AND is recently uploaded, but doesn't grab media that we've recently downloaded and was uploaded a long time ago. This also makes things work as expected when downloading media from a source for the @@ -135,7 +136,7 @@ defmodule Pinchflat.Media do Unlike `create_media_item`, this will attempt an update if the media_item already exists. This is so that future indexing can pick up attributes that - we may not have asked for in the past (eg: upload_date) + we may not have asked for in the past (eg: uploaded_at) Returns {:ok, %MediaItem{}} | {:error, %Ecto.Changeset{}} """ diff --git a/lib/pinchflat/metadata/nfo_builder.ex b/lib/pinchflat/metadata/nfo_builder.ex index a2f7aa8..3db237f 100644 --- a/lib/pinchflat/metadata/nfo_builder.ex +++ b/lib/pinchflat/metadata/nfo_builder.ex @@ -38,7 +38,6 @@ defmodule Pinchflat.Metadata.NfoBuilder do end defp build_for_media_item(metadata) do - # TODO: see how this works post-change upload_date = MetadataFileHelpers.parse_upload_date(metadata["upload_date"]) # Cribbed from a combination of the Kodi wiki, ytdl-nfo, and ytdl-sub. # WHO NEEDS A FANCY XML PARSER ANYWAY?! diff --git a/lib/pinchflat/podcasts/podcast_helpers.ex b/lib/pinchflat/podcasts/podcast_helpers.ex index a40e63b..041107c 100644 --- a/lib/pinchflat/podcasts/podcast_helpers.ex +++ b/lib/pinchflat/podcasts/podcast_helpers.ex @@ -28,7 +28,7 @@ defmodule Pinchflat.Podcasts.PodcastHelpers do MediaQuery.new() |> where(^dynamic(^MediaQuery.for_source(source) and ^MediaQuery.downloaded())) - |> order_by(desc: :upload_date) + |> order_by(desc: :uploaded_at) |> Repo.maybe_limit(limit) |> Repo.all() |> Enum.filter(fn media_item -> File.exists?(media_item.media_filepath) end) diff --git a/lib/pinchflat/podcasts/rss_feed_builder.ex b/lib/pinchflat/podcasts/rss_feed_builder.ex index 34156fe..d5a5aea 100644 --- a/lib/pinchflat/podcasts/rss_feed_builder.ex +++ b/lib/pinchflat/podcasts/rss_feed_builder.ex @@ -7,7 +7,6 @@ defmodule Pinchflat.Podcasts.RssFeedBuilder do import Pinchflat.Utils.XmlUtils, only: [safe: 1] - alias Pinchflat.Utils.DatetimeUtils alias Pinchflat.Podcasts.PodcastHelpers alias PinchflatWeb.Router.Helpers, as: Routes @@ -83,7 +82,7 @@ defmodule Pinchflat.Podcasts.RssFeedBuilder do #{safe(media_item.title)} #{safe(media_item.original_url)} #{safe(media_item.description)} - #{generate_upload_date(media_item)} + #{Calendar.strftime(media_item.uploaded_at, @datetime_format)} #{media_item.duration_seconds} DatetimeUtils.date_to_datetime() - |> Calendar.strftime(@datetime_format) - end - defp podcast_route(action, params) do Routes.podcast_path(PinchflatWeb.Endpoint, action, params) end diff --git a/lib/pinchflat/utils/datetime_utils.ex b/lib/pinchflat/utils/datetime_utils.ex deleted file mode 100644 index 7fce7c6..0000000 --- a/lib/pinchflat/utils/datetime_utils.ex +++ /dev/null @@ -1,17 +0,0 @@ -defmodule Pinchflat.Utils.DatetimeUtils do - @moduledoc """ - Utility methods for working with dates and datetimes - """ - - @doc """ - Converts a Date to a DateTime - - Returns %DateTime{} - """ - def date_to_datetime(date) do - date - |> Date.to_gregorian_days() - |> Kernel.*(86_400) - |> DateTime.from_gregorian_seconds() - end -end diff --git a/lib/pinchflat/yt_dlp/media.ex b/lib/pinchflat/yt_dlp/media.ex index d3dee83..106d6d0 100644 --- a/lib/pinchflat/yt_dlp/media.ex +++ b/lib/pinchflat/yt_dlp/media.ex @@ -90,7 +90,7 @@ defmodule Pinchflat.YtDlp.Media do livestream: !!response["was_live"], duration_seconds: response["duration"] && round(response["duration"]), short_form_content: response["webpage_url"] && short_form_content?(response), - uploaded_at: parse_uploaded_at(response) + uploaded_at: response["upload_date"] && parse_uploaded_at(response) } end diff --git a/lib/pinchflat_web/controllers/media_items/media_item_html/show.html.heex b/lib/pinchflat_web/controllers/media_items/media_item_html/show.html.heex index 1f4d5bf..372fe56 100644 --- a/lib/pinchflat_web/controllers/media_items/media_item_html/show.html.heex +++ b/lib/pinchflat_web/controllers/media_items/media_item_html/show.html.heex @@ -31,7 +31,7 @@ <.media_preview media_item={@media_item} />