Skip to content

Commit

Permalink
1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
uchks committed Dec 11, 2023
0 parents commit f64f265
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .github/README.md
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)
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

qiwiddl.exe
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module main.go

go 1.21.4
70 changes: 70 additions & 0 deletions main.go
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]
}

0 comments on commit f64f265

Please sign in to comment.