forked from aliforever/gista
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmedia.go
40 lines (32 loc) · 872 Bytes
/
media.go
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
package gista
import (
"fmt"
"strconv"
"strings"
"github.com/aliforever/gista/constants"
"github.com/aliforever/gista/responses"
)
type media struct {
ig *Instagram
}
func newMedia(i *Instagram) *media {
return &media{ig: i}
}
func (m *media) GetInfo(mediaId interface{}) (res *responses.MediaInfo, err error) {
mediaIdInt := int64(0)
switch mediaId.(type) {
case int64:
mediaIdInt = mediaId.(int64)
case string:
idTemp, _ := strconv.Atoi(mediaId.(string)[:strings.Index(mediaId.(string), "_")])
mediaIdInt = int64(idTemp)
}
res = &responses.MediaInfo{}
err = m.ig.client.Request(fmt.Sprintf(constants.GetMediaInfo, mediaIdInt)).GetResponse(res)
return
}
func (m *media) GetBlockedMedia() (res *responses.BlockedMedia, err error) {
res = &responses.BlockedMedia{}
err = m.ig.client.Request(constants.BlockedMedia).GetResponse(res)
return
}