crunchybagel / outcastid3 Goto Github PK
View Code? Open in Web Editor NEWA simple Swift library to read and write ID3 tags from MP3 files, as used in Outcast.
Home Page: https://outcast.app
License: MIT License
A simple Swift library to read and write ID3 tags from MP3 files, as used in Outcast.
Home Page: https://outcast.app
License: MIT License
Data+String.swift
in case when comment have encoding .utf8 and we looking for zero bytes end of string we must wait ONE zero byte not two
two zero bytes only for UTF16
// unicode strings are terminated by \0\0, while latin terminated by \0
your comment is wrong only utf16 strinds are termonated by \0\0
http://id3.org/id3v2.4.0-structure
Frames that allow different types of text encoding contains a text
encoding description byte. Possible encodings:
$00 ISO-8859-1 [ISO-8859-1]. Terminated with $00.
$01 UTF-16 [UTF-16] encoded Unicode [UNICODE] with BOM. All
strings in the same frame SHALL have the same byteorder.
Terminated with $00 00.
$02 UTF-16BE [UTF-16] encoded Unicode [UNICODE] without BOM.
Terminated with $00 00.
$03 UTF-8 [UTF-8] encoded Unicode [UNICODE]. Terminated with $00.
I'm having an interesting issue with the Transcription and Comment frames. When I write them using this code:
OutcastID3.Frame.CommentFrame(
encoding: .utf8, language: "eng",
commentDescription: "description",
comment: "Comment Test"),
OutcastID3.Frame.TranscriptionFrame(
encoding: .utf8, language: "eng",
lyricsDescription: "description",
lyrics: "Lyrics Test")
And run this test:
// ... test on StringFrame types
} else if let isolatedFrame = frame as? OutcastID3.Frame.CommentFrame {
XCTAssertEqual(isolatedFrame.language, "eng")
XCTAssertEqual(isolatedFrame.commentDescription, "description")
XCTAssertEqual(isolatedFrame.comment, "Comment Test")
} else if let isolatedFrame = frame as? OutcastID3.Frame.TranscriptionFrame {
XCTAssertEqual(isolatedFrame.language, "eng")
XCTAssertEqual(isolatedFrame.lyricsDescription, "description")
XCTAssertEqual(isolatedFrame.lyrics, "Lyrics Test")
}
This is the result I see:
And the reason I'm including that as a screenshot is because when I try to cut/paste the test of the error, my posts on GitHub get cut off, because this is the actual text:
and GitHub apparently doesn't like that extra character at the beginning.
I've tried every kind of encoding I can think of and none of them improve the result. And that doesn't explain why the content of the TranscriptionFrame is being written to the CommentFrame.
It also looks like OutcastID3 may be having an issue with adding characters to tags written by other writers. This is what happens when I try to read a file written using ID3TagEditor
with OutcastID3
:
for frame in outcastFrames {
if let isolatedFrame = frame as? OutcastID3.Frame.StringFrame {
if isolatedFrame.type == AudiobookTag.authors.outcastType {
XCTAssertEqual(isolatedFrame.str, "Artist")
print((isolatedFrame.str).unicodeScalars.map({ $0.value }))
print("Artist".unicodeScalars.map({ $0.value }))
}
}
}
let id3TagEditor = ID3TagEditor()
if let id3Tag = try id3TagEditor.read(from: Bundle.testMp3FullMeta.path) {
print((id3Tag.frames[.Artist] as? ID3FrameWithStringContent)?.content.unicodeScalars.map({ $0.value }))
}
^^^ this test gets me this result:
/OutcastID3Tests.swift:26: error: -[AudiobookTaggerTests.OutcastID3Tests testMP3AudiobookTag] :
XCTAssertEqual failed: ("Artist[X*]") is not equal to ("Artist")
[65, 114, 116, 105, 115, 116, 0]
[65, 114, 116, 105, 115, 116]
Optional([65, 114, 116, 105, 115, 116])
note*: X marks the extra character I removed so that the post wouldn't get cut off.
Can you also include .h file ,i.e. Objective C headers.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.