diff --git a/src/views/Profile/VideoView.vue b/src/views/Profile/VideoView.vue index c8006ff..3093a4b 100644 --- a/src/views/Profile/VideoView.vue +++ b/src/views/Profile/VideoView.vue @@ -11,8 +11,10 @@ import GeneralTable from "@/components/GeneralTable.vue"; import { getGameInfo } from "@/constants"; import { APIGetPlayVideos } from "@/stores/api/account"; +import { APIGetMusicData } from "@/stores/api/music"; +import BaseDivider from "@/components/BaseDivider.vue"; -var videoData = ref([]); +const videoData = ref([]); const loading = ref(false); const headers = [ @@ -22,6 +24,18 @@ const headers = [ sortable: true, width: 120, }, + { + text: "Song", + value: "name", + sortable: true, + width: 120, + }, + { + text: "Artist", + value: "artist", + sortable: true, + width: 120, + }, { text: "Game", value: "game", @@ -46,7 +60,30 @@ async function loadVideos() { videoData.value = null; try { const data = await APIGetPlayVideos(); - videoData.value = filterVideos(data); + videoData.value = filterVideos(JSON.parse(JSON.stringify(data))); + + const uniqueMusicIds = [ + ...new Set(videoData.value.map((video) => video.musicid)), + ]; + + if (uniqueMusicIds.length > 0) { + const songData = await APIGetMusicData( + "iidx", + data[0].version, + uniqueMusicIds, + true + ); + + const songMap = Object.fromEntries( + songData.map((song) => [song.id, song]) + ); + + videoData.value = videoData.value.map((video) => ({ + ...video, + name: songMap[video.musicid]?.name || "Unknown Song", + artist: songMap[video.musicid]?.artist || "Unknown Artist", + })); + } } catch (error) { console.error("Failed to fetch video data:", error); } @@ -91,6 +128,10 @@ const copyToClipboard = (text) => { alert("Failed to copy to clipboard!"); }); }; + +function openInNewTab(url) { + window.open(url.data?.url, "_blank").focus(); +}