-
Notifications
You must be signed in to change notification settings - Fork 0
/
flash.go
114 lines (101 loc) · 2.95 KB
/
flash.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
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package tvseries
import (
"fmt"
"strings"
"net/http"
"net/url"
"io/ioutil"
"log"
"strconv"
"encoding/json"
"packs"
)
type Structure struct {
ID string `json:"_id"`
AirDate string `json:"air_date"`
Episodes []struct {
AirDate string `json:"air_date"`
EpisodeNumber int `json:"episode_number"`
ID int `json:"id"`
Name string `json:"name"`
Overview string `json:"overview"`
ProductionCode string `json:"production_code"`
SeasonNumber int `json:"season_number"`
ShowID int `json:"show_id"`
StillPath string `json:"still_path"`
VoteAverage float64 `json:"vote_average"`
VoteCount int `json:"vote_count"`
Crew []struct {
ID int `json:"id"`
CreditID string `json:"credit_id"`
Name string `json:"name"`
Department string `json:"department"`
Job string `json:"job"`
Gender int `json:"gender"`
ProfilePath string `json:"profile_path"`
} `json:"crew"`
GuestStars []struct {
ID int `json:"id"`
Name string `json:"name"`
CreditID string `json:"credit_id"`
Character string `json:"character"`
Order int `json:"order"`
Gender int `json:"gender"`
ProfilePath string `json:"profile_path"`
} `json:"guest_stars"`
} `json:"episodes"`
Name string `json:"name"`
Overview string `json:"overview"`
ID2 int `json:"id"`
PosterPath string `json:"poster_path"`
SeasonNumber int `json:"season_number"`
}
func FetchSeasonData(act string) []byte{
url := act
payload := strings.NewReader("{}")
req, _ := http.NewRequest("GET", url, payload)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
return (body)
}
func ExampleURL(season int64,id int64) string{
b16 := strconv.FormatInt(season,10)
fmt.Println(string(b16))
a16 := strconv.FormatInt(id,10)
fmt.Println(string(a16))
u, err := url.Parse("https://api.themoviedb.org/3/tv/"+string(a16)+"/season/"+string(b16)+"?language=jaffa&api_key=cheppa")
if err != nil {
log.Fatal(err)
}
q:= u.Query()
q.Set("api_key","85024bf9f2db24e284e8959926cd3226")
q.Set("language","en-US")
u.RawQuery = q.Encode()
stringURL := u.String()
// fmt.Println(stringURL)
return stringURL
}
func GetSummary(name string, w http.ResponseWriter) Structure{
var j int64
var seasoncount int64
var JSONdata *Structure
seasoncount = packs.GetSeasons(name)
for j= 1;j<seasoncount+1;j++{
JSONdata = &Structure{}
var example = ExampleURL(j,packs.GetID(name))
var byteData = FetchSeasonData(example)
err := json.Unmarshal(byteData, JSONdata)
if err != nil{
fmt.Println(err)
}
for i:= range JSONdata.Episodes{
fmt.Fprintf(w,"<b>season:%depisode:%d</b>",j,i)
fmt.Println()
fmt.Println(JSONdata.Episodes[i].Overview)
fmt.Fprintf(w, JSONdata.Episodes[i].Overview)
fmt.Fprintf(w,"</br>")
}
}
return *JSONdata
}