-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from bilaalrashid/bilaal/portrait-videos
Fix schema for video portraits
- Loading branch information
Showing
7 changed files
with
192 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// FailableCodable.swift | ||
// BbcNews | ||
// | ||
// Created by Bilaal Rashid on 08/07/2024. | ||
// | ||
|
||
import Foundation | ||
|
||
/// A property wrapper that decodes an empty value as nil. | ||
@propertyWrapper | ||
public struct FailableCodable<Wrapped>: Codable, Equatable, Hashable where Wrapped: Codable, Wrapped: Equatable, Wrapped: Hashable { | ||
/// The wrapped value of the property wrapper. | ||
public var wrappedValue: Wrapped? | ||
|
||
/// Creates a new `FailableCodable` property wrapper. | ||
/// | ||
/// - Parameter wrappedValue: The raw value to be wrapped. | ||
public init(wrappedValue: Wrapped?) { | ||
self.wrappedValue = wrappedValue | ||
} | ||
|
||
public init(from decoder: Decoder) throws { | ||
let container = try decoder.singleValueContainer() | ||
self.wrappedValue = try? container.decode(Wrapped.self) | ||
} | ||
|
||
public func encode(to encoder: Encoder) throws { | ||
var container = encoder.singleValueContainer() | ||
try container.encode(self.wrappedValue) | ||
} | ||
} | ||
|
||
extension KeyedDecodingContainer { | ||
func decode<Wrapped: Codable>(_ type: FailableCodable<Wrapped>.Type, forKey key: K) throws -> FailableCodable<Wrapped> { | ||
if let value = try self.decodeIfPresent(type, forKey: key) { | ||
return value | ||
} | ||
|
||
return FailableCodable(wrappedValue: nil) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
{ | ||
"data": { | ||
"metadata": { | ||
"name": "Cornwall ice cream van whipped out to sea", | ||
"allowAdvertising": true, | ||
"lastUpdated": 1720457899000 | ||
}, | ||
"items": [ | ||
{ | ||
"id": "urn:bbc:pips:pid:p0j950j4", | ||
"url": "", | ||
"text": "Cornwall ice cream van whipped out to sea", | ||
"media": { | ||
"source": { | ||
"id": "p0j950j8", | ||
"type": "VIDEO", | ||
"isLive": false, | ||
"canAutoPlay": true, | ||
"duration": 0, | ||
"aspectRatio": 1.7777777777777777, | ||
"episodePid": "p0j950j4" | ||
}, | ||
"metadata": { | ||
"title": "Cornwall ice cream van whipped out to sea", | ||
"summary": "Cornwall ice cream van whipped out to sea", | ||
"caption": "Cornwall ice cream van whipped out to sea", | ||
"timestamp": 1720457899000, | ||
"guidanceMessage": "", | ||
"associatedContentUrl": "", | ||
"allowAdvertising": true | ||
}, | ||
"image": { | ||
"source": { | ||
"url": "https://ichef.bbci.co.uk/images/ic/{width}xn/p0j9519n.jpg", | ||
"sizingMethod": { | ||
"type": "SPECIFIC_WIDTHS", | ||
"widthToken": "{width}", | ||
"widths": [ | ||
80, | ||
128, | ||
160, | ||
240, | ||
288, | ||
320, | ||
400, | ||
432, | ||
480, | ||
512, | ||
576, | ||
640, | ||
720, | ||
768, | ||
800, | ||
960, | ||
1024, | ||
1136, | ||
1152, | ||
1200, | ||
1280, | ||
1440, | ||
1536, | ||
1600, | ||
1920 | ||
] | ||
} | ||
}, | ||
"metadata": { | ||
"altText": "Yellow ice cream van sits in the waves as people look on" | ||
}, | ||
"type": "Image" | ||
}, | ||
"type": "Media" | ||
}, | ||
"subtext": "", | ||
"image": { | ||
"source": { | ||
"url": "https://ichef.bbci.co.uk/images/ic/{width}xn/p0j9519n.jpg", | ||
"sizingMethod": { | ||
"type": "SPECIFIC_WIDTHS", | ||
"widthToken": "{width}", | ||
"widths": [ | ||
80, | ||
128, | ||
160, | ||
240, | ||
288, | ||
320, | ||
400, | ||
432, | ||
480, | ||
512, | ||
576, | ||
640, | ||
720, | ||
768, | ||
800, | ||
960, | ||
1024, | ||
1136, | ||
1152, | ||
1200, | ||
1280, | ||
1440, | ||
1536, | ||
1600, | ||
1920 | ||
] | ||
} | ||
}, | ||
"metadata": { | ||
"altText": "Yellow ice cream van sits in the waves as people look on" | ||
}, | ||
"type": "Image" | ||
}, | ||
"type": "VideoPortraitStory" | ||
} | ||
], | ||
"trackers": [], | ||
"type": "ContentResponse" | ||
}, | ||
"contentType": "application/json; charset=utf-8" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters