Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bluesky support #5640

Closed
ZipFile opened this issue Feb 8, 2024 · 2 comments · Fixed by #5641
Closed

Bluesky support #5640

ZipFile opened this issue Feb 8, 2024 · 2 comments · Fixed by #5641
Labels
Source Support Upload/Source support

Comments

@ZipFile
Copy link
Contributor

ZipFile commented Feb 8, 2024

Post page URL regex: ^https://bsky.app/profile/(.+?)/post/(.+)$ (groups: HANDLE, POST_ID)
Thumbnail URL regex: ^https://cdn.bsky.app/img/.+?/plain/(.+?)/(.+?)@.*$ (groups: DID, CID)
Original Image URL regex: ^https://(?:bsky\.social|.*\.bsky\.network)/xrpc/com\.atproto\.sync\.getBlob\?did=(.*)&cid=(.*)$ (groups: DID, CID)

DID from HANDLE can be retrieved using com.atproto.identity.resolveHandle API call.

Example:
$ curl -L 'https://bsky.social/xrpc/com.atproto.identity.resolveHandle?handle=ixy.bsky.social' | jq .did
"did:plc:3jogsxcisdcdzwjobhxbav2w"

CIDs from post can be retrieved using app.bsky.feed.getPostThread API call.

Example:
$ curl -L 'https://bsky.social/xrpc/app.bsky.feed.getPostThread?uri=at://did:plc:3jogsxcisdcdzwjobhxbav2w/app.bsky.feed.post/3kkvo4d4jd32g' -H "Authorization: Bearer $JWT" | jq '.thread.post.record.embed.images[] | {cid: .image.ref."$link", mime: .image.mimeType}'
{
  "cid": "bafkreiawa4vn5k37h2mlpwuhaqmeog3hsfe3z47iot7reqxjlff6juyge4",
  "mime": "image/jpeg"
}

Note: $JWT contains access jwt token. See details below.

Original image can be retrieved from DID and CID using com.atproto.sync.getBlob API call. File extension is not available, but can be deduced from returned mime type, or by using good old libmagic.

Example:
$ curl -L 'https://bsky.social/xrpc/com.atproto.sync.getBlob?did=did:plc:3jogsxcisdcdzwjobhxbav2w&cid=bafkreiawa4v
n5k37h2mlpwuhaqmeog3hsfe3z47iot7reqxjlff6juyge4' -o image.ext

$ sha256sum image.ext 
16072adeab7f3e98b7da870418471b679149bcf3e874ff1242e9594be4d30627  image.ext

$ file --mime-type image.ext
image.ext: image/jpeg

Auth token can be retrieved using com.atproto.server.createSession API call. com.atproto.server.refreshSession to refresh expired access tokens.

@ZipFile ZipFile added the Feature label Feb 8, 2024
@hdk5
Copy link
Contributor

hdk5 commented Feb 8, 2024

Additional info:

Are you gonna make a PR? Or that's just info for someone else willing to?

@ZipFile
Copy link
Contributor Author

ZipFile commented Feb 8, 2024

Are you gonna make a PR?

Unlikely.

Or that's just info for someone else willing to?

This.

@nonamethanks nonamethanks added Source Support Upload/Source support and removed Feature labels Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Source Support Upload/Source support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants