func (cfg *Config) findVideoId() (videoId string, err error) {
	videoId = cfg.videoId
	if strings.Contains(videoId, "youtu") || strings.ContainsAny(videoId, "\"?&/<%=") {
		log("Provided video id seems to be an url, trying to detect")
		re_list := []*regexp.Regexp{
			regexp.MustCompile(`(?:v|embed|watch\?v)(?:=|/)([^"&?/=%]{11})`),
			regexp.MustCompile(`(?:=|/)([^"&?/=%]{11})`),
			regexp.MustCompile(`([^"&?/=%]{11})`),
		}
		for _, re := range re_list {
			if is_match := re.MatchString(videoId); is_match {
				subs := re.FindStringSubmatch(videoId)
				videoId = subs[1]
			}
		}
	}
	log("Found video id: '%s'", videoId)
	if strings.ContainsAny(videoId, "?&/<%=") {
		return videoId, errors.New("invalid characters in video id")
	}
	if len(videoId) < 10 {
		return videoId, errors.New("the video id must be at least 10 characters long")
	}
	return videoId, nil
}
reads the videoId property and try to find what we need inside
package main
import (
	"flag"
	"regexp"
	"errors"
	"strings"
	"fmt"
	"os"
	"path/filepath"
)
var audioBitrates map[uint][]string = map[uint][]string{
	AUDIO_BITRATE_LOW: []string{QUALITY_SMALL},
	AUDIO_BITRATE_MEDIUM: []string{QUALITY_MEDIUM, QUALITY_LARGE, QUALITY_UNKNOWN},
	AUDIO_BITRATE_HIGH: []string{QUALITY_HD720, QUALITY_HD1080, QUALITY_HIGHRES},
}
var sortedQualities []string = []string{
	QUALITY_HIGHRES,
	QUALITY_HD1080,
	QUALITY_HD720,
	QUALITY_LARGE,
	QUALITY_MEDIUM,
	QUALITY_SMALL,
	QUALITY_UNKNOWN,
}
var formatsTrigger map[string]string = map[string]string{
	FORMAT_MP4: "video/mp4",
	FORMAT_FLV: "video/x-flv",
	FORMAT_WEBM: "video/webm",
	FORMAT_3GP: "video/3gpp",
}
var sortedFormats []string = []string{
	FORMAT_MP4,
	FORMAT_FLV,
	FORMAT_WEBM,
	FORMAT_3GP,
	FORMAT_UNKNOWN,
}
type commaStringList struct {
	values []string
	allowed map[string]struct{}
}
func (sl *commaStringList) String() string {
	return strings.Join(sl.values, ",")
}
func (sl *commaStringList) Set(value string) error {
	sl.values = sl.values[0:0]
	var exists bool
	for _, s := range strings.Split(value, ",") {
		_, exists = sl.allowed[s]
		if len(sl.allowed) > 0 && !exists {
			return errors.New(fmt.Sprintf("non allowed value '%s'", s))
		}
		sl.values = append(sl.values, s)
	}
	return nil
}
func CreateCommaStringList(values []string, allowed []string) *commaStringList {
	sl := &commaStringList{[]string{}, map[string]struct{}{}}
	for _, value := range values {
		sl.values = append(sl.values, value)
	}
	for _, value := range allowed {
		sl.allowed[value] = struct{}{}
	}
	return sl
}
type Config struct {
	verbose bool
	output string	 
	overwrite bool
	quality *commaStringList
	format *commaStringList
	videoId string
	toMp3 bool
	audioBitrate uint
}
var cfg *Config = &Config{
	false,
	DEFAULT_DESTINATION,
	false,
	CreateCommaStringList(
		[]string{QUALITY_HD720, QUALITY_MAX},
		append([]string{QUALITY_MAX, QUALITY_MIN}, sortedQualities...),
	),
	CreateCommaStringList(
		[]string{FORMAT_MP4, FORMAT_FLV, FORMAT_WEBM, FORMAT_3GP},
		sortedFormats,
	),
	"",
	false,
	AUDIO_BITRATE_AUTO,
}