From 03fb598c4da5b5f6b02c69efebcd146527a3c054 Mon Sep 17 00:00:00 2001 From: fren Date: Sat, 13 Jan 2024 00:18:01 +0300 Subject: [PATCH] fixes, add -to --- README.md | 59 ++++++++++++++++++++++++++--------------------------- cmd/main.go | 2 ++ go.mod | 2 +- 3 files changed, 32 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 2db2184..b6d9134 100644 --- a/README.md +++ b/README.md @@ -1,44 +1,44 @@ # Tikwm API -https://tikwm.com is the best middleman for getting TikTok video info, afaik. +https://tikwm.com is the best middleman for getting TikTok video info, afaik. If I'm wrong, contact me immediately. -Request syncing with a timeout is built-in, no worries. Other words don't really matter, here's the common code: +* Download videos in HD +* Download whole profiles in a minimal time (with reasonable naming) -## Library Example +## [Library] Example ```go package main import ( - "github.com/heilkit/tt/tt" - "log" - "time" + "github.com/heilkit/tt/tt" + "log" + "time" ) func main() { - // tt.GetVideo(url string, HD bool) () - videoHD, err := tt.GetPost("https://www.tiktok.com/@locallygrownwig/video/6901498776523951365") - videoHD, err = tt.GetPost("6901498776523951365", true) // with ID - videoSD, err = tt.GetPost("https://vm.tiktok.com/ZM66UoB9m/", false) // with shorten link - localname, err := videoHD.Download() + // tt.GetVideo(url string, HD bool) () + postHD, err := tt.GetPost("https://www.tiktok.com/@locallygrownwig/video/6901498776523951365") + postHD, err = tt.GetPost("6901498776523951365", true) // with ID + postSD, err := tt.GetPost("https://vm.tiktok.com/ZM66UoB9m/", false) // with shorten link + localname, err := postHD.DownloadVideo(tt.DownloadOpt{To: "locallygrownwig.mp4"}) - // Get user posts for the last 30 days - until := time.Now().Add(-time.Hour * 24 * 30) - // func GetUserFeedUntilVerbose(uniqueID string, hd bool, pred func(vid *Post) bool, onError func(err error)) (chan Post, error) { - vidChan, expectedCount, err := tt.GetUserFeed("locallygrownwig", &tt.FeedOpt{ - While: tt.WhileAfter(until), - Filter: tt.FilterVideo, - }) + // Get user posts for the last 30 days + until := time.Now().Add(-time.Hour * 24 * 30) + vidChan, expectedCount, err := tt.GetUserFeed("locallygrownwig", &tt.FeedOpt{ + While: tt.WhileAfter(until), + Filter: tt.FilterVideo, + }) - for vid := range vidChan { - localname, _ := vid.Download() - log.Println(localname) - } + for vid := range vidChan { + localname, _ := vid.DownloadVideo() + log.Println(localname) + } } ``` -## Executable Example +## [Executable] Example * `./tikmeh "https://www.tiktok.com/@locallygrownwig/video/6901498776523951365"` -- download this video in HD to current folder @@ -48,21 +48,20 @@ func main() { ``` $ ./tikmeh Usage: ./tikmeh [-profile | -info] [args...] - -debug - log debug info - -dir string - directory to save files (default "./") -info print info about profiles - -json - print info as json, don't download -profile download/scan profiles + -dir string + directory to save files (default "./") + -debug + log debug info + -json + print info as json, don't download -quiet quiet -sd don't request HD sources of videos (less requests => notably faster) -until string don't download videos earlier than (default "1970-01-01 00:00:00") - ``` diff --git a/cmd/main.go b/cmd/main.go index 284d7be..5c72734 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -23,6 +23,7 @@ func main() { until := flag.String("until", "1970-01-01 00:00:00", "don't download videos earlier than") sd := flag.Bool("sd", false, "don't request HD sources of videos (less requests => notably faster)") directory := flag.String("dir", "./", "directory to save files") + to_ := flag.String("to", "", "filename to save the video (the default is generated automatically)") maxSize := flag.Int("max-size", 1<<10, "download only videos smaller than MB") json_ := flag.Bool("json", false, "print info as json, don't download") debug := flag.Bool("debug", false, "log debug info") @@ -117,6 +118,7 @@ func main() { filename, err := vid.Download( tt.DownloadOpt{ Directory: *directory, + To: *to_, ValidateWith: tt.ValidateWithFfprobe(), }) if err != nil { diff --git a/go.mod b/go.mod index cad09b6..749a1ba 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/heilkit/tt/tt +module github.com/heilkit/tt go 1.21