Advertisement
Guest User

CSFD plugin

a guest
Feb 16th, 2011
489
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 22.52 KB | None
  1. # Replace SiteTemplate with your plugin name.
  2. # The package name must exactly match the file name (.pm)
  3. package GCPlugins::GCfilms::GCCsfd;
  4.  
  5. ###################################################
  6. #
  7. #  Copyright 2005-2009 Tian
  8. #  Copyright 2007,2011 Petr Gajdůšek <gajdusek.petr@centrum.cz>
  9. #
  10. #  This file is part of GCstar.
  11. #
  12. #  GCstar is free software; you can redistribute it and/or modify
  13. #  it under the terms of the GNU General Public License as published by
  14. #  the Free Software Foundation; either version 2 of the License, or
  15. #  (at your option) any later version.
  16. #
  17. #  GCstar is distributed in the hope that it will be useful,
  18. #  but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. #  GNU General Public License for more details.
  21. #
  22. #  You should have received a copy of the GNU General Public License
  23. #  along with GCstar; if not, write to the Free Software
  24. #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  25. #
  26. ###################################################
  27.  
  28. use strict;
  29. #use warnings;
  30. use utf8;
  31.  
  32. use GCPlugins::GCfilms::GCfilmsCommon;
  33.  
  34. {
  35.  
  36.     # Replace SiteTemplate with your exporter name
  37.     # It must be the same name as the one used for file and main package name
  38.     package GCPlugins::GCfilms::GCPluginCsfd;
  39.  
  40.     use base qw(GCPlugins::GCfilms::GCfilmsPluginsBase);
  41.  
  42.     # getSearchCharset
  43.     # Charset of search term
  44.     sub getSearchCharset
  45.     {
  46.         return 'UTF-8';
  47.     }
  48.  
  49.     # getSearchUrl
  50.     # Used to get the URL that to be used to perform searches.
  51.     # $word is the query
  52.     # Returns the full URL.
  53.     sub getSearchUrl
  54.     {
  55.         # needed for search query recoding (from ISO-8859-1 to UTF8)
  56.         use URI::Escape;
  57.         use Encode;
  58.  
  59.         my ($self, $word) = @_;
  60.         my $url;
  61.  
  62.         # Your code here
  63.         $url = return "http://www.csfd.cz/hledat/?q=$word";
  64.  
  65.         return $url;
  66.     }
  67.  
  68.     # getItemUrl
  69.     # Used to get the full URL of a movie page.
  70.     # Useful when url on results pages are relative.
  71.     # $url is the URL as found with a search.
  72.     # Returns the absolute URL.
  73.     sub getItemUrl
  74.     {
  75.         my ($self, $url) = @_;
  76.  
  77.         $url = "http://www.csfd.cz" . $url if ($url !~ /^http:/);
  78.         return $url;
  79.     }
  80.  
  81.     # getCharset
  82.     # Used to convert charset in web pages.
  83.     # Returns the charset as specified in pages.
  84.     #sub getCharset {
  85.     #   my $self = shift;
  86.     #
  87.     #   return "UTF-8";
  88.     #}
  89.  
  90.     # getName
  91.     # Used to display plugin name in GUI.
  92.     # Returns the plugin name.
  93.     sub getName
  94.     {
  95.         return "CSFD.cz";
  96.     }
  97.  
  98.     # getAuthor
  99.     # Used to display the plugin author in GUI.
  100.     # Returns the plugin author name.
  101.     sub getAuthor
  102.     {
  103.         return 'Petr Gajdůšek';
  104.     }
  105.  
  106.     # getLang
  107.     # Used to fill in plugin list with user language plugins
  108.     # Return the language used for this site (2 letters code).
  109.     sub getLang
  110.     {
  111.         return 'CS';
  112.     }
  113.  
  114.     # hasSearchYear
  115.     # Used to hide year column in search results
  116.     # Return 0 to hide column, 1 to show it.
  117.     sub hasSearchYear
  118.     {
  119.         return 1;
  120.     }
  121.  
  122.     # hasSearchDirector
  123.     # Used to hide director column in search results
  124.     # Return 0 to hide column, 1 to show it.
  125.     sub hasSearchDirector
  126.     {
  127.         return 1;
  128.     }
  129.  
  130.     # hasSearchActors
  131.     # Used to hide actors column in search results
  132.     # Return 0 to hide column, 1 to show it.
  133.     sub hasSearchActors
  134.     {
  135.         return 1;
  136.     }
  137.  
  138.     # getExtra
  139.     # Used if the plugin wants an extra column to be displayed in search results
  140.     # Return the column title or empty string to hide the column.
  141.     sub getExtra
  142.     {
  143.  
  144.         return 'Žánr';
  145.     }
  146.  
  147.     # changeUrl
  148.     # Can be used to change URL if movie URL and the one used to
  149.     # extract information are different.
  150.     # Return the modified URL.
  151.     sub changeUrl
  152.     {
  153.         my ($self, $url) = @_;
  154.  
  155.         return $url;
  156.     }
  157.  
  158.     # preProcess
  159.     # Called before each page is processed. You can use it to do some substitutions.
  160.     # $html is the page content.
  161.     # Returns modified version of page content.
  162.     sub preProcess
  163.     {
  164.         my ($self, $html) = @_;
  165.     $self->{parsingEnded} = 0;
  166.         if ($self->{parsingList})
  167.         {
  168.             # Search results
  169.  
  170.             # Initial values for search results parsing
  171.             # There are two movies list:
  172.             # First with detailed info (title, genre, origin country, year, directors, actors)
  173.             # Second with brief list of other movies (title, year)
  174.  
  175.             # We are in brief list containing other movies without details
  176.             $self->{insideOtherMovies} = 0;
  177.             # Movie link; movie's details follow if not in brief list
  178.             $self->{isMovie} = 0;
  179.  
  180.             ## Details:
  181.  
  182.             # Movie's details will follow: Genre, origin, actors, directors, year
  183.             $self->{insideDetails} = 0;
  184.             # In movie's details after paragraph with Genre, origin and date
  185.             $self->{wasDetailsInfo} = 0;
  186.             # In movie's details: directors and actors
  187.             $self->{directors}        = ();
  188.             $self->{directorsCounter} = 0;
  189.             $self->{actors}           = ();
  190.             $self->{actorsCounter}    = 0;
  191.             $self->{insideDirectors}  = 0;
  192.             $self->{insideActors}     = 0;
  193.  
  194.             # Movie year
  195.             $self->{isYear} = 0;
  196.  
  197.             ## Preprocess
  198.  
  199.             # directors and actors
  200.             $html =~ s/\n\s*Režie:\s([^\n]*)/<div class="directors">$1<\/div>/g;
  201.             $html =~ s/\n\s*Hrají:\s([^\n].*)/<div class="actors">$1<\/div>/g;
  202.             # year
  203.             $html =~ s/<span class="film-year">\(([0-9]+)\)<\/span>/<span class="film-year">$1<\/span>/g;
  204.         }
  205.         else
  206.         {
  207.             # Movie page
  208.  
  209.             # Initial values for search results parsing
  210.  
  211.             # array containg other movie titles (not exported to GCStar)
  212.             $self->{titles} = ();
  213.             # in list containing other movie titles
  214.             $self->{isTitles} = 0;
  215.             # in the original title (title for same country as movie's origin)
  216.             $self->{isOrigTitle} = 0;
  217.             # original title (if not set during parsing it will be set to main title at the end)
  218.             $self->{origTitle}     = undef;
  219.             $self->{titlesCounter} = 0;
  220.  
  221.             $self->{insideGenre} = 0;
  222.  
  223.             $self->{awaitingSynopsis} = 0;
  224.             $self->{insideSynopsis}   = 0;
  225.  
  226.             # inside details with country, date (year) and time (length)
  227.             $self->{insideInfo} = 0;
  228.  
  229.             $self->{insideRating} = 0;
  230.  
  231.             # User comments
  232.             # Each comment consists of commenter (user) and his comment
  233.  
  234.             $self->{insideCommentAuthor} = 0;
  235.             $self->{awaitingComment}     = 0;
  236.             $self->{insideComment}       = 0;
  237.  
  238.             # In directors and actors
  239.             $self->{insideDirectors}  = 0;
  240.             $self->{insideActors}     = 0;
  241.             $self->{directors}        = ();
  242.             $self->{directorsCounter} = 0;
  243.             $self->{actors}           = ();
  244.             $self->{actorsCounter}    = 0;
  245.  
  246.             ## Preprocess
  247.  
  248.             # removee <br /> and <br>
  249.             $html =~ s/<br( \/)?>/\n/g;
  250.             ## Synopsis
  251.             # remove list bullet
  252.             $html =~ s/<img src="http:\/\/img.csfd.cz\/sites\/web\/images\/common\/li.gif"[^>]*>//g;
  253.             # remove hyperlink to user profile
  254.             $html =~ s/(&nbsp;<span class="source[^\(]*\()<a[^>]*>([^<]*)<\/a>/$1uživatel $2/g;
  255.             # remove <span></span> around synopsis source
  256.             $html =~ s/&nbsp;<span class="source[^\(]*\(([^\)]*)\)<\/span>/\n-- $1/g;
  257.             $html =~ s/<div data-truncate="570">([^<]*)<\/div>/$1/g;
  258.         }
  259.         return $html;
  260.     }
  261.  
  262.     # In processing functions below, self->{parsingList} can be used.
  263.     # If true, we are processing a search results page
  264.     # If false, we are processing a movie information page.
  265.  
  266.     # $self->{inside}->{tagname} (with correct value for tagname) can be used to test
  267.     # if we are in the corresponding tag.
  268.  
  269.     # You have a counter $self->{movieIdx} that have to be used when processing search results.
  270.     # It is your responsability to increment it!
  271.  
  272.     # When processing search results, you have to fill (if available) following fields:
  273.     #
  274.     #  $self->{movieList}[$self->{movieIdx}]->{title}
  275.     #  $self->{movieList}[$self->{movieIdx}]->{url}
  276.     #  $self->{movieList}[$self->{movieIdx}]->{actors}
  277.     #  $self->{movieList}[$self->{movieIdx}]->{director}
  278.     #  $self->{movieList}[$self->{movieIdx}]->{date}
  279.     #  $self->{movieList}[$self->{movieIdx}]->{extra}
  280.  
  281.     # When processing a movie page, you need to fill the fields (if available) in $self->{curInfo}. They are:
  282.     #
  283.     #  $self->{curInfo}->{title}
  284.     #  $self->{curInfo}->{director}
  285.     #  $self->{curInfo}->{original}        (Original title)
  286.     #  $self->{curInfo}->{actors}
  287.     #  $self->{curInfo}->{genre}        (Comma separated list of movie type)
  288.     #  $self->{curInfo}->{country}        (Movie Nationality or country)
  289.     #  $self->{curInfo}->{date}
  290.     #  $self->{curInfo}->{time}
  291.     #  $self->{curInfo}->{synopsis}
  292.     #  $self->{curInfo}->{image}
  293.     #  $self->{curInfo}->{audio}
  294.     #  $self->{curInfo}->{subt}
  295.     #  $self->{curInfo}->{age}          0     : No information
  296.     #                                   1     : Unrated
  297.     #                                   2     : All audience
  298.     #                                   5     : Parental Guidance
  299.     #                                   >= 10 : Minimum age value
  300.  
  301.     # start
  302.     # Called each time a new HTML tag begins.
  303.     # $tagname is the tag name.
  304.     # $attr is reference to an associative array of tag attributes.
  305.     # $attrseq is an array reference containing all the attributes name.
  306.     # $origtext is the tag text as found in source file
  307.     # Returns nothing
  308.     sub start
  309.     {
  310.         my ($self, $tagname, $attr, $attrseq, $origtext) = @_;
  311.         $self->{inside}->{$tagname}++;
  312.    
  313.         if ($self->{parsingEnded})
  314.         {
  315.             return;
  316.         }
  317.        
  318.         if ($self->{parsingList})
  319.         {
  320.  
  321.             # in brief list of other movies (without details)
  322.             if ($tagname eq "ul" and $attr->{class} eq "films others")
  323.             {
  324.                 $self->{insideOtherMovies} = 1;
  325.             }
  326.  
  327.             # in link to movie page
  328.             if ($tagname eq "a" and $attr->{href} =~ m/\/film\/[0-9]+-.*/)
  329.             {
  330.                 $self->{isMovie} = 1;
  331.                 $self->{itemIdx}++;
  332.                 $self->{itemsList}[ $self->{itemIdx} ]->{url} = $attr->{href};
  333.                 $self->{insideDetails} = 1 if ($self->{insideOtherMovies} != 1);
  334.                 $self->{wasDetailsInfo} = 0;
  335.             }
  336.  
  337.             # directors and actors
  338.             if ($tagname eq "div")
  339.             {
  340.                 $self->{insideDirectors} = 1 if ($attr->{class} eq "directors");
  341.                 $self->{insideActors}    = 1 if ($attr->{class} eq "actors");
  342.             }
  343.  
  344.             # year
  345.             if ($tagname eq "span")
  346.             {
  347.                 $self->{isYear} = 1 if ($attr->{class} eq "film-year");
  348.             }
  349.         }
  350.         else
  351.         {
  352.  
  353.             # Synopsis
  354.             if (    $tagname eq "div"
  355.                 and $attr->{class} eq "content"
  356.                 and $self->{awaitingSynopsis})
  357.             {
  358.                 $self->{insideSynopsis}   = 1;
  359.                 $self->{awaitingSynopsis} = 0;
  360.             }
  361.  
  362.             # Poster
  363.             if (    $tagname eq "img"
  364.                 and $attr->{src} =~ /^http:\/\/img\.csfd\.cz\/posters\//)
  365.             {
  366.                 $self->{curInfo}->{image} = $attr->{src};
  367.             }
  368.  
  369.             # Original name and other names
  370.             if ($tagname eq "ul" and $attr->{class} eq "names")
  371.             {
  372.                 $self->{isTitles} = 1;
  373.             }
  374.  
  375.             if ($tagname eq "img" and $self->{isTitles})
  376.             {
  377.                 $self->{isOrigTitle} = 1 if ($attr->{alt} !~ /název$/);
  378.                 $self->{isSKTitle}   = 1 if ($attr->{alt} =~ /SK název$/);
  379.             }
  380.  
  381.             # Genre
  382.             if ($tagname eq "p" and $attr->{class} eq "genre")
  383.             {
  384.                 $self->{insideGenre} = 1;
  385.             }
  386.  
  387.             # Directors and Actors
  388.             if ($tagname eq "div")
  389.             {
  390.                 $self->{insideDirectors} = 1 if ($attr->{class} eq "directors");
  391.                 $self->{insideActors}    = 1 if ($attr->{class} eq "actors");
  392.             }
  393.  
  394.             # Info (country ,date, time = duration)
  395.             if ($tagname eq "p" and $attr->{class} eq "origin")
  396.             {
  397.                 $self->{insideInfo} = 1;
  398.             }
  399.  
  400.             # Rating
  401.             if ($tagname eq "h2" and $attr->{class} eq "average")
  402.             {
  403.                 $self->{insideRating} = 1;
  404.             }
  405.  
  406.             # Comments
  407.             if ($tagname eq "h5" and $attr->{class} eq "author")
  408.             {
  409.                 $self->{insideCommentAuthor} = 1;
  410.             }
  411.             if ($self->{awaitingComment} and $tagname eq "p" and $attr->{class} eq "post")
  412.             {
  413.                 $self->{awaitingComment} = 0;
  414.                 $self->{insideComment}   = 1;
  415.             }
  416.  
  417.         }
  418.     }
  419.  
  420.     # end
  421.     # Called each time a HTML tag ends.
  422.     # $tagname is the tag name.
  423.     sub end
  424.     {
  425.         my ($self, $tagname) = @_;
  426.         $self->{inside}->{$tagname}--;
  427.  
  428.         if ($self->{parsingList})
  429.         {
  430.  
  431.             # movie details
  432.             $self->{insideDetails} = 0
  433.               if ($tagname eq "div")
  434.               and $self->{insideDetails};
  435.  
  436.             # directors and actors
  437.             if ($tagname eq "div")
  438.             {
  439.                 if ($self->{insideDirectors})
  440.                 {
  441.                     $self->{insideDirectors} = 0;
  442.                     $self->{itemsList}[ $self->{itemIdx} ]->{director} =
  443.                       join(', ', @{$self->{directors}});
  444.                     $self->{directors}        = ();
  445.                     $self->{directorsCounter} = 0;
  446.                 }
  447.                 if ($self->{insideActors})
  448.                 {
  449.                     $self->{insideActors} = 0;
  450.                     $self->{itemsList}[ $self->{itemIdx} ]->{actors} =
  451.                       join(', ', @{$self->{actors}});
  452.                     $self->{actors}           = ();
  453.                     $self->{actorsCounter}    = 0;
  454.                 }
  455.             }
  456.         }
  457.         else
  458.         {
  459.  
  460.             # Synopsis
  461.             $self->{insideSynopsis} = 0 if ($tagname eq "div");
  462.  
  463.             # Titles
  464.             if ($tagname eq "ul" and $self->{isTitles})
  465.             {
  466.                 $self->{isTitles} = 0;
  467.             }
  468.  
  469.             if ( $tagname eq "body" )
  470.             {
  471.                 $self->{curInfo}->{original} ||= $self->{curInfo}->{title};
  472.             }
  473.  
  474.             # Actors
  475.             if ($tagname eq "div" and $self->{insideActors})
  476.             {
  477.                 $self->{curInfo}->{actors} = join(', ', @{$self->{actors}});
  478.                 $self->{insideActors} = 0;
  479.             }
  480.  
  481.             # Directors
  482.             if ($tagname eq "div" and $self->{insideDirectors})
  483.             {
  484.                 $self->{curInfo}->{director} = join(', ', @{$self->{directors}});
  485.                 $self->{insideDirectors} = 0;
  486.             }
  487.  
  488.             # Comment
  489.  
  490.             $self->{insideCommentAuthor} = 0
  491.               if ($tagname eq "h5" and $self->{insideCommentAuthor});
  492.  
  493.             if ($tagname eq "li" and $self->{isComment})
  494.             {
  495.                 $self->{curInfo}->{comment} .= "\n";
  496.                 $self->{isComment} = 0;
  497.             }
  498.  
  499.             # Debug
  500.             if ($tagname eq "body" and $self->{debug})
  501.             {
  502.                 use Data::Dumper;
  503.                 print Dumper $self->{curInfo};
  504.             }
  505.         }
  506.     }
  507.  
  508.     # text
  509.     # Called each time some plain text (between tags) is processed.
  510.     # $origtext is the read text.
  511.     sub text
  512.     {
  513.         my ($self, $origtext) = @_;
  514.  
  515.         return if length($origtext) < 2;
  516.         $origtext =~ s/^\s+|\s+$//g;
  517.    
  518.     return if ($self->{parsingEnded});
  519.  
  520.         if ($self->{parsingList})
  521.         {
  522.         if ($self->{inside}->{h1} && $origtext !~ m/Vyhledávání/i)
  523.             {
  524.                 $self->{parsingEnded} = 1;
  525.                 $self->{itemIdx} = 0;
  526.                 $self->{itemsList}[0]->{url} = $self->{loadedUrl};
  527.             }
  528.  
  529.             # Movie title
  530.             if ($self->{isMovie})
  531.             {
  532.                 $self->{itemsList}[ $self->{itemIdx} ]->{"title"} = $origtext;
  533.                 $self->{isMovie} = 0;
  534.                 return;
  535.             }
  536.  
  537.             # Date (year)
  538.             elsif ($self->{isYear})
  539.             {
  540.                 $self->{itemsList}[ $self->{itemIdx} ]->{"date"} = $origtext;
  541.                 $self->{isYear} = 0;
  542.             }
  543.  
  544.             # Extra movie info: genre, origin, date
  545.             elsif ( $self->{inside}->{p}
  546.                 and $self->{insideDetails}
  547.                 and $self->{wasDetailsInfo} == 0)
  548.             {
  549.                 my @tmp = split(', ', $origtext);
  550.                 my $pos = $#tmp;
  551.                 my ($year, $country, $genre) = (undef, undef, undef);
  552.                 $year = $tmp[$pos] if ($tmp[$pos] =~ /^\d+$/);
  553.                 $pos--;
  554.                 $country = $tmp[$pos] if ($pos >= 0);
  555.                 $pos--;
  556.                 $genre = $tmp[$pos] if ($pos >= 0);
  557.  
  558.                 $self->{itemsList}[ $self->{itemIdx} ]->{date} = $year if (defined $year);
  559.                 $self->{itemsList}[ $self->{itemIdx} ]->{country} = $country
  560.                   if (defined $country);
  561.                 $self->{itemsList}[ $self->{itemIdx} ]->{extra} = $genre
  562.                   if (defined $genre);
  563.                 $self->{wasDetailsInfo} = 1;
  564.             }
  565.  
  566.             # Directors
  567.             elsif ($self->{inside}->{a} and $self->{insideDirectors})
  568.             {
  569.                 push @{$self->{directors}}, $origtext;
  570.                 $self->{directorsCounter}++;
  571.             }
  572.  
  573.             # Actors
  574.             elsif ($self->{inside}->{a} and $self->{insideActors})
  575.             {
  576.                 push @{$self->{actors}}, $origtext;
  577.                 $self->{actorsCounter}++;
  578.             }
  579.         }
  580.         else
  581.         {
  582.  
  583.             # Movie titles
  584.             if ($self->{inside}->{h1})
  585.             {
  586.                 $self->{curInfo}->{title} = $origtext
  587.                   if !$self->{curInfo}->{title};
  588.             }
  589.             if ($self->{inside}->{h3} and $self->{isTitles})
  590.             {
  591.                 $self->{titlesCounter}++;
  592.                 $self->{titles}[ $self->{titlesCounter} ] = $origtext;
  593.                 if ($self->{isOrigTitle})
  594.                 {
  595.                     $self->{curInfo}->{original} ||= $origtext;
  596.                     $self->{isOrigTitle} = 0;
  597.                 }
  598.                 if ($self->{isSKTitle} and $self->{lang} eq "SK")
  599.                 {
  600.                     $self->{curInfo}->{title} = $origtext;
  601.                     $self->{isSKTitle} = 0;
  602.                 }                
  603.             }
  604.  
  605.             # Genre
  606.             if ($self->{insideGenre})
  607.             {
  608.                 $origtext =~ s/ \/ /,/g;
  609.                 $self->{curInfo}->{genre} = $origtext;
  610.                 $self->{insideGenre} = 0;
  611.             }
  612.  
  613.             # Extra movie info: country, date (year), time
  614.             if ($self->{insideInfo})
  615.             {
  616.                 my ($country, $year, $time) = split(', ', $origtext);
  617.                 $country =~ s/ \/ /,/g;
  618.  
  619.                 $self->{curInfo}->{country} = $country;
  620.                 $self->{curInfo}->{date}    = $year;
  621.                 $self->{curInfo}->{time}    = $time;
  622.  
  623.                 $self->{insideInfo} = 0;
  624.             }
  625.  
  626.             # Directors and Actors
  627.             if ($self->{insideDirectorsOrActors})
  628.             {
  629.                 $self->{insideDirectors} = 1 if ($origtext =~ /^Režie:/);
  630.                 $self->{insideActors}    = 1 if ($origtext =~ /^Hrají:/);
  631.             }
  632.             if ($self->{inside}->{a} and $self->{insideDirectors})
  633.             {
  634.                 push @{$self->{directors}}, $origtext;
  635.                 $self->{directorsCounter}++;
  636.             }
  637.             if ($self->{inside}->{a} and $self->{insideActors})
  638.             {
  639.                 #push @{$self->{curInfo}->{actors}}, [$origtext]
  640.                 #  if ($self->{actorsCounter} <
  641.                 #    $GCPlugins::GCfilms::GCfilmsCommon::MAX_ACTORS);
  642.                 #$self->{actorsCounter}++;
  643.                 push @{$self->{actors}}, $origtext;
  644.                 $self->{actorsCounter}++;
  645.             }
  646.  
  647.             # Synopsis
  648.             if ($self->{inside}->{h3})
  649.             {
  650.                 $self->{awaitingSynopsis} = 1 if ($origtext eq "Obsah");
  651.             }
  652.             if ($self->{inside}->{li} and $self->{insideSynopsis})
  653.             {
  654.                 $self->{curInfo}->{synopsis} .= $origtext . "\n\n\n";
  655.             }
  656.  
  657.             # Rating
  658.             if ($self->{insideRating})
  659.             {
  660.                 $origtext =~ s/([0-9]+)%/$1/;
  661.                 $self->{curInfo}->{ratingpress} = int($origtext / 10 + .5)
  662.                   if ($origtext ne "");
  663.                 $self->{insideRating} = 0;
  664.             }
  665.  
  666.             # Comments
  667.             if ($self->{inside}->{a} and $self->{insideCommentAuthor})
  668.             {
  669.                 $self->{curInfo}->{comment} .= $origtext . " napsal(a):\n";
  670.                 $self->{awaitingComment} = 1;
  671.             }
  672.             if ($self->{insideComment})
  673.             {
  674.                 $self->{curInfo}->{comment} .= $origtext . "\n\n";
  675.                 $self->{insideComment} = 0;
  676.             }
  677.         }
  678.     }
  679.  
  680.     # new
  681.     # Constructor.
  682.     # Returns object reference.
  683.     sub new
  684.     {
  685.         my $proto = shift;
  686.         my $class = ref($proto) || $proto;
  687.         my $self  = $class->SUPER::new();
  688.  
  689.         # Do your init stuff here
  690.  
  691.         bless($self, $class);
  692.  
  693.         $self->{hasField} = {
  694.             title    => 1,
  695.             date     => 1,
  696.             director => 1,
  697.             actors   => 1,
  698.             country  => 1
  699.         };
  700.        
  701.         $self->{lang} = "CS";
  702.  
  703.         $self->{curName} = undef;
  704.         $self->{curUrl}  = undef;
  705.        
  706.         $self->{debug} = ($ENV{GCS_DEBUG_PLUGIN_PHASE} > 0);        
  707.  
  708.         return $self;
  709.     }
  710.  
  711. }
  712.  
  713. 1;
Advertisement
RAW Paste Data Copied
Advertisement