43 lines
1.9 KiB
Go
43 lines
1.9 KiB
Go
package interfaces
|
||
|
||
import (
|
||
"context"
|
||
|
||
"gitea.mrixs.me/Mrixs/yamusic-bot/internal/model"
|
||
)
|
||
|
||
// YandexMusicClient определяет методы для взаимодействия с API Yandex.Music.
|
||
type YandexMusicClient interface {
|
||
GetTrackInfo(ctx context.Context, trackID string) (*model.TrackInfo, error)
|
||
GetAlbumTrackInfos(ctx context.Context, albumID string) ([]*model.TrackInfo, error)
|
||
GetArtistTrackInfos(ctx context.Context, artistID string) ([]*model.TrackInfo, error)
|
||
GetDownloadURL(ctx context.Context, trackID string) (string, error)
|
||
}
|
||
|
||
// TrackStorage определяет методы для работы с постоянным кэшем.
|
||
type TrackStorage interface {
|
||
Get(ctx context.Context, yandexTrackID string) (telegramFileID string, err error)
|
||
Set(ctx context.Context, yandexTrackID, telegramFileID string) error
|
||
Count(ctx context.Context) (int, error)
|
||
Close() error
|
||
}
|
||
|
||
// TelegramClient определяет методы для взаимодействия с Telegram Bot API.
|
||
// Мы определяем свой интерфейс, чтобы не зависеть напрямую от библиотеки
|
||
// и упростить тестирование.
|
||
type TelegramClient interface {
|
||
SendAudioToCacheChannel(ctx context.Context, audioPath, title, performer string) (string, error)
|
||
AnswerInlineQuery(ctx context.Context, queryID string, results []interface{}) error
|
||
SendMessage(ctx context.Context, chatID int64, text string) error
|
||
}
|
||
|
||
// Tagger определяет методы для работы с метаданными аудиофайлов.
|
||
type Tagger interface {
|
||
WriteTags(filePath string, coverPath string, info *model.TrackInfo) error
|
||
}
|
||
|
||
// FileDownloader определяет метод для скачивания файла.
|
||
type FileDownloader interface {
|
||
Download(ctx context.Context, url string) (filePath string, err error)
|
||
}
|