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");
        }
        public Task4_PrepareMedia(MyNamedTasks Tasks)
            : base(Tasks, "Task4_PrepareMedia")
        {
            var NamedTasks = Tasks;
            this.Description = @"
            We now should have the torrent, name, seeders, leechers. We must now get the poster, trailer, rating, tagline and hash.
            Uses memory to store tineye poster hash.
            ";

            this.YieldWork =
                (Task, Input) =>
                {

                    var c = Input.ToFieldBuilder();

                    FileMappedField
                        TorrentName = c,
                        TorrentLink = c,
                        TorrentSize = c,
                        TorrentComments = c,
                        IMDBKey = c,
                        IMDBTitle = c,
                        IMDBYear = c,
                        IMDBRaiting = c,
                        IMDBRuntime = c,
                        IMDBGenre = c,
                        IMDBTagline = c,
                        OMDBSearched = c,
                        MPDBSearched = c,
                        PosterLink = c,
                        TinEyeHash = c,
                        BayImageLink = c,
                        BayImageTinyLink = c,
                        //BayImageTinySourceLink = c,
                        YouTubeKey = c,
                        TorrentLinkTinyLink = c,
                        TaskComplete = c;

                    c.FromFile();

                    Input.Delete();

                    //AppendLog("in " + TorrentName.Value);

                    #region IMDBKey
                    c[IMDBKey] = delegate
                    {
                        var TorrentSmartName = new BasicFileNameParser(TorrentName.Value);

                        AppendLog("looking for imdb key");

                        BasicIMDBAliasSearch.SearchSingle(TorrentSmartName.Title, TorrentSmartName.Year,
                            imdb =>
                            {
                                AppendLog("imdb key found");
                                IMDBKey.Value = imdb.Key;
                            }
                        );
                    };
                    #endregion

                    #region IMDBTitle
                    c[IMDBTitle] = delegate
                    {
                        AppendLog("looking for imdb for details");

                        BasicIMDBCrawler.Search(IMDBKey.Value,
                            imdb =>
                            {
                                AppendLog("imdb details found");

                                IMDBTitle.Value = imdb.Title;
                                IMDBYear.Value = imdb.Year;
                                IMDBRaiting.Value = imdb.UserRating;
                                IMDBRuntime.Value = imdb.Runtime;
                                IMDBTagline.Value = imdb.Tagline;
                                IMDBGenre.Value = string.Join("|", imdb.Genres);

                                PosterLink.Value = imdb.MediumPosterImage;
                            }
                        );
                    };
                    #endregion

                    #region PosterLink
                    c[PosterLink] = delegate
                    {
                        AppendLog("looking for posters...");

                        c[OMDBSearched] = delegate
                        {
                            AppendLog("looking for posters... omdb");
                            OMDBSearched.Value = "true";

                            BasicOMDBCrawler.SearchSingle(IMDBTitle.Value, IMDBYear.Value,
                                omdb =>
                                {
                                    omdb.GetPoster(
                                        poster =>
                                        {
                                            AppendLog("looking for posters... omdb... found!");
                                            PosterLink.Value = poster;
                                        }
                                    );
                                }
                            );
                        };

                        c[MPDBSearched] = delegate
                        {
                            AppendLog("looking for posters... mpdb");

                            BasicMPDBCrawler.SearchSingle(IMDBTitle.Value, IMDBYear.Value,
                                mpdb =>
                                {
                                    mpdb.GetPoster(
                                        poster =>
                                        {
                                            AppendLog("looking for posters... mpdb... found!");
                                            PosterLink.Value = poster;
                                        }
                                    );
                                }
                            );
                        };
                    };
                    #endregion

                    #region TinEyeHash
                    c[TinEyeHash] = delegate
                    {
                        AppendLog("looking for tineye hash...");
                        BasicTinEyeSearch.Search(PosterLink.Value,
                            tineye =>
                            {
                                AppendLog("looking for tineye hash... found");
                                TinEyeHash.Value = tineye.Hash;

                                var Memory = this.Memory[TinEyeHash.Value].FirstDirectoryOrDefault();

                                if (Memory != null)
                                {
                                    BayImageLink.Value = "_";
                                    //BayImageTinyLink.Value = "_";
                                    BayImageTinyLink.Value = "http://tinyurl.com/" + Memory.Name;
                                }
                            }
                        );
                    };
                    #endregion

                    #region BayImageLink
                    c[BayImageLink] = delegate
                    {
                        AppendLog("updating bay image...");

                        var tineye = new BasicTinEyeSearch.Entry { Hash = TinEyeHash.Value };

                        BasicPirateBayImage.Clone(tineye.QueryLink.ToUri(),
                            bayimg =>
                            {
                                AppendLog("updating bay image... done");
                                BayImageLink.Value = bayimg.Image.ToString();
                            }
                        );

                    };
                    #endregion

                    #region BayImageTinyLink
                    c[BayImageTinyLink] = delegate
                    {
                        AppendLog("looking for tinyurl...");
                        BasicTinyURLCrawler.Search(BayImageLink.Value,
                            tinyurl =>
                            {
                                AppendLog("looking for tinyurl... found");
                                BayImageTinyLink.Value = tinyurl.Alias;
                            }
                        );
                    };
                    #endregion

                    //#region BayImageTinySourceLink
                    //c[BayImageTinySourceLink] = delegate
                    //{
                    //    BasicTinyURLCrawler.Search("http://i.tinysrc.mobi/" + BayImageTinyLink.Value,
                    //        tinyurl =>
                    //        {
                    //            BayImageTinySourceLink.Value = tinyurl.Alias;

                    //            this.Memory[TinEyeHash.Value].CreateSubdirectory(tinyurl.AliasKey);
                    //        }
                    //    );
                    //};
                    //#endregion

                    #region YouTubeKey
                    c[YouTubeKey] = delegate
                    {
                        var Query = IMDBTitle.Value;
                        var TorrentSmartName = new BasicFileNameParser(TorrentName.Value);

                        var SeasonAndEpisode = TorrentSmartName.SeasonAndEpisode;

                        if (!string.IsNullOrEmpty(SeasonAndEpisode))
                            Query += " " + SeasonAndEpisode;
                        else
                            Query += " trailer";

                        BasicGoogleVideoCrawler.Search(Query,
                            (key, src) =>
                            {
                                YouTubeKey.Value = key;
                            }
                        );
                    };
                    #endregion

                    #region TorrentLinkTinyLink
                    c[TorrentLinkTinyLink] = delegate
                    {
                        BasicTinyURLCrawler.Search(TorrentLink.Value,
                            torrent =>
                            {
                                TorrentLinkTinyLink.Value = torrent.Alias;
                            }
                        );
                    };
                    #endregion

                    c[TaskComplete] = delegate
                    {
                        var TorrentSmartName = new BasicFileNameParser(TorrentName.Value);

                        var YouTubeLink = "http://www.youtube.com/v/" + YouTubeKey + @"&hl=en&fs=1";
                        var YouTubeImage = "http://img.youtube.com/vi/" + YouTubeKey + @"/0.jpg";

                        var SmartTitle = "";

                        if (!string.IsNullOrEmpty(TorrentSmartName.SeasonAndEpisode))
                            SmartTitle = "TV show: " + IMDBTitle.Value + " " + TorrentSmartName.SeasonAndEpisode + " " + IMDBYear.Value;
                        else
                            SmartTitle = "Movie: " + IMDBTitle.Value + " " + IMDBYear.Value;

                        var NextWork = NamedTasks.Task6_MediaCollector.AddWork(5, Input.Name);

                        using (var w = new StreamWriter(NextWork.OpenWrite()))
                        {
                            w.WriteLine("<item>");
                            w.WriteLine("<title>" + SmartTitle + "</title>");
                            w.WriteLine("<link>" + TorrentLinkTinyLink.Value + "</link>");

                            #region description
                            w.WriteLine("<description><![CDATA[");

                            w.WriteLine(@"
            <object width='640' height='385'>
            <param name='movie' " + YouTubeLink.ToAttributeString("value") + @"></param>
            <param name='allowFullScreen' value='true'></param>
            <param name='allowscriptaccess' value='always'></param>
            <embed " + YouTubeLink.ToAttributeString("src") + @" type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='640' height='385'></embed>
            </object>
                            ");

                            w.WriteLine(
                                new IHTMLAnchor
                                {
                                    Style = new IStyle { @float = "left" },
                                    URL = YouTubeLink,
                                    innerHTML = new IHTMLImage
                                    {
                                        alt = YouTubeKey.Value,
                                        align = "left",
                                        src = YouTubeImage
                                    }
                                }.ToString()
                            );

                            w.WriteLine(
                                new IHTMLAnchor
                                {
                                    URL = BasicIMDBCrawler.ToLink(IMDBKey.Value),
                                    Title = SmartTitle,
                                    innerHTML = new IHTMLImage
                                    {
                                        align = "right",
                                        src = BayImageTinyLink.Value,
                                    }
                                }.ToString()
                            );

                            w.WriteLine(
                                "<h2>" + SmartTitle.ToLink("http://piratebay.org" + TorrentComments.Value) + "</h2>"
                            );

                            w.WriteLine(
                                new IHTMLElement { innerHTML = IMDBRaiting.Value, title = "raiting" }.ToString()
                            );

                            w.WriteLine(
                                new IHTMLElement { innerHTML = (IMDBRuntime.Value + ", " + TorrentSize.Value.Replace("&nbsp;", " ")), title = "runtime" }.ToString()
                            );

                            w.WriteLine(
                                new IHTMLElement { innerHTML = IMDBTagline.Value, title = "tagline" }.ToString()
                            );

                            w.WriteLine(
                                new IHTMLElement { innerHTML = IMDBGenre.Value.Replace("|", ", "), title = "genres" }.ToString()
                            );

                            w.WriteLine(
                                new IHTMLElement { innerHTML = TorrentSmartName.SeasonAndEpisode, title = "episode" }.ToString()
                            );

                            w.WriteLine(
                                new IHTMLAnchor
                                {
                                    URL = TorrentLinkTinyLink.Value,
                                    Title = SmartTitle,
                                    innerHTML = new IHTMLImage
                                    {
                                        src = "http://static.thepiratebay.org/img/dl.gif"
                                    }.ToString() + " " + TorrentName.Value
                                }.ToString()
                            );

                            w.WriteLine(" ]]></description>");
                            #endregion

                            #region category
                            if (string.IsNullOrEmpty(TorrentSmartName.SeasonAndEpisode))
                                w.WriteLine("<category>Movies</category>");
                            else
                                w.WriteLine("<category>TV shows</category>");

                            var Genres = IMDBGenre.Value.Split(new[] { '|' });

                            foreach (var g in Genres)
                            {
                                w.WriteLine("<category>" + g + "</category>");
                            }
                            #endregion

                            w.WriteLine("<media:thumbnail url='" + BayImageTinyLink.Value + "' />");
                            w.WriteLine("<media:content " + YouTubeLink.ToAttributeString("url") + @" type='application/x-shockwave-flash' />");
                            w.WriteLine("<media:description type='plain'>" + SmartTitle + " | " + IMDBRaiting.Value + " | " + IMDBTagline.Value + " | " + IMDBGenre.Value + "</media:description>");

                            w.WriteLine("</item>");
                        }
                    };

                    return c.ToFileWhenDirty;
                };
        }
Пример #3
0
        public static void Invoke(Document doc)
        {
            var query = from k in doc.responseData.feed.entries
                        let t = new TitleParser(k.title)
                        select new { k, t };

            var ruleset = new StringBuilder();

            ruleset.AppendLine(@"
            set(hyper_res).
            set(factor).
            set(print_kept).
            formula_list(sos).
            ");

            #region VariableEqualsToAny
            ParamsFunc<string, string, string> VariableEqualsToAny =
                (variable, values) =>
                {
                    var w = new StringBuilder();

                    w.Append("(");
                    values.ForEach(
                        (k, i) =>
                        {
                            if (i > 0)
                                w.AppendLine(" | ");
                            w.AppendLine("$EQ(" + variable + ", " + k.GetHashCode() + @") %" + k);

                        }
                    );

                    w.Append(")");

                    return w.ToString();
                };

            ParamsFunc<string, int, string> VariableEqualsToAnyInteger =
                (variable, values) =>
                {
                    var w = new StringBuilder();

                    w.Append("(");
                    values.ForEach(
                        (k, i) =>
                        {
                            if (i > 0)
                                w.AppendLine(" | ");
                            w.AppendLine("$EQ(" + variable + ", " + k + @")");

                        }
                    );

                    w.Append(")");

                    return w.ToString();
                };
            #endregion

            #region Question 1
            ruleset.AppendLine(@"
            % Question 1
            all x all z all u (
            facts(x,category,u) & " + VariableEqualsToAny("u", "Animation") + @" -> ForChildren(x)
            ).
            ");

            ruleset.AppendLine(@"
            all x all z all u (
            facts(x,category,u) & " + VariableEqualsToAny("u", "Animation", "Comedy", "Family", "Fantasy") + @" -> ForFamily(x)
            ).
            ");

            ruleset.AppendLine(@"
            all x all z all u (
            facts(x,category,u) & " + VariableEqualsToAny("u", "Adventure", "Drama", "Fantasy", "Mystery", "Thriller", "Action", "Crime") + @" -> ForAdults(x)
            ).
            ");
            #endregion

            #region Question 2

            ruleset.AppendLine(@"
            % Question 2
            all x all z all u (
            facts(x,year,u) & " + VariableEqualsToAnyInteger("u", DateTime.Now.Year, DateTime.Now.Year + 1) + @" -> ForGeeks(x)
            ).
            ");

            ruleset.AppendLine(@"
            all x all z all u (
            facts(x,year,u) & " + VariableEqualsToAnyInteger("u", DateTime.Now.Year, DateTime.Now.Year + 1, DateTime.Now.Year - 1, DateTime.Now.Year - 2) + @" -> ForRecent(x)
            ).
            ");

            #endregion

            #region Question 3
            ruleset.AppendLine(@"
            % Question 3
            all x all z all u (
            facts(x,raiting,u) & $GT(u, 65)
            -> GoodRaiting(x)
            ).

            all x all z all u (
            facts(x,raiting,u) & $LT(u, 70)
            -> BadRaiting(x)
            ).
            ");
            #endregion

            #region Question 4

            ruleset.AppendLine(@"
            % Question 4
            all x all z all u (
            facts(x,category,u) & " + VariableEqualsToAny("u", "TV shows") + @" -> IsTVShow(x)
            ).

            all x all z all u (
            facts(x,category,u) & " + VariableEqualsToAny("u", "Movies") + @" -> IsMovie(x)
            ).
            ");
            #endregion

            #region facts
            foreach (var entry in query)
            {

                entry.k.content.ParseMovieItem(
                    m =>
                    {
                        ruleset.AppendLine("facts('" + entry.t.Title.Replace("'", @"-") + "', raiting, " + Convert.ToInt32(m.Raiting * 100) + ").");
                    }
                );

                var p = new BasicFileNameParser(entry.t.Title);

                ruleset.AppendLine("facts('" + entry.t.Title.Replace("'", @"-") + "', year, " + entry.t.Year + ").");

                //if (p.Season != null)
                //    ruleset.AppendLine("facts('" + entry.t.Title.Replace("'", @"-") + "', season, " + int.Parse(p.Season) + ").");
                //if (p.Episode != null)
                //    ruleset.AppendLine("facts('" + entry.t.Title.Replace("'", @"-") + "', episode, " + int.Parse(p.Episode) + ").");

                foreach (var category in entry.k.categories)
                {
                    ruleset.AppendLine("facts('" + entry.t.Title.Replace("'", @"-") + "', category, " + category.GetHashCode() + "). %" + category);

                }
            }
            #endregion

            var Filters = new List<string>();

            Func<string, Action> f =
                filter => () => Filters.Add(filter);

            ConsoleQuestions.Ask(
                new Options
                {
                    { "There are some kids over here", f("ForChildren(x)")},
                    { "My family is in the room, keep it decent", f("ForFamily(x)")},
                    { "There are only some dudes in the room", f("ForAdults(x)")},
                    { "Neither", () => {}},
                },
                new Options
                {
                    { "I am looking for new stuff", f("ForGeeks(x)")},
                    { "I haven't watched that much tv recently!", f("ForRecent(x)")},
                    { "I do not like recent movies at all!", f("-ForRecent(x)")},
                    { "Neither", () => {}},
                },
                new Options
                {
                    { "I am looking for having a good time", f("GoodRaiting(x)")},
                    { "I want to suggest someething really bad to a friend", f("BadRaiting(x)")},
                    { "I cannot decide between options above", () => {}},
                },
                new Options
                {
                    { "I cannot watch tv very long", f("IsTVShow(x)")},
                    { "30 minutes is not enough for me",  f("IsMovie(x)")},
                    { "I cannot decide between options above", () => {}},
                }
            );

            #region IsSelected
            ruleset.AppendLine(@"
            % The anwser
            all x  (
            "
            );

            Filters.ForEach(
                (k, i) =>
                {
                    if (i > 0)
                        ruleset.AppendLine(" & ");

                    ruleset.AppendLine(k);
                }
            );

            ruleset.AppendLine(@"
            -> IsSelected(x)
            )."
            );
            #endregion

            var otter = new OtterApplication(ruleset.ToString());

            Console.WriteLine();
            Console.WriteLine("Movies for you");
            otter.ToConsole(k => k == "IsSelected");

            File.WriteAllText(@"Data\IDX5711.in", ruleset.ToString());
            File.WriteAllText(@"Data\IDX5711.out", otter.Output);
        }