diff options
| author | James Mills <prologic@shortcircuit.net.au> | 2020-04-01 22:13:02 +1000 |
|---|---|---|
| committer | James Mills <prologic@shortcircuit.net.au> | 2020-04-01 22:13:02 +1000 |
| commit | 4e203eb773d83e8c0c7cbcdf1c98b9e3b57e4bcb (patch) | |
| tree | 9a9d0faaa4ba1dfc7e010faa5e7c46e94f35d5db /importers | |
| parent | 9bbfb420f99e87f1cc597bc721c209710ca2b6d1 (diff) | |
Improve video id handling in import to be more user friendly
Diffstat (limited to 'importers')
| -rw-r--r-- | importers/importer.go | 4 | ||||
| -rw-r--r-- | importers/vimeo_importer.go | 4 | ||||
| -rw-r--r-- | importers/youtube_importer.go | 4 |
3 files changed, 6 insertions, 6 deletions
diff --git a/importers/importer.go b/importers/importer.go index f5d4b36..eab5b24 100644 --- a/importers/importer.go +++ b/importers/importer.go @@ -23,9 +23,9 @@ type Importer interface { } func NewImporter(url string) (Importer, error) { - if strings.Contains(url, "youtube.com") || strings.HasPrefix(url, "youtube:") { + if strings.Contains(url, "youtube.com") || strings.HasPrefix(strings.ToLower(url), "youtube:") { return &YoutubeImporter{}, nil - } else if strings.Contains(url, "vimeo.com") || strings.HasPrefix(url, "vimeo:") { + } else if strings.Contains(url, "vimeo.com") || strings.HasPrefix(strings.ToLower(url), "vimeo:") { return &VimeoImporter{}, nil } else { return nil, ErrUnsupportedVideoURL diff --git a/importers/vimeo_importer.go b/importers/vimeo_importer.go index 9983a69..ad21bcc 100644 --- a/importers/vimeo_importer.go +++ b/importers/vimeo_importer.go @@ -10,8 +10,8 @@ import ( type VimeoImporter struct{} func (i *VimeoImporter) GetVideoInfo(url string) (videoInfo VideoInfo, err error) { - if strings.HasPrefix(url, "vimeo:") { - url = strings.TrimPrefix(url, "vimeo:") + if strings.HasPrefix(strings.ToLower(url), "vimeo:") { + url = strings.TrimSpace(strings.SplitN(url, ":", 2)[1]) } if !strings.HasPrefix(url, "http") { diff --git a/importers/youtube_importer.go b/importers/youtube_importer.go index 5702b05..c309850 100644 --- a/importers/youtube_importer.go +++ b/importers/youtube_importer.go @@ -10,8 +10,8 @@ import ( type YoutubeImporter struct{} func (i *YoutubeImporter) GetVideoInfo(url string) (videoInfo VideoInfo, err error) { - if strings.HasPrefix(url, "youtube:") { - url = strings.TrimPrefix(url, "youtube:") + if strings.HasPrefix(strings.ToLower(url), "youtube:") { + url = strings.TrimSpace(strings.SplitN(url, ":", 2)[1]) } info, err := ytdl.GetVideoInfo(url) |
