Beispiel #1
0
        protected override Comic GetComicByIndex(int index)
        {
            // Download comic HTML
            var wc = new WebClient {
                Encoding = Encoding.UTF8
            };
            var comicInfo  = wc.DownloadString(string.Format(UrlFormatString, index + 1));
            var pictureUrl = GetStringBetween(comicInfo, "<img border=0 src=\"", "\" alt=");
            var title      = GetStringBetween(comicInfo, "<h1>", "</h1>");
            var alt        = GetStringBetween(comicInfo, "<div class=\"comics_text\">", "</div>");

            // Download picture
            var imageStream = WebRequest.Create(pictureUrl).GetResponse().GetResponseStream().ToMemoryStream();
            var comic       = Comic.Create(imageStream.GetBuffer());

            if (comic == null)
            {
                return(null);
            }

            comic.Description = alt;
            comic.Index       = index + 1;
            comic.Title       = title;

            return(comic);
        }
        protected override Comic GetComicByIndex(int index)
        {
            // Download comic HTML
            var wc = new WebClient {
                Encoding = Encoding.UTF8
            };
            var comicDate  = StartDate.AddDays(index);
            var dateString = comicDate.ToString("yyyy-MM-dd"); //2007-05-07
            var comicUrl   = string.Format(UrlFormatString, dateString);
            var comicInfo  = wc.DownloadString(comicUrl);

            var pictureUrl = Regex.Match(comicInfo, string.Format(@"http://www.brainlesstales.com/images/{0}/.*\.jpg", comicDate.Year)).Value;
            var title      = GetStringBetween(comicInfo, "<title>", " - Brainless Tales</title>");

            // Download picture
            var imageStream = WebRequest.Create(pictureUrl).GetResponse().GetResponseStream().ToMemoryStream();
            var comic       = Comic.Create(imageStream.GetBuffer());

            if (comic == null)
            {
                return(null);
            }

            comic.Index = index + 1;
            comic.Title = string.Format("{0} ({1})", title, dateString);
            //comic.Description = dateString;
            comic.Url = comicUrl;

            return(comic);
        }
Beispiel #3
0
        protected override Comic GetComicByIndex(int index)
        {
            var comicIndex = index + Offset;
            var number     = comicIndex.ToString("0#"); // Add 0 to one-digit numbers

            while (true)
            {
                var imageUrl = string.Format(UrlFormatString, number);

                // Download picture
                var imageStream = WebRequest.Create(imageUrl).GetResponse().GetResponseStream().ToMemoryStream();

                var comic = Comic.Create(imageStream.GetBuffer());
                if (comic != null)
                {
                    comic.Index           = comicIndex;
                    comic.RotationDegrees = 90;
                    return(comic);
                }

                if (number.Contains("_"))
                {
                    return(null);
                }
                number += "_0"; // Some comics are like 01_0, try that
            }
        }
Beispiel #4
0
        protected override Comic GetComicByIndex(int index)
        {
            // Download comic JSON
            var comicInfo = GetComic(string.Format(UrlFormatString, index + 1));

            if (comicInfo == null)
            {
                return(null);
            }

            // Download picture
            var imageStream = WebRequest.Create(comicInfo.img).GetResponse().GetResponseStream().ToMemoryStream();
            var comic       = Comic.Create(imageStream.GetBuffer());

            if (comic == null)
            {
                return(null);
            }

            comic.Description = comicInfo.alt;
            comic.Url         = comicInfo.link;
            comic.Index       = index + 1;
            comic.Title       = comicInfo.title;

            // Auto-rotate for best fit
            var t = comic.Thumbnail;

            if (t.Width > t.Height)
            {
                comic.RotationDegrees = 90;
            }

            return(comic);
        }
Beispiel #5
0
        protected override Comic GetComicByIndex(int index)
        {
            var url  = string.Format(UrlFormatString, index + Offset);
            var html = new WebClient().DownloadString(url);

            var startIndex = html.IndexOf(ImageToken);

            if (startIndex < 0)
            {
                return(null);
            }

            var endIndex = html.IndexOf('"', startIndex + ImageToken.Length);

            if (endIndex < 0)
            {
                return(null);
            }

            startIndex += ImageToken.Length;
            var imageUrl = html.Substring(startIndex, endIndex - startIndex);

            // Download picture
            var imageStream = WebRequest.Create(imageUrl).GetResponse().GetResponseStream().ToMemoryStream();

            var comic = Comic.Create(imageStream.GetBuffer());

            if (comic != null)
            {
                comic.Url   = url;
                comic.Index = index;
                return(comic);
            }

            return(null);
        }
 protected override Comic GetComicByIndex(int index)
 {
     return(Comic.Create(File.ReadAllBytes(Directory.GetFiles(FolderPath)[index])));
 }