From 006f0ec4936bf0f5e9d1e76e32ae3724f363af06 Mon Sep 17 00:00:00 2001 From: emin Date: Fri, 12 Aug 2022 20:27:02 +0200 Subject: [PATCH 1/4] add contentMediaType for variants object --- Sources/Types+Media.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Sources/Types+Media.swift b/Sources/Types+Media.swift index 2c90339..00fc7f9 100644 --- a/Sources/Types+Media.swift +++ b/Sources/Types+Media.swift @@ -66,6 +66,15 @@ public enum MediaType: String, Codable, RawRepresentable { #endif } +/// Media type specific to `variants` object +public enum ContentMediaType: String, Codable, RawRepresentable { + /// Mpeg media type + case mpeg = "application/x-mpegURL" + + /// MP4 video media type. Gif media falls into this case too. + case video = "video/mp4" +} + extension Media { public struct Metrics: Codable { /// The number of viewers who watched beyond 0% of the video duration From 0d4c3a797a07552e2b0d0b9ff016b301b4f44c9b Mon Sep 17 00:00:00 2001 From: emin Date: Fri, 12 Aug 2022 20:30:02 +0200 Subject: [PATCH 2/4] Assign contentMediaType to the appropriate variant property --- Sources/Types+Media.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Types+Media.swift b/Sources/Types+Media.swift index 00fc7f9..3a3b581 100644 --- a/Sources/Types+Media.swift +++ b/Sources/Types+Media.swift @@ -104,7 +104,7 @@ extension Media { public var bitRate: Int? /// Type of media - public var contentType: MediaType + public var contentType: ContentMediaType /// URL to the media content public var url: String From 91e556d2ac45481f4a5df00c9f27704d7b2cb53e Mon Sep 17 00:00:00 2001 From: emin Date: Sun, 14 Aug 2022 20:20:03 +0200 Subject: [PATCH 3/4] change content type to conform to UTType --- Sources/Types+Media.swift | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/Sources/Types+Media.swift b/Sources/Types+Media.swift index 3a3b581..f10ac86 100644 --- a/Sources/Types+Media.swift +++ b/Sources/Types+Media.swift @@ -1,4 +1,5 @@ import Foundation +import UniformTypeIdentifiers /// Media refers to any image, GIF, or video attached to a Tweet. The media object is not a primary object on any endpoint, but can be found and expanded in the Tweet object. public struct Media: Codable, Identifiable { @@ -66,15 +67,6 @@ public enum MediaType: String, Codable, RawRepresentable { #endif } -/// Media type specific to `variants` object -public enum ContentMediaType: String, Codable, RawRepresentable { - /// Mpeg media type - case mpeg = "application/x-mpegURL" - - /// MP4 video media type. Gif media falls into this case too. - case video = "video/mp4" -} - extension Media { public struct Metrics: Codable { /// The number of viewers who watched beyond 0% of the video duration @@ -104,7 +96,7 @@ extension Media { public var bitRate: Int? /// Type of media - public var contentType: ContentMediaType + public var contentType: UTType /// URL to the media content public var url: String From b8760c66ed79b9f6c7dc69851c87fead9a8ee599 Mon Sep 17 00:00:00 2001 From: Daniel Eden Date: Mon, 15 Aug 2022 13:54:18 +0100 Subject: [PATCH 4/4] Apply suggestions from code review --- Sources/Types+Media.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sources/Types+Media.swift b/Sources/Types+Media.swift index f10ac86..27b5fda 100644 --- a/Sources/Types+Media.swift +++ b/Sources/Types+Media.swift @@ -1,5 +1,4 @@ import Foundation -import UniformTypeIdentifiers /// Media refers to any image, GIF, or video attached to a Tweet. The media object is not a primary object on any endpoint, but can be found and expanded in the Tweet object. public struct Media: Codable, Identifiable { @@ -96,7 +95,7 @@ extension Media { public var bitRate: Int? /// Type of media - public var contentType: UTType + public var contentType: String /// URL to the media content public var url: String