Skip to content

Commit dc0a9e4

Browse files
committed
chore(DownloadCaptions): set a legit user agent
1 parent dc253a0 commit dc0a9e4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

apps/cf/lib/videos/captions_fetcher_youtube.ex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ defmodule CF.Videos.CaptionsFetcherYoutube do
99
require Logger
1010
import SweetXml
1111

12+
@user_agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/135.0"
13+
1214
@impl true
1315
def fetch(%{youtube_id: youtube_id, language: language}) do
1416
with {:ok, data} <- fetch_youtube_data(youtube_id),
@@ -27,7 +29,7 @@ defmodule CF.Videos.CaptionsFetcherYoutube do
2729
defp fetch_youtube_data(video_id) do
2830
url = "https://www.youtube.com/watch?v=#{video_id}"
2931

30-
case HTTPoison.get(url, []) do
32+
case HTTPoison.get(url, [{"User-Agent", @user_agent}]) do
3133
{:ok, %HTTPoison.Response{body: body}} ->
3234
{:ok, body}
3335

@@ -59,7 +61,7 @@ defmodule CF.Videos.CaptionsFetcherYoutube do
5961
end
6062

6163
defp fetch_transcript(base_url) do
62-
case HTTPoison.get(base_url, []) do
64+
case HTTPoison.get(base_url, [{"User-Agent", @user_agent}]) do
6365
{:ok, %HTTPoison.Response{body: body}} ->
6466
{:ok, body}
6567

0 commit comments

Comments
 (0)