From c01f13b7f59eb0b4f6c10dd1f0f4594bac3d40b7 Mon Sep 17 00:00:00 2001 From: jybp <2850825+jybp@users.noreply.github.com> Date: Thu, 11 Jul 2024 19:06:43 +0200 Subject: [PATCH] Support new vod url --- .goreleaser.yml | 16 +++++----------- twitch/twitch.go | 2 +- twitch/twitch_test.go | 5 +++++ 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index 245f5ef..d27f35e 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -10,22 +10,16 @@ builds: ldflags: -X main.defaultClientID=kimne78kx3ncx6brgo4mv6wki5h1ko archives: - id: "archives" - name_template: >- - {{- .ProjectName }}_ - {{- title .Os }}_ - {{- if eq .Arch "amd64" }}x86_64 - {{- else if eq .Arch "386" }}i386 - {{- else }}{{ .Arch }}{{ end }} - {{- if .Arm }}v{{ .Arm }}{{ end -}} + name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}" checksum: - name_template: 'checksums.txt' + name_template: "checksums.txt" snapshot: name_template: "{{ .Tag }}-next" changelog: sort: asc filters: exclude: - - '^docs:' - - '^test:' + - "^docs:" + - "^test:" env_files: - github_token: ./github_token \ No newline at end of file + github_token: ./github_token diff --git a/twitch/twitch.go b/twitch/twitch.go index 8ac91ab..204ef34 100644 --- a/twitch/twitch.go +++ b/twitch/twitch.go @@ -30,7 +30,7 @@ func ID(URL string) (string, VideoType, error) { if !strings.Contains(u.Hostname(), "twitch.tv") { return "", 0, errors.Errorf("URL host for %s is not twitch.tv", URL) } - if strings.HasPrefix(u.Path, "/videos/") { + if strings.HasPrefix(u.Path, "/videos/") || strings.Contains(u.Path, "/video/") { _, id := path.Split(u.Path) return id, TypeVOD, nil } diff --git a/twitch/twitch_test.go b/twitch/twitch_test.go index bc3d84d..ea864b4 100644 --- a/twitch/twitch_test.go +++ b/twitch/twitch_test.go @@ -25,6 +25,11 @@ func TestID(t *testing.T) { expectedID: "12345", expectedType: twitch.TypeVOD, }, + { + input: "https://www.twitch.tv/letsgameitout/video/2182428086", + expectedID: "2182428086", + expectedType: twitch.TypeVOD, + }, { input: "https://www.twitch.tv/test/clip/Slug123", expectedID: "Slug123",