from apollo_utils.core.utils.ext_enum import ExtEnum, extend_enum from server.constants import DSP class StreamsType(ExtEnum): """Types for streams returned with playlists.""" TRACK = "track" # track-in-playlist streams PLAYLIST = "playlist" # playlist streams @extend_enum(StreamsType) class StreamsTypeRequest(ExtEnum): """Types of streams that are allowed to request for playlists.""" PRIORITY = "priority" # mark the case when we'd like to get 'track' streams if there is at least one track with not zero streams # and 'playlist' streams otherwise. class PlaylistTracklistOrder: """Playlist placements order by values.""" ADDED_DATE = "added_date" CURR_POSITION = "current_position" ADDED_DATE_DESC = "-added_date" CURR_POSITION_DESC = "-current_position" ALL = (ADDED_DATE, ADDED_DATE_DESC, CURR_POSITION, CURR_POSITION_DESC) ZERO_TREND = 0 # trend value to return if previous position is undefined RECENT_ADDS_PERIOD = 7 # (days) period during which a track added to a playlist is considered recent. class NMFTrackOrder(ExtEnum): RANK = "top_market" POSITION = "position" CODE = "code" class NMFTrackInclude(ExtEnum): """Additional fields to include.""" TOP_PLAYLIST_IMAGE_URL = "top_playlist_image_url" REGIONS = "regions" INACTIVE_MARKETS = "inactive_markets" NMF_ALL_REGIONS_PLACEHOLDER = "all" NMF_REGIONS = ["af", "as", "an", "ce", "la", "me", "no", "na", "other", "uk", NMF_ALL_REGIONS_PLACEHOLDER] DEFAULT_IMAGE_SIZE = 640 ELASTICSEARCH_ESCAPING_CHARACTERS = [ "+", "-", "=", "&&", "||", ">", "<", "!", "(", ")", "{", "}", "[", "]", "^", '"', "~", "*", "?", ":", "\\", "/", ] class ElasticPlaylistsVendorsData: """Elasticsearch related data for playlists search functionality.""" DOC_TYPES = { DSP.APPLE: "applemusicplaylistindexitem", DSP.SPOTIFY: "playlistindexitem", DSP.AMAZON: "AmazonPlaylistIndexItem", } FACTOR_FIELDS = {DSP.APPLE: "streams56Days", DSP.SPOTIFY: "followers", DSP.AMAZON: "tracksNumber"} SORTING_FIELDS = {DSP.AMAZON: "dspPlaylistId"}