FilmAffinity-UserRating

 view release on metacpan or  search on metacpan

lib/FilmAffinity/Movie.pm  view on Meta::CPAN

      next if $value eq q{};

      if (defined $data->{cleanerSub}){
        $value = $data->{cleanerSub}($value, $accessor);
      }

      next if not defined $value;

      $self->$accessor( $value );
      last;
    }
  }
};

private_method p_findRating => sub {
  my $self = shift;

  my $rating = $self->tree->findvalue( $XPATH_RATING );

  return if not defined $rating or $rating eq q{};
  $self->rating( trim($rating) );
};

private_method p_findVotes => sub {
  my $self = shift;

  my $votes = $self->tree->findvalue( $XPATH_VOTE );

  return if not defined $votes or $votes eq q{};
  $votes =~ s/\D//gixms;
  $self->votes( trim($votes) );
};

private_method p_buildUrlMovie => sub {
  my ($self, $id) = @_;

  return $MOVIE_URL.$id.'.html';
};

private_method p_removeTextBetweenParenthesis => sub {
  my $content = shift;

  $content =~ s/[(].*[)]//gxms;
  return $content;
};

private_method p_cleanDuration => sub {
  my $value = shift;
  $value =~ s/min[.]//gixms;
  $value = trim($value);

  if ( looks_like_number($value) ){
    return $value;
  }
  return;
};

private_method p_cleanPerson => sub {
  my $value = shift;

  my @persons = split m/,/xms, $value;
  @persons = map {trim (p_removeTextBetweenParenthesis($_) )} @persons;
  return \@persons;
};

private_method p_cleanGenre => sub {
  my ($value, $field) = @_;

  my $pos = $field eq 'genre' ? 0 : 1;
  my @list = split m/[|]/xms, $value;

  if ( defined $list[$pos]){
    my @genres = trim ( split m/[.]/xms, $list[$pos] );
    return \@genres;
  }
  return;
};

private_method p_cleanStudio => sub {
  my ($value, $field) = @_;

  my $pos = $field eq 'studio' ? 0 : 1;
  my @list = split m/[.]\sProducer: /xms, $value;

  my @studio = ();
  if (not defined $list[$pos]){
    return;
  } else {
    @studio = trim ( split m{ / }xms, $list[$pos] );
    return \@studio;
  }
};

=head1 AUTHOR

William Belle, C<< <william.belle at gmail.com> >>

=head1 BUGS AND LIMITATIONS

Please report any bugs or feature requests to C<bug-filmaffinity-userrating at rt.cpan.org>, or through
the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=FilmAffinity-UserRating>.  I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.

=head1 SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc FilmAffinity::Movie

You can also look for information at:

=over 4

=item * RT: CPAN's request tracker (report bugs here)

L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=FilmAffinity-UserRating>

=item * AnnoCPAN: Annotated CPAN documentation

L<http://annocpan.org/dist/FilmAffinity-UserRating>

=item * CPAN Ratings

L<http://cpanratings.perl.org/d/FilmAffinity-UserRating>

=item * Search CPAN

L<http://search.cpan.org/dist/FilmAffinity-UserRating/>

=back

=head1 SEE ALSO

L<http://www.filmaffinity.com>

=head1 LICENSE AND COPYRIGHT

Copyright 2013 William Belle.

This program is free software; you can redistribute it and/or modify it
under the terms of either: the GNU General Public License as published
by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.

=cut

1; # End of FilmAffinity::Movie



( run in 0.377 second using v1.01-cache-2.11-cpan-71847e10f99 )