Skip to content

Commit

Permalink
fixes, add -to
Browse files Browse the repository at this point in the history
  • Loading branch information
fren committed Jan 12, 2024
1 parent bcdd8bf commit 03fb598
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 31 deletions.
59 changes: 29 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -48,21 +48,20 @@ func main() {
```
$ ./tikmeh
Usage: ./tikmeh [-profile | -info] [args...] <urls | usernames | ids>
-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")
```
2 changes: 2 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 <VALUE> MB")
json_ := flag.Bool("json", false, "print info as json, don't download")
debug := flag.Bool("debug", false, "log debug info")
Expand Down Expand Up @@ -117,6 +118,7 @@ func main() {
filename, err := vid.Download(
tt.DownloadOpt{
Directory: *directory,
To: *to_,
ValidateWith: tt.ValidateWithFfprobe(),
})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/heilkit/tt/tt
module github.com/heilkit/tt

go 1.21

Expand Down

0 comments on commit 03fb598

Please sign in to comment.