Skip to content

Commit

Permalink
Refactor player-protocol module and update player path handling
Browse files Browse the repository at this point in the history
  • Loading branch information
divyam234 committed Sep 18, 2024
1 parent 11a51da commit a8aa8c5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module player-protocol
module github.com/tgdrive/player-protocol

go 1.22.0

Expand Down
5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// main.go
package main

import (
Expand All @@ -7,6 +6,8 @@ import (
"os"
"os/exec"
"strings"

player_path "github.com/tgdrive/player-protocol/pkg/path"
)

func main() {
Expand Down Expand Up @@ -46,7 +47,7 @@ func main() {
link, _ = url.QueryUnescape(link)
}

playerPath, err := findPlayerPath(player)
playerPath, err := player_path.FindPlayerPath(player)
if err != nil {
fmt.Printf("Error finding %s path: %v\n", player, err)
os.Exit(1)
Expand Down
5 changes: 2 additions & 3 deletions linux.go → pkg/path/path_unix.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
//go:build linux
// +build linux

package main
package path

import (
"fmt"
"os"
"path/filepath"
)

func findPlayerPath(player string) (string, error) {
func FindPlayerPath(player string) (string, error) {
if player == "potplayer" {
return "", fmt.Errorf("PotPlayer is not supported on Linux")
}
Expand Down
5 changes: 2 additions & 3 deletions windows.go → pkg/path/path_windows.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//go:build windows
// +build windows

package main
package path

import (
"fmt"
Expand All @@ -11,7 +10,7 @@ import (
"golang.org/x/sys/windows/registry"
)

func findPlayerPath(player string) (string, error) {
func FindPlayerPath(player string) (string, error) {
path, err := findPathInRegistry(player)
if err == nil {
return path, nil
Expand Down

0 comments on commit a8aa8c5

Please sign in to comment.