Giter Club home page Giter Club logo

outcastid3's Introduction

OutcastID3

A lightweight Swift library for reading and writing ID3 tags, including chapters.

Swift Package Manager

To install via SPM, add the URL https://github.com/CrunchyBagel/OutcastID3 to your project.

CocoaPods

https://cocoapods.org/pods/OutcastID3

Version License Platform

To install via CocoaPods, add the following line to your Podfile:

pod 'OutcastID3'

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Read an ID3 tag:

let url = Bundle.main.url(forResource: "MyFile", withExtension: "mp3")!

let mp3 = try MP3File(localUrl: url)
let tag = try x.readID3Tag()

let version = tag.tag.version

for frame in tag.tag.frames {
    switch frame {
    case let s as OutcastID3.Frame.StringFrame:
        print("\(s.type.description): \(s.str)")
        
    case let u as OutcastID3.Frame.UrlFrame:
        print("\(u.type.description): \(u.urlString)")

    case let comment as OutcastID3.Frame.CommentFrame:
        print("COMMENT: \(comment)")
        
    case let transcription as OutcastID3.Frame.TranscriptionFrame:
        print("TRANSCRIPTION: \(transcription)")
        
    case let picture as OutcastID3.Frame.PictureFrame:
        print("PICTURE: \(picture)")

    case let f as OutcastID3.Frame.ChapterFrame:
        print("CHAPTER: \(f)")
        
    case let toc as OutcastID3.Frame.TableOfContentsFrame:
        print("TOC: \(toc)")
        
    case let rawFrame as OutcastID3.Frame.RawFrame:
        print("Unrecognised frame: \(String(describing: rawFrame.frameIdentifier))")

    default:
        break
    }
}

Write an ID3 tag:

let frames: [OutcastID3TagFrame] = [
    OutcastID3.Frame.StringFrame(type: .title, encoding: .utf8, str: "Tag Writer Test")
]

let tag = OutcastID3.ID3Tag(
    version: .v2_4,
    frames: frames
)

let inputUrl = Bundle.main.url(forResource: "input", withExtension: "mp3")!

let outputUrl = Bundle.main.url(forResource: "output", withExtension: "mp3")!

let mp3File = try OutcastID3.MP3File(localUrl: inputUrl)

try mp3File.writeID3Tag(tag: tag, outputUrl: outputUrl)

Author

Crunchy Bagel, [email protected]

License

OutcastID3 is available under the MIT license. See the LICENSE file for more info.

outcastid3's People

Contributors

hendx avatar marcelmendesfilho avatar michaeljberk avatar ncrusher74 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.