-
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.
* Add scraper * Improved scraper * Split package * /shortcuts エンドポイントの追加 * Added suggestion * Fix handleSelect * Revert debug change * go mod tidy * shortcutsをキャッシュするように * Support cross platform
- Loading branch information
1 parent
6fc6716
commit cbf2765
Showing
8 changed files
with
199 additions
and
36 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
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
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 |
---|---|---|
|
@@ -34,7 +34,7 @@ ifeq ($(OS),Windows_NT) | |
GOPATHDIR = $$env:GOPATH | ||
endif | ||
|
||
.DEFAULT_GOAL := build-windows | ||
.DEFAULT_GOAL := build | ||
|
||
test: | ||
$(GOTEST) -v ./... | ||
|
@@ -49,9 +49,9 @@ deps-web: | |
@cd ./web && yarn | ||
build-prepare: clean | ||
@$(GOINSTALL) github.com/mitchellh/[email protected] | ||
build-windows: build-prepare build-web build-windows-server-only | ||
build-windows-server-only: build-prepare | ||
@cd ./server && gox --osarch "windows/amd64" --output ../$(DIST_DIR)/${BINARY_NAME}_{{.OS}}_{{.Arch}} ./ | ||
build: build-prepare build-web build-server-only | ||
build-server-only: build-prepare | ||
@cd ./server && gox --osarch "windows/amd64 darwin/amd64 linux/amd64" --output ../$(DIST_DIR)/${BINARY_NAME}_{{.OS}}_{{.Arch}} ./ | ||
build-web: | ||
@cd ./web && yarn run build | ||
@$(MKDIR) ./$(SERVER_DIR)/static | ||
|
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,28 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"log" | ||
|
||
"github.com/FlowingSPDG/vmix-utility/scraper" | ||
) | ||
|
||
var ( | ||
helpVer int | ||
) | ||
|
||
func main() { | ||
flag.IntVar(&helpVer, "helpver", 25, "vMix help version") | ||
flag.Parse() | ||
|
||
shortcuts, err := scraper.GetShortcuts(helpVer) | ||
if err != nil { | ||
log.Fatalln(err) | ||
} | ||
|
||
fmt.Printf("Got %d Functions\n", len(shortcuts)) | ||
for i, f := range shortcuts { | ||
fmt.Printf("Shortcut[%d] : %s(%s) . Queries:%v\n", i, f.Name, f.Description, f.Parameters) | ||
} | ||
} |
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,66 @@ | ||
package scraper | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/gocolly/colly/v2" | ||
) | ||
|
||
type Shortcut struct { | ||
Name string | ||
Description string | ||
Parameters []string // comma-separated queries | ||
} | ||
|
||
func GetShortcuts(helpVer int) ([]Shortcut, error) { | ||
shortcuts := make([]Shortcut, 0, 500) | ||
|
||
c := colly.NewCollector() | ||
|
||
// Find and visit all links | ||
c.OnHTML("table", func(e *colly.HTMLElement) { | ||
e.ForEach("tr", func(i int, h *colly.HTMLElement) { | ||
// Filter header column somehow? | ||
s := Shortcut{} | ||
h.ForEach("td", func(i int, j *colly.HTMLElement) { | ||
// fmt.Println("td text:", i, j.Text) | ||
switch i { | ||
case 0: | ||
if j.Text != "" { | ||
t := strings.ReplaceAll(j.Text, "\n", "") | ||
s.Name = t | ||
} | ||
case 1: | ||
if j.Text != "" { | ||
t := strings.ReplaceAll(j.Text, "\n", "") | ||
s.Description = t | ||
} | ||
case 2: | ||
if j.Text != "" { | ||
t := strings.ReplaceAll(j.Text, "\n", "") | ||
if t == "None" { | ||
s.Parameters = []string{} | ||
} else { | ||
ts := strings.Split(t, ",") | ||
s.Parameters = ts | ||
} | ||
} | ||
} | ||
}) | ||
shortcuts = append(shortcuts, s) | ||
}) | ||
}) | ||
|
||
c.OnRequest(func(r *colly.Request) { | ||
// fmt.Println("Visiting", r.URL) | ||
}) | ||
|
||
u := fmt.Sprintf("https://www.vmix.com/help%d/ShortcutFunctionReference.html", helpVer) | ||
|
||
if err := c.Visit(u); err != nil { | ||
return nil, err | ||
} | ||
|
||
return shortcuts, nil | ||
} |
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
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
Oops, something went wrong.