Skip to content

erengy/atf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

atf

atf is an implementation of the scripting language known as Advanced Title Formatting or Tagz. The language has been used by some popular applications such as Winamp, foobar2000, Mp3tag and MusicBrainz Picard.

Basically, it converts this:

[%artist% - ][%album% - ][$num(%track%,2) - ]$if2(%title%,$filepart(%filename%))

...to this:

Iron Maiden - Brave New World - 04 - Blood Brothers

Usage

(atf is currently not in a usable state.)

The library doesn't have any fields on its own. Applications have to override the EvaluateField virtual function in order to provide the data to corresponding fields:

std::string CustomAtf::EvaluateField(const std::string& field) const {
  const std::map<std::string, std::string> fields{
    {"artist", "Iron Maiden"},
    {"album", "Brave New World"},
    {"track", "4"},
    {"title", "Blood Brothers"},
  };

  auto it = fields.find(field);
  return it != fields.end() ? it.second : std::string();
}

The library does provide you with a basic set of functions such as if and len. You may override the EvaluateFunction virtual function according to your application's needs:

std::string CustomAtf::EvaluateFunction(
    const std::string& name, const std::vector<std::string>& params) const {
  std::string result;

  // $reverse(x)
  // Reverses the order of the characters in string x.
  if (name == "reverse" && params.size() == 1) {
    const auto& x = params.back();
    std::copy_backward(x.begin(), x.end(), result.end());
    return result;
  }

  return Atf::EvaluateFunction(name, params);
}

Documentation

License

atf is licensed under the MIT License.

About

Advanced title formatting (WIP)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages