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

Add ability to send aspect ratio with send_video #521

Merged
merged 9 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions examples/send_video.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from atproto import Client
from atproto import Client, models


def main() -> None:
Expand All @@ -9,7 +9,16 @@ def main() -> None:
with open('video.mp4', 'rb') as f:
vid_data = f.read()

client.send_video(text='Post with video from Python', video=vid_data, video_alt='Text version of the video (ALT)')
# Add video aspect ratio to prevent default 1:1 aspect ratio
# Replace with your desired aspect ratio
aspect_ratio = models.AppBskyEmbedDefs.AspectRatio(height=100, width=100)

client.send_video(
text='Post with video from Python',
video=vid_data,
video_alt='Text version of the video (ALT)',
video_aspect_ratio=aspect_ratio,
)


if __name__ == '__main__':
Expand Down
4 changes: 3 additions & 1 deletion packages/atproto_client/client/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ async def send_video(
reply_to: t.Optional['models.AppBskyFeedPost.ReplyRef'] = None,
langs: t.Optional[t.List[str]] = None,
facets: t.Optional[t.List['models.AppBskyRichtextFacet.Main']] = None,
video_aspect_ratio: t.Optional['models.AppBskyEmbedDefs.AspectRatio'] = None,
) -> 'models.AppBskyFeedPost.CreateRecordResponse':
"""Send post with attached video.

Expand All @@ -312,6 +313,7 @@ async def send_video(
reply_to: Root and parent of the post to reply to.
langs: List of used languages in the post.
facets: List of facets (rich text items).
video_aspect_ratio: Aspect ratio of the video.

Returns:
:obj:`models.AppBskyFeedPost.CreateRecordResponse`: Reference to the created record.
Expand All @@ -328,7 +330,7 @@ async def send_video(
text,
profile_identify=profile_identify,
reply_to=reply_to,
embed=models.AppBskyEmbedVideo.Main(video=upload.blob, alt=video_alt),
embed=models.AppBskyEmbedVideo.Main(video=upload.blob, alt=video_alt, aspect_ratio=video_aspect_ratio),
langs=langs,
facets=facets,
)
Expand Down
4 changes: 3 additions & 1 deletion packages/atproto_client/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ def send_video(
reply_to: t.Optional['models.AppBskyFeedPost.ReplyRef'] = None,
langs: t.Optional[t.List[str]] = None,
facets: t.Optional[t.List['models.AppBskyRichtextFacet.Main']] = None,
video_aspect_ratio: t.Optional['models.AppBskyEmbedDefs.AspectRatio'] = None,
) -> 'models.AppBskyFeedPost.CreateRecordResponse':
"""Send post with attached video.

Expand All @@ -303,6 +304,7 @@ def send_video(
reply_to: Root and parent of the post to reply to.
langs: List of used languages in the post.
facets: List of facets (rich text items).
video_aspect_ratio: Aspect ratio of the video.

Returns:
:obj:`models.AppBskyFeedPost.CreateRecordResponse`: Reference to the created record.
Expand All @@ -319,7 +321,7 @@ def send_video(
text,
profile_identify=profile_identify,
reply_to=reply_to,
embed=models.AppBskyEmbedVideo.Main(video=upload.blob, alt=video_alt),
embed=models.AppBskyEmbedVideo.Main(video=upload.blob, alt=video_alt, aspect_ratio=video_aspect_ratio),
langs=langs,
facets=facets,
)
Expand Down
Loading