Created
September 22, 2021 02:00
-
-
Save nullenc0de/ee3fc14520f6dc61b3e9a888d5703a9f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"os" | |
"os/exec" | |
) | |
func main() { | |
decoder := json.NewDecoder(os.Stdin) | |
for { | |
json := make(map[string]interface{}) | |
decoder.Decode(&json) | |
urlUrl := json["url"] | |
urlTitle := json["title"] | |
urlChecksum := json["checksum"] | |
urlContentType := json["content_file"] | |
urlContentLength := json["length"] | |
urlStatusCode := json["status"] | |
urlFavicon := json["favicon"] | |
urlRedirect := json["redirect"] | |
urlUrlString := fmt.Sprintf("%v", urlUrl) | |
urlTitleString := fmt.Sprintf("%v", urlTitle) | |
urlChecksumString := fmt.Sprintf("%v", urlChecksum) | |
urlFaviconString := fmt.Sprintf("%v", urlFavicon) | |
urlContentTypeString := fmt.Sprintf("%v", urlContentType) | |
urlContentLengthString := fmt.Sprintf("%v", urlContentLength) | |
urlStatusCodeString := fmt.Sprintf("%v", urlStatusCode) | |
urlRedirectString := fmt.Sprintf("%v", urlRedirect) | |
if urlUrlString != "<nil>" { | |
fullCommand := "bbrf url add '" + urlUrlString +"' -t 'title:" + urlTitleString + "' -t 'favicon:" + urlFaviconString + "'" + " -t 'checksum:" + urlChecksumString + "'" + " -t 'contenttype:" + urlContentTypeString + "'" + " -t 'contentlength:" + urlContentLengthString + "'" + " -t 'statuscode:" + urlStatusCodeString + "'" + " -t 'redirect:" + urlRedirectString + "'" | |
showOutput := "echo \"bbrf url add '" + urlUrlString +"' -t 'title:" + urlTitleString + "' -t 'favicon:" + urlFaviconString + "'" + " -t 'checksum:" + urlChecksumString + "'" + " -t 'contenttype:" + urlContentTypeString + "'" + " -t 'contentlength:" + urlContentLengthString + "'" + " -t 'statuscode:" + urlStatusCodeString + "'" + " -t 'redirect:" + urlRedirectString + "'\"" | |
out, _ :=exec.Command("sh","-c",fullCommand).Output() | |
out2, _ :=exec.Command("sh","-c",showOutput).Output() | |
fmt.Printf("%s", out) | |
fmt.Printf("%s", out2) | |
} else { | |
break | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment