dt_automate/main.go
2025-02-19 18:30:19 +08:00

117 lines
4.7 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package main
import (
"dt_automate/method"
"dt_automate/tool"
"flag"
"fmt"
"log"
"os"
"strconv"
"time"
)
var (
urls string // 存储 -t 参数值
keyss bool // 存储值
runs bool //存储值
// helpFlag bool
)
func main() {
//SetFlags函数用来设置标准logger的输出配置
log.SetFlags(log.Llongfile | log.Lmicroseconds | log.Ldate)
// key.Keyprin("iPoTwF953OJExi8uLGOALs7cwpdiHyfLYDLXfno9nY7KLsLyOu5wDxN424pLFyIymNAzpNEdVQCkOBQM7Tj3uTkSQ7tOLPSzUXrLgMZj5Ft0s1Iv3Ls9Aq6W0NxBPNSY3r1NuXY3L0378YKoopsc68untFqlrXhjq5PIDah90Tlq/sQ3onL+/qd9xNn4Lj+PcDY8R0edNpOormOduN2p8JpS0H0WaZW5SV0iCYET9jRFcfXY3qZutAD9W3UGO2EjzkyZMfyN8lG4YgUGBTghkw4Ihoe9GQZF5NgYJumhvFzE1S8PvW0gBqQK9K1LpESyN1bcvXIALUEUzT+4vC6UBA==")
// 定义标志 -url 并设置其默认值为空字符串
flag.StringVar(&urls, "url", "", "指定直播间URL")
flag.BoolVar(&keyss, "v", false, "查看授权状态")
flag.BoolVar(&runs, "run", false, "开始截取图片")
// flag.BoolVar(&helpFlag, "h", false, "Show help message")
//解析命令行参数
flag.Parse()
// log.Println(os.Args[1])
if len(os.Args) > 1 {
if keyss {
key := tool.Keyprin(tool.Auth_main()["key"])
if key.End_time != "" {
a, _ := strconv.ParseInt(key.End_time, 10, 64)
// b, _ := strconv.ParseInt(key.Initial_time, 10, 64) // 获取的不是当前时间
duration := time.Unix(a, 0).Sub(time.Unix(tool.Timestamp("second"), 0))
days := int(duration / (24 * time.Hour)) //天
hours := int(duration % (24 * time.Hour) / time.Hour) //小时
minutes := int(duration / time.Minute % 60) //分钟
secod := int(duration / time.Second % 60) //秒
if days <= 0 && hours <= 0 && minutes <= 0 {
log.Printf("授权已到期,剩余时间:%d天 %d小时 %d分钟 %d秒", days, hours, minutes, secod)
} else {
log.Printf("授权未到期,剩余时间:%d天 %d小时 %d分钟 %d秒", days, hours, minutes, secod)
}
// log.Printf("剩余时间:%d天 %d小时 %d分钟 %d秒", days, hours, minutes, secod) //剩余时间
} else {
log.Println("没有授权")
}
}
if urls != "" {
key := tool.Keyprin(tool.Auth_main()["key"])
if key.End_time != "" {
a, _ := strconv.ParseInt(key.End_time, 10, 64)
// b, _ := strconv.ParseInt(key.Initial_time, 10, 64)
duration := time.Unix(a, 0).Sub(time.Unix(tool.Timestamp("second"), 0))
days := int(duration / (24 * time.Hour)) //天
hours := int(duration % (24 * time.Hour) / time.Hour) //小时
minutes := int(duration / time.Minute % 60) //分钟
secod := int(duration / time.Second % 60) //秒
if days <= 0 && hours <= 0 && minutes <= 0 {
log.Printf("授权已到期,剩余时间:%d天 %d小时 %d分钟 %d秒", days, hours, minutes, secod)
} else {
log.Printf("授权未到期,剩余时间:%d天 %d小时 %d分钟 %d秒", days, hours, minutes, secod)
//可执行程序位置
}
// log.Println(days, hours, minutes, secod) //剩余时间
} else {
log.Println("没有授权,请联系管理员")
}
}
if runs {
key := tool.Keyprin(tool.Auth_main()["key"])
if key.End_time != "" {
a, _ := strconv.ParseInt(key.End_time, 10, 64)
// b, _ := strconv.ParseInt(key.Initial_time, 10, 64) // 获取的不是当前时间
duration := time.Unix(a, 0).Sub(time.Unix(tool.Timestamp("second"), 0))
days := int(duration / (24 * time.Hour)) //天
hours := int(duration % (24 * time.Hour) / time.Hour) //小时
minutes := int(duration / time.Minute % 60) //分钟
secod := int(duration / time.Second % 60) //秒
if days <= 0 && hours <= 0 && minutes <= 0 {
log.Printf("授权已到期,剩余时间:%d天 %d小时 %d分钟 %d秒", days, hours, minutes, secod)
} else {
log.Printf("授权未到期,剩余时间:%d天 %d小时 %d分钟 %d秒", days, hours, minutes, secod)
//可执行程序位置
//互联网区
method.HW_FAC1() //截取流量清洗的图片
method.HW_FW1() //截取防火墙的图片
}
} else {
log.Println("没有授权")
}
}
} else {
// log.Println("\n使用说明\n请在主程序后面带上参数↓↓↓\n# # # # # # # # # # # # # # # # # # # # # # # # #\n\n实例: main -url https://www.douyin.com/follow/live/923670558441\n\n# # # # # # # # # # # # # # # # # # # # # # # # #")
flag.Usage()
os.Exit(0)
}
}
func init() {
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0])
fmt.Println(" -url https://www.douyin.com 指定URL地址")
fmt.Println(" -v 查看授权状态")
fmt.Println(" -run 开始截取图片")
// fmt.Println(" -h, 帮助信息")
}
}