Fixing GOFILE + Adding LICENSE

gofile.io changed their api so switched to a new extracting mechanism.
needs clean IP do download from gofile else it will give an error
This commit is contained in:
icxven 2024-05-01 06:47:16 +05:30
parent 4d971810cf
commit 5e52c9a414
Signed by: x
GPG key ID: 07D47D6C17A8E630
3 changed files with 59 additions and 21 deletions

14
LICENSE Normal file
View file

@ -0,0 +1,14 @@
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.

View file

@ -4,7 +4,6 @@ import (
"io"
"os"
"fmt"
"strings"
"net/http"
"github.com/spf13/cobra"
"github.com/schollz/progressbar/v3"
@ -19,13 +18,16 @@ func check(f func() error) {
func dl(url string) {
fileName, dl, token := FindSite(url)
req, _ := http.NewRequest("GET", dl, nil)
if token == "none" {
fmt.Println("cookies not needed, so not loading >.<")
} else {
cookie := "accountToken=" + token
req.Header.Set("Cookie", cookie)
req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0")
req.Header.Set("Accept-Encoding", "gzip, deflate, br")
req.Header.Set("Accept", "*/*")
req.Header.Set("Connection", "keep-alive")
}
resp, _ := http.DefaultClient.Do(req)
@ -59,7 +61,7 @@ func main() {
and directly download the file to the local storage`,
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
dl((strings.Join(args, " ")))
dl(args[0])
},
}

View file

@ -1,26 +1,48 @@
package sites
package sites
import (
"strings"
"github.com/tidwall/gjson"
"github.com/imroc/req/v3"
import (
"fmt"
"os"
"strings"
"github.com/imroc/req/v3"
"github.com/tidwall/gjson"
)
// example - https://gofile.io/d/UUj5aO
func GoFile(durl string) (string, string, string) {
url := "https://api.gofile.io/createAccount"
resp := Response{req.MustGet(url)}
data := resp.GetJsonStringField("data")
token := gjson.Get(data, "token")
Client := req.C()
AccountCreationURL := "https://api.gofile.io/accounts"
AccountCreationRESP, err := Client.R().SetHeaders(map[string]string{
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0",
"Accept-Encoding": "gzip, deflate, br",
"Accept": "*/*",
"Connection": "keep-alive",
}).Post(AccountCreationURL)
if err != nil {
fmt.Println("unable to fetch data from gofile >,>")
os.Exit(1)
}
Token := gjson.Get(AccountCreationRESP.String(), "data.token")
dsplit := strings.Split(durl, "/")
id := dsplit[len(dsplit)-1]
geturl := "https://api.gofile.io/getContent?contentId=" + id + "&token=" + token.String() + "&wt=4fd6sg89d7s6&cache=true"
resp2 := Response{req.MustGet(geturl)}
fileid := gjson.Get(resp2.String(), "data.childs.0")
contentstring := "data.contents." + fileid.String()
filenameString := contentstring + ".name"
durlString := contentstring + ".link"
filename := gjson.Get(resp2.String(), filenameString)
durlr := gjson.Get(resp2.String(), durlString)
return filename.String(), durlr.String(), token.String()
geturl := "https://api.gofile.io/contents/" + id + "?wt=4fd6sg89d7s6&cache=true"
FileInfoRESP, err := Client.R().SetHeaders(map[string]string{
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0",
"Accept-Encoding": "gzip, deflate, br",
"Accept": "*/*",
"Connection": "keep-alive",
"Authorization": "Bearer" + " " + Token.String(),
}).Get(geturl)
if err != nil {
fmt.Println("unable to fetch data from gofile >,>")
os.Exit(1)
}
FileID := gjson.Get(FileInfoRESP.String(), "data.childrenIds.0")
ContentJSONStr := "data.children." + FileID.String()
FileNameJSONStr := ContentJSONStr + ".name"
DownloadURLJSONStr := ContentJSONStr + ".link"
Filename := gjson.Get(FileInfoRESP.String(), FileNameJSONStr)
DownloadURL := gjson.Get(FileInfoRESP.String(), DownloadURLJSONStr)
return Filename.String(), DownloadURL.String(), Token.String()
}