Podcasts hosted on ATProto

Fix streaming endpoint to use Agent API for record fetching

Changed files
+10 -17
src
routes
+10 -17
src/routes/media.js
··· 39 39 console.log(`Resolved PDS for ${did}: ${pdsUrl}`); 40 40 41 41 // Try to find the episode record that matches this CID 42 - const rpc = new Client({ 43 - handler: (pathname, init) => { 44 - // pathname is the full URL from @atcute/client 45 - return fetch(pathname, init); 46 - }, 47 - service: pdsUrl 42 + // Use Agent instead of Client for better PDS compatibility 43 + const { Agent } = await import('@atproto/api'); 44 + const agent = new Agent({ service: pdsUrl }); 45 + 46 + const records = await agent.com.atproto.repo.listRecords({ 47 + repo: did, 48 + collection: 'app.podcast.episode' 48 49 }); 49 50 50 - const records = await ok( 51 - rpc.get('com.atproto.repo.listRecords', { 52 - params: { 53 - repo: did, 54 - collection: 'app.podcast.episode' 55 - } 56 - }) 57 - ); 58 - 59 - console.log(`Found ${records.records?.length || 0} episode records`); 51 + console.log(`Found ${records.data.records?.length || 0} episode records`); 60 52 61 53 // Find the episode with this CID in its audio field 62 - const episode = records.records?.find(record => { 54 + const episode = records.data.records?.find(record => { 63 55 const audioCid = record.value.audio?.ref?.$link || record.value.audio?.ref?.toString(); 56 + console.log(`Checking record audio CID: ${audioCid} against ${cid}`); 64 57 return audioCid === cid; 65 58 }); 66 59