MCPcopy Index your code
hub / github.com/dinofizz/diskplayer / PlayPath

Function PlayPath

diskplayer.go:14–32  ·  view source on GitHub ↗

PlayPath will play an album or playlist by reading a Spotify URI from a file whose filepath is passed into the function. An error is returned if one is encountered.

(c Client, p string)

Source from the content-addressed store, hash-verified

12// function.
13// An error is returned if one is encountered.
14func PlayPath(c Client, p string) error {
15 f, err := os.Open(p)
16 if err != nil {
17 return err
18 }
19 defer f.Close()
20
21 s := bufio.NewScanner(f)
22 var l string
23 if s.Scan() {
24 l = s.Text()
25 }
26
27 if l == "" {
28 return fmt.Errorf("unable to read line from path: %s", p)
29 }
30
31 return PlayUri(c, l)
32}
33
34// PlayURI will play the album or playlist Spotify URI that is passed in to the function.
35// An error is returned if one is encountered.

Callers 4

mainFunction · 0.92
TestPlayPathSuccessFunction · 0.85
TestPlayPathInvalidPathFunction · 0.85

Calls 1

PlayUriFunction · 0.85

Tested by 3

TestPlayPathSuccessFunction · 0.68
TestPlayPathInvalidPathFunction · 0.68