update youtube download library

This commit is contained in:
Niko Storni 2018-03-13 17:48:01 -04:00 committed by Niko Storni
parent 4c2391030c
commit 5fa1681b82
No known key found for this signature in database
GPG key ID: F37FE63398800368
3 changed files with 33 additions and 14 deletions

30
Gopkg.lock generated
View file

@ -1,6 +1,18 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
[[projects]]
name = "github.com/PuerkitoBio/goquery"
packages = ["."]
revision = "09540e565986583836b5fc792fe951ec5fd201dd"
version = "v1.3.0"
[[projects]]
name = "github.com/andybalholm/cascadia"
packages = ["."]
revision = "901648c87902174f774fac311d7f176f8647bdaa"
version = "v1.0.0"
[[projects]] [[projects]]
name = "github.com/aws/aws-sdk-go" name = "github.com/aws/aws-sdk-go"
packages = [ packages = [
@ -121,12 +133,6 @@
revision = "3433f3ea46d9f8019119e7dd41274e112a2359a9" revision = "3433f3ea46d9f8019119e7dd41274e112a2359a9"
version = "0.2.2" version = "0.2.2"
[[projects]]
branch = "master"
name = "github.com/kkdai/youtube"
packages = ["."]
revision = "ac4c6cefe62a7eb2e894cb37014ee63eb7c12b8e"
[[projects]] [[projects]]
branch = "master" branch = "master"
name = "github.com/lbryio/lbryschema.go" name = "github.com/lbryio/lbryschema.go"
@ -139,6 +145,12 @@
packages = ["."] packages = ["."]
revision = "00c29f56e2386353d58c599509e8dc3801b0d716" revision = "00c29f56e2386353d58c599509e8dc3801b0d716"
[[projects]]
branch = "master"
name = "github.com/nikooo777/ytdl"
packages = ["."]
revision = "64fe19bb69f66746824eb7812caf9f382c0e0bd8"
[[projects]] [[projects]]
name = "github.com/shopspring/decimal" name = "github.com/shopspring/decimal"
packages = ["."] packages = ["."]
@ -195,7 +207,9 @@
name = "golang.org/x/net" name = "golang.org/x/net"
packages = [ packages = [
"context", "context",
"context/ctxhttp" "context/ctxhttp",
"html",
"html/atom"
] ]
revision = "803fdb99c0f72e493c28ef2099d250a9c989d8ff" revision = "803fdb99c0f72e493c28ef2099d250a9c989d8ff"
@ -229,6 +243,6 @@
[solve-meta] [solve-meta]
analyzer-name = "dep" analyzer-name = "dep"
analyzer-version = 1 analyzer-version = 1
inputs-digest = "f682d1d74ea3bad9f49de558985c802ba82f08d8aa6b6593891226d8441e5824" inputs-digest = "d09cbc6007ff3e80d5f89504e55bc464289f7dfca50d90b708ee23fcb4577e37"
solver-name = "gps-cdcl" solver-name = "gps-cdcl"
solver-version = 1 solver-version = 1

View file

@ -12,7 +12,7 @@
[[constraint]] [[constraint]]
branch = "master" branch = "master"
name = "github.com/kkdai/youtube" name = "github.com/nikooo777/ytdl"
[[constraint]] [[constraint]]
branch = "master" branch = "master"

View file

@ -14,7 +14,7 @@ import (
"github.com/lbryio/lbry.go/errors" "github.com/lbryio/lbry.go/errors"
"github.com/lbryio/lbry.go/jsonrpc" "github.com/lbryio/lbry.go/jsonrpc"
ytdl "github.com/kkdai/youtube" "github.com/nikooo777/ytdl"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"google.golang.org/api/youtube/v3" "google.golang.org/api/youtube/v3"
) )
@ -103,16 +103,21 @@ func (v YoutubeVideo) download() error {
return nil return nil
} }
downloader := ytdl.NewYoutube(false) videoUrl := "https://www.youtube.com/watch?v=" + v.id
err = downloader.DecodeURL("https://www.youtube.com/watch?v=" + v.id) videoInfo, err := ytdl.GetVideoInfo(videoUrl)
if err != nil { if err != nil {
return err return err
} }
err = downloader.StartDownload(videoPath)
var downloadedFile *os.File
downloadedFile, err = os.Create(v.getFilename())
if err != nil { if err != nil {
return err return err
} }
return nil
defer downloadedFile.Close()
return videoInfo.Download(videoInfo.Formats.Best(ytdl.FormatAudioEncodingKey)[0], downloadedFile)
} }
func (v YoutubeVideo) triggerThumbnailSave() error { func (v YoutubeVideo) triggerThumbnailSave() error {