TagCleaner is a Swift package that provides a robust solution for cleaning and standardizing music metadata tags. It offers a set of filters to remove common extraneous information from song titles, album names, and other music-related text.
- Multiple built-in filters for common tag cleaning tasks
- Customizable filter application
- Easy to use API
- Support for iOS, macOS, watchOS, and tvOS
TagCleaner is inspired by and based on the work of Web Scrobbler's metadata-filter. It's essentially a Swift port of this JavaScript library, adapted for use in Apple's ecosystem.
TagCleaner uses a combination of RegexBuilder patterns and Swift's string manipulation capabilities to clean music metadata. It includes filters for:
- Explicit/Clean labels
- Featured artists
- Remastered versions
- Reissues
- Remixes
- Singles and EPs
- Bonus tracks
- Live recordings
- Parodies
- Version information
- YouTube-specific tags
- And more!
- In Xcode, select "File" → "Swift Packages" → "Add Package Dependency"
- Enter the repository URL:
https://github.com/yourusername/TagCleaner.git
- Select the version you want to use
Alternatively, you can add it to your Package.swift
file:
dependencies: [
.package(url: "https://github.com/yourusername/TagCleaner.git", from: "1.0.0")
]
Here's a basic example of how to use TagCleaner:
import TagCleaner
let cleaner = TagCleaner()
let cleanedTitle = cleaner.apply("Song Title (Remastered 2021) [feat. Another Artist]", filter: FilterDirectory.releaseInformation)
print(cleanedTitle) // Outputs: "Song Title"
You can also use the @TCFilteredString
property wrapper for automatic cleaning:
struct Song {
@TCFilteredString(filters:
FilterDirectory.releaseInformation.remaster,
FilterDirectory.artistInformation.featuredArtists
)
var title: String = ""
}
let song = Song(title: "Song Title (Remastered 2021) [feat. Another Artist]")
print(song.title) // Outputs: "Song Title"
- iOS 16.0+
- macOS 13.0+
- watchOS 9.0+
- tvOS 16.0+
- Swift 5.7+
TagCleaner is released under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.