コード例 #1
0
        public static void Search(string title, Action <string, string> VideoSourceFound)
        {
            var c = new BasicGoogleVideoCrawler();

            c.VideoSourceFound += VideoSourceFound;

            c.Search(title);
        }
コード例 #2
0
        public static void Search(string title, Action<string, string> VideoSourceFound)
        {
            var c = new BasicGoogleVideoCrawler();

            c.VideoSourceFound += VideoSourceFound;

            c.Search(title);
        }
コード例 #3
0
        private static void ShowGoogleVideo()
        {
            var c = new BasicGoogleVideoCrawler();

            c.VideoSourceFound +=
                (video, src) =>
                {
                    Console.WriteLine(src.ToLink(src));

                };

            c.Search("terminator+trailer");
        }
コード例 #4
0
        private static void ShowPirateBayWithVideo()
        {
            Console.WriteLine("<style>");
            Console.WriteLine("img { border: 0; }");
            //Console.WriteLine("ol { -moz-column-count: 2; }");
            Console.WriteLine(@"
            embed {
            width: 100%;
            height: 100%;
            position: absolute;
            left: 0;
            top: 0;
            z-index: 0;
            }

            ol
            {
            display: block;
            width: 100%;
            height: 100%;
            position: absolute;
            left: 0;
            top: 0;
            z-index: 1;

            overflow: scroll;
            }

            li
            {
            }

            body{
            text-align: center;
            font-family:Verdana, Arial, Helvetica, sans-serif;
            font-size:.7em;
            margin: 10px;
            color: #fff;
            background: #000;
            min-width: 520px;
            overflow: hidden;
            }

            a{
            color: #009;
            text-decoration: none;
            border-bottom: 1px dotted #4040D9;
            }
            a:hover{
            text-decoration: none;
            border-bottom: 1px solid #009;
            }
            li {

            text-align: left;
            margin: 1em;}

            ");
            Console.WriteLine("</style>");

            var DefaultLink = new { Link = "", Title = "", Text = "" };
            var DefaultImage = new { Source = "", Alt = "", Title = "" };

            var ParseLink = DefaultLink.ToAnonymousConstructor(
                (string element) =>
                {
                    var Link = "";
                    var Title = "";
                    var Text = "";

                    element.
                        ParseAttribute("href", value => Link = value).
                        ParseAttribute("title", value => Title = value).
                        ParseContent(value => Text = value).
                        Parse();

                    return new { Link, Title, Text };
                }
            );

            var ParseImage = DefaultImage.ToAnonymousConstructor(
                (string element) =>
                {
                    var Source = "";
                    var Alt = "";
                    var Title = "";

                    element.
                        ParseAttribute("src", value => Source = value).
                        ParseAttribute("alt", value => Alt = value).
                        ParseAttribute("title", value => Title = value).
                        ParseContent(null).
                        Parse();

                    return new { Source, Alt, Title };
                }
            );

            Action<string, BasicIMDBAliasSearch.Entry> SearchPoster =
                 (Title, e) =>
                 {
                     //Console.WriteLine(e.Link);
                     Native.API.set_time_limit(20);

                     var Link = new Uri(e.Link);
                     var Segments = Link.Segments;
                     var Key = Segments[2];

                     Key = Key.Substring(0, Key.Length - 1);

                     //Console.WriteLine(Key);

                     BasicIMDBCrawler.Search(Key,
                         k =>
                         {
                             IHTMLImage Image = k.MediumPosterImageCoralCache.OriginalString;

                             new IHTMLAnchor
                             {
                                 Title = k.SmartTitle,
                                 URL = Link.ToCoralCache().WithoutQuery().OriginalString,
                                 innerHTML = Image.ToString()
                             }.ToString().ToConsole();

                             Native.API.set_time_limit(20);

                             BasicIMDBPosterSearch.Search(
                                     k.MediumPosterImagePage,
                                     LargePosterImage =>
                                     {

                                         var ur = new Uri(LargePosterImage);

                                         IHTMLImage LargeImage = ur.ToCoralCache().OriginalString;

                                         new IHTMLAnchor
                                         {
                                             Title = k.SmartTitle,
                                             URL = Link.ToCoralCache().WithoutQuery().OriginalString,
                                             innerHTML = LargeImage.ToString()
                                         }.ToString().ToConsole();
                                     }
                                 );
                         }
                     );

                 };

            var search = new BasicPirateBaySearch();

            search.Loaded +=
                ForEachEntry =>
                {

                    //Console.WriteLine("<hr />");

                    //var logo = "http://static.thepiratebay.org/img/tpblogo_sm_ny.gif";

                    //Console.WriteLine(logo.ToImage().ToLink("http://tineye.com/search?url=" + logo));

                    // http://code.google.com/apis/youtube/chromeless_example_1.html
                    Console.WriteLine("<embed wmode='transparent' id='tv' src='http://www.youtube.com/apiplayer?enablejsapi=1&playerapiid=tv' allowScriptAccess='always' width='400' height='300' />");

                    //Console.WriteLine("<h2>Top Movies</h2>");

                    Console.WriteLine("<ol>");

                    ForEachEntry(
                        (entry, entryindex) =>
                        {
                            Native.API.set_time_limit(20);
                            //if (entryindex > 2)
                            //    return;

                            var Type = ParseLink(entry.Type);
                            var Name = ParseLink(entry.Name);

                            var SmartName = new BasicFileNameParser(Name.Text);

                            var MovieInfo = default(BasicIMDBAliasSearch.Entry);

                            BasicIMDBAliasSearch.Search(SmartName.Title,
                                (e, index) =>
                                {
                                    if (MovieInfo == null)
                                        MovieInfo = e;

                                }
                            );

                            var c = new BasicGoogleVideoCrawler();

                            var Video = "";
                            var VideoSource = "";

                            c.VideoSourceFound +=
                                (video, src) =>
                                {
                                    Video = video;
                                    VideoSource = src;

                                };

                            Native.API.set_time_limit(16);

                            //Thread.Sleep(1500);

                            c.Search(SmartName.Title + " trailer");

                            Console.WriteLine("<li>");

                            new IHTMLButton
                            {
                                //onclick = "if (getElementById(\"tv\").getPlayerState() != 1) getElementById(\"tv\").loadVideoById(\"" + Video + "\")",
                                onclick = "getElementById(\"tv\").loadVideoById(\"" + Video + "\")",
                                innerHTML = "View Trailer"
                            }.ToString().ToConsole();

                            Console.WriteLine("<span style='background: white; color: black;'>");

                            if (MovieInfo != null)
                            {
                                SearchPoster(SmartName.Title, MovieInfo);

                                //if (MovieInfo.Image != null)
                                //    Console.WriteLine(MovieInfo.Image.ToImage().ToLink(MovieInfo.Link));

                                Console.WriteLine("<b>" + SmartName.Title.ToLink(MovieInfo.Link) + "</b>");
                            }
                            else
                            {
                                Console.WriteLine("<b>" + SmartName.Title.ToLink(k => "http://www.imdb.com/find?s=tt;site=aka;q=" + k) + "</b>");
                            }

                            if (!string.IsNullOrEmpty(SmartName.Season))
                            {
                                Console.WriteLine(" | Season <i>" + SmartName.Season + "</i>");
                            }

                            if (!string.IsNullOrEmpty(SmartName.Episode))
                            {
                                Console.WriteLine(" | Episode <i>" + SmartName.Episode + "</i>");
                            }

                            if (!string.IsNullOrEmpty(SmartName.SubTitle))
                            {
                                Console.WriteLine(" | <b>" + SmartName.SubTitle + "</b>");
                            }

                            if (!string.IsNullOrEmpty(SmartName.Year))
                            {
                                Console.WriteLine(" | <i>" + SmartName.Year + "</i>");
                            }

                            Console.WriteLine(" | ");
                            Console.WriteLine("<b>");
                            Console.WriteLine("trailer".ToLink(VideoSource, Video));
                            Console.WriteLine("</b>");

                            Console.WriteLine("<br />");

                            Console.WriteLine("<small>");
                            Console.WriteLine(SmartName.ColoredText.ToString().ToLink("http://thepiratebay.org" + Name.Link) + "<br />");

                            Console.WriteLine(Type.Text.ToLink("http://thepiratebay.org" + Type.Link));

                            entry.Links.ParseElements(
                                (tag, index, element) =>
                                {
                                    if (tag == "a")
                                    {
                                        var a = ParseLink(element);

                                        Console.WriteLine(" | " + "torrent".ToLink(a.Link));
                                    }

                                    if (tag == "img")
                                    {
                                        var img = ParseImage(element);

                                        if (img.Title.Contains("comment"))
                                        {
                                            Console.WriteLine(" | " + img.Title.ToLink("http://thepiratebay.org" + Name.Link));
                                        }
                                        else
                                        {
                                            Console.WriteLine(" | " + img.Title);
                                        }
                                    }
                                }
                            );

                            Console.WriteLine(" | " + entry.Size);
                            Console.WriteLine(" | " + entry.Seeders);
                            Console.WriteLine(" | " + entry.Leechers + "<br />");

                            Console.WriteLine("</small>");

                            Console.WriteLine("</span>");

                            //Console.WriteLine("</div>");
                            Console.WriteLine("</li>");

                        }
                    );

                    Console.WriteLine("</ol>");
                };

            search.Crawler.Crawl("/top/200");
        }