Improve video id handling in import to be more user friendly
This commit is contained in:
parent
9bbfb420f9
commit
4e203eb773
4 changed files with 10 additions and 10 deletions
File diff suppressed because one or more lines are too long
|
@ -23,9 +23,9 @@ type Importer interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewImporter(url string) (Importer, error) {
|
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
|
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
|
return &VimeoImporter{}, nil
|
||||||
} else {
|
} else {
|
||||||
return nil, ErrUnsupportedVideoURL
|
return nil, ErrUnsupportedVideoURL
|
||||||
|
|
|
@ -10,8 +10,8 @@ import (
|
||||||
type VimeoImporter struct{}
|
type VimeoImporter struct{}
|
||||||
|
|
||||||
func (i *VimeoImporter) GetVideoInfo(url string) (videoInfo VideoInfo, err error) {
|
func (i *VimeoImporter) GetVideoInfo(url string) (videoInfo VideoInfo, err error) {
|
||||||
if strings.HasPrefix(url, "vimeo:") {
|
if strings.HasPrefix(strings.ToLower(url), "vimeo:") {
|
||||||
url = strings.TrimPrefix(url, "vimeo:")
|
url = strings.TrimSpace(strings.SplitN(url, ":", 2)[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
if !strings.HasPrefix(url, "http") {
|
if !strings.HasPrefix(url, "http") {
|
||||||
|
|
|
@ -10,8 +10,8 @@ import (
|
||||||
type YoutubeImporter struct{}
|
type YoutubeImporter struct{}
|
||||||
|
|
||||||
func (i *YoutubeImporter) GetVideoInfo(url string) (videoInfo VideoInfo, err error) {
|
func (i *YoutubeImporter) GetVideoInfo(url string) (videoInfo VideoInfo, err error) {
|
||||||
if strings.HasPrefix(url, "youtube:") {
|
if strings.HasPrefix(strings.ToLower(url), "youtube:") {
|
||||||
url = strings.TrimPrefix(url, "youtube:")
|
url = strings.TrimSpace(strings.SplitN(url, ":", 2)[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
info, err := ytdl.GetVideoInfo(url)
|
info, err := ytdl.GetVideoInfo(url)
|
||||||
|
|
Loading…
Reference in a new issue