Skip to content
This repository has been archived by the owner on Oct 6, 2024. It is now read-only.

Commit

Permalink
auth: Refactored auth package since youtube api is no longer used.
Browse files Browse the repository at this point in the history
The Youtube API creates the YoutubeService object used to access objects from within youtube. However Google doesn't current support video extraction for files not uploaded by the current authenticated user. So this makes it no longer necessary to invoke the Youtube API for any purpose.

Fixes #8
  • Loading branch information
Nyah Check committed Sep 16, 2017
1 parent b9074d4 commit 9b3234a
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 219 deletions.
181 changes: 0 additions & 181 deletions auth/auth.go

This file was deleted.

1 change: 0 additions & 1 deletion auth/auth_test.go

This file was deleted.

1 change: 0 additions & 1 deletion auth/client_secret.json

This file was deleted.

1 change: 0 additions & 1 deletion auth/ytd-auth.json

This file was deleted.

52 changes: 21 additions & 31 deletions simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,37 @@ import (
//"encoding/json"
"fmt"
"io"
"strings"
//"os"
//"os/exec"
"io/ioutil"
//"log"
"net/http"
"net/url"

"github.com/Sirupsen/logrus"

"google.golang.org/api/googleapi/transport"
youtube "google.golang.org/api/youtube/v3"
)


const developerKey = "AIzaSyCZSy5sOGsZrOrI0vLtowf_VJ-tl_USzNE"

type RawVideoData struct {
Title string `json:"title"`
Author string `json:"author`
Status string `json:"status"`
URLEncodedFmtStreamMap map[string][]string `json:"url_encoded_fmt_stream_map"`
Title string `json:"title"`
Author string `json:"author`
Status string `json:"status"`
URLEncodedFmtStreamMap map[string][]string `json:"url_encoded_fmt_stream_map"`
}


func main() {

videoExtractor := "https://youtube.com/get_video_info?video_id="
var decodedVideo []string
id := "Ks-_Mh1QhMc"

video := new(RawVideoData)

client := &http.Client{
Transport: &transport.APIKey{Key: developerKey},
}
Expand All @@ -49,9 +48,8 @@ func main() {
logrus.Fatalf("Error creating new YouTube client: %v", err)
}


logrus.Infof("Starting the Video extration process.")

//Get Video Data stream
videoUrl := videoExtractor + id
res, er := http.Get(videoUrl)
Expand All @@ -68,13 +66,13 @@ func main() {
logrus.Fatalf("Error unmarshalling output", e)
}
fmt.Println(string(output))

//Process Video stream
video.URLEncodedFmtStreamMap = output["url_encoded_fmt_stream_map"]
video.Author = output["author"]
video.Author = output["author"]
video.Title = output["title"]
video.Status = output["status"]

//Decode Video
outputStreams := strings.Split(video.URLEncodedFmtStreamMap[0], ",")
for cur, raw_data := range outputStream {
Expand All @@ -84,29 +82,26 @@ func main() {
logrus.Errorf("Error Decoding Video data: %d, %v", cur, err)
continue
}

data := map[string]string{
"quality": dec_data["quality"][0],
"type": dec_data["type"][0],
"url": dec_data["url"][0],
"sig": dec_data["sig"][0],
"title": video.Title,
"author": video.Author,
"format": dec_data["format"][0],
"type": dec_data["type"][0],
"url": dec_data["url"][0],
"sig": dec_data["sig"][0],
"title": video.Title,
"author": video.Author,
"format": dec_data["format"][0],
}

decodedVideo = append(decodedVideo, data)
logrus.Infof("\nDecoded %d bytes of '%s' in '%s'", format, len(decodedVideo), dec_data["quality"][0], dec_data["format"][0])
}

//Download video



return
}


func (stream stream) download(out io.Writer) error {
url := stream.Url()

Expand All @@ -129,8 +124,3 @@ func (stream stream) download(out io.Writer) error {

return nil
}





9 changes: 5 additions & 4 deletions vendor/google.golang.org/api/youtube/v3/youtube-gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9b3234a

Please sign in to comment.