tube/importers/importer.go

34 lines
792 B
Go
Raw Permalink Normal View History

2020-03-28 05:16:45 +03:00
package importers
import (
"errors"
"strings"
)
var (
ErrUnsupportedVideoURL = errors.New("error: unsupported video url")
)
type VideoInfo struct {
ID string `json:"id"`
Title string `json:"title"`
Description string `json:"description"`
VideoURL string `json:"video_url"`
ThumbnailURL string `json:"thumbnail_url"`
}
type Importer interface {
GetVideoInfo(url string) (VideoInfo, error)
}
func NewImporter(url string) (Importer, error) {
2024-12-23 19:54:59 +03:00
/*if strings.Contains(url, "youtube.com") || strings.HasPrefix(strings.ToLower(url), "youtube:") {
2020-03-28 05:16:45 +03:00
return &YoutubeImporter{}, nil
2024-12-23 19:54:59 +03:00
} else*/ if strings.Contains(url, "vimeo.com") || strings.HasPrefix(strings.ToLower(url), "vimeo:") {
2020-03-28 05:16:45 +03:00
return &VimeoImporter{}, nil
} else {
return nil, ErrUnsupportedVideoURL
}
}