forked from Firehawk52-backup/Telegram-Odesli-Bot
Add files via upload
This commit is contained in:
36
TelegramBot/helpers/odesli/entity/song/Song.py
Normal file
36
TelegramBot/helpers/odesli/entity/song/Song.py
Normal 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
|
||||
25
TelegramBot/helpers/odesli/entity/song/SongResult.py
Normal file
25
TelegramBot/helpers/odesli/entity/song/SongResult.py
Normal 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))
|
||||
|
||||
Reference in New Issue
Block a user