mirror of
https://github.com/miniflux/v2.git
synced 2025-06-27 16:36:00 +00:00
feat(processor): fetch YouTube watch time in bulk using the API
This commit is contained in:
parent
c3c42b0c37
commit
369054b02d
8 changed files with 396 additions and 330 deletions
|
@ -36,3 +36,37 @@ func TestParseISO8601(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetYouTubeVideoIDFromURL(t *testing.T) {
|
||||
scenarios := []struct {
|
||||
url string
|
||||
expected string
|
||||
}{
|
||||
{"https://www.youtube.com/watch?v=HLrqNhgdiC0", "HLrqNhgdiC0"},
|
||||
{"https://www.youtube.com/watch?v=HLrqNhgdiC0&feature=youtu.be", "HLrqNhgdiC0"},
|
||||
{"https://example.org/test", ""},
|
||||
}
|
||||
for _, tc := range scenarios {
|
||||
result := getVideoIDFromYouTubeURL(tc.url)
|
||||
if tc.expected != result {
|
||||
t.Errorf(`Unexpected result, got %q for url %q`, result, tc.url)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsYouTubeVideoURL(t *testing.T) {
|
||||
scenarios := []struct {
|
||||
url string
|
||||
expected bool
|
||||
}{
|
||||
{"https://www.youtube.com/watch?v=HLrqNhgdiC0", true},
|
||||
{"https://www.youtube.com/watch?v=HLrqNhgdiC0&feature=youtu.be", true},
|
||||
{"https://example.org/test", false},
|
||||
}
|
||||
for _, tc := range scenarios {
|
||||
result := isYouTubeVideoURL(tc.url)
|
||||
if tc.expected != result {
|
||||
t.Errorf(`Unexpected result, got %v for url %q`, result, tc.url)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue