Skip to content

Commit

Permalink
fix json access and missing function
Browse files Browse the repository at this point in the history
  • Loading branch information
Yay295 committed Oct 18, 2024
1 parent 48145a3 commit 9a640d8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/philomena_proxy/scrapers/bluesky.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ defmodule PhilomenaProxy.Scrapers.Bluesky do
[handle, id] = Regex.run(@url_regex, url, capture: :all_but_first)

api_url_resolve_handle = "https://public.api.bsky.app/xrpc/com.atproto.identity.resolveHandle?handle=#{handle}"
did = PhilomenaProxy.Http.get(api_url_resolve_handle) |> json!() |> &1["did"]
did = PhilomenaProxy.Http.get(api_url_resolve_handle) |> json!() |> Map.fetch!(:did)

api_url_get_posts = "https://public.api.bsky.app/xrpc/app.bsky.feed.getPosts?uris=at://#{did}/app.bsky.feed.post/#{id}"
post_json = PhilomenaProxy.Http.get(api_url_get_posts) |> json!() |> &1["posts"][0]
post_json = PhilomenaProxy.Http.get(api_url_get_posts) |> json!() |> Map.fetch!(:posts) |> hd

%{
source_url: url,
Expand All @@ -37,4 +37,6 @@ defmodule PhilomenaProxy.Scrapers.Bluesky do
)
}
end

defp json!({:ok, %{body: body, status: 200}}), do: Jason.decode!(body)
end

0 comments on commit 9a640d8

Please sign in to comment.