Your music, beautifully tracked. All yours. (coming soon) teal.fm
teal-fm atproto

Start work on manual submissions

+79 -11
+79 -11
app/(tabs)/two.tsx
··· 1 - import { View, Image } from "react-native"; 2 - import { Text } from "~/components/ui/text"; 3 4 export default function TabTwoScreen() { 5 return ( 6 <View className="flex-1 flex gap-2 items-center justify-center align-center w-full h-full bg-background"> 7 - <Text className="text-3xl">oh honey honey honey pie alya</Text> 8 - <Image 9 - style={{ 10 - height: 200, 11 - width: 200, 12 - }} 13 - source={require("../../assets/images/honeypie_alya.png")} 14 - /> 15 - <Text className="font-serif-old">Alisa Mikhailovna Kujou</Text> 16 </View> 17 ); 18 }
··· 1 + import { View } from "react-native"; 2 + 3 + import { useStore } from "@/stores/mainStore"; 4 + import { Button } from "@/components/ui/button"; 5 + import { Text } from "@/components/ui/text"; 6 + 7 + import { 8 + Record as Play, 9 + validateRecord, 10 + } from "@/lexicons/server/types/fm/teal/alpha/play"; 11 + 12 + async function searchMusicbrainz(query: string) { 13 + try { 14 + const res = await fetch( 15 + `https://musicbrainz.org/ws/2/recording?query=${encodeURIComponent(query)}&fmt=json` 16 + ); 17 + const data = await res.json(); 18 + return data.recordings?.[0]; // Get the first recording result 19 + } catch (error) { 20 + console.error("Failed to fetch MusicBrainz data:", error); 21 + return null; 22 + } 23 + } 24 25 export default function TabTwoScreen() { 26 + const agent = useStore((state) => state.pdsAgent); 27 + 28 + const submitPlay = async () => { 29 + const query = "release title:this is why AND artist:Paramore"; 30 + const result = await searchMusicbrainz(query); 31 + 32 + if (result) { 33 + console.log(result); 34 + const play: Play = { 35 + trackName: result.title ?? "Unknown Title", 36 + recordingMbId: result.id ?? undefined, 37 + duration: result.length ? Math.floor(result.length / 1000) : undefined, // Convert ms to seconds 38 + artistName: 39 + result["artist-credit"]?.[0]?.artist?.name ?? "Unknown Artist", 40 + artistMbIds: result["artist-credit"]?.[0]?.artist?.id 41 + ? [result["artist-credit"][0].artist.id] 42 + : undefined, 43 + releaseName: result["releases"]?.[0]?.title ?? undefined, 44 + releaseMbId: result["releases"]?.[0]?.id ?? undefined, 45 + isrc: result.isrcs?.[0] ?? undefined, 46 + originUrl: `https://tidal.com/browse/track/274816578?u`, 47 + musicServiceBaseDomain: "tidal.com", 48 + submissionClientAgent: "tealtracker/0.0.1b", 49 + playedTime: new Date().toISOString(), 50 + }; 51 + 52 + try { 53 + let result = validateRecord(play); 54 + console.log("Validated play:", result); 55 + console.log("Submitting play:", play); 56 + // const res = await agent?.call( 57 + // "com.atproto.repo.createRecord", 58 + // {}, 59 + // { 60 + // repo: agent.did, 61 + // collection: "fm.teal.alpha.play", 62 + // rkey: undefined, 63 + // record: play, 64 + // } 65 + // ); 66 + // console.log("Play submitted successfully:", res); 67 + } catch (error) { 68 + console.error("Failed to submit play:", error); 69 + } 70 + } else { 71 + console.error("No results found for the query."); 72 + } 73 + }; 74 + 75 return ( 76 <View className="flex-1 flex gap-2 items-center justify-center align-center w-full h-full bg-background"> 77 + {agent ? ( 78 + <Button onPress={() => submitPlay()}> 79 + <Text>Get Profile</Text> 80 + </Button> 81 + ) : ( 82 + <Text>Loading...</Text> 83 + )} 84 </View> 85 ); 86 }