Skip to content

Commit

Permalink
switch to urfave/cli
Browse files Browse the repository at this point in the history
  • Loading branch information
iawia002 authored and iawia002 committed Jul 3, 2021
1 parent 7a8f915 commit fd6c04a
Show file tree
Hide file tree
Showing 12 changed files with 277 additions and 255 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ jobs:
go get github.com/golangci/golangci-lint/cmd/[email protected]
golangci-lint --version
- name: Lint
run: golangci-lint run ./... -v
run: |
go mod tidy
golangci-lint run ./... -v
- name: Test
env:
GOFLAGS: -mod=mod
Expand Down
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ linter-settings:
linters:
enable:
- goconst
- gofmt
- goimports
- misspell
- unparam
Expand Down
4 changes: 0 additions & 4 deletions config/version.go

This file was deleted.

20 changes: 9 additions & 11 deletions extractors/acfun/acfun.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,21 @@ import (
"net/url"
"regexp"

jsoniter "github.com/json-iterator/go"

"github.com/iawia002/annie/extractors/types"
"github.com/iawia002/annie/parser"
"github.com/iawia002/annie/request"
"github.com/iawia002/annie/utils"
jsoniter "github.com/json-iterator/go"
)

const (
bangumiDataPattern = "window.pageInfo = window.bangumiData = (.*);"
qualityConfigPattern = "window.qualityConfig = (.*);"
bangumiListPattern = "window.bangumiList = (.*);"
bangumiDataPattern = "window.pageInfo = window.bangumiData = (.*);"
bangumiListPattern = "window.bangumiList = (.*);"

bangumiHTMLURL = "https://www.acfun.cn/bangumi/aa%d_36188_%d"
bangumiVideoURL = "https://%s/mediacloud/acfun/acfun_video/hls/"
bangumiHTMLURL = "https://www.acfun.cn/bangumi/aa%d_36188_%d"

referer = "https://www.acfun.cn"
host = "https://www.acfun.cn"
)

type extractor struct{}
Expand All @@ -31,6 +29,7 @@ func New() types.Extractor {
return &extractor{}
}

// Extract ...
func (e *extractor) Extract(URL string, option types.Options) ([]*types.Data, error) {
html, err := request.GetByte(URL, referer, nil)
if err != nil {
Expand Down Expand Up @@ -65,7 +64,7 @@ func (e *extractor) Extract(URL string, option types.Options) ([]*types.Data, er
wgp.Add()
go func() {
defer wgp.Done()
datas = append(datas, extractBangumi(concatURL(t), option))
datas = append(datas, extractBangumi(concatURL(t)))
}()
}
wgp.Wait()
Expand All @@ -76,7 +75,7 @@ func concatURL(epData *episodeData) string {
return fmt.Sprintf(bangumiHTMLURL, epData.BangumiID, epData.ItemID)
}

func extractBangumi(URL string, option types.Options) *types.Data {
func extractBangumi(URL string) *types.Data {
var err error
html, err := request.GetByte(URL, referer, nil)
if err != nil {
Expand All @@ -98,8 +97,7 @@ func extractBangumi(URL string, option types.Options) *types.Data {

urls, err := utils.M3u8URLs(m3u8URL.String())
if err != nil {

m3u8URL, err = url.Parse(stm.URL)
_, err = url.Parse(stm.URL)
if err != nil {
return types.EmptyData(URL, err)
}
Expand Down
3 changes: 2 additions & 1 deletion extractors/iqiyi/iqiyi.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ func getVF(params string) string {
} else {
v8 = v4 + 49
}
suffix += string(v8) // string(97) -> "a"
// string(97) -> "a"
suffix += string(v8) // nolint
}
}
params += suffix
Expand Down
2 changes: 0 additions & 2 deletions extractors/types/defs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@ import (
var (
// ErrURLParseFailed defines url parse failed error.
ErrURLParseFailed = errors.New("url parse failed")
// ErrLoginRequired defines login required error.
ErrLoginRequired = errors.New("login required")
)
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ require (
github.com/kr/pretty v0.1.0
github.com/robertkrimen/otto v0.0.0-20191219234010-c382bd3c16ff
github.com/tidwall/gjson v1.8.1
github.com/urfave/cli/v2 v2.3.0
gopkg.in/sourcemap.v1 v1.0.5 // indirect
)
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand Down Expand Up @@ -285,9 +287,11 @@ github.com/robertkrimen/otto v0.0.0-20191219234010-c382bd3c16ff/go.mod h1:xvqspo
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
Expand Down Expand Up @@ -322,6 +326,8 @@ github.com/tidwall/match v1.0.3/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JT
github.com/tidwall/pretty v1.1.0 h1:K3hMW5epkdAVwibsQEfR/7Zj0Qgt4DxtNumTq/VloO8=
github.com/tidwall/pretty v1.1.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M=
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
github.com/vbauerster/mpb/v5 v5.4.0/go.mod h1:fi4wVo7BVQ22QcvFObm+VwliQXlV1eBT8JDaKXR4JGI=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/ysmood/goob v0.3.0 h1:XZ51cZJ4W3WCoCiUktixzMIQF86W7G5VFL4QQ/Q2uS0=
Expand Down
18 changes: 0 additions & 18 deletions go.test.sh

This file was deleted.

Loading

0 comments on commit fd6c04a

Please sign in to comment.