File size: 653 Bytes
65aae53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from pydantic import BaseModel
from typing import List, Optional

class Song(BaseModel):
    name: str
    artists: List[str]
    year: int
    popularity: int

class Recommendation(BaseModel):
    name: str
    artists: List[str]
    year: int
    popularity: int
    danceability: float
    energy: float
    valence: float

class TrackInfo(BaseModel):
    name: str
    artist: str
    preview_url: Optional[str]
    full_track_url: Optional[str]
    album_image: Optional[str]
    genre: Optional[str]
    album: Optional[str]

class RecommendationWithPreview(Recommendation):
    preview_info: Optional[TrackInfo] = None