forked from LMS-Community/slimserver-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scrape-bug-summary
executable file
·60 lines (40 loc) · 1.19 KB
/
scrape-bug-summary
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/perl -w
# $Id$
#
# Simple script to scrape the bug summaries from Bugzilla for inclusion in the changelog.
#
# It will write out two files - a plain text for sending email, and an HTMLized version.
use strict;
use lib qw(CPAN);
use HTML::Entities;
use LWP::Simple;
sub main {
my $url = 'http://bugs.slimdevices.com/show_bug.cgi?id=%d';
my $file = $ARGV[0] || die "Usage $0 <file>\n";
open FH, $file or die $!;
open OUTHTML, ">bugs.html" or die $!;
open OUTTEXT, ">bugs.txt" or die $!;
while (my $bug = <FH>) {
chomp $bug;
print "Fetching summary for bug $bug..\n";
my $content = get(sprintf($url, $bug));
my $summary = '';
for my $line (split /\n/, $content) {
if ($line =~ m|Bug $bug: (.+?)</div>$|) {
$summary = $1;
last;
}
}
unless ($summary) {
print "Couldn't find a summary for bug $bug - please check it manually.\n";
}
printf(OUTTEXT "\t#%.4d - %s\n\n", $bug, decode_entities($summary));
# <li><a href="http://bugs.slimdevices.com/show_bug.cgi?id=121">#121</a> -
printf(OUTHTML "\t\t<li><a href=\"%s\">#%.4d</a> - %s</li>\n", sprintf($url, $bug), $bug, $summary);
}
close FH;
close OUTTEXT;
close OUTHTML;
}
main();
__END__