MCPcopy
hub / github.com/mxpv/podsync / ParseURL

Function ParseURL

pkg/builder/url.go:12–60  ·  view source on GitHub ↗
(link string)

Source from the content-addressed store, hash-verified

10)
11
12func ParseURL(link string) (model.Info, error) {
13 parsed, err := parseURL(link)
14 if err != nil {
15 return model.Info{}, err
16 }
17
18 info := model.Info{}
19
20 if strings.HasSuffix(parsed.Host, "youtube.com") {
21 kind, id, err := parseYoutubeURL(parsed)
22 if err != nil {
23 return model.Info{}, err
24 }
25
26 info.Provider = model.ProviderYoutube
27 info.LinkType = kind
28 info.ItemID = id
29
30 return info, nil
31 }
32
33 if strings.HasSuffix(parsed.Host, "vimeo.com") {
34 kind, id, err := parseVimeoURL(parsed)
35 if err != nil {
36 return model.Info{}, err
37 }
38
39 info.Provider = model.ProviderVimeo
40 info.LinkType = kind
41 info.ItemID = id
42
43 return info, nil
44 }
45
46 if strings.HasSuffix(parsed.Host, "soundcloud.com") {
47 kind, id, err := parseSoundcloudURL(parsed)
48 if err != nil {
49 return model.Info{}, err
50 }
51
52 info.Provider = model.ProviderSoundcloud
53 info.LinkType = kind
54 info.ItemID = id
55
56 return info, nil
57 }
58
59 return model.Info{}, errors.New("unsupported URL host")
60}
61
62func parseURL(link string) (*url.URL, error) {
63 if !strings.HasPrefix(link, "http") {

Callers 4

updateFeedMethod · 0.92
BuildMethod · 0.85
BuildMethod · 0.85
BuildMethod · 0.85

Calls 4

parseURLFunction · 0.85
parseYoutubeURLFunction · 0.85
parseVimeoURLFunction · 0.85
parseSoundcloudURLFunction · 0.85

Tested by

no test coverage detected