A decentralized music tracking and discovery platform built on AT Protocol 馃幍 rocksky.app
spotify atproto lastfm musicbrainz scrobbling listenbrainz
96
fork

Configure Feed

Select the types of activity you want to include in your feed.

at feat/pgpull 124 lines 3.3 kB view raw
1import { client } from "."; 2 3export const getSongByUri = async (uri: string) => { 4 if (uri.includes("app.rocksky.scrobble")) { 5 return null; 6 } 7 8 const response = await client.get("/xrpc/app.rocksky.song.getSong", { 9 params: { uri }, 10 }); 11 return { 12 id: response.data?.id, 13 title: response.data?.title, 14 artist: response.data?.artist, 15 albumArtist: response.data?.albumArtist, 16 album: response.data?.album, 17 cover: response.data?.albumArt, 18 tags: [], 19 artistUri: response.data?.artistUri, 20 albumUri: response.data?.albumUri, 21 listeners: response.data?.uniqueListeners || 1, 22 scrobbles: response.data?.playCount || 1, 23 lyrics: response.data?.lyrics, 24 spotifyLink: response.data?.spotifyLink, 25 composer: response.data?.composer, 26 uri: response.data?.uri, 27 }; 28}; 29 30export const getArtistTracks = async ( 31 uri: string, 32 limit = 10 33): Promise< 34 { 35 id: string; 36 title: string; 37 artist: string; 38 albumArtist: string; 39 albumArt: string; 40 uri: string; 41 playCount: number; 42 albumUri?: string; 43 artistUri?: string; 44 }[] 45> => { 46 const response = await client.get( 47 "/xrpc/app.rocksky.artist.getArtistTracks", 48 { params: { uri, limit } } 49 ); 50 return response.data.tracks; 51}; 52 53export const getArtistAlbums = async ( 54 uri: string, 55 limit = 10 56): Promise< 57 { 58 id: string; 59 title: string; 60 artist: string; 61 albumArt: string; 62 artistUri: string; 63 uri: string; 64 }[] 65> => { 66 const response = await client.get( 67 "/xrpc/app.rocksky.artist.getArtistAlbums", 68 { params: { uri, limit } } 69 ); 70 return response.data.albums; 71}; 72 73export const getArtists = async (did: string, offset = 0, limit = 30) => { 74 const response = await client.get("/xrpc/app.rocksky.actor.getActorArtists", { 75 params: { did, limit, offset }, 76 }); 77 return response.data; 78}; 79 80export const getAlbums = async (did: string, offset = 0, limit = 12) => { 81 const response = await client.get("/xrpc/app.rocksky.actor.getActorAlbums", { 82 params: { did, limit, offset }, 83 }); 84 return response.data; 85}; 86 87export const getTracks = async (did: string, offset = 0, limit = 20) => { 88 const response = await client.get("/xrpc/app.rocksky.actor.getActorSongs", { 89 params: { did, limit, offset }, 90 }); 91 return response.data; 92}; 93 94export const getLovedTracks = async (did: string, offset = 0, limit = 20) => { 95 const response = await client.get( 96 "/xrpc/app.rocksky.actor.getActorLovedSongs", 97 { 98 params: { did, limit, offset }, 99 } 100 ); 101 return response.data.tracks; 102}; 103 104export const getAlbum = async (did: string, rkey: string) => { 105 const response = await client.get("/xrpc/app.rocksky.album.getAlbum", { 106 params: { uri: `at://${did}/app.rocksky.album/${rkey}` }, 107 }); 108 return response.data; 109}; 110 111export const getArtist = async (did: string, rkey: string) => { 112 const response = await client.get("/xrpc/app.rocksky.artist.getArtist", { 113 params: { uri: `at://${did}/app.rocksky.artist/${rkey}` }, 114 }); 115 return response.data; 116}; 117 118export const getArtistListeners = async (uri: string, limit: number) => { 119 const response = await client.get( 120 "/xrpc/app.rocksky.artist.getArtistListeners", 121 { params: { uri, limit } } 122 ); 123 return response.data; 124};