-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom attributes #1
Comments
Hi @iDevelopper ! Yes, there is a bug with #EXTINF attribute e.g.: struct EXTINF2: Decodable {
public let duration: Double
public let title: String
public let artist: String
public let url: String
}
struct Playlist: Decodable {
let extinf: [EXTINF2]
}
let m3u8 = """
#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:171115544
#EXTINF:10,title="The Ben Maller Show",artist="zc4732",url="song_spot=\"T\" spotInstanceId=\"-1\" length=\"04:00:00\" MediaBaseId=\"\" TAID=\"0\" TPID=\"0\" cartcutId=\"\" amgArtworkURL=\"https://storage.googleapis.com/portal-content.zettacloud.appspot.com/shows/cff92185-5e92-11ec-9478-8bbc72f158cb/logo\" spEventID=\"01f47968-ccac-11ee-a9cf-f50937f44113\" "
https://n0ab-e2.revma.ihrhls.com/zc4732/10_sz0pexjzvq8g02/main/171115542.aac
"""
let playlist = try! M3U8Decoder().decode(Playlist.self, from: m3u8)
print(playlist.extinf[0])
// Prints: EXTINF2(duration: 10.0, title: "The Ben Maller Show", artist: "zc4732", url: "song_spot=") But
And then you are able to parse this string value manually because the library parses coma-separated attributes on the top level only. Thanks for bug reporting. |
Okay, that's exactly what I tested and found. I'm not getting the full text for the url key. Thank you for your response. So are you going to fix the bug? |
Yes, the fix will be available in the next release version. |
Fixed in 1.2.0. Thanks. |
Hi @ikhvorost, Awesome! Thanks! Could you modify the regex attributes so that it also detects quotes (char code 39 "'"), perhaps like this:
Add it to the charSetQuotes:
Take this into account in the func convertType(text: String) -> Any
As I receive the url with some quotes (') (instead of ""): And expose the function parse(attributes: String, keyValues: inout [String : Any]) to be public. |
Thanks for this great decoder!
However, I'm looking for the best way to decode an m3u8 file like the one below, to recover all the attributes of EXTINF if they exist.
Thank you for your help.
The text was updated successfully, but these errors were encountered: