Exemplo n.º 1
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);
        }
        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);
            };
        }
Exemplo n.º 3
0
        // http://diveintomark.org/archives/2004/02/04/incompatible-rss
        // http://base.google.com/support/bin/answer.py?hl=en&answer=58085

        // C:\util\Otter33-Win32>

        // more examples:
        // http://www.comp.leeds.ac.uk/krr/handouts/otter_exercise.pdf
        // http://mally.stanford.edu/Papers/computation.pdf

        // http://www.cs.unm.edu/~mccune/otter/otter-examples/auto/index.html
        // http://www.cs.unm.edu/~mccune/otter/download.html
        // http://www.cs.unm.edu/~mccune/prover9/download/
        // http://www.cs.unm.edu/~mccune/prover9/download/LADR1007B-win.zip

        // http://download.dojotoolkit.org/release-1.0.2/dojo-release-1.0.2/dojox/gfx/demos/beautify.html
        // http://lambda.ee/index.php/Details_of_the_second_lab:_rule_system
        //Concretely, you will have:
        //    * Look at your rdfa pages and invent/create sensible small rule files in the
        //		Otter syntax for deriving new data from physically present rdfa data.
        //          o It may happen that the rdfa pages from the first lab do not
        //				contain really suitable/interesting data for this. In that
        //				case, create new pages.
        //          o The rdfa pages should indicate (by having a corresponding link
        //				in the rdfa data) which rule set should be used. You should
        //				have at least two different rdfa pages and two different
        //				rulesets, one for each page.
        //					-> Movies
        //					-> TV Shows
        //          o The rule file should be such that no contradiction arises and
        //				the set of derived facts is still maintainable (not millions
        //				of new facts).
        //    * Write a program which takes your first lab output, finds an indicated
        //		rule file and builds a new Otter syntax file containing both rules
        //		and the data obtained from the rdfa page.
        //    * Then let the same program call Otter with the newly built file and send
        //		the result to a result file.
        //    * Write a program which takes the output file, parses out the derived
        //		facts (fact has just one atom and no variables) and adds these to
        //		the original rdfa-parsed dataset.
        //    * Finally print out the extended dataset: the original facts and newly
        //		derived facts from this dataset.
        //    * Create an addition to the program which answers the posed
        //		query: true/false or finds a concrete necessary value (or values).
        //		Use otter atom like person(X) or forall person(X) or
        //		similar (choose a suitable one yourself) as a query input.
        //You may write just one program for all these tasks or several different. In the latter case you will also have to write a "master" program (as a shell script or bat file, for example) calling these subprograms.
        //The final resulting program should take a page url or file name as a single input and produce a list of all found and derived facts as output.

        static void Main(string[] args)
        {
            var limit = 250;

            Console.WriteLine("loading latest movies...");

            Document doc =
                // offline
                new FileInfo(@"Data\test.txt");

            // online
            //new Uri("http://www.google.com/uds/Gfeeds?scoring=h&context=0&num=250&hl=en&output=json&v=1.0&nocache=0&q=http://feeds2.feedburner.com/zmovies");


            Console.WriteLine(doc.responseData.feed.entries.Length + " feed items found!");
            Console.WriteLine();

            IDX5711.DecisionEngine.Invoke(doc);


            var query = from k in doc.responseData.feed.entries
                        let t = new TitleParser(k.title)
                                select new { k, t };


            var rulesets = new
            {
                TV_show = new StringBuilder(),
                Movie   = new StringBuilder(),
            };

            Func <string, StringBuilder> rulesets_AppendLine = null;

            rulesets_AppendLine += rulesets.Movie.AppendLine;
            rulesets_AppendLine += rulesets.TV_show.AppendLine;

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



            #region ruleset: TV show

            rulesets.TV_show.AppendLine(@"
%sensible small rule files
	all x all z all u (
		facts(x,season,u) & $EQ(u, 1)
		->
		pilot(x) 
	).

	all x all z all u (
		facts(x,episode,u) & $GT(u, 20)
		->
		probablyendofseason(x) 
	).

");

            foreach (var entry in query.Where(k => k.t.Type == "TV show").Take(limit))
            {
                var p = new BasicFileNameParser(entry.t.Title);

                rulesets.TV_show.AppendLine("facts('" + entry.t.Title.Replace("'", @"-") + "', year, " + entry.t.Year + ").");
                rulesets.TV_show.AppendLine("facts('" + entry.t.Title.Replace("'", @"-") + "', season, " + int.Parse(p.Season) + ").");
                rulesets.TV_show.AppendLine("facts('" + entry.t.Title.Replace("'", @"-") + "', episode, " + int.Parse(p.Episode) + ").");


                Console.ForegroundColor = ConsoleColor.Red;
                Console.Write("# " + entry.t.Title);

                Console.ForegroundColor = ConsoleColor.Green;
                Console.Write("; " + entry.t.Year);

                Console.ForegroundColor = ConsoleColor.Cyan;
                foreach (var category in entry.k.categories)
                {
                    rulesets.TV_show.AppendLine("facts('" + entry.t.Title.Replace("'", @"-") + "', category, " + category.GetHashCode() + "). %" + category);

                    Console.Write("; " + category);
                }
                Console.WriteLine();
            }
            #endregion



            var o_TV_show = new OtterApplication(rulesets.TV_show.ToString());

            o_TV_show.ToConsole();

            File.WriteAllText(@"Data\TV_show.in", rulesets.TV_show.ToString());
            File.WriteAllText(@"Data\TV_show.out", o_TV_show.Output);


            Console.WriteLine();

            #region ruleset: Movie


            rulesets.Movie.AppendLine(@"

%sensible small rule files
all x all z all u (
    facts(x,year,u) & $LT(u, 2009)
    ->
    oldmedia(x)
).

all x all z all u (
	oldmedia(x) &
    facts(x,category,u) & $EQ(u, " + "Comedy".GetHashCode() + @")
    ->
    oldcomedy(x)
).
			"
                                      );

            foreach (var entry in query.Where(k => k.t.Type == "Movie").Take(limit))
            {
                rulesets.Movie.AppendLine("facts('" + entry.t.Title.Replace("'", @"-") + "', year, " + entry.t.Year + ").");

                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.Write("# " + entry.t.Title);

                Console.ForegroundColor = ConsoleColor.Green;
                Console.Write("; " + entry.t.Year);

                Console.ForegroundColor = ConsoleColor.Cyan;
                foreach (var category in entry.k.categories)
                {
                    rulesets.Movie.AppendLine("facts('" + entry.t.Title.Replace("'", @"-") + "', category, " + category.GetHashCode() + "). %" + category);

                    Console.Write("; " + category);
                }
                Console.WriteLine();
            }
            #endregion

            Console.WriteLine();



            var o_Movie = new OtterApplication(rulesets.Movie.ToString());

            o_Movie.ToConsole();

            File.WriteAllText(@"Data\Movie.in", rulesets.Movie.ToString());
            File.WriteAllText(@"Data\Movie.out", o_Movie.Output);

            using (var w = new StreamWriter(new FileInfo(@"Data\extended.xml").OpenWrite()))
            {
                w.WriteLine(@"<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<rss version='2.0' xmlns:media='http://search.yahoo.com/mrss' xmlns:atom='http://www.w3.org/2005/Atom'>
  <channel>
    <title>zmovies</title>
    <description>zmovies can haz entertainment</description>
    <link>http://zproxy.planet.ee/zmovies</link>");

                #region TV show
                foreach (var k in query.Where(k => k.t.Type == "TV show").Take(limit))
                {
                    w.WriteLine("<item>");
                    w.WriteLine("<title>" + k.k.title + "</title>");
                    w.WriteLine("<link>" + k.k.link + "</link>");

                    w.WriteLine("<description><![CDATA[");
                    w.WriteLine(k.k.content);

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


                    foreach (var g in k.k.categories)
                    {
                        w.WriteLine("<category>" + g + "</category>");
                    }

                    foreach (var f in o_TV_show.KeptFactsDictionary.Where(kk => kk.Value == k.t.Title.Replace("'", @"-")))
                    {
                        w.WriteLine("<category>" + f.Name + "</category>");
                    }

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

                #region Movie
                foreach (var k in query.Where(k => k.t.Type == "Movie").Take(limit))
                {
                    w.WriteLine("<item>");
                    w.WriteLine("<title>" + k.k.title + "</title>");
                    w.WriteLine("<link>" + k.k.link + "</link>");

                    w.WriteLine("<description><![CDATA[");
                    w.WriteLine(k.k.content);

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


                    foreach (var g in k.k.categories)
                    {
                        w.WriteLine("<category>" + g + "</category>");
                    }

                    foreach (var f in o_Movie.KeptFactsDictionary.Where(kk => kk.Value == k.t.Title.Replace("'", @"-")))
                    {
                        w.WriteLine("<category>" + f.Name + "</category>");
                    }

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

                w.WriteLine(@"
	  </channel>
</rss>");
            }
        }