forked from henry-richard7/Go-Voot-Streamer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Go-Voot-Streamer.go
76 lines (60 loc) · 1.9 KB
/
Go-Voot-Streamer.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
package main
import (
"fmt"
"github.com/Jeffail/gabs/v2"
"html/template"
"io"
"net/http"
"strings"
)
func getStreamingUrl(url string) (string, string, string) {
videoID := url[strings.LastIndex(url, "/")+1:]
webURL := "https://wapi.voot.com/ws/ott/getMediaInfo.json?platform=Web&pId=2&mediaId=" + videoID
httpClient := http.Client{}
requests, _ := http.NewRequest("GET", webURL, nil)
result, _ := httpClient.Do(requests)
response, _ := io.ReadAll(result.Body)
jsonParsed, _ := gabs.ParseJSON(response)
if jsonParsed.Path("status.message").Data().(string) != "Data not found or Invalid MediaID" {
streamURL := jsonParsed.Path("assets.Files.3.URL").Data().(string)
title := jsonParsed.Path("assets.MediaName").Data().(string)
thumbnail := jsonParsed.Path("assets.Pictures.0.URL").Data().(string)
thumbnail = strings.ReplaceAll(thumbnail, "https://viacom18-res.cloudinary.com/image/upload/f_auto,q_auto:eco,fl_lossy/kimg", "https://kimg.voot.com")
return title, thumbnail, streamURL
} else {
return "", "", ""
}
}
func welcomeScreen() {
fmt.Println("Go Voot Streamer\n" +
"Developed By Henry Richard J")
fmt.Println("Example: http://localhost:8080/player?url=https://www.voot.com/movies/petta/962823")
}
type streamingLink struct {
Title string
LinkUrl string
PosterUrl string
}
func handlePlayer(w http.ResponseWriter, r *http.Request) {
vootURL := r.URL.Query().Get("url")
title, thumbNail, steamUrl := getStreamingUrl(vootURL)
if title != "" {
w.WriteHeader(http.StatusOK)
s := streamingLink{LinkUrl: steamUrl,
PosterUrl: thumbNail,
Title: title}
t, _ := template.ParseFiles("templates/player.html")
err := t.Execute(w, s)
if err != nil {
panic(err)
}
} else {
w.WriteHeader(http.StatusBadRequest)
fmt.Fprintf(w, "The given URL is Invalid")
}
}
func main() {
welcomeScreen()
http.HandleFunc("/player", handlePlayer)
http.ListenAndServe(":8080", nil)
}