Changeset 1566 for trunk

Show
Ignore:
Timestamp:
07/08/09 22:45:15 (5 months ago)
Author:
mpaschal
Message:

Fix Steam achievement stream for new HTML (thanks, Brendan O'Connor for the patch!)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/ActionStreams/plugins/ActionStreams/lib/ActionStreams/Event/Steam.pm

    r1563 r1566  
    4141        process q{div#BG_top h2}, 
    4242            'title' => 'TEXT'; 
    43         process q{//div[@class='achievementClosed']}, 
     43                process q{html}, 
     44                        'html' => 'HTML'; 
     45        process q{//div[@class='achieveTxtHolder']}, 
    4446            'achvs[]' => scraper { 
    4547                process 'h3',  'title'       => 'TEXT'; 
     
    7375        next URL if !$items; 
    7476 
    75         my ($title, $achvs) = @$items{qw( title achvs )}; 
     77        my ($title, $html, $achvs) = @$items{qw( title html achvs )}; 
    7678        $title =~ s{ \s* Stats \z }{}xmsi; 
    7779 
    78         for my $item (@$achvs) { 
     80                next URL if ($title =~ /Global Gameplay/i); 
     81 
     82                # So we have the full source code in $html; we need to count how many achievements are before 
     83                # the critical <br /><br /><br /> line dividing achieved from unachieved. 
     84                 
     85                next URL if ($html !~ /\<br\ \/\>\<br\ \/\>\<br\ \/\>.+/); # If the line isn't there, they don't have any achievements yet. 
     86                 
     87                $html =~ s/\<br\ \/\>\<br\ \/\>\<br\ \/\>.+//; 
     88                my $count = scalar split(/achieveTxtHolder/, $html); 
     89                $count = $count - 2; #This method ends up with one too many, always, and we want the last valid *INDEX* number. 
     90 
     91                my @achievements = @$achvs; 
     92                $#achievements = $count; # Truncates the array 
     93 
     94        for my $item (@achievements) { 
    7995            $item->{gametitle} = $title; 
    8096            $item->{ident}     = $ident; 
     
    88104        $class->build_results( 
    89105            author     => $author, 
    90             items      => $achvs, 
     106            items      => \@achievements, 
    91107            identifier => 'ident,gamecode,title', 
    92108        );