-
Notifications
You must be signed in to change notification settings - Fork 0
/
find.go
47 lines (37 loc) · 1.07 KB
/
find.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
// Copyright 2019 Alberto Bregliano. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package manifest
import (
// "net/http"
"net/url"
"regexp"
"strings"
)
var isDash = regexp.MustCompile(`(?m)\.mpd$`)
var isSS = regexp.MustCompile(`(?m)^.*\.ism`)
// Find restituisce la url del manifest per la url passata come argomento.
func Find(rawurl string) (urlmanifest string, err error) {
// serve a rendere gestibili le url encodate
if strings.Contains(rawurl, "%") {
rawurl, err = url.QueryUnescape(rawurl)
if err != nil {
return "", err
}
}
//rawurlbyte := []byte(decodedurl)
// gestione dei dash
if isDash.MatchString(rawurl) {
urlmanifest = rawurl
}
// gestione degli SmoothStreaming
if isSS.MatchString(rawurl) {
urlmanifest = isSS.FindString(rawurl) + "/Manifest"
}
return urlmanifest, err
}
// IsManifestReachable esegue un curl HEAD sul manifest passato come argomento.
// func IsManifestReachable(urlmanifest string) error {
// _, err := http.Head(urlmanifest)
// return err
// }