I'm using the google_api_you_tube library to search for YouTube videos, then use the videoIds to request the comment threads, and then finally extracting the comments from the maps.
{:ok, videos} = Search.youtube_search_list(search_conn, ["snippet"], [{:key, @api_key}, {:q, "cats"}])
comment_threads = Enum.map(videos.items, fn video -> CommentThreads.youtube_comment_threads_list(search_conn, ["snippet"], [{:key, @api_key}, {:videoId, video.id.videoId}, {:maxResults, 2}]) end)
comments = Enum.map(comment_threads.items, fn comment_thread -> extract_comments(comment_thread) end)
My issue is that when I inspect comment_threads it looks like this:
comment_threads: [
ok: %GoogleApi.YouTube.V3.Model.CommentThreadListResponse{
visitorId: nil,
tokenPagination: nil,
pageInfo: %GoogleApi.YouTube.V3.Model.PageInfo{
totalResults: 2,
resultsPerPage: 2
},
... ,
ok: %GoogleApi.YouTube.V3.Model.CommentThreadListResponse{
visitorId: nil,
tokenPagination: nil,
pageInfo: %GoogleApi.YouTube.V3.Model.PageInfo{
totalResults: 2,
resultsPerPage: 2
},
These are not tuples. Is there something I'm doing wrong to make it not return as tuples? And if not, is there a way to pattern match to remove the ok: on each list element? I have tried but been implementing it incorrectly.