Skip to content

Commit

Permalink
Merge pull request #33 from Go-phie/annie-deps-fix
Browse files Browse the repository at this point in the history
FIX: Annie dependency issue
  • Loading branch information
MeNsaaH authored Jul 25, 2020
2 parents b39b8cc + 0bfe2c8 commit 056f216
Show file tree
Hide file tree
Showing 3 changed files with 157 additions and 22 deletions.
33 changes: 18 additions & 15 deletions downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,34 @@ import (
"path"

"github.com/go-phie/gophie/engine"
"github.com/iawia002/annie/config"
"github.com/iawia002/annie/downloader"
"github.com/iawia002/annie/extractors/types"
"github.com/iawia002/annie/request"
"github.com/iawia002/annie/utils"
log "github.com/sirupsen/logrus"
"github.com/spf13/viper"
)

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

filename, ext, err := utils.GetNameAndExt(url)
if err != nil {
return nil, err
}
size, err := request.Size(url, url)
log.Debug(size)
if err != nil {
return nil, err
}
urlData := downloader.URL{
URL: url,
Size: size,
Ext: ext,
}
streams := map[string]downloader.Stream{
streams := map[string]*types.Stream{
"default": {
URLs: []downloader.URL{urlData},
Parts: []*types.Part{
{
URL: url,
Size: size,
Ext: ext,
},
},
Size: size,
},
}
Expand All @@ -42,11 +42,11 @@ func Extract(url, source string) ([]downloader.Data, error) {
return nil, err
}

return []downloader.Data{
return []*types.Data{
{
Site: source,
Title: filename,
Type: contentType,
Type: types.DataType(contentType),
Streams: streams,
URL: url,
},
Expand All @@ -69,7 +69,7 @@ type Downloader struct {
func (f *Downloader) DownloadFile() error {
var (
err error
data []downloader.Data
data []*types.Data
)

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

config.OutputPath = f.Dir
for _, item := range data {
if item.Err != nil {
// if this error occurs, the preparation step is normal, but the data extraction is wrong.
// the data is an empty struct.
return item.Err
}
err = downloader.Download(item, f.URL, config.ChunkSizeMB)
movieDownloader := downloader.New(downloader.Options{
OutputPath: f.Dir,
Stream: "default",
})
err = movieDownloader.Download(item)
if err != nil {
return err
}
Expand Down
9 changes: 2 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,12 @@ require (
github.com/bisoncorps/mplayer v0.0.0-20200330192254-e2f647162350
github.com/briandowns/spinner v1.11.1
github.com/chromedp/chromedp v0.5.3
github.com/gocolly/colly v1.2.0
github.com/gocolly/colly/v2 v2.0.2-0.20200302170631-ef2d2b016e78
github.com/iawia002/annie v0.0.0-20200217104547-c4b096ad402a
github.com/gocolly/colly/v2 v2.1.0
github.com/iawia002/annie v0.0.0-20200720035628-03c160f28b4b
github.com/manifoldco/promptui v0.7.0
github.com/mensaah/go-cloudflare-scraper v0.0.0-20200516233131-970abdc95990
github.com/mitchellh/go-homedir v1.1.0
github.com/robertkrimen/otto v0.0.0-20191219234010-c382bd3c16ff
github.com/sirupsen/logrus v1.6.0
github.com/spf13/cobra v1.0.0
github.com/spf13/viper v1.7.0
github.com/tebeka/selenium v0.9.9
golang.org/x/net v0.0.0-20200301022130-244492dfa37a // indirect
google.golang.org/appengine v1.6.5 // indirect
)
Loading

0 comments on commit 056f216

Please sign in to comment.