Skip to content

Commit

Permalink
code format
Browse files Browse the repository at this point in the history
  • Loading branch information
iawia002 committed Apr 19, 2024
1 parent 3f3e647 commit 4c772e5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,6 @@ As a text file:
$ lux -c cookies.txt "https://www.bilibili.com/video/av20203945"
```

Another example
```
$ lux -c "msToken=yoEh0-qLUq4obZ8Sfxsem_CxCo9R3NM6ViTrWaRcM1...; ttwid=1%7C..." "https://m.toutiao.com/is/iYbTfJ79/"
```

### Proxy

You can set the HTTP/SOCKS5 proxy using environment variables:
Expand Down Expand Up @@ -660,8 +655,12 @@ $ lux -j "https://www.bilibili.com/video/av20203945"

最好是每次下载都附带登录过的 Cookie 以避免部分 `ccode` 的问题

### 西瓜&头条
西瓜&头条视频必须带Cookie才能下载成功,西瓜和头条可共用西瓜视频的Cookie,Cookie的有效期可能较短,下载失败就更新Cookie尝试(2024-04-19)
### 西瓜/头条视频
西瓜/头条视频必须带 Cookie 才能下载成功,西瓜和头条可共用西瓜视频的 Cookie,Cookie 的有效期可能较短,下载失败就更新 Cookie 尝试:

```
$ lux -c "msToken=yoEh0-qLUq4obZ8Sfxsem_CxCo9R3NM6ViTrWaRcM1...; ttwid=1%7C..." "https://m.toutiao.com/is/iYbTfJ79/"
```

## Contributing

Expand Down
15 changes: 6 additions & 9 deletions extractors/ixigua/ixigua.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
browser "github.com/EDDYCJY/fake-useragent"
"github.com/iawia002/lux/utils"
"net/http"
"regexp"
"strings"

browser "github.com/EDDYCJY/fake-useragent"
"github.com/pkg/errors"

"github.com/iawia002/lux/extractors"
"github.com/iawia002/lux/request"
"github.com/iawia002/lux/utils"
)

func init() {
Expand Down Expand Up @@ -71,7 +71,6 @@ func (e *extractor) Extract(url string, option extractors.Options) ([]*extractor

r := regexp.MustCompile(`(ixigua.com/)(\w+)?`)
id := r.FindSubmatch([]byte(finalURL))[2]
//url2 := fmt.Sprintf("https://www.ixigua.com/api/public/videov2/brief/details?group_id=%s", string(id))
url2 := fmt.Sprintf("https://www.ixigua.com/%s", string(id))

body, err := request.Get(url2, url, headers)
Expand All @@ -87,15 +86,13 @@ func (e *extractor) Extract(url string, option extractors.Options) ([]*extractor
videoUrl := videoListJson[1]
videoUrl = strings.Replace(videoUrl, ":undefined", ":\"undefined\"", -1)

// 解析JSON字符串
var xiguanData xiguanData
err = json.Unmarshal([]byte(videoUrl), &xiguanData)
if err != nil {
var data xiguanData
if err = json.Unmarshal([]byte(videoUrl), &data); err != nil {
return nil, errors.WithStack(err)
}

title := xiguanData.AnyVideo.GidInformation.PackerData.Video.Title
videoList := xiguanData.AnyVideo.GidInformation.PackerData.Video.VideoResource.Normal.VideoList
title := data.AnyVideo.GidInformation.PackerData.Video.Title
videoList := data.AnyVideo.GidInformation.PackerData.Video.VideoResource.Normal.VideoList

streams := make(map[string]*extractors.Stream)
for _, v := range videoList {
Expand Down

0 comments on commit 4c772e5

Please sign in to comment.