Skip to content

Commit 35e772c

Browse files
authored
Fix/update sha1 with sha256 for file hash (#159)
* fix(download): fixed download --live doesn't work with authticet and lookuphash
1 parent bd97ed6 commit 35e772c

File tree

3 files changed

+14
-34
lines changed

3 files changed

+14
-34
lines changed

cmd/download_m3u8.go

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -168,49 +168,29 @@ func (d *M3u8Downloader) autoRefreshList() {
168168
}
169169

170170
func (d *M3u8Downloader) download(item MediaItem) (string, error) {
171-
172171
wg := &sync.WaitGroup{}
173172
statusBar := &StatusBar{wg: wg}
174173
wg.Add(1)
175174

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

179-
if len(d.remotePath) > 0 {
178+
downloader, err := sdk.CreateDownloader(d.allocationID, localPath, remotePath,
179+
sdk.WithAllocation(d.allocationObj),
180+
sdk.WithAuthticket(d.authTicket, d.lookupHash),
181+
sdk.WithRxPay(d.rxPay))
180182

181-
err := d.allocationObj.DownloadFile(localPath, remotePath, statusBar)
183+
if err != nil {
184+
return "", err
185+
}
182186

183-
if err != nil {
184-
return "", err
185-
}
187+
err = downloader.Start(statusBar)
186188

187-
wg.Wait()
189+
if err != nil {
190+
return "", err
188191
}
189192

190-
//TODO: add download ts files from auth ticket
191-
// allocationObj, err = sdk.GetAllocationFromAuthTicket(authticket)
192-
// if err != nil {
193-
// PrintError("Error fetching the allocation", err)
194-
// os.Exit(1)
195-
// }
196-
// at := sdk.InitAuthTicket(authticket)
197-
// filename, err := at.GetFileName()
198-
// if err != nil {
199-
// PrintError("Error getting the filename from authticket", err)
200-
// os.Exit(1)
201-
// }
202-
// if len(lookuphash) == 0 {
203-
// lookuphash, err = at.GetLookupHash()
204-
// if err != nil {
205-
// PrintError("Error getting the lookuphash from authticket", err)
206-
// os.Exit(1)
207-
// }
208-
// }
209-
210-
// return d.allocationObj.DownloadFromAuthTicket(localpath,
211-
// authticket, lookuphash, filename, rxPay, statusBar)
212-
213-
//}
193+
wg.Wait()
214194

215195
return item.Name, nil
216196
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.13
44

55
require (
66
github.com/0chain/errors v1.0.3
7-
github.com/0chain/gosdk v1.4.1-0.20220105140556-1e37d2ba4e8a
7+
github.com/0chain/gosdk v1.4.1-0.20220127152226-9c642c9955e9
88
github.com/olekukonko/tablewriter v0.0.5
99
github.com/spf13/cobra v1.1.1
1010
github.com/spf13/pflag v1.0.5

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ collectd.org v0.3.0/go.mod h1:A/8DzQBkF6abtvrT2j/AU/4tiBgJWYyh0y/oB/4MlWE=
4949
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
5050
github.com/0chain/errors v1.0.3 h1:QQZPFxTfnMcRdt32DXbzRQIfGWmBsKoEdszKQDb0rRM=
5151
github.com/0chain/errors v1.0.3/go.mod h1:xymD6nVgrbgttWwkpSCfLLEJbFO6iHGQwk/yeSuYkIc=
52-
github.com/0chain/gosdk v1.4.1-0.20220105140556-1e37d2ba4e8a h1:VYZNUfUTdEB3PLT81bkPWBkRNklUymjdUawAYxhWgyw=
53-
github.com/0chain/gosdk v1.4.1-0.20220105140556-1e37d2ba4e8a/go.mod h1:FB2xXhQyIM1vwvQ1jC98wNclbDTBwqrG+Z/IQC0LaBs=
52+
github.com/0chain/gosdk v1.4.1-0.20220127152226-9c642c9955e9 h1:igz4J+VZH10beCmt7SWAdhlH6vtMZ2+jO7XjmUy+WLM=
53+
github.com/0chain/gosdk v1.4.1-0.20220127152226-9c642c9955e9/go.mod h1:FB2xXhQyIM1vwvQ1jC98wNclbDTBwqrG+Z/IQC0LaBs=
5454
github.com/Azure/azure-pipeline-go v0.2.1/go.mod h1:UGSo8XybXnIGZ3epmeBw7Jdz+HiUVpqIlpz/HKHylF4=
5555
github.com/Azure/azure-pipeline-go v0.2.2/go.mod h1:4rQ/NZncSvGqNkkOsNpOU1tgoNuIlp9AfUH5G1tvCHc=
5656
github.com/Azure/azure-storage-blob-go v0.7.0/go.mod h1:f9YQKtsG1nMisotuTPpO0tjNuEjKRYAcJU8/ydDI++4=

0 commit comments

Comments
 (0)