Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

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

Merge pull request #29 from tsirysndr/track-album-art

save track album art on scan library

authored by

Tsiry Sandratraina and committed by
GitHub
7d5c93ba bfe618a4

+74 -27
+6
crates/graphql/src/schema/objects/track.rs
··· 29 29 pub album_id: Option<String>, 30 30 pub artist_id: Option<String>, 31 31 pub genre_id: Option<String>, 32 + pub album_art: Option<String>, 32 33 } 33 34 34 35 #[Object] ··· 132 133 async fn genre_id(&self) -> Option<&str> { 133 134 self.genre_id.as_deref() 134 135 } 136 + 137 + async fn album_art(&self) -> Option<&str> { 138 + self.album_art.as_deref() 139 + } 135 140 } 136 141 137 142 impl From<Mp3Entry> for Track { ··· 207 212 album_id: Some(track.album_id), 208 213 genre_id: Some(track.genre_id), 209 214 path: track.path, 215 + album_art: track.album_art, 210 216 ..Default::default() 211 217 } 212 218 }
+2 -1
crates/library/src/audio_scan.rs
··· 90 90 }, 91 91 year: entry.year as u32, 92 92 year_string: entry.year_string.clone(), 93 - album_art, 93 + album_art: album_art.clone(), 94 94 md5: album_md5, 95 95 artist_id: artist_id.clone(), 96 96 }, ··· 124 124 updated_at: Utc::now(), 125 125 artist_id: artist_id.clone(), 126 126 album_id: album_id.clone(), 127 + album_art, 127 128 ..Default::default() 128 129 }, 129 130 )
+4 -2
crates/library/src/repo/track.rs
··· 25 25 created_at, 26 26 updated_at, 27 27 artist_id, 28 - album_id 28 + album_id, 29 + album_art 29 30 ) 30 - VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21) 31 + VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22) 31 32 "#, 32 33 ) 33 34 .bind(&track.id) ··· 51 52 .bind(track.updated_at) 52 53 .bind(&track.artist_id) 53 54 .bind(&track.album_id) 55 + .bind(&track.album_art) 54 56 .execute(&pool) 55 57 .await { 56 58 Ok(_) => Ok(track.id.clone()),
+12
webui/rockbox/graphql.schema.json
··· 2040 2040 "deprecationReason": null 2041 2041 }, 2042 2042 { 2043 + "name": "albumArt", 2044 + "description": null, 2045 + "args": [], 2046 + "type": { 2047 + "kind": "SCALAR", 2048 + "name": "String", 2049 + "ofType": null 2050 + }, 2051 + "isDeprecated": false, 2052 + "deprecationReason": null 2053 + }, 2054 + { 2043 2055 "name": "albumArtist", 2044 2056 "description": null, 2045 2057 "args": [],
-1
webui/rockbox/src/Components/ArtistDetails/ArtistDetails.stories.tsx
··· 24 24 albums, 25 25 onPlayAll: fn(), 26 26 onShuffleAll: fn(), 27 - onClickAlbum: fn(), 28 27 onPlayAlbum: fn(), 29 28 onLikeAlbum: fn(), 30 29 onUnLikeAlbum: fn(),
-1
webui/rockbox/src/Components/ArtistDetails/ArtistDetails.test.tsx
··· 16 16 albums={albums} 17 17 onPlayAll={vi.fn()} 18 18 onShuffleAll={vi.fn()} 19 - onClickAlbum={vi.fn()} 20 19 onPlayAlbum={vi.fn()} 21 20 onLikeAlbum={vi.fn()} 22 21 onUnLikeAlbum={vi.fn()}
+6 -7
webui/rockbox/src/Components/ArtistDetails/ArtistDetails.tsx
··· 22 22 Link, 23 23 AlbumFooterMenu, 24 24 FloatingButton, 25 + NoAlbumCover, 25 26 } from "./styles"; 26 27 import ArrowBack from "../Icons/ArrowBack"; 27 28 import Shuffle from "../Icons/Shuffle"; ··· 40 41 41 42 const columnHelper = createColumnHelper<Track>(); 42 43 const columns = [ 43 - columnHelper.accessor("cover", { 44 + columnHelper.accessor("albumArt", { 44 45 header: "Title", 45 46 size: 48, 46 47 cell: (info) => ( ··· 139 140 name: string; 140 141 tracks: Track[]; 141 142 albums: any[]; 142 - onClickAlbum: (album: any) => void; 143 143 onPlayAll: () => void; 144 144 onShuffleAll: () => void; 145 145 onPlayAlbum: (album: any) => void; ··· 214 214 </AlbumFooterMenu> 215 215 </Hover> 216 216 <RouterLink to={`/albums/${item.id}`}> 217 - <AlbumCover 218 - src={item.cover ? item.cover : AlbumArt} 219 - onClick={() => props.onClickAlbum(item)} 220 - effect="opacity" 221 - /> 217 + {item.albumArt && ( 218 + <AlbumCover src={item.albumArt} effect="opacity" /> 219 + )} 220 + {!item.albumArt && <NoAlbumCover src={AlbumArt} />} 222 221 </RouterLink> 223 222 </div> 224 223 <AlbumTitle to={`/albums/${item.id}`}>
+25 -7
webui/rockbox/src/Components/ArtistDetails/ArtistDetailsWithData.tsx
··· 1 1 import { FC } from "react"; 2 2 import ArtistDetails from "./ArtistDetails"; 3 - import { tracks, albums } from "./mocks"; 4 - import { useNavigate } from "react-router-dom"; 3 + import { useNavigate, useParams } from "react-router-dom"; 4 + import { useGetArtistQuery } from "../../Hooks/GraphQL"; 5 + import { useTimeFormat } from "../../Hooks/useFormat"; 5 6 6 7 const ArtistDetailsWithData: FC = () => { 7 8 const navigate = useNavigate(); 9 + const { id } = useParams<{ id: string }>(); 10 + const { data } = useGetArtistQuery({ 11 + variables: { 12 + id: id!, 13 + }, 14 + }); 15 + const { formatTime } = useTimeFormat(); 16 + const tracks = 17 + data?.artist?.tracks.map((x) => ({ 18 + ...x, 19 + time: formatTime(x.length), 20 + albumArt: x.albumArt ? `http://localhost:6062/covers/${x.albumArt}` : "", 21 + })) || []; 22 + const albums = 23 + data?.artist?.albums.map((x) => ({ 24 + ...x, 25 + albumArt: x.albumArt ? `http://localhost:6062/covers/${x.albumArt}` : "", 26 + })) || []; 8 27 return ( 9 28 <ArtistDetails 10 - name={"Daft Punk"} 11 - tracks={tracks} 12 - albums={albums} 13 - // eslint-disable-next-line @typescript-eslint/no-unused-vars 14 - onClickAlbum={(_album) => {}} 29 + name={data?.artist?.name || ""} 30 + // eslint-disable-next-line @typescript-eslint/no-explicit-any 31 + tracks={(tracks as any) || []} 32 + albums={albums || []} 15 33 onPlayAll={() => {}} 16 34 onShuffleAll={() => {}} 17 35 onPlayAlbum={() => {}}
+6 -6
webui/rockbox/src/Components/ArtistDetails/mocks.tsx
··· 5 5 title: "Get Lucky", 6 6 artist: "Daft Punk", 7 7 album: "Random Access Memories", 8 - cover: 8 + albumArt: 9 9 "https://resources.tidal.com/images/09b59e6e/717e/43e3/b2e2/d2a153c24775/320x320.jpg", 10 10 time: "6:10", 11 11 artistId: "1", ··· 17 17 title: "Instant Crush", 18 18 artist: "Daft Punk", 19 19 album: "Random Access Memories", 20 - cover: 20 + albumArt: 21 21 "https://resources.tidal.com/images/09b59e6e/717e/43e3/b2e2/d2a153c24775/320x320.jpg", 22 22 time: "5:38", 23 23 artistId: "1", ··· 29 29 title: "Arround the World", 30 30 artist: "Daft Punk", 31 31 album: "Homework", 32 - cover: 32 + albumArt: 33 33 "https://resources.tidal.com/images/f853861c/0c5f/4e73/b608/eeb00618fe6f/320x320.jpg", 34 34 time: "7:10", 35 35 artistId: "1", ··· 42 42 id: "1", 43 43 title: "Random Access Memories", 44 44 artist: "Daft Punk", 45 - cover: 45 + albumArt: 46 46 "https://resources.tidal.com/images/09b59e6e/717e/43e3/b2e2/d2a153c24775/320x320.jpg", 47 47 year: 2013, 48 48 }, ··· 50 50 id: "2", 51 51 title: "Tron: Legacy", 52 52 artist: "Daft Punk", 53 - cover: 53 + albumArt: 54 54 "https://resources.tidal.com/images/866bb671/5ec8/4b45/8a60/50e51f5dbf10/320x320.jpg", 55 55 year: 2010, 56 56 }, ··· 58 58 id: "3", 59 59 title: "Homework", 60 60 artist: "Daft Punk", 61 - cover: 61 + albumArt: 62 62 "https://resources.tidal.com/images/f853861c/0c5f/4e73/b608/eeb00618fe6f/320x320.jpg", 63 63 year: 2001, 64 64 },
+6
webui/rockbox/src/Components/ArtistDetails/styles.tsx
··· 170 170 background-color: #434242b5; 171 171 } 172 172 `; 173 + 174 + export const NoAlbumCover = styled.img` 175 + width: 100%; 176 + border-radius: 3px; 177 + cursor: pointer; 178 + `;
+2
webui/rockbox/src/GraphQL/Library/Query.tsx
··· 55 55 title 56 56 artist 57 57 album 58 + albumArt 58 59 albumArtist 59 60 artistId 60 61 albumId ··· 77 78 albumArtist 78 79 artistId 79 80 albumId 81 + albumArt 80 82 path 81 83 length 82 84 }
+5 -2
webui/rockbox/src/Hooks/GraphQL.tsx
··· 212 212 export type Track = { 213 213 __typename?: 'Track'; 214 214 album: Scalars['String']['output']; 215 + albumArt?: Maybe<Scalars['String']['output']>; 215 216 albumArtist: Scalars['String']['output']; 216 217 albumId?: Maybe<Scalars['String']['output']>; 217 218 artist: Scalars['String']['output']; ··· 461 462 }>; 462 463 463 464 464 - export type GetArtistQuery = { __typename?: 'Query', artist?: { __typename?: 'Artist', id: string, name: string, albums: Array<{ __typename?: 'Album', id: string, title: string, artist: string, albumArt?: string | null, year: number, yearString: string, artistId: string, md5: string }>, tracks: Array<{ __typename?: 'Track', id?: string | null, title: string, artist: string, album: string, albumArtist: string, artistId?: string | null, albumId?: string | null, path: string, length: number }> } | null }; 465 + export type GetArtistQuery = { __typename?: 'Query', artist?: { __typename?: 'Artist', id: string, name: string, albums: Array<{ __typename?: 'Album', id: string, title: string, artist: string, albumArt?: string | null, year: number, yearString: string, artistId: string, md5: string }>, tracks: Array<{ __typename?: 'Track', id?: string | null, title: string, artist: string, album: string, albumArt?: string | null, albumArtist: string, artistId?: string | null, albumId?: string | null, path: string, length: number }> } | null }; 465 466 466 467 export type TracksQueryVariables = Exact<{ [key: string]: never; }>; 467 468 468 469 469 - export type TracksQuery = { __typename?: 'Query', tracks: Array<{ __typename?: 'Track', id?: string | null, tracknum: number, title: string, artist: string, album: string, discnum: number, albumArtist: string, artistId?: string | null, albumId?: string | null, path: string, length: number }> }; 470 + export type TracksQuery = { __typename?: 'Query', tracks: Array<{ __typename?: 'Track', id?: string | null, tracknum: number, title: string, artist: string, album: string, discnum: number, albumArtist: string, artistId?: string | null, albumId?: string | null, albumArt?: string | null, path: string, length: number }> }; 470 471 471 472 export type GetAlbumQueryVariables = Exact<{ 472 473 id: Scalars['String']['input']; ··· 639 640 title 640 641 artist 641 642 album 643 + albumArt 642 644 albumArtist 643 645 artistId 644 646 albumId ··· 693 695 albumArtist 694 696 artistId 695 697 albumId 698 + albumArt 696 699 path 697 700 length 698 701 }