private async void btnGetInfo_Click(object sender, RoutedEventArgs e)
        {
            int videoId = ValidateUrl(textUrl.Text);

            if (videoId > 0)
            {
                currentVideoId = videoId;
                try
                {
                    Task <JObject> taskInfo        = InfoHelper.GetVideoInfo(videoId);
                    Task <JObject> taskAccessToken = InfoHelper.GetVideoToken(videoId, textOauth.Text);
                    await Task.WhenAll(taskInfo, taskAccessToken);

                    string             thumbUrl     = taskInfo.Result["preview"]["medium"].ToString();
                    Task <BitmapImage> thumbImage   = InfoHelper.GetThumb(thumbUrl);
                    Task <string[]>    taskPlaylist = InfoHelper.GetVideoPlaylist(videoId, taskAccessToken.Result["token"].ToString(), taskAccessToken.Result["sig"].ToString());
                    await taskPlaylist;
                    try
                    {
                        await thumbImage;
                    }
                    catch
                    {
                        AppendLog("ERROR: Unable to find thumbnail");
                    }

                    comboQuality.Items.Clear();
                    videoQualties.Clear();
                    string[] playlist = taskPlaylist.Result;
                    for (int i = 0; i < playlist.Length; i++)
                    {
                        if (playlist[i].Contains("#EXT-X-MEDIA"))
                        {
                            string lastPart      = playlist[i].Substring(playlist[i].IndexOf("NAME=\"") + 6);
                            string stringQuality = lastPart.Substring(0, lastPart.IndexOf("\""));

                            if (!videoQualties.ContainsKey(stringQuality))
                            {
                                videoQualties.Add(stringQuality, playlist[i + 2]);
                                comboQuality.Items.Add(stringQuality);
                            }
                        }
                    }
                    comboQuality.SelectedIndex = 0;

                    if (!thumbImage.IsFaulted)
                    {
                        imgThumbnail.Source = thumbImage.Result;
                    }
                    TimeSpan vodLength = TimeSpan.FromSeconds(taskInfo.Result["length"].ToObject <int>());
                    textStreamer.Text  = taskInfo.Result["channel"]["display_name"].ToString();
                    textTitle.Text     = taskInfo.Result["title"].ToString();
                    textCreatedAt.Text = taskInfo.Result["created_at"].ToString();
                    numEndHour.Value   = vodLength.Hours;
                    numEndMinute.Value = vodLength.Minutes;
                    numEndSecond.Value = vodLength.Seconds;
                    labelLength.Text   = String.Format("{0:00}:{1:00}:{2:00}", vodLength.Hours, vodLength.Minutes, vodLength.Seconds);

                    SetEnabled(true);
                }
                catch (Exception ex)
                {
                    btnGetInfo.IsEnabled = true;
                    AppendLog("ERROR: " + ex.Message);
                    MessageBox.Show("Unable to get the video information." + Environment.NewLine + "Please make sure the video ID is correct and try again.", "Unable To Fetch Video Info", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                MessageBox.Show("Please enter a valid video ID/URL" + Environment.NewLine + "Examples:" + Environment.NewLine + "https://www.twitch.tv/videos/470741744" + Environment.NewLine + "470741744", "Invalid Video ID/URL", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private async void btnGetInfo_Click(object sender, RoutedEventArgs e)
        {
            string id = ValidateUrl(textUrl.Text);

            if (id != "")
            {
                btnGetInfo.IsEnabled = false;
                downloadId           = id;
                if (id.All(Char.IsDigit))
                {
                    downloadType = DownloadType.Video;
                }
                else
                {
                    downloadType = DownloadType.Clip;
                }

                try
                {
                    if (downloadType == DownloadType.Video)
                    {
                        Task <JObject> taskInfo = InfoHelper.GetVideoInfo(Int32.Parse(downloadId));
                        await Task.WhenAll(taskInfo);

                        videoData = taskInfo.Result;
                        string             thumbUrl  = taskInfo.Result["preview"]["medium"].ToString();
                        Task <BitmapImage> taskThumb = InfoHelper.GetThumb(thumbUrl);

                        try
                        {
                            await taskThumb;
                        }
                        catch
                        {
                            AppendLog("ERROR: Unable to find thumbnail");
                        }
                        if (!taskThumb.IsFaulted)
                        {
                            imgThumbnail.Source = taskThumb.Result;
                        }
                        textTitle.Text     = taskInfo.Result["title"].ToString();
                        textStreamer.Text  = taskInfo.Result["channel"]["display_name"].ToString();
                        textCreatedAt.Text = taskInfo.Result["created_at"].ToString();
                        streamerId         = taskInfo.Result["channel"]["_id"].ToObject <int>();
                        SetEnabled(true, false);
                    }
                    else if (downloadType == DownloadType.Clip)
                    {
                        string         clipId   = downloadId;
                        Task <JObject> taskInfo = InfoHelper.GetClipInfo(clipId);
                        await Task.WhenAll(taskInfo);

                        JToken clipData = taskInfo.Result;
                        videoData = taskInfo.Result;
                        string             thumbUrl  = clipData["thumbnails"]["medium"].ToString();
                        Task <BitmapImage> taskThumb = InfoHelper.GetThumb(thumbUrl);
                        await Task.WhenAll(taskThumb);

                        imgThumbnail.Source = taskThumb.Result;
                        textStreamer.Text   = clipData["broadcaster"]["display_name"].ToString();
                        textCreatedAt.Text  = clipData["created_at"].ToString();
                        textTitle.Text      = clipData["title"].ToString();
                        streamerId          = clipData["broadcaster"]["id"].ToObject <int>();
                        SetEnabled(true, false);
                        SetEnabled(false, true);
                    }

                    btnGetInfo.IsEnabled = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Unable to get Clip/Video information. Please double check your link and try again", "Unable to get info", MessageBoxButton.OK, MessageBoxImage.Error);
                    AppendLog("ERROR: " + ex.Message);
                    btnGetInfo.IsEnabled = true;
                }
            }
            else
            {
                MessageBox.Show("Please double check the VOD/Clip link", "Unable to parse input", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }