Skip to content
This repository was archived by the owner on Jan 31, 2023. It is now read-only.

Commit 7402a50

Browse files
committed
Add proxy option in yt
1 parent 1e44adc commit 7402a50

5 files changed

Lines changed: 24 additions & 8 deletions

File tree

pkg/engine/engine.go

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -666,16 +666,28 @@ func RemoveTwitterShortLink(text string) string {
666666
}
667667

668668
//GetRSS GetRSS from Channel
669-
func GetRSS(YtID string) []string {
669+
func GetRSS(YtID string, proxy bool) []string {
670670
var (
671671
DataXML YtXML
672672
VideoID []string
673+
URL = "https://www.youtube.com/feeds/videos.xml?channel_id=" + YtID + "&q=searchterms"
673674
)
674675

675-
Data, err := network.Curl("https://www.youtube.com/feeds/videos.xml?channel_id="+YtID+"&q=searchterms", nil)
676-
if err != nil {
677-
log.Error(err, string(Data))
678-
}
676+
Data := func() []byte {
677+
if proxy {
678+
D, err := network.Curl(URL, nil)
679+
if err != nil {
680+
log.Error(err, string(D))
681+
}
682+
return D
683+
} else {
684+
D, err := network.CoolerCurl(URL, nil)
685+
if err != nil {
686+
log.Error(err, string(D))
687+
}
688+
return D
689+
}
690+
}()
679691

680692
xml.Unmarshal(Data, &DataXML)
681693

service/livestream/youtube/checker/getdata.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func StartCheckYT(Group database.Group, Update bool, wg *sync.WaitGroup) {
2727
"Group": Group.GroupName,
2828
}).Info("Checking Group channel")
2929

30-
VideoID := engine.GetRSS(YtChan.YtChannel)
30+
VideoID := engine.GetRSS(YtChan.YtChannel, *proxy)
3131
for _, ID := range VideoID {
3232
YoutubeData, err := YtChan.CheckYoutubeVideo(ID)
3333
if err != nil {
@@ -231,7 +231,7 @@ func StartCheckYT(Group database.Group, Update bool, wg *sync.WaitGroup) {
231231
"Group": Group.GroupName,
232232
}).Info("Checking Vtuber channel")
233233

234-
VideoID := engine.GetRSS(Member.YoutubeID)
234+
VideoID := engine.GetRSS(Member.YoutubeID, *proxy)
235235
for _, ID := range VideoID {
236236
YoutubeData, err := Member.CheckYoutubeVideo(ID)
237237
if err != nil {

service/livestream/youtube/checker/youtube.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"context"
55
"encoding/json"
6+
"flag"
67
"math"
78
"strings"
89
"sync"
@@ -24,6 +25,7 @@ var (
2425
Bot *discordgo.Session
2526
GroupPayload *[]database.Group
2627
gRCPconn pilot.PilotServiceClient
28+
proxy = flag.Bool("MultiTOR", false, "Enable MultiTOR for scrapping yt rss")
2729
)
2830

2931
const (
@@ -32,6 +34,7 @@ const (
3234

3335
func init() {
3436
log.SetFormatter(&log.TextFormatter{FullTimestamp: true, DisableColors: true})
37+
flag.Parse()
3538
gRCPconn = pilot.NewPilotServiceClient(network.InitgRPC(config.Pilot))
3639
}
3740

service/migrate/scraper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func TwitterFanart() {
3636
}
3737

3838
func FilterYt(Dat database.Member, wg *sync.WaitGroup) {
39-
VideoID := engine.GetRSS(Dat.YoutubeID)
39+
VideoID := engine.GetRSS(Dat.YoutubeID, false)
4040
defer wg.Done()
4141
body, err := network.Curl("https://www.googleapis.com/youtube/v3/videos?part=statistics,snippet,liveStreamingDetails&fields=items(snippet(publishedAt,title,description,thumbnails(standard),channelTitle,liveBroadcastContent),liveStreamingDetails(scheduledStartTime,actualEndTime),statistics(viewCount))&id="+strings.Join(VideoID, ",")+"&key="+*YoutubeToken, nil)
4242
if err != nil {

swarm/live.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ services:
2727
- "/etc/localtime:/etc/localtime:ro"
2828
networks:
2929
- go-simp-net
30+
command: ./liveyoutube -MultiTOR
3031

3132
youtube_counter:
3233
image: justhumanz/go-simp-youtube-counter-livestream:${RELEASE_VERSION}

0 commit comments

Comments
 (0)