-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmodule.go
49 lines (41 loc) · 1.05 KB
/
module.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
package gdown
import (
"github.com/Juvenal-Yescas/gdown/internal/process"
"github.com/Juvenal-Yescas/gdown/internal/utils"
)
func Download(url string) (string, error) {
idFile, err := process.GetIdFromUrl(url)
if err != nil {
return "", err
}
clientHttp := utils.CreateClientHttp()
outputName, err := process.GetNameOutput(clientHttp, idFile)
if err != nil {
return "", err
}
urlDirect, err := process.GetUrlConfirmation(clientHttp, idFile)
if err != nil {
return "", err
}
downloaded, err := process.StartDownload(clientHttp, urlDirect, outputName)
if err != nil {
return "", err
}
return downloaded, nil
}
func DownloadOutput(url string, outputName string) (string, error) {
idFile, err := process.GetIdFromUrl(url)
if err != nil {
return "", err
}
clientHttp := utils.CreateClientHttp()
urlDirect, err := process.GetUrlConfirmation(clientHttp, idFile)
if err != nil {
return "", err
}
downloaded, err := process.StartDownload(clientHttp, urlDirect, outputName)
if err != nil {
return "", err
}
return downloaded, nil
}