diff --git a/Nos/Models/OpenGraph/OpenGraphParser.swift b/Nos/Models/OpenGraph/OpenGraphParser.swift index a76fc91bb..5ef63de60 100644 --- a/Nos/Models/OpenGraph/OpenGraphParser.swift +++ b/Nos/Models/OpenGraph/OpenGraphParser.swift @@ -1,5 +1,6 @@ import Foundation +/// Parses the Open Graph metadata from an HTML document. protocol OpenGraphParser { func videoMetadata(html: Data) -> OpenGraphMedia? } diff --git a/Nos/Service/Media/MediaService.swift b/Nos/Service/Media/MediaService.swift index 74941b648..82c39fbe6 100644 --- a/Nos/Service/Media/MediaService.swift +++ b/Nos/Service/Media/MediaService.swift @@ -47,7 +47,7 @@ struct DefaultMediaService: MediaService { } } - /// Loads the content at the given URL and returns its orientation. + /// Fetches metadata for the given URL and returns its orientation. /// - Parameter url: The URL of the data to download. /// - Returns: The orientation of the content. /// - Note: For web pages, `landscape` is returned. For videos, we're returning `portrait` until we implement diff --git a/Nos/Service/Media/OpenGraphService.swift b/Nos/Service/Media/OpenGraphService.swift index 695bab861..52d1d6865 100644 --- a/Nos/Service/Media/OpenGraphService.swift +++ b/Nos/Service/Media/OpenGraphService.swift @@ -1,9 +1,14 @@ import Foundation +/// A service that fetches metadata for a URL. protocol OpenGraphService { + /// Fetches metadata for the given URL. + /// - Parameter url: The URL to fetch. + /// - Returns: The Open Graph metadata for the URL. func fetchMetadata(for url: URL) async throws -> OpenGraphMetadata } +/// A default implementation for `OpenGraphService`. struct DefaultOpenGraphService: OpenGraphService { let session: URLSessionProtocol let parser: OpenGraphParser @@ -16,17 +21,19 @@ struct DefaultOpenGraphService: OpenGraphService { } } +/// Open Graph metadata for a URL. struct OpenGraphMetadata: Equatable { let media: OpenGraphMedia? } +/// Open Graph metadata for media, such as an image or video. struct OpenGraphMedia: Equatable { - let url: String? let type: OpenGraphMediaType? let width: Double? let height: Double? } +/// The type of Open Graph media. enum OpenGraphMediaType { case image case video