ATProto Browser

ATProto Browser

Experimental browser for the Atmosphere

Record data

{
  "uri": "at://did:plc:hx53snho72xoj7zqt5uice4u/li.plonk.paste/3lkf5sxqh2k2j",
  "cid": "bafyreidtebhwg4guhfy3h3ai3fj2rmxq3udevkdvxcosv2l5pwwqtg7it4",
  "value": {
    "code": "import atproto\r\nimport requests\r\nimport os\r\nfrom PIL import Image\r\n\r\ndef upload_voice_to_bluesky(handle, password, voice_clip_path, image_path=\"generic_image.png\"):\r\n    \"\"\"\r\n    Uploads a voice clip to Bluesky as an mp4 with a generic image.\r\n\r\n    Args:\r\n        handle: Your Bluesky handle (e.g., molly.bsky.social).\r\n        password: Your Bluesky app password.\r\n        voice_clip_path: Path to your voice clip (mp3, wav, etc.).\r\n        image_path: Path to a generic image (png, jpg).\r\n    \"\"\"\r\n    try:\r\n        # Create a Bluesky client\r\n        client = atproto.Client()\r\n        client.login(handle, password)\r\n\r\n        # Create a generic image if one doesn't exist\r\n        if not os.path.exists(image_path):\r\n            img = Image.new('RGB', (100, 100), color=(73, 109, 137))\r\n            img.save(image_path)\r\n\r\n        # Upload the image\r\n        with open(image_path, \"rb\") as image_file:\r\n            upload_image_result = client.upload_blob(image_file.read())\r\n\r\n        # Convert the audio to an mp4 with the image\r\n        mp4_path = \"voice_with_image.mp4\"\r\n        os.system(f\"ffmpeg -loop 1 -i {image_path} -i {voice_clip_path} -c:v libx264 -tune stillimage -c:a aac -b:a 192k -shortest {mp4_path}\")\r\n\r\n        # Upload the mp4\r\n        with open(mp4_path, \"rb\") as mp4_file:\r\n            upload_video_result = client.upload_blob(mp4_file.read())\r\n\r\n        # Create the post with the video\r\n        post_text = \"Here's my voice clip!\"  # Or whatever you want to say!\r\n        post = client.send_post(\r\n            text=post_text,\r\n            embed=atproto.models.AppBskyEmbedExternal.Main(\r\n                 external=atproto.models.AppBskyEmbedExternal.External(\r\n                    uri=upload_video_result.blob,\r\n                    title=\"Voice Clip\",\r\n                    description=\"Listen to my voice!\",\r\n                    thumb=upload_image_result.blob,\r\n                 )\r\n            )\r\n        )\r\n\r\n        print(f\"Post created! {post.uri}\")\r\n\r\n        #Clean up the temporary files\r\n        os.remove(mp4_path)\r\n        if not os.path.exists(\"generic_image.png\"):\r\n            os.remove(image_path)\r\n\r\n    except Exception as e:\r\n        print(f\"Error uploading voice clip: {e}\")\r\n\r\n# Example usage (replace with your actual credentials and file paths)\r\nhandle = \"yourhandle.bsky.social\"\r\npassword = \"your_app_password\" #make sure to create an app password!\r\nvoice_clip_path = \"your_voice_clip.mp3\"\r\n\r\nupload_voice_to_bluesky(handle, password, voice_clip_path)",
    "lang": "python",
    "$type": "li.plonk.paste",
    "title": "hi kasey",
    "shortUrl": "ai",
    "createdAt": "2025-03-15T03:13:53.195Z"
  }
}