leeeboo 最近的时间轴更新
leeeboo

leeeboo

V2EX 第 65388 号会员,加入于 2014-06-17 15:04:35 +08:00
leeeboo 最近回复了
备注一下,ng-zorro & ng-alain 如果没有接触过问题不大,但 Angular 是刚需
2019-06-14 17:26:41 +08:00
回复了 NieKing 创建的主题 程序员 国内 Remote 工作推荐?
我司是远程工作的,你是做什么的?
2019-03-08 16:18:34 +08:00
回复了 pidan 创建的主题 互联网 熊猫关服务器了,想下载喜欢的主播的高能视频
package main

import (
"crypto/tls"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"os/exec"
"strings"
)

type Video struct {
Vurl string `json:"v_url"`
Title string `json:"title"`
}

type Data struct {
Total int `json:"total"`
Items []Video `json:"items"`
}

type Resp struct {
ErrNo int `json:"errno"`
ErrMsg string `json:"errmsg"`
Data Data
}

var success int
var fail int

func init() {
success = 0
fail = 0
}

func main() {

page := 1
count := 20

for {

api := fmt.Sprintf("https://vod.gate.panda.tv/api/hostvideos?token=efcc794d06d7718d674306c6ee1b8096&hostid=3169412&pageno=%d&pagenum=%d&__plat=pc_web&_=1552030867202", page, count)

body, err := httpGet(api, nil)

if err != nil {
panic(err)
}

var resp Resp

err = json.Unmarshal(body, &resp)

if err != nil {
panic(err)
}

if resp.ErrNo != 0 {
fmt.Errorf("%s\n", resp.ErrMsg)
break
}

if len(resp.Data.Items) <= 0 {
fmt.Println("完成了!")
break
}

for _, video := range resp.Data.Items {
fmt.Println("Starting...", video.Title, video.Vurl)

download(video.Vurl, video.Title)
}

page++
}

select {}
}

func download(u string, title string) {

c := fmt.Sprintf("./m3u8.sh %s ./video/%s", u, title)
cmd := exec.Command("sh", "-c", c)
_, err := cmd.Output()

if err != nil {
fmt.Println(err.Error(), title, "失败")
success++
} else {
fmt.Println(title, "成功")
fail++
}
}

func httpGet(api string, param map[string]interface{}) ([]byte, error) {

queryStr, err := build(param)

if err != nil {
return nil, err
}

apiInfo, err := url.Parse(api)

if err != nil {
return nil, err
}

if apiInfo.RawQuery == "" {
api = fmt.Sprintf("%s?%s", api, queryStr)
} else {
api = fmt.Sprintf("%s&%s", api, queryStr)
}

http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}

resp, err := http.Get(api)

if err != nil {
return nil, err
}

defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)

return body, err
}

func build(raw map[string]interface{}) (string, error) {

p := make(map[string]string, 0)

for k, v := range raw {

switch vv := v.(type) {
case []interface{}:

parseNormal(p, vv, []string{k})

break
case map[string]interface{}:

parseKeyValue(p, vv, []string{k})

break
default:

p[k] = fmt.Sprintf("%s", vv)

break
}
}

data := url.Values{}

for k, v := range p {
data.Add(k, v)
}

return data.Encode(), nil
}

func parseKeyValue(p map[string]string, raw map[string]interface{}, keys []string) {

for k, v := range raw {
switch vv := v.(type) {
case []interface{}:

tmpKeys := append(keys, k)

parseNormal(p, vv, tmpKeys)

break
case map[string]interface{}:

tmpKeys := append(keys, k)

parseKeyValue(p, vv, tmpKeys)

break
default:

//keys = append(keys, k)

var tmp []string

for m, n := range keys {
if m > 0 {
n = fmt.Sprintf("[%s]", n)
}

tmp = append(tmp, n)
}

kStr := strings.Join(tmp, "")

p[fmt.Sprintf("%s[%s]", kStr, k)] = fmt.Sprintf("%s", vv)

break
}
}
}

func parseNormal(p map[string]string, raw []interface{}, keys []string) {

for k, v := range raw {
switch vv := v.(type) {
case []interface{}:

tmpKeys := append(keys, fmt.Sprintf("%d", k))

parseNormal(p, vv, tmpKeys)

break
case map[string]interface{}:

tmpKeys := append(keys, fmt.Sprintf("%d", k))

parseKeyValue(p, vv, tmpKeys)

break
default:

//keys = append(keys, fmt.Sprintf("%d", k))

var tmp []string

for m, n := range keys {
if m > 0 {
n = fmt.Sprintf("[%s]", n)
}

tmp = append(tmp, n)
}

kStr := strings.Join(tmp, "")

p[fmt.Sprintf("%s[%d]", kStr, k)] = fmt.Sprintf("%s", vv)

break
}
}
}

我已经开始下了 @pidan
2019-03-08 15:42:59 +08:00
回复了 pidan 创建的主题 互联网 熊猫关服务器了,想下载喜欢的主播的高能视频
https://vod.gate.panda.tv/api/hostvideos?token=XXX&hostid=3169412&pageno=1&pagenum=12&__plat=pc_web&_=1552030867202

这个是获取高能列表的 api,其中 pageno 和 pagenum 就是分页,token 我不能给你我的,你自己登陆看看吧就是在 https://www.panda.tv/20641 这个页面开 chrome 的 console 看 network,过滤只看 xhr 就能找到这个请求
2019-03-08 15:40:04 +08:00
回复了 pidan 创建的主题 互联网 熊猫关服务器了,想下载喜欢的主播的高能视频
例如:
https://v.panda.tv/video/70466

关键是这个:
https://vod.gate.panda.tv/api/singlevideo?__plat=pc_web&_=1552030554705&videoid=70468
1552030554705 是时间戳
70468 这个是 video 的 id
这个接口会返回一个字段:v_url
例如: https://pl-vod28.live.panda.tv/transcode/20641/2019-03-01/c1a47ce176593250334a9c6ab7a2d831/index.m3u8
这个就是 m3u8

我也想弄,但这两天特别忙,兄弟费心了 @pidan
2019-01-04 13:57:20 +08:00
回复了 vhus 创建的主题 宽带症候群 南京电信终于把 IPV6 搞通了, IPV6 还有啥玩法儿?
现在北京联通又没有 v6 了
2018-11-29 16:25:56 +08:00
回复了 Liqianyu 创建的主题 宽带症候群 路由器丢弃指定域名 AAAA 记录
@Liqianyu 确实如果有一个 iptables 的脚本就好了,一键丢弃所有被 reset 的域名的 AAAA
2018-11-21 08:20:17 +08:00
回复了 cyyself 创建的主题 宽带症候群 iOS 三网 IPv6 APN 配置文件
@cyyself 谢谢!
2018-11-20 17:59:26 +08:00
回复了 cyyself 创建的主题 宽带症候群 iOS 三网 IPv6 APN 配置文件
@cyyself 请教 ios12.1 还有删除无效的 bug 么?谢谢
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5107 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 14ms · UTC 09:45 · PVG 17:45 · LAX 02:45 · JFK 05:45
Developed with CodeLauncher
♥ Do have faith in what you're doing.