diff --git a/Frameworks/Account/Account.xcodeproj/project.pbxproj b/Frameworks/Account/Account.xcodeproj/project.pbxproj index c3ba67d5b..730b7be66 100644 --- a/Frameworks/Account/Account.xcodeproj/project.pbxproj +++ b/Frameworks/Account/Account.xcodeproj/project.pbxproj @@ -52,6 +52,8 @@ 5133BB4D2460CA0B0001E3D0 /* RedditMe.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5133BB4C2460CA0B0001E3D0 /* RedditMe.swift */; }; 5133BB4F2460EC230001E3D0 /* RedditMedia.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5133BB4E2460EC230001E3D0 /* RedditMedia.swift */; }; 5133BB512460EE730001E3D0 /* RedditMediaEmbed.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5133BB502460EE730001E3D0 /* RedditMediaEmbed.swift */; }; + 5138B4CA24CF85050018089B /* RedditMediaMetadata.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5138B4C924CF85050018089B /* RedditMediaMetadata.swift */; }; + 5138B4CC24CF877A0018089B /* RedditGalleryData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5138B4CB24CF877A0018089B /* RedditGalleryData.swift */; }; 5139A6382459822D004D960C /* CloudKitArticleStatusUpdate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5139A6372459822D004D960C /* CloudKitArticleStatusUpdate.swift */; }; 5141000A2464DAA6001DA326 /* RedditSort.swift in Sources */ = {isa = PBXBuildFile; fileRef = 514100092464DAA6001DA326 /* RedditSort.swift */; }; 5144EA49227B497600D19003 /* FeedbinAPICaller.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5144EA48227B497600D19003 /* FeedbinAPICaller.swift */; }; @@ -316,6 +318,8 @@ 5133BB4C2460CA0B0001E3D0 /* RedditMe.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RedditMe.swift; sourceTree = ""; }; 5133BB4E2460EC230001E3D0 /* RedditMedia.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RedditMedia.swift; sourceTree = ""; }; 5133BB502460EE730001E3D0 /* RedditMediaEmbed.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RedditMediaEmbed.swift; sourceTree = ""; }; + 5138B4C924CF85050018089B /* RedditMediaMetadata.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RedditMediaMetadata.swift; sourceTree = ""; }; + 5138B4CB24CF877A0018089B /* RedditGalleryData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RedditGalleryData.swift; sourceTree = ""; }; 5139A6372459822D004D960C /* CloudKitArticleStatusUpdate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CloudKitArticleStatusUpdate.swift; sourceTree = ""; }; 514100092464DAA6001DA326 /* RedditSort.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RedditSort.swift; sourceTree = ""; }; 5144EA48227B497600D19003 /* FeedbinAPICaller.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedbinAPICaller.swift; sourceTree = ""; }; @@ -649,11 +653,13 @@ isa = PBXGroup; children = ( 5193CD53245E3F7A0092735E /* RedditFeedProvider.swift */, + 5138B4CB24CF877A0018089B /* RedditGalleryData.swift */, 5133BB48246078910001E3D0 /* RedditLink.swift */, 5133BB46245FD8140001E3D0 /* RedditLinkListing.swift */, 5133BB4C2460CA0B0001E3D0 /* RedditMe.swift */, 5133BB4E2460EC230001E3D0 /* RedditMedia.swift */, 5133BB502460EE730001E3D0 /* RedditMediaEmbed.swift */, + 5138B4C924CF85050018089B /* RedditMediaMetadata.swift */, 5100E4CC246243990010A63D /* RedditPreview.swift */, 514100092464DAA6001DA326 /* RedditSort.swift */, 5133BB4A2460BDF30001E3D0 /* RedditSubreddit.swift */, @@ -1187,6 +1193,7 @@ 51F6C591245DB302001E41CA /* CloudKitReceiveStatusOperation.swift in Sources */, 9E672394236F7CA0000BE141 /* FeedlyRefreshAccessTokenOperation.swift in Sources */, 1748B4A724CADA17008F9850 /* AccountSyncError.swift in Sources */, + 5138B4CA24CF85050018089B /* RedditMediaMetadata.swift in Sources */, 514BF5202391B0DB00902FE8 /* SingleArticleFetcher.swift in Sources */, 9EC688EC232C583300A8D0A2 /* FeedlyAccountDelegate+OAuth.swift in Sources */, 8469F81C1F6DD15E0084783E /* Account.swift in Sources */, @@ -1256,6 +1263,7 @@ 9EF1B10323584B4C000A486A /* FeedlySyncStreamContentsOperation.swift in Sources */, 5154367B228EEB28005E1CDF /* FeedbinImportResult.swift in Sources */, 84B2D4D02238CD8A00498ADA /* WebFeedMetadata.swift in Sources */, + 5138B4CC24CF877A0018089B /* RedditGalleryData.swift in Sources */, 9E84DC472359A23200D6E809 /* FeedlyIngestUnreadArticleIdsOperation.swift in Sources */, 9EAEC624233315F60085D7C9 /* FeedlyEntry.swift in Sources */, 9EEAE073235D01AE00E3FEE4 /* FeedlyGetStreamIdsService.swift in Sources */, diff --git a/Frameworks/Account/FeedProvider/Reddit/RedditGalleryData.swift b/Frameworks/Account/FeedProvider/Reddit/RedditGalleryData.swift new file mode 100644 index 000000000..821b88c80 --- /dev/null +++ b/Frameworks/Account/FeedProvider/Reddit/RedditGalleryData.swift @@ -0,0 +1,29 @@ +// +// RedditGalleryData.swift +// Account +// +// Created by Maurice Parker on 7/27/20. +// Copyright © 2020 Ranchero Software, LLC. All rights reserved. +// + +import Foundation + +struct RedditGalleryData: Codable { + + let items: [RedditGalleryDataItem]? + + enum CodingKeys: String, CodingKey { + case items = "items" + } + +} + +struct RedditGalleryDataItem: Codable { + + let mediaID: String? + + enum CodingKeys: String, CodingKey { + case mediaID = "media_id" + } + +} diff --git a/Frameworks/Account/FeedProvider/Reddit/RedditLink.swift b/Frameworks/Account/FeedProvider/Reddit/RedditLink.swift index 65378b311..e7113960c 100644 --- a/Frameworks/Account/FeedProvider/Reddit/RedditLink.swift +++ b/Frameworks/Account/FeedProvider/Reddit/RedditLink.swift @@ -37,6 +37,8 @@ final class RedditLinkData: Codable { let mediaEmbed: RedditMediaEmbed? let preview: RedditPreview? let crossPostParents: [RedditLinkData]? + let galleryData: RedditGalleryData? + let mediaMetadata: [String: RedditMediaMetadata]? enum CodingKeys: String, CodingKey { case title = "title" @@ -54,6 +56,8 @@ final class RedditLinkData: Codable { case mediaEmbed = "media_embed" case preview = "preview" case crossPostParents = "crosspost_parent_list" + case galleryData = "gallery_data" + case mediaMetadata = "media_metadata" } var createdDate: Date? { @@ -139,6 +143,21 @@ final class RedditLinkData: Codable { return html } + if let galleryDataItems = galleryData?.items, let mediaMetadata = mediaMetadata { + var html = "" + for item in galleryDataItems { + if let mediaID = item.mediaID, let itemMetadata = mediaMetadata[mediaID], let imageURL = itemMetadata.image?.url { + html += "