From af09c17487cc8433e644defdbf3ed55665c1bf3e Mon Sep 17 00:00:00 2001 From: Martin Lindhe Date: Mon, 9 Sep 2024 09:31:26 +0200 Subject: [PATCH] fix some deprecations --- ccdb_test.go | 4 ++-- cleaner.go | 2 +- filter_ocr_test.go | 8 ++++---- helpers.go | 22 ---------------------- testextras.go | 6 +++--- 5 files changed, 10 insertions(+), 32 deletions(-) delete mode 100644 helpers.go diff --git a/ccdb_test.go b/ccdb_test.go index 5c64dcd..d8096dc 100644 --- a/ccdb_test.go +++ b/ccdb_test.go @@ -28,12 +28,12 @@ func TestNewFromCCDBCapture(t *testing.T) { makeTime(0, 0, 16, 24), makeTime(0, 1, 25, 82), []string{"Whoa."}, - }, Caption{ + }, { 2, makeTime(0, 1, 31, 45), makeTime(0, 1, 33, 62), []string{"Go on. Get out."}, - }, Caption{ + }, { 3, makeTime(0, 1, 33, 65), makeTime(0, 1, 34, 81), diff --git a/cleaner.go b/cleaner.go index 893432f..2cf5416 100644 --- a/cleaner.go +++ b/cleaner.go @@ -23,7 +23,7 @@ var ( // english: "captions paid for by", "english subtitles", - "subtitles:", "subtitles by", + "subtitles -", "subtitles:", "subtitles by", "subtitles downloaded", "captioning by", "captions by", "transcript :", "transcript:", "transcript by", diff --git a/filter_ocr_test.go b/filter_ocr_test.go index fb17976..cce1372 100644 --- a/filter_ocr_test.go +++ b/filter_ocr_test.go @@ -111,10 +111,10 @@ func TestStartsWithUppercase(t *testing.T) { func TestCountCaseInLetters(t *testing.T) { input := map[string][]caseCount{ - "HELLO": []caseCount{{upper, 5}}, - "hello": []caseCount{{lower, 5}}, - "Hello": []caseCount{{upper, 1}, {lower, 4}}, - "GAsPs": []caseCount{{upper, 2}, {lower, 1}, {upper, 1}, {lower, 1}}, + "HELLO": {{upper, 5}}, + "hello": {{lower, 5}}, + "Hello": {{upper, 1}, {lower, 4}}, + "GAsPs": {{upper, 2}, {lower, 1}, {upper, 1}, {lower, 1}}, } for in, out := range input { assert.Equal(t, out, countCaseInLetters(in)) diff --git a/helpers.go b/helpers.go deleted file mode 100644 index cf5e15e..0000000 --- a/helpers.go +++ /dev/null @@ -1,22 +0,0 @@ -package subtitles - -import "os" - -// Exists reports whether the named file or directory exists. -func exists(name string) bool { - if _, err := os.Stat(name); err != nil { - if os.IsNotExist(err) { - return false - } - } - return true -} - -// IsDirectory reports wether the named path is a directory -func isDirectory(path string) bool { - fileInfo, err := os.Stat(path) - if err != nil { - return false - } - return fileInfo.IsDir() -} diff --git a/testextras.go b/testextras.go index 2b4193c..88bc3e2 100644 --- a/testextras.go +++ b/testextras.go @@ -2,7 +2,7 @@ package subtitles import ( "fmt" - "io/ioutil" + "os" ) const tempFilePrefix = "moviehash-temp" @@ -25,7 +25,7 @@ func createTempFile(byteSize int) string { cnt++ } - f, err := ioutil.TempFile("/tmp", tempFilePrefix) + f, err := os.CreateTemp("/tmp", tempFilePrefix) check(err) defer f.Close() @@ -39,7 +39,7 @@ func createZeroedTempFile(byteSize int) string { data := make([]byte, byteSize) - f, err := ioutil.TempFile("/tmp", tempFilePrefix) + f, err := os.CreateTemp("/tmp", tempFilePrefix) check(err) defer f.Close()