Removing leading and trailing spaces in title/artist/album tags
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
- "signal not exposed" problem if a user logout and login again. bad resource destruction?
|
||||
[admin/DB]
|
||||
- Do not make the update start time field active when update perdiod is "Never"
|
||||
- refresh the audio/video view when the database directories have been updated
|
||||
[user/transcoding]
|
||||
- Prefered codecs for audio/video?
|
||||
|
||||
|
||||
@@ -99,11 +99,11 @@ AvFormat::parse(const boost::filesystem::path& p, Items& items)
|
||||
for (it = metadata.begin(); it != metadata.end(); ++it)
|
||||
{
|
||||
if (boost::iequals(it->first, "artist"))
|
||||
items.insert( std::make_pair(MetaData::Artist, string_to_utf8(it->second)) );
|
||||
items.insert( std::make_pair(MetaData::Artist, string_trim( string_to_utf8(it->second)) ));
|
||||
else if (boost::iequals(it->first, "album"))
|
||||
items.insert( std::make_pair(MetaData::Album, string_to_utf8(it->second) ));
|
||||
items.insert( std::make_pair(MetaData::Album, string_trim( string_to_utf8(it->second)) ));
|
||||
else if (boost::iequals(it->first, "title"))
|
||||
items.insert( std::make_pair(MetaData::Title, string_to_utf8(it->second) ));
|
||||
items.insert( std::make_pair(MetaData::Title, string_trim( string_to_utf8(it->second)) ));
|
||||
else if (boost::iequals(it->first, "track")) {
|
||||
std::size_t number;
|
||||
if (readAs<std::size_t>(it->second, number))
|
||||
|
||||
@@ -20,6 +20,23 @@ static inline bool readAs(const std::string& str, T& data)
|
||||
return iss >> data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::string
|
||||
static inline string_trim(const std::string& str,
|
||||
const std::string& whitespace = " \t")
|
||||
{
|
||||
const auto strBegin = str.find_first_not_of(whitespace);
|
||||
if (strBegin == std::string::npos)
|
||||
return ""; // no content
|
||||
|
||||
const auto strEnd = str.find_last_not_of(whitespace);
|
||||
const auto strRange = strEnd - strBegin + 1;
|
||||
|
||||
return str.substr(strBegin, strRange);
|
||||
}
|
||||
|
||||
|
||||
std::string
|
||||
static inline string_to_utf8(const std::string& str)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user