@@ -9,11 +9,11 @@ public class ParselyMetadata {
9
9
var section : String ?
10
10
var tags : Array < String > ?
11
11
var duration : TimeInterval ?
12
-
12
+
13
13
/**
14
14
A class to manage and re-use metadata. Metadata contained in an instance of this
15
15
class will conform to Parsely's schema.
16
-
16
+
17
17
- Parameter canonical_url: A post's canonical url. For videos, it is overridden with the vId and thus can be omitted.
18
18
- Parameter pub_date: Date this piece of content was published.
19
19
- Parameter title: Title of the content.
@@ -22,15 +22,15 @@ public class ParselyMetadata {
22
22
- Parameter section: Same as section for website integration.
23
23
- Parameter tags: Up to 20 tags on an event are allowed.
24
24
- Parameter duration: Durations passed explicitly to trackVideoStart take precedence over any in metadata.
25
- */
25
+ */
26
26
public init ( canonical_url: String ? = nil ,
27
- pub_date: Date ? = nil ,
28
- title: String ? = nil ,
29
- authors: Array < String > ? = nil ,
30
- image_url: String ? = nil ,
31
- section: String ? = nil ,
32
- tags: Array < String > ? = nil ,
33
- duration: TimeInterval ? = nil ) {
27
+ pub_date: Date ? = nil ,
28
+ title: String ? = nil ,
29
+ authors: Array < String > ? = nil ,
30
+ image_url: String ? = nil ,
31
+ section: String ? = nil ,
32
+ tags: Array < String > ? = nil ,
33
+ duration: TimeInterval ? = nil ) {
34
34
self . canonical_url = canonical_url
35
35
self . pub_date = pub_date
36
36
self . title = title
@@ -40,15 +40,15 @@ public class ParselyMetadata {
40
40
self . tags = tags
41
41
self . duration = duration
42
42
}
43
-
43
+
44
44
func toDict( ) -> Dictionary < String , Any > {
45
45
var metas : Dictionary < String , Any > = [ : ]
46
-
46
+
47
47
if let canonical_url {
48
48
metas [ " link " ] = canonical_url
49
49
}
50
50
if let pub_date {
51
- metas [ " pub_date " ] = String ( format: " %i " , pub_date. millisecondsSince1970)
51
+ metas [ " pub_date " ] = String ( format: " %i " , pub_date. millisecondsSince1970)
52
52
}
53
53
if let title {
54
54
metas [ " title " ] = title
@@ -68,7 +68,7 @@ public class ParselyMetadata {
68
68
if let duration {
69
69
metas [ " duration " ] = duration
70
70
}
71
-
71
+
72
72
return metas
73
73
}
74
74
}
0 commit comments