main.go 781 Bytes
Newer Older
大地缸's avatar
lazydog  
大地缸 committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main

import (
	"fmt"
	"io"
	"net/http"
	"os"
)

func DownloadDouyinVideo(url string, filename string) error {
	response, err := http.Get(url)
	if err != nil {
		return err
	}
	defer response.Body.Close()

	file, err := os.Create(filename)
	if err != nil {
		return err
	}
	defer file.Close()

	_, err = io.Copy(file, response.Body)
	if err != nil {
		return err
	}

	return nil
}

func main() {
	videoURL := "https://www.douyin.com/video/7225813424251473163" // Replace with the actual video URL
	filename := "video.mp4"                                        // Replace with the desired filename

	err := DownloadDouyinVideo(videoURL, filename)
	if err != nil {
		fmt.Println("Error downloading video:", err)
		return
	}

	fmt.Println("Video downloaded successfully!")
}