Skip to content
This repository was archived by the owner on Jul 21, 2020. It is now read-only.

Commit 767e830

Browse files
committed
Updated VOD URL handling
1 parent 73840cf commit 767e830

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

BeamAPI.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "BeamAPI"
3-
s.version = "1.2.2"
3+
s.version = "1.2.3"
44
s.summary = "An interface to communicate with Beam's backend."
55
s.homepage = "https://github.com/WatchBeam/beam-client-swift"
66
s.license = "MIT"
@@ -9,7 +9,7 @@ Pod::Spec.new do |s|
99
s.requires_arc = true
1010
s.ios.deployment_target = "8.2"
1111
s.tvos.deployment_target = "9.0"
12-
s.source = { :git => "https://github.com/WatchBeam/beam-client-swift.git", :tag => "1.2.2" }
12+
s.source = { :git => "https://github.com/WatchBeam/beam-client-swift.git", :tag => "1.2.3" }
1313
s.source_files = "Pod/Classes/**/*"
1414

1515
s.dependency "Starscream", "~> 1.1"

Pod/Classes/Models/BeamVOD.swift

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,40 @@ import SwiftyJSON
1111
public struct BeamVOD {
1212

1313
public let id: Int
14-
public let storageNode: String
15-
public let mainUrl: String
14+
public let storageNode: String?
15+
public let baseUrl: String?
16+
public let mainUrl: String?
1617
public let format: String
1718
public let createdAt: NSDate?
1819
public let updatedAt: NSDate?
1920
public let recordingId: Int
2021

21-
public var url: NSURL {
22-
return NSURL(string: "https://\(storageNode)/\(id)/\(mainUrl)")!
22+
public var url: NSURL? {
23+
func filePath() -> String? {
24+
return [
25+
"dash": "manifest.mpd",
26+
"hls": "manifest.m3u8",
27+
"thumbnail": "source.json",
28+
"raw": "source.mp4",
29+
"chat": "source.json"
30+
][format]
31+
}
32+
33+
if let baseUrl = baseUrl, filePath = filePath() {
34+
return NSURL(string: "\(baseUrl)\(filePath)")
35+
} else if let storageNode = storageNode, mainUrl = mainUrl {
36+
return NSURL(string: "https://\(storageNode)/\(id)/\(mainUrl)")
37+
}
38+
39+
return nil
2340
}
2441

2542
init(json: JSON) {
2643
id = json["id"].int ?? 0
27-
storageNode = json["storageNode"].string ?? ""
28-
mainUrl = json["mainUrl"].string ?? ""
29-
format = json["format"].string ?? ""
44+
storageNode = json["storageNode"].string
45+
baseUrl = json["baseUrl"].string
46+
mainUrl = json["mainUrl"].string
47+
format = json["format"].string ?? "unknown"
3048
createdAt = NSDate.fromBeam(json["createdAt"].string)
3149
updatedAt = NSDate.fromBeam(json["updatedAt"].string)
3250
recordingId = json["recordingId"].int ?? 0

0 commit comments

Comments
 (0)