#!/usr/bin/perl -w use strict; use warnings; use Text::CSV; # config: my $include_my_tags = env('ST_include_my_tags', 1); my $include_comm_tags = env('ST_include_comm_tags', 1); my $main_link_type = env('ST_main_link_type', 'play_linux'); # play, store my $title = env('ST_title', "Steam Games"); sub env { my ($k, $default) = @_; return exists $ENV{$k} ? $ENV{$k} : $default; } binmode STDIN, ':utf8'; binmode STDOUT, ':utf8'; my $csv = Text::CSV->new ({ binary => 1 }) or die "Cannot use CSV: ".Text::CSV->error_diag(); $csv->eol("\n"); sub ee { my ($s) = @_; $s =~ s/&/&/g; $s =~ s//>/g; return $s; } print < $title End print <<'End'; End print <<'End' if $main_link_type eq 'play_linux'; End #
  • play in wine
  • print <<'End';
    End my %already; my ($info); while (my $line = ) { chomp $line; $csv->parse($line) or die "can't parse line: $line"; my ($id, $name, $metacritic_name, $store_tags, $dev_tags, $sys_tags, $my_tags, $comm_tags, $key) = $csv->fields(); if ($key && $key =~ m{^https?://}) { $key = qq{gift link}; } elsif ($key) { # $key = "Steam Key: $key"; } next if $already{$id}++; my $name_esc = ee($name); my @my_tags = split(/ /, $my_tags||''); my @sys_tags = split(/ /, $sys_tags||''); my @store_tags = split(/ /, $store_tags||''); my @dev_tags = split(/ /, $dev_tags||''); my @comm_tags = split(/ /, $comm_tags||''); my (@tags1, @tags2); push @tags1, @my_tags, @sys_tags if $include_my_tags; push @tags1, @store_tags; push @tags2, @comm_tags; my @dev_with_d = map { qq{$_} } @dev_tags; my @tags1_with_t = map { qq{$_} } @tags1; my @tags2_with_t = map { qq{$_} } @tags2; my $proto = "steam"; $proto = "steamwine" if $main_link_type eq "play_linux" && !grep {$_ eq "linux"} @sys_tags; my $main_link = "#"; my $link_target = qq{ target="_blank"}; if ($main_link_type eq "play" || $main_link_type eq "play_linux") { $main_link = "$proto://rungameid/$id"; $link_target = ""; } elsif ($main_link_type eq "store") { $main_link = "http://store.steampowered.com/app/$id/"; } my $image = "headers/$id.jpg"; $image = "logos/$id.jpg" if ! -s $image; print <
    $name_esc @dev_with_d End if ($key) { print <$key End } else { print <$id End } print <
    @tags1_with_t End print <@tags2_with_t End print < End } print <<'End';
    End