Add files via upload

This commit is contained in:
suhail-c
2024-04-26 17:22:01 +05:30
committed by GitHub
parent 820267f22b
commit 5272338e91
2 changed files with 61 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
from __future__ import annotations
from ..Entity import Entity
"""
Represents a song for one provider.
id: Id of the song that's used by the provider.
provider: The provider.
title: The title of the song.
artistName: The name of the artistName of this song.
thumbnailUrl: The thumbnail url of the song.
thumbnailWidth: The width of the thumbnail of the song.
thumbnailHeight: The height of the thumbnail of the song.
linksByPlatform: Dictionary, mapping platforms to links to this song.
Note that Platform != Provider. There is the provider youtube
with the two platforms youtube and youtubeMusic.
"""
class Song(Entity):
def __init__(self, id, provider, title, artistName, thumbnailUrl, thumbnailWidth,
thumbnailHeight, linksByPlatform):
super().__init__(id, provider, title, artistName, thumbnailUrl, thumbnailWidth,
thumbnailHeight, linksByPlatform)
def getType(self):
return 'song'
@staticmethod
def parse(rawSongEntity, linksByPlatform) -> Song:
return Song(*Entity.parse(rawSongEntity, linksByPlatform))
def __eq__(self, o):
if isinstance(o, Song):
return super().__eq__(o)
return False

View File

@@ -0,0 +1,25 @@
from __future__ import annotations
from ..EntityResult import EntityResult
from .Song import Song
"""
Represents the result when a song was requested.
songLink: Odesli song page url.
song: Instance of Song. Provides title, artist, etc.
Represents the song corresponding to the provider
that was used for querying.
songsByProvider: Dictionary, mapping providers to the corresponding
songs (The attribute song is included in this dictionary).
"""
class SongResult(EntityResult):
def __init__(self, songLink, song, songsByProvider):
self.songLink = songLink
self.song = song
self.songsByProvider = songsByProvider
@staticmethod
def parse(result) -> SongResult:
return SongResult(*super(SongResult, SongResult).parse(result, Song))