This repository has been archived by the owner on Aug 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 150
/
json.go
95 lines (83 loc) · 2.9 KB
/
json.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package ytdl
import (
"github.com/antchfx/jsonquery"
)
type playerConfig struct {
Assets struct {
JS string `json:"js"`
} `json:"assets"`
Args struct {
Status string `json:"status"`
Errorcode string `json:"errorcode"`
Reason string `json:"reason"`
PlayerResponse string `json:"player_response"`
URLEncodedFmtStreamMap string `json:"url_encoded_fmt_stream_map"`
AdaptiveFmts string `json:"adaptive_fmts"`
Dashmpd string `json:"dashmpd"`
} `json:"args"`
}
type formatInfo struct {
Itag int `json:"itag"`
MimeType string `json:"mimeType"`
Bitrate int `json:"bitrate"`
Width int `json:"width"`
Height int `json:"height"`
LastModified string `json:"lastModified"`
ContentLength string `json:"contentLength"`
Quality string `json:"quality"`
QualityLabel string `json:"qualityLabel"`
ProjectionType string `json:"projectionType"`
AverageBitrate int `json:"averageBitrate"`
AudioQuality string `json:"audioQuality"`
ApproxDurationMs string `json:"approxDurationMs"`
AudioSampleRate string `json:"audioSampleRate"`
AudioChannels int `json:"audioChannels"`
Cipher *string `json:"cipher"`
SignatureCipher *string `json:"signatureCipher"`
URL string `json:"url"`
Index *Range `json:"indexRange,omitempty"`
Init *Range `json:"initRange,omitempty"`
}
type playerResponse struct {
PlayabilityStatus struct {
Status string `json:"status"`
Reason string `json:"reason"`
} `json:"playabilityStatus"`
StreamingData struct {
ExpiresInSeconds string `json:"expiresInSeconds"`
Formats []formatInfo `json:"formats"`
AdaptiveFormats []formatInfo `json:"adaptiveFormats"`
DashManifestUrl string `json:"dashManifestUrl"`
HlsManifestUrl string `json:"hlsManifestUrl"`
} `json:"streamingData"`
VideoDetails struct {
Title string `json:"title"`
Author string `json:"author"`
LengthSeconds string `json:"lengthSeconds"`
Keywords []string `json:"keywords"`
ViewCount string `json:"viewCount"`
} `json:"videoDetails"`
Microformat struct {
Renderer struct {
ViewCount string `json:"viewCount"`
PublishDate string `json:"publishDate"`
UploadDate string `json:"uploadDate"`
} `json:"playerMicroformatRenderer"`
} `json:"microformat"`
}
type representation struct {
Itag int `xml:"id,attr"`
Height int `xml:"height,attr"`
URL string `xml:"BaseURL"`
}
func getMetaDataRow(row *jsonquery.Node) (string, string) {
title, _ := jsonquery.Query(row, "title")
text, _ := jsonquery.Query(row, "contents//simpleText")
if text == nil {
text, _ = jsonquery.Query(row, "contents//text")
}
if title == nil || text == nil {
return "", ""
}
return title.InnerText(), text.InnerText()
}