本文整理汇总了C++中Album::setCoverFilepath方法的典型用法代码示例。如果您正苦于以下问题:C++ Album::setCoverFilepath方法的具体用法?C++ Album::setCoverFilepath怎么用?C++ Album::setCoverFilepath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Album
的用法示例。
在下文中一共展示了Album::setCoverFilepath方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tmp
vector<string> MusicVideoService::downloadAudio(const string& url) {
LOG(INFO) << "downloadYouTubeAudio with url " << url;
vector<string> filepaths;
boost::filesystem::path tmpPath(SoulSifterSettings::getInstance().get<string>("dir.tmp")); // todo: use os.tmpdir()
if (!boost::filesystem::exists(tmpPath)) {
if (!boost::filesystem::create_directories(tmpPath)) {
LOG(WARNING) << "Unable to create temporary directory " << tmpPath;
return filepaths;
}
} else if (!boost::filesystem::is_directory(tmpPath)) {
LOG(WARNING) << "Temporary directory is not a directory " << tmpPath;
return filepaths;
}
FILE *fpipe;
stringstream command;
command << "cd " << tmpPath << "; youtube-dl --print-json --write-all-thumbnails --restrict-filenames --extract-audio --audio-format mp3 --audio-quality 0 --quiet " << url;
if (!(fpipe = (FILE*)popen(command.str().c_str(), "r"))) {
LOG(WARNING) << "Problem with youtube-dl pipe.";
return filepaths;
}
char buffer[1024];
stringstream ss;
LOG(INFO) << "Running command '" << command.str() << "'";
while (fgets(buffer, sizeof buffer, fpipe)) {
ss << buffer;
}
pclose(fpipe);
// read output
string json;
while (std::getline(ss, json, '\n')) {
if (json.at(0) == '{') {
boost::property_tree::ptree ptree;
std::stringstream tmp(json);
read_json(tmp, ptree);
Song* song = new Song();
Album* album = new Album();
song->setAlbum(album);
string baseFileName = ptree.get<string>("_filename").substr(0, ptree.get<string>("_filename").size() - ptree.get<string>("ext").size());
song->setFilepath(SoulSifterSettings::getInstance().get<string>("dir.tmp") + '/' + baseFileName + "mp3");
album->setCoverFilepath(SoulSifterSettings::getInstance().get<string>("dir.tmp") + '/' + baseFileName + "jpg");
string title = ptree.get<string>("title");
if (!MusicManager::getInstance().splitArtistAndTitle(title, song)) {
song->setArtist(ptree.get<string>("uploader"));
song->setTitle(title);
}
MusicManager::getInstance().moveFeaturing(song);
MusicManager::getInstance().copyRemixer(song);
song->setLowQuality(true);
song->setCurator(ptree.get<string>("uploader"));
string date = ptree.get<string>("upload_date", "00000000");
if (!date.empty() && !!date.compare("null")) {
album->setReleaseDateYear(std::stoi(date.substr(0, 4)));
album->setReleaseDateMonth(std::stoi(date.substr(4, 2)));
album->setReleaseDateDay(std::stoi(date.substr(6, 4)));
}
album->setArtist(song->getArtist());
album->setName(song->getTitle());
TagService::writeId3v2Tag(song);
filepaths.push_back(song->getFilepath());
filepaths.push_back(album->getCoverFilepath());
delete song;
return filepaths;
}
}
return filepaths;
}