-
Notifications
You must be signed in to change notification settings - Fork 0
/
UserHandles.go
75 lines (63 loc) · 1.52 KB
/
UserHandles.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
package yougoclient
import (
"context"
"fmt"
"io/ioutil"
"log"
"golang.org/x/oauth2/google"
"google.golang.org/api/youtube/v3"
)
func NewClient() {
//get call context
ctx := context.Background()
//grab API Key from JSON file
b, err := ioutil.ReadFile("client_secret.json")
if err != nil {
log.Fatalf("Unable to read client secret file: %v", err)
}
//grab service config
config, err := google.ConfigFromJSON(b, youtube.YoutubeReadonlyScope)
if err != nil {
log.Fatalf("Unable to parse client secret file to config: %v", err)
}
//create API client
client := CreateClient(ctx, config)
//run youtube service
service, err := youtube.New(client)
HandleError(err, "Error creating YouTube client")
//API query
videos := SearchQuery(service, CurrentSearch)
//package response
RelatedVideoGenerate(service, videos)
//FOR TESTING
/*data := &Respond{
VideoID: "PLZ",
ThumbnailURL: "HELP",
VideoTitle: "HELLO",
}
UserSearch = append(UserSearch, data)
//fmt.Println(UserSearch)*/
}
/*
*Creates user struct and appends to session clients slice
*/
func NewUser(name string) {
tempUser := &Users{
UserName: name,
SessionTime: 0,
}
ClientList = append(ClientList, tempUser)
}
/*
*Searches linearly through session clients and deletes selected username
*/
func DeleteUser(name string) {
fmt.Println("User " + name + " has timed out of their session.")
tempList := ClientList
ClientList = nil
for _, user := range tempList {
if user.UserName != name {
ClientList = append(ClientList, user)
}
}
}