[Bugfix] Fix reddit bugs v2 (#82)

* Ensured thumbnail is converted to jpg before embedding

* Ensured media indexing doesn't fail if an upload date can't be parsed
This commit is contained in:
Kieran
2024-03-12 20:23:51 -07:00
committed by GitHub
parent abe99ce6f0
commit 1cc8731914
6 changed files with 61 additions and 4 deletions
@@ -66,7 +66,7 @@ defmodule Pinchflat.Downloading.DownloadOptionBuilder do
acc ++ [:write_thumbnail, convert_thumbnail: "jpg"]
{:embed_thumbnail, true} ->
acc ++ [:embed_thumbnail]
acc ++ [:embed_thumbnail, convert_thumbnail: "jpg"]
_ ->
acc
@@ -41,6 +41,7 @@ defmodule Pinchflat.SlowIndexing.SlowIndexingHelpers do
Given a media source, creates (indexes) the media by creating media_items for each
media ID in the source. Afterward, kicks off a download task for each pending media
item belonging to the source. You can't tell me the method name isn't descriptive!
Returns a list of media items or changesets (if the media item couldn't be created).
Indexing is slow and usually returns a list of all media data at once for record creation.
To help with this, we use a file follower to watch the file that yt-dlp writes to
@@ -56,7 +57,7 @@ defmodule Pinchflat.SlowIndexing.SlowIndexingHelpers do
Since indexing returns all media data EVERY TIME, we that that opportunity to update
indexing metadata for media items that have already been created.
Returns [%MediaItem{}, ...]
Returns [%MediaItem{} | %Ecto.Changeset{}]
"""
def index_and_enqueue_download_for_media_items(%Source{} = source) do
# See the method definition below for more info on how file watchers work
+5 -2
View File
@@ -85,8 +85,8 @@ defmodule Pinchflat.YtDlp.Media do
description: response["description"],
original_url: response["webpage_url"],
livestream: response["was_live"],
short_form_content: short_form_content?(response),
upload_date: parse_upload_date(response["upload_date"])
short_form_content: response["webpage_url"] && short_form_content?(response),
upload_date: response["upload_date"] && parse_upload_date(response["upload_date"])
}
end
@@ -99,6 +99,9 @@ defmodule Pinchflat.YtDlp.Media do
# WILL returns false positives, but it's a best-effort approach
# that should work for most cases. The aspect_ratio check is
# based on a gut feeling and may need to be tweaked.
#
# These don't fail if duration or aspect_ratio are missing
# due to Elixir's comparison semantics
response["duration"] <= 60 && response["aspect_ratio"] < 0.8
end
end