From 4d01b13e0ae079e130360864eb615662c72c6e8b Mon Sep 17 00:00:00 2001 From: Kethsar Date: Tue, 22 Aug 2023 07:11:02 -0700 Subject: [PATCH] Remove parsing /membership since streams appear on /streams already --- .github/workflows/pre-release.yml | 2 +- .github/workflows/tagged-release.yml | 2 +- player_response.go | 55 +++------------------------- 3 files changed, 7 insertions(+), 52 deletions(-) diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index fc2f5af..4f80341 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -19,7 +19,7 @@ jobs: - name: build run: ./make.sh prerelease - name: version - run: echo "::set-output name=version::$(./ytarchive -V)" + run: echo "version=$(./ytarchive -V)" >> $GITHUB_OUTPUT id: version - name: release uses: marvinpinto/action-automatic-releases@latest diff --git a/.github/workflows/tagged-release.yml b/.github/workflows/tagged-release.yml index fda858d..57e3ad9 100644 --- a/.github/workflows/tagged-release.yml +++ b/.github/workflows/tagged-release.yml @@ -17,7 +17,7 @@ jobs: - name: build run: ./make.sh - name: version - run: echo "::set-output name=version::$(./ytarchive -V)" + run: echo "version=$(./ytarchive -V)" >> $GITHUB_OUTPUT id: version - name: release uses: marvinpinto/action-automatic-releases@latest diff --git a/player_response.go b/player_response.go index ad1637d..cbf14f0 100644 --- a/player_response.go +++ b/player_response.go @@ -250,55 +250,6 @@ func GetNewestStreamFromStreams(liveUrl string) string { return streamUrl } -func GetNewestStreamFromMembership(liveUrl string) string { - initialData := &YtInitialData{} - var contents []SectionListContent - streamsUrl := strings.Replace(liveUrl, "/live", "/membership", 1) - streamsHtml := DownloadData(streamsUrl) - ytInitialData := GetJsonFromHtml(streamsHtml, ytInitialDataDecl) - streamUrl := "" - - err := json.Unmarshal(ytInitialData, initialData) - if err != nil { - return streamUrl - } - - for _, tab := range initialData.Contents.Twocolumnbrowseresultsrenderer.Tabs { - if strings.HasSuffix(tab.Tabrenderer.Endpoint.Commandmetadata.Webcommandmetadata.URL, "/membership") { - contents = tab.Tabrenderer.Content.SectionListRenderer.Contents - } - } - - for _, content := range contents { - for _, videoContent := range content.ItemSectionRenderer.Contents { - videoRenderer := videoContent.Videorenderer - - for _, thumbnailRenderer := range videoRenderer.Thumbnailoverlays { - if thumbnailRenderer.Thumbnailoverlaytimestatusrenderer.Style == "LIVE" { - streamUrl = fmt.Sprintf("https://www.youtube.com/watch?v=%s", videoRenderer.Videoid) - return streamUrl - } - } - } - } - - return streamUrl -} - -func (di *DownloadInfo) GetNewestLiveStream() string { - streamUrl := "" - - if di.CookiesURL != nil { - streamUrl = GetNewestStreamFromMembership(di.URL) - } - - if len(streamUrl) == 0 { - streamUrl = GetNewestStreamFromStreams(di.URL) - } - - return streamUrl -} - // At the time of adding, retrieving the player response from the api while // claiming to be the android client seems to result in unthrottled download // URLs. Credit to yt-dlp devs for POST data and headers. @@ -364,7 +315,11 @@ func (di *DownloadInfo) GetVideoHtml() []byte { var videoHtml []byte if di.LiveURL { - streamUrl := di.GetNewestLiveStream() + streamUrl := "" + + if len(streamUrl) == 0 { + streamUrl = GetNewestStreamFromStreams(di.URL) + } if len(streamUrl) > 0 { videoHtml = DownloadData(streamUrl)