livestream improvements, "search" function
This commit is contained in:
parent
c616c9b5fe
commit
396c4a456e
310
main.go
310
main.go
|
@ -21,6 +21,7 @@ import (
|
|||
)
|
||||
|
||||
var Os, Ip, DeviceId string;
|
||||
var liveClient *http.Client
|
||||
|
||||
func DownloadAweme(filename string, uri string) (bool, error) {
|
||||
var (
|
||||
|
@ -59,13 +60,29 @@ func DownloadAweme(filename string, uri string) (bool, error) {
|
|||
}
|
||||
return false, nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
liveClient = createHTTPClient()
|
||||
}
|
||||
func createHTTPClient() *http.Client {
|
||||
client := &http.Client{
|
||||
Transport: &http.Transport{
|
||||
MaxIdleConnsPerHost: 20,
|
||||
},
|
||||
Timeout: 0,//time.Duration(RequestTimeout) * time.Second,
|
||||
}
|
||||
return client
|
||||
}
|
||||
func DownloadStream(filename string, uri string) (bool, error) {
|
||||
var (
|
||||
e error
|
||||
f *os.File
|
||||
rs *http.Response
|
||||
rq *http.Request
|
||||
|
||||
/*tr = &http.Transport{
|
||||
IdleConnTimeout: 0,
|
||||
}
|
||||
client = &http.Client{Transport: tr}*/
|
||||
)
|
||||
/*_, e = os.Stat(filename)
|
||||
if e == nil {
|
||||
|
@ -73,11 +90,14 @@ func DownloadStream(filename string, uri string) (bool, error) {
|
|||
} else if !os.IsNotExist(e) {
|
||||
return true, e
|
||||
}*/
|
||||
|
||||
rq, e = http.NewRequest("GET", uri, nil)
|
||||
rq.Header.Set("User-Agent", "okhttp")
|
||||
fmt.Println(rq.Header)
|
||||
//rq.Header.Set("Connection", "keep-alive")
|
||||
fmt.Println(rq)
|
||||
rs, e = http.DefaultClient.Do(rq)
|
||||
rs, e = liveClient.Do(rq)
|
||||
//rs, e = http.DefaultClient.Do(rq)
|
||||
if e != nil {
|
||||
return false, e
|
||||
//DownloadStream(filename, uri)
|
||||
|
@ -103,6 +123,7 @@ func DownloadStream(filename string, uri string) (bool, error) {
|
|||
if e != nil {
|
||||
return false, e
|
||||
}*/
|
||||
// 00 00 00 00 17 01 00 00 00 00 00 00 6a 06 64
|
||||
_, e = io.Copy(f, rs.Body)
|
||||
f.Close()
|
||||
if e != nil {
|
||||
|
@ -336,12 +357,12 @@ func GetUserInfo(id string, retry int) (string, bool, int, int, int, int, string
|
|||
}
|
||||
return "", false, 0, 0, 0, 0, "", "", "", 0, e
|
||||
} else if len(d.User.UniqueId) == 0 {
|
||||
return "", false, 0, 0, 0, 0, "", "", "", 0, errors.New("Cannot find user name.")
|
||||
return "", false, 0, 0, 0, 0, "", "", "", 0, errors.New("error: Invalid user id or user no longer exists")
|
||||
}
|
||||
return d.User.UniqueId, d.User.Secret != 0, d.User.AwemeCount, d.User.FollowCount, d.User.FollowingCount, d.User.Likes, d.User.Ig, d.User.Yt, d.User.X, d.User.RoomId, nil
|
||||
}
|
||||
|
||||
func GetUserIdFromVideos(username string, retry int) (string, bool, int, int, int, int, string, string, string, int64, error) {
|
||||
func GetUserIdFromVideos(username string, related []string, retry int) (string, bool, int, int, int, int, string, string, string, int64, error) {
|
||||
var (
|
||||
i int
|
||||
e error
|
||||
|
@ -378,7 +399,7 @@ func GetUserIdFromVideos(username string, retry int) (string, bool, int, int, in
|
|||
if e != nil {
|
||||
if retry < 7 {
|
||||
Ip = GeneratePublicIp()
|
||||
return GetUserIdFromVideos(username, retry + 1)
|
||||
return GetUserIdFromVideos(username, related, retry + 1)
|
||||
}
|
||||
return "", false, 0, 0, 0, 0, "", "", "", 0, e
|
||||
}
|
||||
|
@ -387,7 +408,16 @@ func GetUserIdFromVideos(username string, retry int) (string, bool, int, int, in
|
|||
return GetUserInfo(d.AwemeList[i].Author.Uid, 0)
|
||||
}
|
||||
}
|
||||
return "", false, 0, 0, 0, 0, "", "", "", 0, errors.New("Cannot find user id.")
|
||||
fmt.Println("User not found!")
|
||||
if len(related) > 0 {
|
||||
fmt.Println("Did you mean: ")
|
||||
for i = 0; i < 10; i++ {
|
||||
fmt.Println(related[i])
|
||||
}
|
||||
} else {
|
||||
fmt.Println("(no related usernames found)")
|
||||
}
|
||||
return "", false, 0, 0, 0, 0, "", "", "", 0, errors.New("error: Username not found")
|
||||
}
|
||||
|
||||
func GetUserId(username string, retry int) (string, bool, int, int, int, int, string, string, string, int64, error) {
|
||||
|
@ -395,6 +425,7 @@ func GetUserId(username string, retry int) (string, bool, int, int, int, int, st
|
|||
i int
|
||||
e error
|
||||
b []byte
|
||||
related []string
|
||||
d struct {
|
||||
UserList []struct {
|
||||
UserInfo struct {
|
||||
|
@ -437,7 +468,62 @@ func GetUserId(username string, retry int) (string, bool, int, int, int, int, st
|
|||
return d.UserList[i].UserInfo.Uid, d.UserList[i].UserInfo.Secret != 0, d.UserList[i].UserInfo.AwemeCount, d.UserList[i].UserInfo.FollowCount, d.UserList[i].UserInfo.FollowingCount, d.UserList[i].UserInfo.Likes, d.UserList[i].UserInfo.Ig, d.UserList[i].UserInfo.Yt, d.UserList[i].UserInfo.X, d.UserList[i].UserInfo.RoomId, nil
|
||||
}
|
||||
}
|
||||
return GetUserIdFromVideos(username, 0)
|
||||
related = make([]string, 0)
|
||||
for i = 0; i < len(d.UserList); i++ {
|
||||
related = append(related, d.UserList[i].UserInfo.UniqueId + " (" + d.UserList[i].UserInfo.Uid + ")")
|
||||
}
|
||||
return GetUserIdFromVideos(username, related, 0)
|
||||
}
|
||||
|
||||
func SearchUsers(username string, cursor *int, retry int) (users []string, more bool, _error error) {
|
||||
var (
|
||||
i int
|
||||
e error
|
||||
b []byte
|
||||
d struct {
|
||||
HasMore int "json:\"has_more\""
|
||||
UserList []struct {
|
||||
UserInfo struct {
|
||||
UniqueId string "json:\"unique_id\""
|
||||
Uid string "json:\"uid\""
|
||||
AwemeCount int "json:\"aweme_count\""
|
||||
FollowCount int "json:\"follower_count\""
|
||||
FollowingCount int "json:\"following_count\""
|
||||
Likes int "json:\"total_favorited\""
|
||||
Ig string "json:\"ins_id\""
|
||||
Yt string "json:\"youtube_channel_id\""
|
||||
X string "json:\"signature\""
|
||||
Secret int "json:\"secret\""
|
||||
RoomId int64 "json:\"room_id\""
|
||||
} "json:\"user_info\""
|
||||
} "json:\"user_list\""
|
||||
}
|
||||
)
|
||||
b, e = AwemeRequest("/aweme/v1/discover/search/" +
|
||||
"?keyword=" + url.QueryEscape(username) +
|
||||
"&count=20" +
|
||||
"&cursor=" + strconv.Itoa(*cursor) +
|
||||
"&type=1" +
|
||||
"&search_source=discover" +
|
||||
"&is_pull_refresh=1" +
|
||||
"&hot_search=0")
|
||||
if e != nil {
|
||||
return nil, false, e
|
||||
}
|
||||
e = json.Unmarshal(b, &d)
|
||||
if e != nil {
|
||||
if retry < 7 {
|
||||
Ip = GeneratePublicIp()
|
||||
return SearchUsers(username, cursor, retry + 1)
|
||||
}
|
||||
return nil, false, e
|
||||
}
|
||||
users = make([]string, 0)
|
||||
for i = 0; i < len(d.UserList); i++ {
|
||||
users = append(users, d.UserList[i].UserInfo.Uid + "\t" + d.UserList[i].UserInfo.UniqueId)
|
||||
}
|
||||
*cursor += 20
|
||||
return users, d.HasMore != 0, nil
|
||||
}
|
||||
|
||||
func GetUserVideos(id string, until int64, cursor *int64, retry int) (videos []string, more bool, _error error) {
|
||||
|
@ -493,7 +579,7 @@ func GetUserVideos(id string, until int64, cursor *int64, retry int) (videos []s
|
|||
return videos, d.HasMore != 0, nil
|
||||
}
|
||||
|
||||
func GetUserFollows(id string, cursor *int64, retry int) (follows []string, followsn []string, more bool, _error error) {
|
||||
func GetUserFollows(id string, cursor *int64, retry int) (follows []string, more bool, _error error) {
|
||||
var (
|
||||
i int
|
||||
e error
|
||||
|
@ -512,7 +598,7 @@ func GetUserFollows(id string, cursor *int64, retry int) (follows []string, foll
|
|||
"&count=20" +
|
||||
"&max_time=" + strconv.FormatInt(*cursor, 10))
|
||||
if e != nil {
|
||||
return nil, nil, false, e
|
||||
return nil, false, e
|
||||
}
|
||||
e = json.Unmarshal(b, &d)
|
||||
if e != nil {
|
||||
|
@ -520,19 +606,19 @@ func GetUserFollows(id string, cursor *int64, retry int) (follows []string, foll
|
|||
Ip = GeneratePublicIp()
|
||||
return GetUserFollows(id, cursor, retry + 1)
|
||||
}
|
||||
return nil, nil, false, e
|
||||
return nil, false, e
|
||||
}
|
||||
follows = make([]string, 0)
|
||||
followsn = make([]string, 0)
|
||||
//followsn = make([]string, 0)
|
||||
for i = 0; i < len(d.UserList); i++ {
|
||||
follows = append(follows, d.UserList[i].Uid)
|
||||
followsn = append(followsn, d.UserList[i].UniqueId)
|
||||
follows = append(follows, d.UserList[i].Uid + "\t" + d.UserList[i].UniqueId)
|
||||
//followsn = append(followsn, d.UserList[i].UniqueId)
|
||||
}
|
||||
*cursor = d.MaxCursor
|
||||
return follows, followsn, d.HasMore != false, nil
|
||||
return follows, d.HasMore != false, nil
|
||||
}
|
||||
|
||||
func GetUserFollowers(id string, cursor *int64, retry int) (followers []string, followersn []string, more bool, _error error) {
|
||||
func GetUserFollowers(id string, cursor *int64, retry int) (followers []string, more bool, _error error) {
|
||||
var (
|
||||
i int
|
||||
e error
|
||||
|
@ -551,7 +637,7 @@ func GetUserFollowers(id string, cursor *int64, retry int) (followers []string,
|
|||
"&count=20" +
|
||||
"&max_time=" + strconv.FormatInt(*cursor, 10))
|
||||
if e != nil {
|
||||
return nil, nil, false, e
|
||||
return nil, false, e
|
||||
}
|
||||
e = json.Unmarshal(b, &d)
|
||||
if e != nil {
|
||||
|
@ -559,19 +645,19 @@ func GetUserFollowers(id string, cursor *int64, retry int) (followers []string,
|
|||
Ip = GeneratePublicIp()
|
||||
return GetUserFollows(id, cursor, retry + 1)
|
||||
}
|
||||
return nil, nil, false, e
|
||||
return nil, false, e
|
||||
}
|
||||
followers = make([]string, 0)
|
||||
followersn = make([]string, 0)
|
||||
//followersn = make([]string, 0)
|
||||
for i = 0; i < len(d.UserList); i++ {
|
||||
followers = append(followers, d.UserList[i].Uid)
|
||||
followersn = append(followersn, d.UserList[i].UniqueId)
|
||||
followers = append(followers, d.UserList[i].Uid + "\t" + d.UserList[i].UniqueId)
|
||||
//followersn = append(followersn, d.UserList[i].UniqueId)
|
||||
}
|
||||
*cursor = d.MaxCursor
|
||||
return followers, followersn, d.HasMore != false, nil
|
||||
return followers, d.HasMore != false, nil
|
||||
}
|
||||
|
||||
func GetUserFavorites(id string, cursor *int64, retry int) (videoids []string, videourls []string, authorid []string, authorname []string, _error error) {
|
||||
func GetUserFavorites(id string, cursor *int64, retry int) (videos []string, more bool, _error error) {
|
||||
var (
|
||||
i int
|
||||
e error
|
||||
|
@ -598,7 +684,7 @@ func GetUserFavorites(id string, cursor *int64, retry int) (videoids []string, v
|
|||
"&count=20" +
|
||||
"&max_cursor=" + strconv.FormatInt(*cursor, 10))
|
||||
if e != nil {
|
||||
return nil, nil, nil, nil, e
|
||||
return nil, false, e
|
||||
}
|
||||
e = json.Unmarshal(b, &d)
|
||||
if e != nil {
|
||||
|
@ -606,22 +692,14 @@ func GetUserFavorites(id string, cursor *int64, retry int) (videoids []string, v
|
|||
Ip = GeneratePublicIp()
|
||||
return GetUserFavorites(id, cursor, retry + 1)
|
||||
}
|
||||
return nil, nil, nil, nil, e
|
||||
return nil, false, e
|
||||
}
|
||||
videoids = make([]string, 0)
|
||||
videourls = make([]string, 0)
|
||||
authorid = make([]string, 0)
|
||||
authorname = make([]string, 0)
|
||||
videos = make([]string, 0)
|
||||
for i = 0; i < len(d.AwemeList); i++ {
|
||||
videoids = append(videoids, d.AwemeList[i].AwemeId)
|
||||
authorid = append(authorid, d.AwemeList[i].UserInfo.Uid)
|
||||
authorname = append(authorname, d.AwemeList[i].UserInfo.UniqueId)
|
||||
if len(d.AwemeList[i].Video.PlayAddr.UrlList) > 0 {
|
||||
videourls = append(videourls, d.AwemeList[i].Video.PlayAddr.UrlList[0])
|
||||
}
|
||||
videos = append(videos, d.AwemeList[i].AwemeId + "\t" + d.AwemeList[i].UserInfo.Uid + "\t" + d.AwemeList[i].UserInfo.UniqueId + "\t" + d.AwemeList[i].Video.PlayAddr.UrlList[0])
|
||||
}
|
||||
*cursor = d.MaxCursor
|
||||
return videoids, videourls, authorid, authorname, nil
|
||||
return videos, d.HasMore != 0, nil
|
||||
}
|
||||
|
||||
func GetHashtag(keyword string, retry int) (cid string, _error error) {
|
||||
|
@ -644,7 +722,6 @@ func GetHashtag(keyword string, retry int) (cid string, _error error) {
|
|||
"&search_source=challenge" +
|
||||
"&is_pull_refresh=1" +
|
||||
"&hot_search=0")
|
||||
fmt.Println(len(b))
|
||||
if e != nil {
|
||||
return "", e
|
||||
}
|
||||
|
@ -659,7 +736,7 @@ func GetHashtag(keyword string, retry int) (cid string, _error error) {
|
|||
return d.ChallengeList[0].ChallengeInfo.Id, nil
|
||||
}
|
||||
|
||||
func GetHashtagVideos(top bool, id string, cursor *int, retry int) (videos []string, users []string, usersn []string, urls []string, more bool, _error error) {
|
||||
func GetHashtagVideos(top bool, id string, cursor *int, retry int) (videos []string, more bool, _error error) {
|
||||
var (
|
||||
i int
|
||||
e error
|
||||
|
@ -697,7 +774,7 @@ func GetHashtagVideos(top bool, id string, cursor *int, retry int) (videos []str
|
|||
"&type=5")
|
||||
}
|
||||
if e != nil {
|
||||
return nil, nil, nil, nil, false, e
|
||||
return nil, false, e
|
||||
}
|
||||
e = json.Unmarshal(b, &d)
|
||||
if e != nil {
|
||||
|
@ -705,23 +782,17 @@ func GetHashtagVideos(top bool, id string, cursor *int, retry int) (videos []str
|
|||
Ip = GeneratePublicIp()
|
||||
return GetHashtagVideos(top, id, cursor, retry + 1)
|
||||
}
|
||||
return nil, nil, nil, nil, false, e
|
||||
return nil, false, e
|
||||
}
|
||||
videos = make([]string, 0)
|
||||
users = make([]string, 0)
|
||||
usersn = make([]string, 0)
|
||||
urls = make([]string, 0)
|
||||
for i = 0; i < len(d.AwemeList); i++ {
|
||||
videos = append(videos, d.AwemeList[i].AwemeId)
|
||||
users = append(users, d.AwemeList[i].UserInfo.Uid)
|
||||
usersn = append(usersn, d.AwemeList[i].UserInfo.UniqueId)
|
||||
urls = append(urls, d.AwemeList[i].Video.PlayAddr.UrlList[0])
|
||||
videos = append(videos, d.AwemeList[i].AwemeId + "\t" + d.AwemeList[i].UserInfo.Uid + "\t" + d.AwemeList[i].UserInfo.UniqueId + "\t" + d.AwemeList[i].Video.PlayAddr.UrlList[0])
|
||||
}
|
||||
*cursor += 20
|
||||
return videos, users, usersn, urls, d.HasMore != 0, nil
|
||||
return videos, d.HasMore != 0, nil
|
||||
}
|
||||
|
||||
func GetMusicVideos(top bool, id string, cursor *int, retry int) (ids []string, videos []string, users []string, usersn []string, more bool, _error error) {
|
||||
func GetMusicVideos(top bool, id string, cursor *int, retry int) (videos []string, more bool, _error error) {
|
||||
var (
|
||||
i int
|
||||
e error
|
||||
|
@ -758,7 +829,7 @@ func GetMusicVideos(top bool, id string, cursor *int, retry int) (ids []string,
|
|||
"&type=6")
|
||||
}
|
||||
if e != nil {
|
||||
return nil, nil, nil, nil, false, e
|
||||
return nil, false, e
|
||||
}
|
||||
e = json.Unmarshal(b, &d)
|
||||
if e != nil {
|
||||
|
@ -766,22 +837,22 @@ func GetMusicVideos(top bool, id string, cursor *int, retry int) (ids []string,
|
|||
Ip = GeneratePublicIp()
|
||||
return GetMusicVideos(top, id, cursor, retry + 1)
|
||||
}
|
||||
return nil, nil, nil, nil, false, e
|
||||
return nil, false, e
|
||||
}
|
||||
ids = make([]string, 0)
|
||||
//ids = make([]string, 0)
|
||||
videos = make([]string, 0)
|
||||
users = make([]string, 0)
|
||||
usersn = make([]string, 0)
|
||||
//users = make([]string, 0)
|
||||
//usersn = make([]string, 0)
|
||||
for i = 0; i < len(d.AwemeList); i++ {
|
||||
ids = append(ids, d.AwemeList[i].AwemeId)
|
||||
if len(d.AwemeList[i].Video.PlayAddr.UrlList) > 0 {
|
||||
videos = append(videos, d.AwemeList[i].Video.AwemeId, d.AwemeList[i].Video.PlayAddr.UrlList[0])
|
||||
}
|
||||
users = append(users, d.AwemeList[i].UserInfo.Uid)
|
||||
usersn = append(usersn, d.AwemeList[i].UserInfo.UniqueId)
|
||||
//ids = append(ids, d.AwemeList[i].AwemeId)
|
||||
//if len(d.AwemeList[i].Video.PlayAddr.UrlList) > 0 {
|
||||
videos = append(videos, d.AwemeList[i].AwemeId + "\t" + d.AwemeList[i].UserInfo.Uid + "\t" + d.AwemeList[i].UserInfo.UniqueId + "\t" + d.AwemeList[i].Video.PlayAddr.UrlList[0])
|
||||
//}
|
||||
//users = append(users, d.AwemeList[i].UserInfo.Uid)
|
||||
//usersn = append(usersn, d.AwemeList[i].UserInfo.UniqueId)
|
||||
}
|
||||
*cursor += 20
|
||||
return ids, videos, users, usersn, d.HasMore != 0, nil
|
||||
return videos, d.HasMore != 0, nil
|
||||
}
|
||||
|
||||
func GetVideos(ids string, retry int) (videos []string, _error error) {
|
||||
|
@ -879,7 +950,7 @@ func GetVideoInfo(id string, retry int) (awemeid string, auth string, ctime int6
|
|||
return d.AwemeDetails.AwemeId, d.AwemeDetails.Author.Uid, d.AwemeDetails.CreateTime, d.AwemeDetails.Video.PlayAddr.UrlList[0], d.AwemeDetails.Video.DownloadAddr.UrlList[0], d.AwemeDetails.Music.Uid, d.AwemeDetails.Music.Title, d.AwemeDetails.Music.Author, d.AwemeDetails.Desc, d.AwemeDetails.Stats.Comments, d.AwemeDetails.Stats.Downloads, d.AwemeDetails.Stats.Views, d.AwemeDetails.Stats.Shares, d.AwemeDetails.Status.IsPrivate, d.AwemeDetails.Status.InReviewing, d.AwemeDetails.Status.SelfSee, nil
|
||||
}
|
||||
|
||||
func GetVideoComments(id string, cursor *int, retry int) (users []string, usersn []string, texts []string, more bool, _error error) {
|
||||
func GetVideoComments(id string, cursor *int, retry int) (comments []string, more bool, _error error) {
|
||||
var (
|
||||
i int
|
||||
e error
|
||||
|
@ -888,7 +959,6 @@ func GetVideoComments(id string, cursor *int, retry int) (users []string, usersn
|
|||
HasMore int "json:\"has_more\""
|
||||
Cursor int "json:\"cursor\""
|
||||
Comments []struct {
|
||||
//Cid string "json:\"cid\""
|
||||
Text string "json:\"text\""
|
||||
CreateTime int64 "json:\"create_time\""
|
||||
User struct {
|
||||
|
@ -906,7 +976,7 @@ func GetVideoComments(id string, cursor *int, retry int) (users []string, usersn
|
|||
"&digged_cid" +
|
||||
"&insert_cids")
|
||||
if e != nil {
|
||||
return nil, nil, nil, false, e
|
||||
return nil, false, e
|
||||
}
|
||||
e = json.Unmarshal(b, &d)
|
||||
if e != nil {
|
||||
|
@ -914,20 +984,14 @@ func GetVideoComments(id string, cursor *int, retry int) (users []string, usersn
|
|||
Ip = GeneratePublicIp()
|
||||
return GetVideoComments(id, cursor, retry + 1)
|
||||
}
|
||||
return nil, nil, nil, false, e
|
||||
return nil, false, e
|
||||
}
|
||||
texts = make([]string, 0)
|
||||
users = make([]string, 0)
|
||||
usersn = make([]string, 0)
|
||||
//times = make([]int64, 0)
|
||||
comments = make([]string, 0)
|
||||
for i = 0; i < len(d.Comments); i++ {
|
||||
users = append(users, d.Comments[i].User.Uid)
|
||||
usersn = append(usersn, d.Comments[i].User.UniqueId)
|
||||
//times = append(times, d.Comments[i].CreateTime)
|
||||
texts = append(texts, d.Comments[i].Text)
|
||||
comments = append(comments, d.Comments[i].User.Uid + "\t" + d.Comments[i].User.UniqueId + "\t" + d.Comments[i].Text)
|
||||
}
|
||||
*cursor += 20
|
||||
return users, usersn, texts, d.HasMore != 0, nil
|
||||
return comments, d.HasMore != 0, nil
|
||||
}
|
||||
|
||||
func IsValidId(id string) bool {
|
||||
|
@ -967,7 +1031,7 @@ func EnsureDirectory(directory string) error {
|
|||
return e
|
||||
}
|
||||
} else if !s.IsDir() {
|
||||
return errors.New("Cannot create a directory if a file with the same name exists.")
|
||||
return errors.New("error: File exists")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -1097,10 +1161,11 @@ func main() {
|
|||
)
|
||||
var (
|
||||
HELP string = "usage:\n" +
|
||||
filepath.Base(os.Args[0]) + " <name/id/file> [date/ping/video/followers/following/list/liked/music/hashtag/comments/live]\n" +
|
||||
filepath.Base(os.Args[0]) + " <name/id/file> [date/ping/video/followers/following/list/liked/music/hashtag/comments/live/search]\n" +
|
||||
"arguments:\n" +
|
||||
"name/id/file (@name, id, path) - name or id of a user, video, song, or hashtag, or a file with video ids\n" +
|
||||
"using @name or user id:\n" +
|
||||
" search (without '@') - find matching or similar usernames\n" +
|
||||
" list - list a user's videos instead of downloading them\n" +
|
||||
" date (YYYY-MM-DD) - date until which to download videos\n" +
|
||||
" ping - ping a user\n" +
|
||||
|
@ -1127,13 +1192,13 @@ func main() {
|
|||
"*comment lists are output likewise like this:\n" +
|
||||
"6693429093034095344 loomaster2020 open bob and vagene\n" +
|
||||
"(user id) (user name) (text)"
|
||||
top, isMusic, isVideo, isHashtag, isLiked, isList, isComments, isLive, o, m, ru, isFi, isFo, isp, inr, ss bool
|
||||
top, isMusic, isVideo, isHashtag, isLiked, isList, isComments, isLive, isSearchUser, o, m, ru, isFi, isFo, isp, inr, ss bool
|
||||
i, j, y, nfo, nfi, nl, k, com, dl, view, sh int
|
||||
c, u, ctime int64
|
||||
d time.Time
|
||||
id, n, g, yt, x, htid, vid, vauth, vvid, playurl, durl, mid, mtitle, mauth, desc string
|
||||
id, n, g, yt, x, vid, vauth, vvid, playurl, durl, mid, mtitle, mauth, desc string
|
||||
ig map[string]bool
|
||||
ov, nv, v, fi, fin, fo, fon, htv, htu, htun, htuu, mvid, muv, muu, muun, likeid, likeurl, likaid, likan, comauth, comauthn, comt []string
|
||||
ov, nv, v, tabFi, tabFo, tabHtv, tabMuv, tabLiv, tabCom, tabUserq []string
|
||||
e error
|
||||
f *os.File
|
||||
l sync.Mutex
|
||||
|
@ -1153,6 +1218,8 @@ func main() {
|
|||
o = true
|
||||
} else if os.Args[2] == "user" {
|
||||
o = true
|
||||
} else if os.Args[2] == "search" {
|
||||
isSearchUser = true
|
||||
} else if os.Args[2] == "following" {
|
||||
isFi = true
|
||||
} else if os.Args[2] == "followers" {
|
||||
|
@ -1207,39 +1274,38 @@ func main() {
|
|||
return
|
||||
}
|
||||
n = n[1:]
|
||||
htid, e = GetHashtag(n, 0)
|
||||
id, e = GetHashtag(n, 0)
|
||||
ru = true
|
||||
m = true
|
||||
k = 0
|
||||
for ru && m {
|
||||
/*if top == true {
|
||||
htv, htu, htun, htuu, m, e = GetHashtagVideos(true, htid, &k, 0)
|
||||
tabHtv, m, e = GetHashtagVideos(true, id, &k, 0)
|
||||
} else {
|
||||
htv, htu, htun, htuu, m, e = GetHashtagVideos(false, htid, &k, 0)
|
||||
tabHtv, m, e = GetHashtagVideos(false, id, &k, 0)
|
||||
}
|
||||
for i = 0; i < len(htv); i++ {
|
||||
fmt.Println(htv[i] + "\t" + htu[i] + "\t" + htun[i] + "\t" + htuu[i])
|
||||
for i = 0; i < len(tabHtv); i++ {
|
||||
fmt.Println(tabHtv[i])
|
||||
}
|
||||
}*/
|
||||
htv, htu, htun, htuu, m, e = GetHashtagVideos(false, htid, &k, 0)
|
||||
for i = 0; i < len(htv); i++ {
|
||||
fmt.Println(htv[i] + "\t" + htu[i] + "\t" + htun[i] + "\t" + htuu[i])
|
||||
tabHtv, m, e = GetHashtagVideos(false, id, &k, 0)
|
||||
for i = 0; i < len(tabHtv); i++ {
|
||||
fmt.Println(tabHtv[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
} else if isHashtag {
|
||||
ru = true
|
||||
m = true
|
||||
htid = n
|
||||
k = 0
|
||||
for ru && m {
|
||||
if top == true {
|
||||
htv, htu, htun, htuu, m, e = GetHashtagVideos(true, htid, &k, 0)
|
||||
tabHtv, m, e = GetHashtagVideos(true, n, &k, 0)
|
||||
} else {
|
||||
htv, htu, htun, htuu, m, e = GetHashtagVideos(false, htid, &k, 0)
|
||||
tabHtv, m, e = GetHashtagVideos(false, n, &k, 0)
|
||||
}
|
||||
for i = 0; i < len(htv); i++ {
|
||||
fmt.Println(htv[i] + "\t" + htu[i] + "\t" + htun[i] + "\t" + htuu[i])
|
||||
for i = 0; i < len(tabHtv); i++ {
|
||||
fmt.Println(tabHtv[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
|
@ -1248,44 +1314,53 @@ func main() {
|
|||
m = true
|
||||
c = 0
|
||||
for ru && m {
|
||||
likeid, likeurl, likaid, likan, e = GetUserFavorites(n, &c, 0)
|
||||
for i = 0; i < len(likeid); i++ {
|
||||
fmt.Println(likeid[i] + "\t" + likaid[i] + "\t" + likan[i] + "\t" + likeurl[i])
|
||||
tabLiv, m, e = GetUserFavorites(n, &c, 0)
|
||||
for i = 0; i < len(tabLiv); i++ {
|
||||
fmt.Println(tabLiv[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
} else if isMusic {
|
||||
mid = n
|
||||
ru = true
|
||||
m = true
|
||||
k = 0
|
||||
for ru && m {
|
||||
if top == true {
|
||||
mvid, muv, muu, muun, m, e = GetMusicVideos(true, mid, &k, 0)
|
||||
tabMuv, m, e = GetMusicVideos(true, n, &k, 0)
|
||||
} else {
|
||||
mvid, muv, muu, muun, m, e = GetMusicVideos(false, mid, &k, 0)
|
||||
tabMuv, m, e = GetMusicVideos(false, n, &k, 0)
|
||||
}
|
||||
for i = 0; i < len(muun); i++ {
|
||||
fmt.Println(mvid[i] + "\t" + muu[i] + "\t" + muun[i] + "\t" + muv[i])
|
||||
for i = 0; i < len(tabMuv); i++ {
|
||||
fmt.Println(tabMuv[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
} else if isSearchUser {
|
||||
ru = true
|
||||
m = true
|
||||
k = 0
|
||||
for ru && m {
|
||||
tabUserq, m, e = SearchUsers(n, &k, 0)
|
||||
for i = 0; i < len(tabUserq); i++ {
|
||||
fmt.Println(tabUserq[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
} else if isComments {
|
||||
vid =n
|
||||
ru = true
|
||||
m = true
|
||||
k = 0
|
||||
for ru && m {
|
||||
comauth, comauthn, comt, m, e = GetVideoComments(vid, &k, 0)
|
||||
for i = 0; i < len(comauth); i++ {
|
||||
fmt.Println(comauth[i] + "\t" + comauthn[i] + "\t" + comt[i])
|
||||
tabCom, m, e = GetVideoComments(vid, &k, 0)
|
||||
for i = 0; i < len(tabCom); i++ {
|
||||
fmt.Println(tabCom[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
} else if isVideo {
|
||||
vid = n
|
||||
vvid, vauth, ctime, playurl, durl, mid, mtitle, mauth, desc, com, dl, view, sh, isp, inr, ss, e = GetVideoInfo(vid, 0)
|
||||
fmt.Println("creator:\t\t", vauth)
|
||||
vvid, vauth, ctime, playurl, durl, mid, mtitle, mauth, desc, com, dl, view, sh, isp, inr, ss, e = GetVideoInfo(n, 0)
|
||||
fmt.Println("creator:\t", vauth)
|
||||
fmt.Println("video id:\t", vvid)
|
||||
fmt.Println("create time:\t", strconv.FormatInt(ctime, 10))
|
||||
fmt.Println("views:\t\t", strconv.Itoa(view))
|
||||
|
@ -1402,9 +1477,9 @@ func main() {
|
|||
ru = true
|
||||
m = true
|
||||
for ru && m {
|
||||
fi, fin, m, e = GetUserFollows(id, &c, 0)
|
||||
for i = 0; i < len(fi); i++ {
|
||||
fmt.Println(fi[i], fin[i])
|
||||
tabFi, m, e = GetUserFollows(id, &c, 0)
|
||||
for i = 0; i < len(tabFi); i++ {
|
||||
fmt.Println(tabFi[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
|
@ -1413,9 +1488,9 @@ func main() {
|
|||
ru = true
|
||||
m = true
|
||||
for ru && m {
|
||||
fo, fon, m, e = GetUserFollowers(id, &c, 0)
|
||||
for i = 0; i < len(fo); i++ {
|
||||
fmt.Println(fo[i], fon[i])
|
||||
tabFo, m, e = GetUserFollowers(id, &c, 0)
|
||||
for i = 0; i < len(tabFo); i++ {
|
||||
fmt.Println(tabFo[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
|
@ -1460,10 +1535,10 @@ func main() {
|
|||
DownloadStream(strconv.FormatInt(c, 10) + ".flv", n)
|
||||
}
|
||||
} else {
|
||||
fmt.Println("Could not get livestream URL")
|
||||
fmt.Println("Could not get livestream URL.")
|
||||
}
|
||||
} else {
|
||||
fmt.Println("User is not live")
|
||||
fmt.Println("User is not live.")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -1473,13 +1548,16 @@ func main() {
|
|||
fmt.Println("likes:\t\t", nl )
|
||||
fmt.Println("followers:\t", nfo, nfi)
|
||||
if len(g) > 0 {
|
||||
fmt.Println("ig:\t\t", g)
|
||||
fmt.Println("ig:\t\t", g)
|
||||
}
|
||||
if len(yt) > 0 {
|
||||
fmt.Println("yt:\t\t", yt)
|
||||
fmt.Println("yt:\t\t", yt)
|
||||
}
|
||||
if len(x) > 0 {
|
||||
fmt.Println("signature:\t", x)
|
||||
fmt.Println("signature:\t", x)
|
||||
}
|
||||
if m {
|
||||
fmt.Println("(private user)")
|
||||
}
|
||||
if c != 0 {
|
||||
n = RequestStream(c)
|
||||
|
|
Loading…
Reference in New Issue