Files
radiola-android/app/src/main/java/com/radiola/data/remote/RadiolaApi.kt
nk 69682268f3 feat(app): кнопка «Распознать трек» (Shazam) + история распознанных
- кнопка распознавания в плеере: видна только на музыкальных станциях без
  метаданных эфира (track == null), показывает спиннер и результат через Toast
- распознанный трек отображается в плеере и пишется в ОТДЕЛЬНУЮ историю
  распознанных (не дублируется в историю эфирных треков — гейт по ключу)
- экран Истории: переключатель «Треки эфира | Распознанные», два списка
- Room: таблица recognized_track (миграция 7→8), DAO/репозиторий
- ShazamRepository → POST /shazam/recognize/{stationId}, маппинг 503/400 в текст
- MusicGenres.isMusicStation — клиентский гейт (синхронизирован с бэкендом)
- bump backend submodule (модуль shazam)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-07 18:38:17 +03:00

91 lines
3.3 KiB
Kotlin

package com.radiola.data.remote
import com.radiola.data.remote.dto.AuthResponseDto
import com.radiola.data.remote.dto.BackendNowPlayingDto
import com.radiola.data.remote.dto.BackendStationDto
import com.radiola.data.remote.dto.ChartsResponseDto
import com.radiola.data.remote.dto.GenresResponseDto
import com.radiola.data.remote.dto.HistoryResponseDto
import com.radiola.data.remote.dto.MagicLinkRequestDto
import com.radiola.data.remote.dto.MagicLinkVerifyDto
import com.radiola.data.remote.dto.RecognizeResponseDto
import com.radiola.data.remote.dto.TrackStatsDto
import com.radiola.data.remote.dto.UserSettingsDto
import kotlinx.serialization.json.JsonObject
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.PATCH
import retrofit2.http.Path
import retrofit2.http.Query
interface RadiolaApi {
@POST("auth/magic-link")
suspend fun requestMagicLink(@Body dto: MagicLinkRequestDto): JsonObject
@POST("auth/verify")
suspend fun verifyMagicLink(@Body dto: MagicLinkVerifyDto): AuthResponseDto
@GET("now-playing")
suspend fun getNowPlaying(): List<BackendNowPlayingDto>
// Распознавание играющего трека через Shazam (бэкенд сам тянет аудио из потока).
@POST("shazam/recognize/{stationId}")
suspend fun recognizeTrack(@Path("stationId") stationId: Int): RecognizeResponseDto
// Сабмит обложки, найденной клиентом в iTunes (см. CoverEnrichmentManager).
@POST("covers/submit")
suspend fun submitCover(@Body dto: com.radiola.data.remote.dto.SubmitCoverDto): com.radiola.data.remote.dto.SubmitCoverResponse
// station_id оффлайн-станций — скрываем их в каталоге (мёртвые потоки)
@GET("stations/offline-ids")
suspend fun getOfflineStationIds(): List<Int>
@GET("users/me")
suspend fun getMe(): JsonObject
@GET("users/me/settings")
suspend fun getSettings(): UserSettingsDto
@PATCH("users/me/settings")
suspend fun updateSettings(@Body dto: UserSettingsDto): UserSettingsDto
@GET("users/me/favorites")
suspend fun getFavorites(): List<BackendStationDto>
@POST("users/me/favorites/{stationId}")
suspend fun addFavorite(@Path("stationId") stationId: String): JsonObject
@DELETE("users/me/favorites/{stationId}")
suspend fun removeFavorite(@Path("stationId") stationId: String): JsonObject
@GET("users/me/history")
suspend fun getHistory(): HistoryResponseDto
@POST("users/me/history/{stationId}")
suspend fun addHistory(@Path("stationId") stationId: String): JsonObject
// --- Чарты ---
@GET("charts/tracks")
suspend fun getCharts(
@Query("period") period: String,
@Query("limit") limit: Int = 100,
@Query("genre") genre: String? = null
): ChartsResponseDto
@GET("charts/genres")
suspend fun getGenres(): GenresResponseDto
@GET("charts/tracks/{trackId}")
suspend fun getTrackStats(@Path("trackId") trackId: String): TrackStatsDto
@POST("charts/tracks/{trackId}/like")
suspend fun likeTrack(@Path("trackId") trackId: String): JsonObject
@DELETE("charts/tracks/{trackId}/like")
suspend fun unlikeTrack(@Path("trackId") trackId: String): JsonObject
}