-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f64f265
Showing
4 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# qiwi.ddl-go | ||
a Go program that converts [qiwi](https://qiwi.gg) links to DDL. <br> | ||
this is likely to be continously updated due to the qiwi team changing the links over and over; <br> | ||
i.e. spyderrock, texturepackguy, and now qiwi.lol | ||
|
||
**Usage:** <br> | ||
`qiwiddl.exe https://qiwi.gg/file/xxxxxxx` <br> | ||
`qiwiddl.exe` prompts for a download link | ||
|
||
download available in [releases](https://github.com/unethicalteam/qiwi.ddl-go/releases) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
qiwiddl.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module main.go | ||
|
||
go 1.21.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package main | ||
|
||
import ( | ||
"bufio" | ||
"fmt" | ||
"io" | ||
"net/http" | ||
"os" | ||
"strings" | ||
) | ||
|
||
func main() { | ||
var url string | ||
|
||
// Check if a URL argument is provided | ||
if len(os.Args) > 1 { | ||
url = os.Args[1] | ||
} else { | ||
// No URL argument, prompt user for URL | ||
url = promptForURL() | ||
} | ||
|
||
// Process the URL | ||
processURL(url) | ||
} | ||
|
||
func promptForURL() string { | ||
reader := bufio.NewReader(os.Stdin) | ||
fmt.Print("Enter download link: ") | ||
url, _ := reader.ReadString('\n') | ||
return strings.TrimSpace(url) | ||
} | ||
|
||
func processURL(url string) { | ||
resp, err := http.Get(url) | ||
if err != nil { | ||
fmt.Println("Error while sending request:", err) | ||
return | ||
} | ||
defer resp.Body.Close() | ||
|
||
body, err := io.ReadAll(resp.Body) | ||
if err != nil { | ||
fmt.Println("Error while reading response:", err) | ||
return | ||
} | ||
bodyString := string(body) | ||
|
||
slug := extractBetween(bodyString, "\\\"slug\\\":\\\"", "\\\"") | ||
fileName := extractBetween(bodyString, "\\\"fileName\\\":\\\"", "\\\"") | ||
ext := fileName[strings.LastIndex(fileName, ".")+1:] | ||
|
||
fmt.Printf("https://qiwi.lol/%s.%s\n", slug, ext) | ||
} | ||
|
||
// extractBetween finds a substring between two delimiters | ||
func extractBetween(s, start, end string) string { | ||
startIndex := strings.Index(s, start) | ||
if startIndex == -1 { | ||
return "" | ||
} | ||
startIndex += len(start) | ||
|
||
endIndex := strings.Index(s[startIndex:], end) | ||
if endIndex == -1 { | ||
return "" | ||
} | ||
|
||
return s[startIndex : startIndex+endIndex] | ||
} |