/
simulant-downloader.go
99 lines (73 loc) · 2.25 KB
/
simulant-downloader.go
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package main
import (
"fmt"
"net/http"
"os"
"time"
"strings"
)
// RequestAction struct
type RequestAction struct {
AuthRequest string
CheckRequest string
DownloadRequest string
}
// Properties of pretend human to download files in a human-like way to avoid rate limiting, detection, etc
type Simulant struct {
// ultimatejitter - seed a random value between the average time for user to download based on the (age, tool, filetype, service values) more age, using browser, files that larger are probably going to use web services that require more clicks so more time
}
// open a file containing urls
// Check the file is downloadable else append to file title failedURLs.txt
// use a template checkRequest
// - Video name
// - Size of video
// Beware the neeed for some sort of config for browser and human-like mouse clicking and typing
// queue to manage downloads
// replacer to replace URL with the url
// wrapper for curl
func DownloadCMDFile(cmd,request, filename string) error {
return nil
}
// Make a type for Check,Auth,Download
// type RequestAction struct {}
//const DownloadRequest string //
// request factory - check,download,auth
// Modify default requests of auth,check and download with url
func ReplaceURLRequest(request, url string) (string,error){
return result, nil
}
func main() {
defaultRequests := RequestAction{}
//
// QUEUE IS ABSTRACTION - REMEMBER Simulate action not automation
// create queues: TODO consider file -> map{},
checkingQueue := initStrArray()
downloadingQueue := initStrArray()
os.exit()
}
func initStrArray(n int) []string {
result := make([]string, n)
for i := 0; i <= n-1; i++ {
result[i] = ""
}
return result
}
func checkFileExists(path string) (bool error) {
_, err := os.Stat(path)
if err == nil {
log.Fatal(err)
return false, err
}
if os.IsNotExist(err) {
log.Fatal("File path does not exist")
return false, err
}
return true, nil
}
func isDirectory(path string) (bool, error) {
fileInfo, err := os.Stat(path)
if err != nil {
return false, err
}
return fileInfo.IsDir(), err
}