From 727a634d0cde46bd451a143482bda8dfc284368f Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 21 Jan 2025 07:26:55 +0100 Subject: [PATCH 1/8] Added video aspect ratio to send_video --- packages/atproto_client/client/client.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/atproto_client/client/client.py b/packages/atproto_client/client/client.py index 5f5e894d..d8741474 100644 --- a/packages/atproto_client/client/client.py +++ b/packages/atproto_client/client/client.py @@ -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. @@ -319,7 +320,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, ) From a58c1a07c13d2eaa511edb46516839e187980468 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 21 Jan 2025 07:30:03 +0100 Subject: [PATCH 2/8] Added video_aspect_ratio to the example --- examples/send_video.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/examples/send_video.py b/examples/send_video.py index 4541b237..d627e7c1 100644 --- a/examples/send_video.py +++ b/examples/send_video.py @@ -1,4 +1,4 @@ -from atproto import Client +from atproto import Client, models def main() -> None: @@ -8,8 +8,17 @@ def main() -> None: # replace the path to your video file with open('video.mp4', 'rb') as f: vid_data = f.read() + + # Add image 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)') + 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__': From 8e42e3e829cccc8f1f1dd6980bab268a54e65a2f Mon Sep 17 00:00:00 2001 From: Yoshitura Yamamoto <112742954+yamamotura@users.noreply.github.com> Date: Tue, 21 Jan 2025 10:15:37 +0100 Subject: [PATCH 3/8] Change 'image' to 'video' --- examples/send_video.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/send_video.py b/examples/send_video.py index d627e7c1..a5b56f54 100644 --- a/examples/send_video.py +++ b/examples/send_video.py @@ -9,7 +9,7 @@ def main() -> None: with open('video.mp4', 'rb') as f: vid_data = f.read() - # Add image aspect ratio to prevent default 1:1 aspect ratio + # 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) From a7e19cacfdc24e7da8f4155f8aec579f0373ef11 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 21 Jan 2025 11:08:33 +0100 Subject: [PATCH 4/8] Video aspect ratio for async_client --- packages/atproto_client/client/async_client.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/atproto_client/client/async_client.py b/packages/atproto_client/client/async_client.py index 574f8787..430b77b3 100644 --- a/packages/atproto_client/client/async_client.py +++ b/packages/atproto_client/client/async_client.py @@ -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. @@ -328,7 +329,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, ) From 39b080ff50cc22ddb5deef8f0e159cd980524d14 Mon Sep 17 00:00:00 2001 From: Yoshitura Yamamoto <112742954+yamamotura@users.noreply.github.com> Date: Tue, 21 Jan 2025 11:14:19 +0100 Subject: [PATCH 5/8] Update client.py --- packages/atproto_client/client/client.py | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/atproto_client/client/client.py b/packages/atproto_client/client/client.py index d8741474..60767c19 100644 --- a/packages/atproto_client/client/client.py +++ b/packages/atproto_client/client/client.py @@ -304,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. From e57930b8a469850ead84d0edf4da37098509aafc Mon Sep 17 00:00:00 2001 From: Yoshitura Yamamoto <112742954+yamamotura@users.noreply.github.com> Date: Tue, 21 Jan 2025 11:15:15 +0100 Subject: [PATCH 6/8] Update async_client.py --- packages/atproto_client/client/async_client.py | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/atproto_client/client/async_client.py b/packages/atproto_client/client/async_client.py index 430b77b3..12d836c0 100644 --- a/packages/atproto_client/client/async_client.py +++ b/packages/atproto_client/client/async_client.py @@ -313,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. From ebacf8b31cf239c966b00e50bcfc1b0479985435 Mon Sep 17 00:00:00 2001 From: Yoshitura Yamamoto <112742954+yamamotura@users.noreply.github.com> Date: Tue, 21 Jan 2025 11:17:16 +0100 Subject: [PATCH 7/8] Update send_video.py --- examples/send_video.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/send_video.py b/examples/send_video.py index a5b56f54..7b652a6f 100644 --- a/examples/send_video.py +++ b/examples/send_video.py @@ -8,7 +8,7 @@ def main() -> None: # replace the path to your video file with open('video.mp4', 'rb') as f: vid_data = f.read() - + # 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) From 759f94d72a45ad1022489cd75fa8818e2c0f0a64 Mon Sep 17 00:00:00 2001 From: Yoshitura Yamamoto <112742954+yamamotura@users.noreply.github.com> Date: Tue, 21 Jan 2025 20:06:54 +0100 Subject: [PATCH 8/8] Update client.py --- packages/atproto_client/client/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/atproto_client/client/client.py b/packages/atproto_client/client/client.py index 60767c19..f3ef8094 100644 --- a/packages/atproto_client/client/client.py +++ b/packages/atproto_client/client/client.py @@ -321,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,aspect_ratio=video_aspect_ratio), + embed=models.AppBskyEmbedVideo.Main(video=upload.blob, alt=video_alt, aspect_ratio=video_aspect_ratio), langs=langs, facets=facets, )