From b66086ea1072fb2bc1da1a0a4512fabdccbf0aa4 Mon Sep 17 00:00:00 2001 From: suhail-c <106970070+suhail-c@users.noreply.github.com> Date: Fri, 26 Apr 2024 17:20:31 +0530 Subject: [PATCH] Add files via upload --- .../helpers/odesli/entity/album/Album.py | 36 +++++++++++++++++++ .../odesli/entity/album/AlbumResult.py | 25 +++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 TelegramBot/helpers/odesli/entity/album/Album.py create mode 100644 TelegramBot/helpers/odesli/entity/album/AlbumResult.py diff --git a/TelegramBot/helpers/odesli/entity/album/Album.py b/TelegramBot/helpers/odesli/entity/album/Album.py new file mode 100644 index 0000000..62592bf --- /dev/null +++ b/TelegramBot/helpers/odesli/entity/album/Album.py @@ -0,0 +1,36 @@ +from __future__ import annotations + +from ..Entity import Entity + +""" +Represents a album for one provider. + +id: Id of the album that's used by the provider. +provider: The provider. +title: The title of the album. +artistName: The name of the artistName of this album. +thumbnailUrl: The thumbnail url of the album. +thumbnailWidth: The width of the thumbnail of the album. +thumbnailHeight: The height of the thumbnail of the album. +linksByPlatform: Dictionary, mapping platforms to links to this album. + Note that Platform != Provider. There is the provider youtube + with the two platforms youtube and youtubeMusic. + +""" +class Album(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 'album' + + @staticmethod + def parse(rawAlbumEntity, linksByPlatform) -> Album: + return Album(*Entity.parse(rawAlbumEntity, linksByPlatform)) + + def __eq__(self, o): + if isinstance(o, Album): + return super().__eq__(o) + return False diff --git a/TelegramBot/helpers/odesli/entity/album/AlbumResult.py b/TelegramBot/helpers/odesli/entity/album/AlbumResult.py new file mode 100644 index 0000000..986a56d --- /dev/null +++ b/TelegramBot/helpers/odesli/entity/album/AlbumResult.py @@ -0,0 +1,25 @@ +from __future__ import annotations + +from ..EntityResult import EntityResult +from .Album import Album + +""" +Represents the result when a album was requested. + +albumLink: Odesli album page url. +album: Instance of Album. Provides title, artist, etc. + Represents the album corresponding to the provider + that was used for querying. +albumsByProvider: Dictionary, mapping providers to the corresponding + albums (The attribute album is included in this dictionary). +""" +class AlbumResult(EntityResult): + def __init__(self, albumLink, album, albumsByProvider): + self.albumLink = albumLink + self.album = album + self.albumsByProvider = albumsByProvider + + @staticmethod + def parse(result) -> AlbumResult: + return AlbumResult(*super(AlbumResult, AlbumResult).parse(result, Album)) +