forked from tellytv/telly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
structs.go
136 lines (119 loc) · 3.28 KB
/
structs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
package main
import (
"encoding/xml"
"fmt"
"net"
"regexp"
"strconv"
"github.com/tellytv/telly/m3u"
)
type config struct {
RegexInclusive bool
Regex *regexp.Regexp
DirectMode bool
M3UPath string
ConcurrentStreams int
StartingChannel int
DeviceAuth string
DeviceID int
DeviceUUID string
FriendlyName string
Manufacturer string
ModelNumber string
FirmwareName string
FirmwareVersion string
SSDP bool
LogRequests bool
LogLevel string
ListenAddress *net.TCPAddr
BaseAddress *net.TCPAddr
lineup []LineupItem
}
func (c *config) DiscoveryData() DiscoveryData {
return DiscoveryData{
FriendlyName: c.FriendlyName,
Manufacturer: c.Manufacturer,
ModelNumber: c.ModelNumber,
FirmwareName: c.FirmwareName,
TunerCount: c.ConcurrentStreams,
FirmwareVersion: c.FirmwareVersion,
DeviceID: strconv.Itoa(c.DeviceID),
DeviceAuth: c.DeviceAuth,
BaseURL: fmt.Sprintf("http://%s", c.BaseAddress),
LineupURL: fmt.Sprintf("http://%s/lineup.json", c.BaseAddress),
}
}
// DiscoveryData contains data about telly to expose in the HDHomeRun format for Plex detection.
type DiscoveryData struct {
FriendlyName string
Manufacturer string
ModelNumber string
FirmwareName string
TunerCount int
FirmwareVersion string
DeviceID string
DeviceAuth string
BaseURL string
LineupURL string
}
// UPNP returns the UPNP representation of the DiscoveryData.
func (d *DiscoveryData) UPNP() UPNP {
return UPNP{
SpecVersion: upnpVersion{
Major: 1, Minor: 0,
},
URLBase: d.BaseURL,
Device: upnpDevice{
DeviceType: "urn:schemas-upnp-org:device:MediaServer:1",
FriendlyName: d.FriendlyName,
Manufacturer: d.Manufacturer,
ModelName: d.ModelNumber,
ModelNumber: d.ModelNumber,
UDN: fmt.Sprintf("uuid:%s", d.DeviceID),
},
}
}
// LineupStatus exposes the status of the channel lineup.
type LineupStatus struct {
ScanInProgress int
ScanPossible int
Source string
SourceList []string
}
// LineupItem is a single channel found in the playlist.
type LineupItem struct {
GuideNumber string
GuideName string
URL string
}
// Track describes a single M3U segment. This struct includes m3u.Track as well as specific IPTV fields we want to get.
type Track struct {
*m3u.Track
Catchup string `m3u:"catchup"`
CatchupDays string `m3u:"catchup-days"`
CatchupSource string `m3u:"catchup-source"`
GroupTitle string `m3u:"group-title"`
TvgID string `m3u:"tvg-id"`
TvgLogo string `m3u:"tvg-logo"`
TvgName string `m3u:"tvg-name"`
}
type upnpVersion struct {
Major int32 `xml:"major"`
Minor int32 `xml:"minor"`
}
type upnpDevice struct {
DeviceType string `xml:"deviceType"`
FriendlyName string `xml:"friendlyName"`
Manufacturer string `xml:"manufacturer"`
ModelName string `xml:"modelName"`
ModelNumber string `xml:"modelNumber"`
SerialNumber string `xml:"serialNumber"`
UDN string `xml:"UDN"`
}
// UPNP describes the UPNP/SSDP XML.
type UPNP struct {
XMLName xml.Name `xml:"urn:schemas-upnp-org:device-1-0 root"`
SpecVersion upnpVersion `xml:"specVersion"`
URLBase string `xml:"URLBase"`
Device upnpDevice `xml:"device"`
}