This repository was archived by the owner on Sep 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathOembed.swift
84 lines (81 loc) · 2.44 KB
/
Oembed.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//
// Oembed.swift
// reddift
//
// Created by sonson on 2015/04/20.
// Copyright (c) 2015年 sonson. All rights reserved.
//
import Foundation
import HTMLSpecialCharacters
/**
Media represents the content which is embeded a link.
*/
public struct Oembed {
/**
example, "http://i.imgur.com",
*/
public let providerUrl: String
/**
example, "The Internet's visual storytelling community. Explore, share, and discuss the best visual stories the Internet has to offer.",
*/
public let description: String
/**
example, "Imgur GIF",
*/
public let title: String
/**
example, 245,
*/
public let thumbnailWidth: Int
/**
example, 333,
*/
public let height: Int
/**
example, 245,
*/
public let width: Int
/**
example, "<iframe class=\"embedly-embed\" src=\"//cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fi.imgur.com%2FkhgfcrQ.mp4&src_secure=1&url=http%3A%2F%2Fi.imgur.com%2FkhgfcrQ.gifv&image=http%3A%2F%2Fi.imgur.com%2FkhgfcrQ.gif&key=2aa3c4d5f3de4f5b9120b660ad850dc9&type=video%2Fmp4&schema=imgur\" width=\"245\" height=\"333\" scrolling=\"no\" frameborder=\"0\" allowfullscreen></iframe>",
*/
public let html: String
/**
example, "1.0",
*/
public let version: String
/**
example, "Imgur",
*/
public let providerName: String
/**
example, "http://i.imgur.com/khgfcrQ.gif",
*/
public let thumbnailUrl: String
/**
example, "video",
*/
public let type: String
/**
example, 333
*/
public let thumbnailHeight: Int
/**
Update each property with JSON object.
- parameter json: JSON object which is included "t2" JSON.
*/
public init (json: JSONDictionary) {
self.providerUrl = json["provider_url"] as? String ?? ""
self.description = json["description"] as? String ?? ""
self.title = json["title"] as? String ?? ""
self.thumbnailWidth = json["thumbnail_width"] as? Int ?? 0
self.height = json["height"] as? Int ?? 0
self.width = json["width"] as? Int ?? 0
let tempHtml = json["html"] as? String ?? ""
self.html = tempHtml.unescapeHTML
self.version = json["version"] as? String ?? ""
self.providerName = json["provider_name"] as? String ?? ""
self.thumbnailUrl = json["thumbnail_url"] as? String ?? ""
self.type = json["type"] as? String ?? ""
self.thumbnailHeight = json["thumbnail_height"] as? Int ?? 0
}
}