Add audio.album_cover.

This commit is contained in:
levlam 2022-07-28 17:11:51 +03:00
parent 90df870adb
commit fac6b73999
5 changed files with 17 additions and 7 deletions

View File

@ -292,8 +292,9 @@ animation duration:int32 width:int32 height:int32 file_name:string mime_type:str
//@description Describes an audio file. Audio is usually in MP3 or M4A format @duration Duration of the audio, in seconds; as defined by the sender @title Title of the audio; as defined by the sender @performer Performer of the audio; as defined by the sender
//@file_name Original name of the file; as defined by the sender @mime_type The MIME type of the file; as defined by the sender @album_cover_minithumbnail The minithumbnail of the album cover; may be null
//@album_cover_thumbnail The thumbnail of the album cover in JPEG format; as defined by the sender. The full size thumbnail is supposed to be extracted from the downloaded file; may be null @audio File containing the audio
audio duration:int32 title:string performer:string file_name:string mime_type:string album_cover_minithumbnail:minithumbnail album_cover_thumbnail:thumbnail audio:file = Audio;
//@album_cover_thumbnail The thumbnail of the album cover in JPEG format; as defined by the sender. The full size thumbnail is supposed to be extracted from the downloaded audio file; may be null
//@album_cover Album cover to use if the downloaded audio file have no album cover; may be null. Downloading of this file is expected to fail if album cover is unknown @audio File containing the audio
audio duration:int32 title:string performer:string file_name:string mime_type:string album_cover_minithumbnail:minithumbnail album_cover_thumbnail:thumbnail album_cover:file audio:file = Audio;
//@description Describes a document of any type @file_name Original name of the file; as defined by the sender @mime_type MIME type of the file; as defined by the sender
//@minithumbnail Document minithumbnail; may be null @thumbnail Document thumbnail in JPEG or PNG format (PNG will be used only for background patterns); as defined by the sender; may be null @document File containing the document

View File

@ -45,10 +45,18 @@ tl_object_ptr<td_api::audio> AudiosManager::get_audio_object(FileId file_id) con
CHECK(it != audios_.end());
auto audio = it->second.get();
CHECK(audio != nullptr);
td_api::object_ptr<td_api::file> album_cover_file;
if (!td_->auth_manager_->is_bot()) {
auto r_file_id = td_->file_manager_->get_audio_thumbnail_file_id(audio->title, audio->performer, DialogId());
if (r_file_id.is_ok()) {
album_cover_file = td_->file_manager_->get_file_object(r_file_id.move_as_ok());
}
}
return make_tl_object<td_api::audio>(
audio->duration, audio->title, audio->performer, audio->file_name, audio->mime_type,
get_minithumbnail_object(audio->minithumbnail),
get_thumbnail_object(td_->file_manager_.get(), audio->thumbnail, PhotoFormat::Jpeg),
get_thumbnail_object(td_->file_manager_.get(), audio->thumbnail, PhotoFormat::Jpeg), std::move(album_cover_file),
td_->file_manager_->get_file_object(file_id));
}

View File

@ -1245,7 +1245,7 @@ template <>
tl_object_ptr<td_api::audio> copy(const td_api::audio &obj) {
return td_api::make_object<td_api::audio>(obj.duration_, obj.title_, obj.performer_, obj.file_name_, obj.mime_type_,
copy(obj.album_cover_minithumbnail_), copy(obj.album_cover_thumbnail_),
copy(obj.audio_));
copy(obj.album_cover_), copy(obj.audio_));
}
template <>

View File

@ -160,10 +160,11 @@ class WebFileDownloadGenerateActor final : public FileGenerateActor {
return Status::Error("Title or performer must be non-empty");
}
file_name_ = PSTRING() << "music_thumbnail_" << parts[3] << " - " << parts[2] << ".jpg";
file_name_ = PSTRING() << "Album cover for " << parts[3] << " - " << parts[2] << ".jpg";
auto flags = telegram_api::inputWebFileAudioAlbumThumbLocation::TITLE_MASK;
return make_tl_object<telegram_api::inputWebFileAudioAlbumThumbLocation>(flags, nullptr, parts[2].str(), parts[3].str());
return make_tl_object<telegram_api::inputWebFileAudioAlbumThumbLocation>(flags, nullptr, parts[2].str(),
parts[3].str());
}
if (parts.size() != 9 || parts[1] != "map") {

View File

@ -988,7 +988,7 @@ Status FileManager::check_local_location(FullLocalFileLocation &location, int64
};
if ((location.file_type_ == FileType::Thumbnail || location.file_type_ == FileType::EncryptedThumbnail) &&
size > MAX_THUMBNAIL_SIZE && !begins_with(PathView(location.path_).file_name(), "map") &&
!begins_with(PathView(location.path_).file_name(), "music_thumbnail")) {
!begins_with(PathView(location.path_).file_name(), "Album cover for ")) {
return get_file_size_error(" for a thumbnail");
}
if (size > MAX_FILE_SIZE) {