from typing import Optional from apollo_messages_views.config import MESSAGE_PREFIX from apollo_messages_views.constants.base import Emoji from apollo_messages_views.constants.playlists import DspName from apollo_messages_views.utils.misc import get_artists_str, get_flag def get_playlist_entry_body( dsp: str, country_code: Optional[str], content: dict, unknown_flag_as: str = "", is_starred: bool = False ) -> str: playlist_name = content["playlist"]["name"] if is_starred: playlist_name = f"⭐ {playlist_name}" body = ( f"{Emoji.FIRE.value} {get_artists_str(content['track']['artists'])} - {content['track']['name']} " f"has been added to {playlist_name} at position {content['current_position']} on " f"{DspName[dsp]} {get_flag(country_code, unknown_as=unknown_flag_as)}" ) return MESSAGE_PREFIX + body def get_playlist_update_body( dsp: str, country_code: Optional[str], content: dict, unknown_flag_as: str = "", ) -> str: body = ( f"⭐ {content['playlist']['name']} tracklist has been updated on {DspName[dsp]} " f"{get_flag(country_code, unknown_as=unknown_flag_as)}" ) return MESSAGE_PREFIX + body def get_playlist_exit_body( dsp: str, country_code: Optional[str], content: dict, unknown_flag_as: str = "", is_starred: bool = False ) -> str: playlist_name = content["playlist"]["name"] if is_starred: playlist_name = f"⭐ {playlist_name}" body = ( f"{Emoji.EXCLAMATION_POINT.value} {get_artists_str(content['track']['artists'])} - {content['track']['name']} " f"has been removed from {playlist_name} at position {content['previous_position']} on " f"{DspName[dsp]} {get_flag(country_code, unknown_as=unknown_flag_as)}" ) return MESSAGE_PREFIX + body def get_playlist_major_move_body( dsp: str, country_code: Optional[str], content: dict, unknown_flag_as: str = "", is_starred: bool = False ) -> str: playlist_name = content["playlist"]["name"] if is_starred: playlist_name = f"⭐ {playlist_name}" current_position = content['current_position'] previous_position = content['previous_position'] moved_up = current_position < previous_position moved_positions = abs(current_position - previous_position) body = ( f"{Emoji.FIRE.value if moved_up else Emoji.EXCLAMATION_POINT.value} " f"{get_artists_str(content['track']['artists'])} - {content['track']['name']} " f"has moved {'up' if moved_up else 'down'} {moved_positions} spots on {playlist_name} to position " f"{current_position} on {DspName[dsp]} {get_flag(country_code, unknown_as=unknown_flag_as)}" ) return MESSAGE_PREFIX + body