Beispiel #1
0
        async static Task <List <string> > GetSlideURLs(string query, string size, CancellationToken token)
        {
            try
            {
                var url  = $"https://www.google.com/search?q={Uri.EscapeUriString(query)}&tbm=isch&tbs=isz:lt,islt:{size}";
                var data = await URLDownloader.GetURLString(url, token);

                return(Regex.Matches(data, @"""ou"":""(.*?)""").Cast <Match>().Select(match => match.Groups[1].Value).ToList());
            }
            catch { return(new List <string>()); }
        }
Beispiel #2
0
        async static Task <string> FetchSlideAsync(string url, Action <string> action, CancellationToken token)
        {
            var fileName = $@"{Settings.SlidesPath}\{nameof(NeoPlayer)}-Slide-{++slideCount:0000000000}.bmp";

            try
            {
                using (var ms = await URLDownloader.GetURLData(url, token))
                    await AsyncHelper.ThreadPoolRunAsync(() => ShrinkSlide(ms, fileName, token));

                token.ThrowIfCancellationRequested();

                action(fileName);
                return(fileName);
            }
            catch
            {
                File.Delete(fileName);
                return(null);
            }
        }