Hi, I’m getting a playlist of videos from the Youtube api. I’m doing Enum.each/2 to make them into a list of structs but when I IO.inspect(thing) I get {:ok, :ok} instead of a list of my abbreviated structs. Not clear why that is so…
thing = YouTubeConnection.new()
|> GoogleApi.YouTube.V3.Api.PlaylistItems.youtube_playlist_items_list("snippet", maxResults: 50, playlistId: playlist_id, key: api_key)
|> Result.map_error(fn e -> "YouTube API Error: #{inspect(e)}" end)
|> Result.keep_if(&(!Enum.empty?(&1.items)), "remote_video_404")
|> Result.map(fn %GoogleApi.YouTube.V3.Model.PlaylistItemListResponse{items: videos} ->
Enum.each(videos, fn video ->
%{
title: video.snippet.title,
language: "en",
url: Video.build_url(%{youtube_id: video.snippet.resourceId.videoId})
}
end)
end)
IO.inspect(thing)
regards,
Michael