Skip to content

Commit

Permalink
Fix/update sha1 with sha256 for file hash (#159)
Browse files Browse the repository at this point in the history
* fix(download): fixed download --live doesn't work with authticet and lookuphash
  • Loading branch information
cnlangzi authored Jan 28, 2022
1 parent bd97ed6 commit 35e772c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 34 deletions.
42 changes: 11 additions & 31 deletions cmd/download_m3u8.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,49 +168,29 @@ func (d *M3u8Downloader) autoRefreshList() {
}

func (d *M3u8Downloader) download(item MediaItem) (string, error) {

wg := &sync.WaitGroup{}
statusBar := &StatusBar{wg: wg}
wg.Add(1)

localPath := filepath.Join(d.localDir, item.Name)
remotePath := item.Path

if len(d.remotePath) > 0 {
downloader, err := sdk.CreateDownloader(d.allocationID, localPath, remotePath,
sdk.WithAllocation(d.allocationObj),
sdk.WithAuthticket(d.authTicket, d.lookupHash),
sdk.WithRxPay(d.rxPay))

err := d.allocationObj.DownloadFile(localPath, remotePath, statusBar)
if err != nil {
return "", err
}

if err != nil {
return "", err
}
err = downloader.Start(statusBar)

wg.Wait()
if err != nil {
return "", err
}

//TODO: add download ts files from auth ticket
// allocationObj, err = sdk.GetAllocationFromAuthTicket(authticket)
// if err != nil {
// PrintError("Error fetching the allocation", err)
// os.Exit(1)
// }
// at := sdk.InitAuthTicket(authticket)
// filename, err := at.GetFileName()
// if err != nil {
// PrintError("Error getting the filename from authticket", err)
// os.Exit(1)
// }
// if len(lookuphash) == 0 {
// lookuphash, err = at.GetLookupHash()
// if err != nil {
// PrintError("Error getting the lookuphash from authticket", err)
// os.Exit(1)
// }
// }

// return d.allocationObj.DownloadFromAuthTicket(localpath,
// authticket, lookuphash, filename, rxPay, statusBar)

//}
wg.Wait()

return item.Name, nil
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.13

require (
github.com/0chain/errors v1.0.3
github.com/0chain/gosdk v1.4.1-0.20220105140556-1e37d2ba4e8a
github.com/0chain/gosdk v1.4.1-0.20220127152226-9c642c9955e9
github.com/olekukonko/tablewriter v0.0.5
github.com/spf13/cobra v1.1.1
github.com/spf13/pflag v1.0.5
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ collectd.org v0.3.0/go.mod h1:A/8DzQBkF6abtvrT2j/AU/4tiBgJWYyh0y/oB/4MlWE=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/0chain/errors v1.0.3 h1:QQZPFxTfnMcRdt32DXbzRQIfGWmBsKoEdszKQDb0rRM=
github.com/0chain/errors v1.0.3/go.mod h1:xymD6nVgrbgttWwkpSCfLLEJbFO6iHGQwk/yeSuYkIc=
github.com/0chain/gosdk v1.4.1-0.20220105140556-1e37d2ba4e8a h1:VYZNUfUTdEB3PLT81bkPWBkRNklUymjdUawAYxhWgyw=
github.com/0chain/gosdk v1.4.1-0.20220105140556-1e37d2ba4e8a/go.mod h1:FB2xXhQyIM1vwvQ1jC98wNclbDTBwqrG+Z/IQC0LaBs=
github.com/0chain/gosdk v1.4.1-0.20220127152226-9c642c9955e9 h1:igz4J+VZH10beCmt7SWAdhlH6vtMZ2+jO7XjmUy+WLM=
github.com/0chain/gosdk v1.4.1-0.20220127152226-9c642c9955e9/go.mod h1:FB2xXhQyIM1vwvQ1jC98wNclbDTBwqrG+Z/IQC0LaBs=
github.com/Azure/azure-pipeline-go v0.2.1/go.mod h1:UGSo8XybXnIGZ3epmeBw7Jdz+HiUVpqIlpz/HKHylF4=
github.com/Azure/azure-pipeline-go v0.2.2/go.mod h1:4rQ/NZncSvGqNkkOsNpOU1tgoNuIlp9AfUH5G1tvCHc=
github.com/Azure/azure-storage-blob-go v0.7.0/go.mod h1:f9YQKtsG1nMisotuTPpO0tjNuEjKRYAcJU8/ydDI++4=
Expand Down

0 comments on commit 35e772c

Please sign in to comment.