Skip to content

Commit

Permalink
Remove parsing /membership since streams appear on /streams already
Browse files Browse the repository at this point in the history
  • Loading branch information
Kethsar committed Aug 22, 2023
1 parent a3dce1c commit 4d01b13
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tagged-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
55 changes: 5 additions & 50 deletions player_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 4d01b13

Please sign in to comment.