class Track:
    """The track gotten from Andesite.

    Attributes
    ----------
    id: :class:`str`
        Not the ID found in YouTube, use :attr:`.yt_id`
    data: :class:`dict`
    title: :class:`str`
    author: :class:`str`
    length: :class:`str`
        The length of the track in ``milliseconds``.
    uri: :class:`str`
    is_stream: :class:`bool`
        Whether the current track is a live stream.
    is_seekable: :class:`bool`
        Whether the current track can be seeked.
    position: :class:`int`
    """
    def __init__(self, _id, data: dict):
        self.id = _id
        self.data = data

        self.title = data.get("title")
        self.author = data.get("author")
        self.length = data.get("length")
        self.yt_id = data.get("identifier")
        self.uri = data.get("uri")
        self.is_stream = data.get("isStream")
        self.is_seekable = data.get("isSeekable")
        self.position = data.get("position")

    def __str__(self):
        return self.title


    def __repr__(self):
        return "<Track length={0.length} is_stream={0.is_stream}>".format(self)


class Playlist:
    """Similar to :class:`.Track`, but a playlist containing more tracks.

    Attributes
    ----------
    data: :class:`dict`
    name: :class:`str`
    tracks: List[:class:`.Track`]
    """
    def __init__(self, data: dict):
        self.data = data

        self.name = data['playlistInfo']['name']

        self.tracks = [Track(_id = track['track'], data = track['info']) for track in data['tracks']]


    def __str__(self):
        return self.name


    def __repr__(self):
        return "<Playlist name={0.name}>".format(self)
