forked from pdbogen/circle
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathactivity.go
More file actions
32 lines (26 loc) · 698 Bytes
/
activity.go
File metadata and controls
32 lines (26 loc) · 698 Bytes
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
package circle
import (
"fmt"
"io"
"net/http"
"net/url"
)
func (a *Activity) GetMp4() (io.ReadCloser, error) {
mp4Url := fmt.Sprintf("accessories/%s/activities/%s/mp4",
url.PathEscape(a.accessory.AccessoryId),
url.PathEscape(a.ActivityId))
req, err := http.NewRequest("GET", "https://video.logi.com/api/"+mp4Url, nil)
if err != nil {
return nil, fmt.Errorf("NewRequest: %v", err)
}
a.accessory.session.addHeaders(req)
res, err := http.DefaultClient.Do(req)
if err != nil {
return nil, fmt.Errorf("GET %s: %v", mp4Url, err)
}
if res.StatusCode/100 != 2 {
res.Body.Close()
return nil, fmt.Errorf("GET %q: non-2XX %d", mp4Url, res.StatusCode)
}
return res.Body, nil
}