WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 3365ced

Browse files
committed
Add support for Twitch protocol
Rename project to MultiMC-Twitch Update README Added Makefile
1 parent d039db1 commit 3365ced

File tree

9 files changed

+82
-19
lines changed

9 files changed

+82
-19
lines changed

.gitignore

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
*
2-
!.gitignore
3-
!main.go
4-
!README.md
5-
!example.ccip
1+
build/darwin/MultiMC-Twitch.app/Contents/MacOS/MultiMC-Twitch
2+
build/linux/usr/bin/multimc-twitch
3+
build/windows/MultiMC-Twitch.exe
4+
output/

Makefile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
all: clean darwin linux windows
2+
3+
clean:
4+
-rm -rf ./output
5+
-rm ./build/darwin/MultiMC-Twitch.app/Contents/MacOS/MultiMC-Twitch
6+
-rm ./build/linux/usr/bin/multimc-twitch
7+
-rm ./build/windows/MultiMC-Twitch.exe
8+
9+
darwin:
10+
mkdir -p output
11+
GOOS=darwin go build -o ./build/darwin/MultiMC-Twitch.app/Contents/MacOS/MultiMC-Twitch
12+
tar -czvf ./output/darwin.tar.gz --exclude .gitkeep -C ./build/darwin .
13+
14+
linux:
15+
mkdir -p output
16+
GOOS=linux go build -o ./build/linux/usr/bin/multimc-twitch
17+
tar -czvf ./output/linux.tar.gz --exclude .gitkeep -C ./build/linux .
18+
19+
windows:
20+
mkdir -p output
21+
GOOS=windows go build -o ./build/windows/MultiMC-Twitch.exe
22+
tar -czvf ./output/windows.tar.gz --exclude .gitkeep -C ./build/windows .

README.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,28 @@
1-
# MultiMC-CCIP
1+
# MultiMC-Twitch
22

3-
A simple Go program that reads CurseForge CCIP files for MultiMC
4-
1. Reads the [CurseForge] `.ccip` file
3+
A simple Go program that handles Twitch's custom protocol and ccip files
4+
1. Reads the [CurseForge] `.ccip` file or [Twtch] `twitch://` protocol
55
2. Requests the [TwitchAPI] to get the zip url
6-
3. Launches [MultiMC] with the `--import` flag, with the url
6+
3. Launches [MultiMC] with the `--import` flag, with the url
7+
8+
Examples:
9+
- `MultiMC-Twitch example.ccip`
10+
- `MultiMC-Twitch twitch://www.curseforge.com/minecraft/modpacks/aesthetic-construction/download-client/2246179`
11+
12+
Includes:
13+
- Pre-configured Info.plist for handling Twitch protocol
14+
- Pre-configured multimc-twitch.desktop for handling Twitch protocol
15+
- Twitch.reg for handling Twitch protocol (Must be configured)
16+
17+
Configure Twitch.reg for Windows:
18+
1. Edit `Twitch.reg` with any text editor
19+
2. Update the two paths to `MultiMC-Twitch.exe`
20+
(Defaults to C:\MultiMC\MultiMC-Twitch.exe)
21+
3. Run `Twitch.reg`
722

823
[Download](https://github.com/ShayBox/MultiMC-CCIP/releases)
924

1025
[CurseForge]: https://www.curseforge.com/
26+
[Twitch]: https://twitch.tv/
1127
[TwitchAPI]: https://twitchappapi.docs.apiary.io/
1228
[MultiMC]: https://multimc.org/
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleExecutable</key>
6+
<string>MultiMC-Twitch</string>
7+
<key>CFBundleIdentifier</key>
8+
<string>com.shaybox.multimc-twitch</string>
9+
</dict>
10+
</plist>

build/darwin/MultiMC-Twitch.app/Contents/MacOS/.gitkeep

Whitespace-only changes.

build/linux/usr/bin/.gitkeep

Whitespace-only changes.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[Desktop Entry]
2+
Type=Application
3+
Name=MultiMC-Twitch
4+
Exec=multimc-twitch %u
5+
Terminal=true
6+
MimeType=x-scheme-handler/twitch;

build/windows/Twitch.reg

728 Bytes
Binary file not shown.

main.go

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ import (
55
"fmt"
66
"io/ioutil"
77
"net/http"
8+
"net/url"
89
"os"
910
"os/exec"
1011
"runtime"
12+
"strings"
1113
)
1214

13-
// Package - XML structure the CurseForge CCIP files
15+
// Package - XML structure the Twitch CCIP files
1416
type Package struct {
1517
XMLName xml.Name `xml:"package"`
1618
Project struct {
@@ -21,21 +23,29 @@ type Package struct {
2123

2224
func main() {
2325
if len(os.Args) < 2 {
24-
fmt.Println("No path provided")
26+
fmt.Println("Nothing provided")
2527
os.Exit(128)
2628
}
2729

28-
pkg := LoadXML(os.Args[1])
29-
url := GetURL(pkg)
30+
var pack string
31+
32+
url, err := url.ParseRequestURI(os.Args[1])
33+
if err == nil && url.Scheme == "twitch" {
34+
paths := strings.Split(url.Path, "/")
35+
pack = GetPackURL(paths[3], paths[5])
36+
} else {
37+
pkg := LoadXML(os.Args[1])
38+
pack = GetPackURL(pkg.Project.ID, pkg.Project.File)
39+
}
3040

3141
var args []string
3242
switch runtime.GOOS {
3343
case "darwin":
34-
args = []string{"open", "-a", "MultiMC", "--args", "import", url}
44+
args = []string{"open", "-a", "MultiMC", "--args", "import", pack}
3545
case "freebsd", "linux", "netbsd", "openbsd":
36-
args = []string{"multimc", "--import", url}
46+
args = []string{"multimc", "--import", pack}
3747
case "windows":
38-
args = []string{"MultiMC.exe", "--import", url}
48+
args = []string{"MultiMC.exe", "--import", pack}
3949
}
4050

4151
LoadMultiMC(args)
@@ -59,9 +69,9 @@ func LoadXML(fileName string) Package {
5969
return pkg
6070
}
6171

62-
// GetURL - Request the download url from Twitch's API
63-
func GetURL(pkg Package) string {
64-
url := "https://addons-ecs.forgesvc.net/api/v2/addon/" + pkg.Project.ID + "/file/" + pkg.Project.File + "/download-url"
72+
// GetPackURL - Request the download url from Twitch's API
73+
func GetPackURL(id string, file string) string {
74+
url := "https://addons-ecs.forgesvc.net/api/v2/addon/" + id + "/file/" + file + "/download-url"
6575
resp, err := http.Get(url)
6676
if err != nil {
6777
fmt.Println(err)

0 commit comments

Comments
 (0)