diff --git a/docs/dev-log.md b/docs/dev-log.md index 9fdece5..3a6a07f 100644 --- a/docs/dev-log.md +++ b/docs/dev-log.md @@ -1,3 +1,9 @@ +## FIXME: download youtube big video + +![error log: download youtube big video](./error_log_download_youtube_big_video.png) + +![log: stream date](./error_log_streaming_data.png) + ## FIXME: bug: 无法发送 20 分钟的长视频 ![bug log: 无法发送 20 分钟的长视频](./bug_log_发送20分钟长视频.png) diff --git a/docs/error_log_download_youtube_big_video.png b/docs/error_log_download_youtube_big_video.png new file mode 100644 index 0000000..b5b45df Binary files /dev/null and b/docs/error_log_download_youtube_big_video.png differ diff --git a/docs/error_log_streaming_data.png b/docs/error_log_streaming_data.png new file mode 100644 index 0000000..36fb821 Binary files /dev/null and b/docs/error_log_streaming_data.png differ diff --git a/lib/aier_bot/bot.ex b/lib/aier_bot/bot.ex index d215aa2..6f45deb 100644 --- a/lib/aier_bot/bot.ex +++ b/lib/aier_bot/bot.ex @@ -40,7 +40,7 @@ defmodule AierBot.Bot do {:ok, download_url} -> {:ok, file_name, file_content} = FileDownloader.download(download_url) - {:ok, _} = bot_send_file(chat.id, file_name, file_content) + {:ok, _} = bot_send_file(chat.id, file_name, file_content, url) {:error, error} -> ExGram.send_message(chat.id, "Failed to download file. Reason: #{inspect(error)}") @@ -56,26 +56,51 @@ defmodule AierBot.Bot do Enum.map(matches, fn [url] -> url end) end - defp bot_send_file(chat_id, file_name, file_content) do + # TODO: 额外参数可以使用 options 来传递 + defp bot_send_file(chat_id, file_name, file_content, _original_url) do IO.inspect(file_name) cond do String.ends_with?(file_name, ".png") -> - ExGram.send_photo(chat_id, {:file_content, file_content, file_name}) + ExGram.send_photo( + chat_id, + {:file_content, file_content, file_name} + # TODO: original_url 作为 caption 收益不高,AI generated searchable caption 会更好 + # original_text + # AI generated searchable caption + # and some other metadata + # caption: "Image from URL: #{original_url}" + ) String.ends_with?(file_name, ".jpg") -> - ExGram.send_photo(chat_id, {:file_content, file_content, file_name}) + ExGram.send_photo( + chat_id, + {:file_content, file_content, file_name} + # caption: "Image from URL: #{original_url}" + ) String.ends_with?(file_name, ".jpeg") -> - ExGram.send_photo(chat_id, {:file_content, file_content, file_name}) + ExGram.send_photo( + chat_id, + {:file_content, file_content, file_name} + # caption: "Image from URL: #{original_url}" + ) String.ends_with?(file_name, ".mp4") -> # {:file_content, iodata() | Enum.t(), String.t()} # MEMO: 注意:参数是 {:file_content, file_content, file_name} ,3 个元素的 tuple - ExGram.send_video(chat_id, {:file_content, file_content, file_name}) + ExGram.send_video( + chat_id, + {:file_content, file_content, file_name} + # caption: "Image from URL: #{original_url}" + ) true -> - ExGram.send_document(chat_id, {:file_content, file_content, file_name}) + ExGram.send_document( + chat_id, + {:file_content, file_content, file_name} + # caption: "Image from URL: #{original_url}" + ) end end