From ceb0a0c423ae6f1de17b9d2ee12d75b3798fd33d Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Tue, 5 May 2020 20:17:46 -0500 Subject: [PATCH] Add image previews and size to videos. --- .../Account/Account.xcodeproj/project.pbxproj | 4 ++ .../FeedProvider/Reddit/RedditLink.swift | 16 ++++++- .../FeedProvider/Reddit/RedditMedia.swift | 6 ++- .../FeedProvider/Reddit/RedditPreview.swift | 43 +++++++++++++++++++ 4 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 Frameworks/Account/FeedProvider/Reddit/RedditPreview.swift diff --git a/Frameworks/Account/Account.xcodeproj/project.pbxproj b/Frameworks/Account/Account.xcodeproj/project.pbxproj index 0faca32c2..d895ccfdf 100644 --- a/Frameworks/Account/Account.xcodeproj/project.pbxproj +++ b/Frameworks/Account/Account.xcodeproj/project.pbxproj @@ -27,6 +27,7 @@ 3B826DAE2385C81C00FC1ADB /* FeedWranglerSubscriptionsRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3B826DA52385C81C00FC1ADB /* FeedWranglerSubscriptionsRequest.swift */; }; 3B826DAF2385C81C00FC1ADB /* FeedWranglerGenericResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3B826DA62385C81C00FC1ADB /* FeedWranglerGenericResult.swift */; }; 3BC23AB92385ECB100371CBA /* FeedWranglerSubscriptionResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3BC23AB82385ECB100371CBA /* FeedWranglerSubscriptionResult.swift */; }; + 5100E4CD246243990010A63D /* RedditPreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5100E4CC246243990010A63D /* RedditPreview.swift */; }; 5102FD80244009E000534F17 /* Secrets.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5102FD7F244009E000534F17 /* Secrets.framework */; }; 5103A9D92422546800410853 /* CloudKitAccountDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5103A9D82422546800410853 /* CloudKitAccountDelegate.swift */; }; 5107A09B227DE49500C7C3C5 /* TestAccountManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5107A09A227DE49500C7C3C5 /* TestAccountManager.swift */; }; @@ -285,6 +286,7 @@ 3B826DA52385C81C00FC1ADB /* FeedWranglerSubscriptionsRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedWranglerSubscriptionsRequest.swift; sourceTree = ""; }; 3B826DA62385C81C00FC1ADB /* FeedWranglerGenericResult.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedWranglerGenericResult.swift; sourceTree = ""; }; 3BC23AB82385ECB100371CBA /* FeedWranglerSubscriptionResult.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedWranglerSubscriptionResult.swift; sourceTree = ""; }; + 5100E4CC246243990010A63D /* RedditPreview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RedditPreview.swift; sourceTree = ""; }; 5102FD7F244009E000534F17 /* Secrets.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Secrets.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 5103A9D82422546800410853 /* CloudKitAccountDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CloudKitAccountDelegate.swift; sourceTree = ""; }; 5107A098227DE42E00C7C3C5 /* AccountCredentialsTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountCredentialsTest.swift; sourceTree = ""; }; @@ -648,6 +650,7 @@ 5133BB4C2460CA0B0001E3D0 /* RedditMe.swift */, 5133BB4E2460EC230001E3D0 /* RedditMedia.swift */, 5133BB502460EE730001E3D0 /* RedditMediaEmbed.swift */, + 5100E4CC246243990010A63D /* RedditPreview.swift */, 5133BB4A2460BDF30001E3D0 /* RedditSubreddit.swift */, ); path = Reddit; @@ -1288,6 +1291,7 @@ 9EC688EA232B973C00A8D0A2 /* FeedlyAPICaller.swift in Sources */, 9E1773D32345700F0056A5A8 /* FeedlyLink.swift in Sources */, 9EAEC62823331C350085D7C9 /* FeedlyCategory.swift in Sources */, + 5100E4CD246243990010A63D /* RedditPreview.swift in Sources */, 3B826DAE2385C81C00FC1ADB /* FeedWranglerSubscriptionsRequest.swift in Sources */, 9E964EB823754AC400A7AF2E /* OAuthAuthorizationClient+Feedly.swift in Sources */, 9EF1B10923590E93000A486A /* FeedlyStreamIds.swift in Sources */, diff --git a/Frameworks/Account/FeedProvider/Reddit/RedditLink.swift b/Frameworks/Account/FeedProvider/Reddit/RedditLink.swift index 76657ba68..72015adce 100644 --- a/Frameworks/Account/FeedProvider/Reddit/RedditLink.swift +++ b/Frameworks/Account/FeedProvider/Reddit/RedditLink.swift @@ -33,6 +33,7 @@ struct RedditLinkData: Codable { let isVideo: Bool? let media: RedditMedia? let mediaEmbed: RedditMediaEmbed? + let preview: RedditPreview? enum CodingKeys: String, CodingKey { case title = "title" @@ -46,6 +47,7 @@ struct RedditLinkData: Codable { case isVideo = "is_video" case media = "media" case mediaEmbed = "media_embed" + case preview = "preview" } var createdDate: Date? { @@ -75,7 +77,19 @@ struct RedditLinkData: Codable { guard let fallbackURL = media?.video?.fallbackURL else { return nil } - return "" + + var html = "" + return html } guard url.hasSuffix(".jpg") || url.hasSuffix(".jpeg") || url.hasSuffix(".png") || url.hasSuffix(".gif") else { diff --git a/Frameworks/Account/FeedProvider/Reddit/RedditMedia.swift b/Frameworks/Account/FeedProvider/Reddit/RedditMedia.swift index 8b4857014..f2339c9fb 100644 --- a/Frameworks/Account/FeedProvider/Reddit/RedditMedia.swift +++ b/Frameworks/Account/FeedProvider/Reddit/RedditMedia.swift @@ -21,9 +21,13 @@ struct RedditMedia: Codable { struct RedditVideo: Codable { let fallbackURL: String? - + let height: Int? + let width: Int? + enum CodingKeys: String, CodingKey { case fallbackURL = "fallback_url" + case height = "height" + case width = "width" } } diff --git a/Frameworks/Account/FeedProvider/Reddit/RedditPreview.swift b/Frameworks/Account/FeedProvider/Reddit/RedditPreview.swift new file mode 100644 index 000000000..93e90f3a0 --- /dev/null +++ b/Frameworks/Account/FeedProvider/Reddit/RedditPreview.swift @@ -0,0 +1,43 @@ +// +// RedditPreview.swift +// Account +// +// Created by Maurice Parker on 5/5/20. +// Copyright © 2020 Ranchero Software, LLC. All rights reserved. +// + +import Foundation + +struct RedditPreview: Codable { + + let images: [RedditPreviewImage]? + + enum CodingKeys: String, CodingKey { + case images = "images" + } + +} + +struct RedditPreviewImage: Codable { + + let source: RedditPreviewImageSource? + + enum CodingKeys: String, CodingKey { + case source = "source" + } + +} + +struct RedditPreviewImageSource: Codable { + + let url: String? + let width: Int? + let height: Int? + + enum CodingKeys: String, CodingKey { + case url = "url" + case width = "width" + case height = "height" + } + +}