✨ add back year to album detailed
This commit is contained in:
parent
5c93e58da4
commit
149fc48a00
|
|
@ -9,6 +9,7 @@
|
|||
| `playlistId` | `string` | Playlist ID for Album |
|
||||
| `name` | `string` | Name |
|
||||
| `artists` | [ArtistBasic](./ArtistBasic.html)`[]` | Creators of the Album |
|
||||
| `year` | `number \| null` | Year of release |
|
||||
| `thumbnails` | [ThumbnailFull](./ThumbnailFull.html)`[]` | Thumbnails |
|
||||
|
||||
## TypeScript Source Code
|
||||
|
|
@ -20,6 +21,7 @@ interface AlbumDetailed {
|
|||
playlistId: string
|
||||
name: string
|
||||
artists: ArtistBasic[]
|
||||
year: number | null
|
||||
thumbnails: ThumbnailFull[]
|
||||
}
|
||||
```
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
| `playlistId` | `string` | Playlist ID for Album |
|
||||
| `name` | `string` | Name |
|
||||
| `artists` | [ArtistBasic](./ArtistBasic.html)`[]` | Creators of the Album |
|
||||
| `year` | `number \| null` | Year of release |
|
||||
| `thumbnails` | [ThumbnailFull](./ThumbnailFull.html)`[]` | Thumbnails |
|
||||
| `description` | `string` | Description |
|
||||
| `songs` | [SongDetailed](./SongDetailed.html)`[]` | Songs in the Album |
|
||||
|
|
@ -22,6 +23,7 @@ interface AlbumFull {
|
|||
playlistId: string
|
||||
name: string
|
||||
artists: ArtistBasic[]
|
||||
year: number | null
|
||||
thumbnails: ThumbnailFull[]
|
||||
description: string
|
||||
songs: SongDetailed[]
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ export interface AlbumDetailed extends AlbumBasic {
|
|||
type: "ALBUM"
|
||||
playlistId: string
|
||||
artists: ArtistBasic[]
|
||||
year: number | null
|
||||
thumbnails: ThumbnailFull[]
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { BOOLEAN, LIST, NUMBER, OBJECT, STRING } from "validate-any"
|
||||
import { BOOLEAN, LIST, NULL, NUMBER, OBJECT, OR, STRING } from "validate-any"
|
||||
import ObjectValidator from "validate-any/dist/validators/ObjectValidator"
|
||||
|
||||
import {
|
||||
|
|
@ -54,6 +54,7 @@ export const ALBUM_DETAILED: ObjectValidator<AlbumDetailed> = OBJECT({
|
|||
playlistId: STRING(),
|
||||
name: STRING(),
|
||||
artists: LIST(ARTIST_BASIC),
|
||||
year: OR(NUMBER(), NULL()),
|
||||
thumbnails: LIST(THUMBNAIL_FULL)
|
||||
})
|
||||
|
||||
|
|
@ -108,6 +109,7 @@ export const ALBUM_FULL: ObjectValidator<AlbumFull> = OBJECT({
|
|||
playlistId: STRING(),
|
||||
name: STRING(),
|
||||
artists: LIST(ARTIST_BASIC),
|
||||
year: OR(NUMBER(), NULL()),
|
||||
thumbnails: LIST(THUMBNAIL_FULL),
|
||||
description: STRING(),
|
||||
songs: LIST(SONG_DETAILED)
|
||||
|
|
|
|||
|
|
@ -25,6 +25,9 @@ export default class AlbumParser {
|
|||
...albumBasic,
|
||||
playlistId: traverseString(data, "buttonRenderer", "playlistId")(),
|
||||
artists,
|
||||
year: AlbumParser.processYear(
|
||||
traverseString(data, "header", "subtitle", "text")(-1)
|
||||
),
|
||||
thumbnails,
|
||||
description: traverseString(data, "description", "text")(),
|
||||
songs: traverseList(data, "musicResponsiveListItemRenderer").map(item =>
|
||||
|
|
@ -49,6 +52,7 @@ export default class AlbumParser {
|
|||
artistId: traverseString(run, "browseId")(),
|
||||
name: traverseString(run, "text")()
|
||||
})),
|
||||
year: AlbumParser.processYear(traverseString(flexColumns[1], "runs", "text")(-1)),
|
||||
name: traverseString(flexColumns[0], "runs", "text")(),
|
||||
thumbnails: traverseList(item, "thumbnails")
|
||||
},
|
||||
|
|
@ -64,6 +68,7 @@ export default class AlbumParser {
|
|||
playlistId: traverseString(item, "thumbnailOverlay", "playlistId")(),
|
||||
name: traverseString(item, "title", "text")(),
|
||||
artists: [artistBasic],
|
||||
year: AlbumParser.processYear(traverseString(item, "subtitle", "text")(-1)),
|
||||
thumbnails: traverseList(item, "thumbnails")
|
||||
},
|
||||
ALBUM_DETAILED
|
||||
|
|
@ -78,9 +83,14 @@ export default class AlbumParser {
|
|||
playlistId: traverseString(item, "musicPlayButtonRenderer", "playlistId")(),
|
||||
name: traverseString(item, "title", "text")(),
|
||||
artists: [artistBasic],
|
||||
year: AlbumParser.processYear(traverseString(item, "subtitle", "text")(-1)),
|
||||
thumbnails: traverseList(item, "thumbnails")
|
||||
},
|
||||
ALBUM_DETAILED
|
||||
)
|
||||
}
|
||||
|
||||
private static processYear(year: string) {
|
||||
return year.match(/^\d{4}$/) ? +year : null
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue