-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support info (device name and other meta-information) in the status.
Examplar result: ``` % curl "http://0.0.0.0:8011/status?uuid=edfaf976-0411-41c4-9e5a-724c8781f0bc" | jq % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 610 100 610 0 0 288 0 0:00:02 0:00:02 --:--:-- 288 { "info": { "name": "Sisters Room speaker", "ip_address": "192.168.0.161", "locale": "pl", "mac_address": "54:60:09:D0:10:A4", "ssid": "Szum", "timezone": "Europe/Warsaw", "uptime": 45394.987882 }, "app_id": "", "display_name": "", "is_idle_screen": false, "status_text": "", "player_state": "", "current_time": 0, "idle_reason": "", "current_item_id": 0, "loading_item_id": 0, "content_id": "", "content_type": "", "stream_type": "", "duration": 0, "artist": "", "title": "", "subtitle": "", "volume_level": 0.89, "volume_muted": false, "media_volume_level": 0, "media_volume_muted": false, "session_id": "", "transport_id": "", "media_session_id": 0, "player_state_id": 0 } ```
- Loading branch information
Showing
7 changed files
with
92 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package application | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"io" | ||
"log" | ||
"net/http" | ||
|
||
"github.com/vishen/go-chromecast/cast" | ||
) | ||
|
||
// getInfo uses the http://<ip>:8008/setup/eureka_endpoint to obtain more | ||
// information about the cast-device. | ||
// OBS: The 8008 seems to be pure http, whereas 8009 is typically the port | ||
// to use for protobuf-communication, | ||
func GetInfo(ip string) (info *cast.DeviceInfo, err error) { | ||
url := fmt.Sprintf("http://%v:8008/setup/eureka_info", ip) | ||
log.Printf("Fetching: %s", url) | ||
resp, err := http.Get(url) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer resp.Body.Close() | ||
data, err := io.ReadAll(resp.Body) | ||
if err != nil { | ||
return nil, err | ||
} | ||
info = new(cast.DeviceInfo) | ||
if err := json.Unmarshal(data, info); err != nil { | ||
return nil, err | ||
} | ||
return info, 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
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