Skip to content

Commit 0bfe2c8

Browse files
committed
FIX: Annie dependency issue
1 parent b39b8cc commit 0bfe2c8

File tree

3 files changed

+157
-22
lines changed

3 files changed

+157
-22
lines changed

downloader/downloader.go

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,34 @@ import (
66
"path"
77

88
"github.com/go-phie/gophie/engine"
9-
"github.com/iawia002/annie/config"
109
"github.com/iawia002/annie/downloader"
10+
"github.com/iawia002/annie/extractors/types"
1111
"github.com/iawia002/annie/request"
1212
"github.com/iawia002/annie/utils"
1313
log "github.com/sirupsen/logrus"
1414
"github.com/spf13/viper"
1515
)
1616

1717
// Extract is the main function for extracting data before passing to Annie
18-
func Extract(url, source string) ([]downloader.Data, error) {
18+
func Extract(url, source string) ([]*types.Data, error) {
1919

2020
filename, ext, err := utils.GetNameAndExt(url)
2121
if err != nil {
2222
return nil, err
2323
}
2424
size, err := request.Size(url, url)
25-
log.Debug(size)
2625
if err != nil {
2726
return nil, err
2827
}
29-
urlData := downloader.URL{
30-
URL: url,
31-
Size: size,
32-
Ext: ext,
33-
}
34-
streams := map[string]downloader.Stream{
28+
streams := map[string]*types.Stream{
3529
"default": {
36-
URLs: []downloader.URL{urlData},
30+
Parts: []*types.Part{
31+
{
32+
URL: url,
33+
Size: size,
34+
Ext: ext,
35+
},
36+
},
3737
Size: size,
3838
},
3939
}
@@ -42,11 +42,11 @@ func Extract(url, source string) ([]downloader.Data, error) {
4242
return nil, err
4343
}
4444

45-
return []downloader.Data{
45+
return []*types.Data{
4646
{
4747
Site: source,
4848
Title: filename,
49-
Type: contentType,
49+
Type: types.DataType(contentType),
5050
Streams: streams,
5151
URL: url,
5252
},
@@ -69,7 +69,7 @@ type Downloader struct {
6969
func (f *Downloader) DownloadFile() error {
7070
var (
7171
err error
72-
data []downloader.Data
72+
data []*types.Data
7373
)
7474

7575
// Extract data to be downloaded with the streams
@@ -90,14 +90,17 @@ func (f *Downloader) DownloadFile() error {
9090
}
9191
}
9292

93-
config.OutputPath = f.Dir
9493
for _, item := range data {
9594
if item.Err != nil {
9695
// if this error occurs, the preparation step is normal, but the data extraction is wrong.
9796
// the data is an empty struct.
9897
return item.Err
9998
}
100-
err = downloader.Download(item, f.URL, config.ChunkSizeMB)
99+
movieDownloader := downloader.New(downloader.Options{
100+
OutputPath: f.Dir,
101+
Stream: "default",
102+
})
103+
err = movieDownloader.Download(item)
101104
if err != nil {
102105
return err
103106
}

go.mod

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,12 @@ require (
66
github.com/bisoncorps/mplayer v0.0.0-20200330192254-e2f647162350
77
github.com/briandowns/spinner v1.11.1
88
github.com/chromedp/chromedp v0.5.3
9-
github.com/gocolly/colly v1.2.0
10-
github.com/gocolly/colly/v2 v2.0.2-0.20200302170631-ef2d2b016e78
11-
github.com/iawia002/annie v0.0.0-20200217104547-c4b096ad402a
9+
github.com/gocolly/colly/v2 v2.1.0
10+
github.com/iawia002/annie v0.0.0-20200720035628-03c160f28b4b
1211
github.com/manifoldco/promptui v0.7.0
13-
github.com/mensaah/go-cloudflare-scraper v0.0.0-20200516233131-970abdc95990
1412
github.com/mitchellh/go-homedir v1.1.0
15-
github.com/robertkrimen/otto v0.0.0-20191219234010-c382bd3c16ff
1613
github.com/sirupsen/logrus v1.6.0
1714
github.com/spf13/cobra v1.0.0
1815
github.com/spf13/viper v1.7.0
1916
github.com/tebeka/selenium v0.9.9
20-
golang.org/x/net v0.0.0-20200301022130-244492dfa37a // indirect
21-
google.golang.org/appengine v1.6.5 // indirect
2217
)

0 commit comments

Comments
 (0)