Skip to content

Commit

Permalink
ytdlp: add dubbed audio streams
Browse files Browse the repository at this point in the history
  • Loading branch information
CorentinB committed Sep 10, 2024
1 parent 59c402f commit 5178cb3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions internal/pkg/crawl/dependencies/ytdlp/ytdlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"os/exec"
"strconv"
"strings"
)

func GetJSON(port int) (URLs []string, rawJSON string, HTTPHeaders HTTPHeaders, err error) {
Expand Down Expand Up @@ -56,6 +57,13 @@ func GetJSON(port int) (URLs []string, rawJSON string, HTTPHeaders HTTPHeaders,
}
}

// Get all dubbed audio URLs
for _, audio := range video.Formats {
if strings.Contains(audio.FormatNote, "dubbed") {
URLs = append(URLs, audio.URL, audio.URL+"&video_id="+video.ID)
}
}

// write output to a .json file (debug)
// err = ioutil.WriteFile("output.json", []byte(output), 0644)
// if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/crawl/sitespecific/youtube/youtube_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestParse(t *testing.T) {
}

// Check the number of URLs
expected := 148
expected := 204
if len(URLs) != expected {
t.Fatalf("Expected %d URLs, got %d", expected, len(URLs))
}
Expand Down

0 comments on commit 5178cb3

Please sign in to comment.