Пример #1
0
// Loads the base url and extracts the playlist url
func (c *Channel) extractPlaylistURL() string {
	base_url := strings.TrimSpace(c.Url)

	data := proxy.GetStringForURL(base_url)

	segments := strings.Split(data, "\"")

	url := ""

	for _, segment := range segments {
		segments := strings.Split(segment, "'")

		for _, segment := range segments {

			if len(segment) > 4 &&
				string(segment[0:4]) == "http" &&
				strings.Contains(segment, "m3u8") {
				url = strings.Replace(segment, "\r", "", 0)
				url = strings.Replace(url, "\n", "", 0)
				break
			}
		}

		if url != "" {
			break
		}
	}

	return url
}
Пример #2
0
// Reloads & Loads the channel cache. Pulls the CSV from the github repository
func reloadChannels() {
	csv := proxy.GetStringForURL("https://openstreamproject.github.io/StreamDatabase/channels.csv")

	lines := strings.Split(csv, "\n")

	for _, line := range lines {
		if len(line) != 0 && string(line[0]) != "#" {
			addOrUpdateChannelWithData(strings.Split(line, ","))
		}
	}
}