A community based topic aggregation platform built on atproto
at main 4.0 kB view raw
1#!/usr/bin/env python3 2""" 3Quick script to post a Streamable video to test-usnews community. 4Uses the kagi-news CovesClient infrastructure. 5""" 6 7import sys 8import os 9 10# Add kagi-news src to path to use CovesClient 11sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../aggregators/kagi-news')) 12 13from src.coves_client import CovesClient 14 15def main(): 16 # Configuration 17 COVES_API_URL = "http://localhost:8081" 18 PDS_URL = "http://localhost:3001" 19 20 # Use PDS instance credentials (from .env.dev) 21 HANDLE = "testuser123.local.coves.dev" 22 PASSWORD = "test-password-123" 23 24 # Post details 25 COMMUNITY_HANDLE = "test-usnews.community.coves.social" 26 27 # Post 1: Streamable video 28 STREAMABLE_URL = "https://streamable.com/7kpdft" 29 STREAMABLE_TITLE = "NBACentral - \"Your son don't wanna be here, we know it's your last weekend. Enjoy ..." 30 31 # Post 2: Reddit highlight 32 REDDIT_URL = "https://www.reddit.com/r/nba/comments/1orfsgm/highlight_giannis_antetokounmpo_41_pts_15_reb_9/" 33 REDDIT_TITLE = "[Highlight] Giannis Antetokounmpo (41 PTS, 15 REB, 9 AST) tallies his 56th career regular season game of 40+ points, passing Kareem Abdul-Jabbar for the most such games in franchise history. Milwaukee defeats Chicago 126-110 to win their NBA Cup opener." 34 35 # Initialize client 36 print(f"Initializing Coves client...") 37 print(f" API URL: {COVES_API_URL}") 38 print(f" PDS URL: {PDS_URL}") 39 print(f" Handle: {HANDLE}") 40 41 client = CovesClient( 42 api_url=COVES_API_URL, 43 handle=HANDLE, 44 password=PASSWORD, 45 pds_url=PDS_URL 46 ) 47 48 # Authenticate 49 print("\nAuthenticating...") 50 try: 51 client.authenticate() 52 print(f"✓ Authenticated as {client.did}") 53 except Exception as e: 54 print(f"✗ Authentication failed: {e}") 55 return 1 56 57 # Post 1: Streamable video 58 print("\n" + "="*60) 59 print("POST 1: STREAMABLE VIDEO") 60 print("="*60) 61 62 print("\nCreating minimal external embed (URI only)...") 63 streamable_embed = { 64 "$type": "social.coves.embed.external", 65 "external": { 66 "uri": STREAMABLE_URL 67 } 68 } 69 print(f"✓ Embed created with URI only (unfurl service should enrich)") 70 71 print(f"\nPosting to {COMMUNITY_HANDLE}...") 72 print(f" Title: {STREAMABLE_TITLE}") 73 print(f" Video: {STREAMABLE_URL}") 74 75 try: 76 post_uri = client.create_post( 77 community_handle=COMMUNITY_HANDLE, 78 title=STREAMABLE_TITLE, 79 content="", 80 facets=[], 81 embed=streamable_embed 82 ) 83 84 print(f"\n✓ Streamable post created successfully!") 85 print(f" URI: {post_uri}") 86 87 except Exception as e: 88 print(f"\n✗ Streamable post creation failed: {e}") 89 import traceback 90 traceback.print_exc() 91 return 1 92 93 # Post 2: Reddit highlight 94 print("\n" + "="*60) 95 print("POST 2: REDDIT HIGHLIGHT") 96 print("="*60) 97 98 print("\nCreating minimal external embed (URI only)...") 99 reddit_embed = { 100 "$type": "social.coves.embed.external", 101 "external": { 102 "uri": REDDIT_URL 103 } 104 } 105 print(f"✓ Embed created with URI only (unfurl service should enrich)") 106 107 print(f"\nPosting to {COMMUNITY_HANDLE}...") 108 print(f" Title: {REDDIT_TITLE}") 109 print(f" URL: {REDDIT_URL}") 110 111 try: 112 post_uri = client.create_post( 113 community_handle=COMMUNITY_HANDLE, 114 title=REDDIT_TITLE, 115 content="", 116 facets=[], 117 embed=reddit_embed 118 ) 119 120 print(f"\n✓ Reddit post created successfully!") 121 print(f" URI: {post_uri}") 122 print(f"\n" + "="*60) 123 print("Both posts created! Check them out at !test-usnews") 124 print("="*60) 125 return 0 126 127 except Exception as e: 128 print(f"\n✗ Reddit post creation failed: {e}") 129 import traceback 130 traceback.print_exc() 131 return 1 132 133if __name__ == "__main__": 134 sys.exit(main())