Changeset 12265 for trunk/bbc/collect
- Timestamp:
- 2006-07-20T15:45:08+12:00 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bbc/collect/bbc/perllib/plugins/BRSPlug.pm
r4647 r12265 13 13 } 14 14 15 my $bbc_collections_list = 16 [{'name' => "all", # all collections 17 'desc' => "{BRSPlug.bbc_collections.all}"}, 18 {'name' => "nsa", # National Sound Archive 19 'desc' => "{BRSPlug.bbc_collections.nsa"}, 20 {'name' => "bfi", # Brisith File Institute 21 'desc' => "{BRSPlug.bbc_collections.bfi"}, 22 {'name' => "bbcother", # BBC Other 23 'desc' => "{BRSPlug.bbc_collections.bbcother"}]; 24 25 26 my $arguments = 27 [{ 'name' => "bbc_collections", 28 'desc' => "{BRSPlug.bbc_collections}", 29 #'type' => $bbc_collections_list, 30 'type' => "string", 31 'reqd' => "no", 32 'deft' => "all"}]; 33 15 34 %Exclude = (); 16 35 36 my $options = { 'name' => "BRSPlug", 37 'desc' => "{BRSPlug.desc}", 38 'abstract' => "yes", 39 'inherits' => "no", 40 'args' => $arguments }; 17 41 18 42 # Note: sext is short for scrollable text … … 79 103 disp_type => "text", crit_type => "text", 80 104 width => 30, height => 1 }, 105 { field_name => "RFTI", field_id => 116, label => "RFTI", 106 disp_type => "text", crit_type => "text", 107 width => 30, height => 1 }, 81 108 { field_name => "TEXT", field_id => 1, label => "Text", 82 109 disp_type => "scrl", crit_type => "text", 83 110 width => 40, height => 16 }, 84 85 111 { field_name => "T006", field_id => 10, label => "Sport prdcr", 86 112 disp_type => "text", crit_type => "text", … … 189 215 190 216 sub new { 191 my ($class) = @_;217 my $class = shift (@_); 192 218 my $self = new BasPlug ($class, @_); 193 219 $self->{'plugin_type'} = "BRSPlug"; 220 221 # 14-05-02 To allow for proper inheritance of arguments - John Thompson 222 my $option_list = $self->{'option_list'}; 223 push( @{$option_list}, $options ); 224 225 if (!parsargv::parse(\@_, 226 q^bbc_collections/(all|nsa|bfi|bbcother)/^, \$self->{'bbc_collections'}, 227 "allow_extra_options")) { 228 229 print STDERR "\nIncorrect options passed to BRSPlug, check your collect.cfg configuration file\n"; 230 $self->print_txt_usage(""); # Use default resource bundle 231 die "\n"; 232 } 233 234 #my ($class) = @_; 235 #my $self = new BasPlug ($class, @_); 236 194 237 return bless $self, $class; 195 238 } … … 199 242 200 243 # return q^(?i)\.brs$^; 201 return q^ b.+^;244 return q^TVRD.+^; 202 245 } 203 246 … … 220 263 my $extra_trigger = '\s*>'; 221 264 my $text_divider = "-" x 78; 222 my $text_end = '^\.\.[^:]+:$'; 223 265 #my $text_end = '^\.\.[^:]+:$'; 266 my $meta_key = '^\.\.(\w+):$'; 267 224 268 # Print "." to signify processing if enough records have been read in 225 269 $brs_doc_count++; … … 240 284 { 241 285 $line = shift(@brs_lines); 286 242 287 $line =~ s/\cM//g; 243 288 244 289 $brs_line_no++; 245 290 246 if ($line =~ m/^\.\.([^:]+):$/) 291 # if ($line =~ m/^\.\.([^:]+):$/) 292 if ($line =~ m/$meta_key/) 247 293 { 248 294 my $field_name = $1; … … 258 304 while (scalar(@brs_lines)>0) 259 305 { 260 last if ($brs_lines[0] =~ m/$text_end/); 261 306 307 last if ($brs_lines[0] =~ m/$meta_key/); 308 309 262 310 $line = shift(@brs_lines); 311 312 263 313 $brs_line_no++; 264 314 … … 275 325 next; 276 326 } 277 278 if ($line =~ m/^\.\.[^:]+:/) 327 328 if ($line =~ m/$meta_key/) 329 #if ($line =~ m/^\.\.[^:]+:/) 279 330 { 280 331 if ($line =~ m/^\.\.TEXT/) … … 282 333 $add_mode = "above"; 283 334 next; 284 } 335 } 285 336 else 286 337 { … … 312 363 elsif ($field_name =~ /^RF/) 313 364 { 365 # deal with the field name start with RF, eg. RFTI,RFAN, RFAB... 314 366 # read zz fields until end of record 315 367 … … 317 369 { 318 370 my $line_ahead = $brs_lines[0]; 319 last if ($line_ahead =~ m/^\.\.[^:]+:$/);320 371 #last if ($line_ahead =~ m/^\.\.[^:]+:$/); 372 last if ($line_ahead =~ m/$meta_key/); 321 373 $line = shift(@brs_lines); 322 374 $brs_line_no++; 323 375 #if (!defined($brs_rec->{$field_name})) 376 #{ 377 #$brs_rec->{$field_name} = [$line]; 378 #} 379 #else 380 #{ 381 #push(@{$brs_rec->{$field_name}},$line); 382 #} 383 324 384 if (!defined($brs_rec->{$field_name})) 325 385 { 326 $brs_rec->{$field_name} = [$line];386 $brs_rec->{$field_name} = (); #[$line]; 327 387 } 328 else 329 { 330 push(@{$brs_rec->{$field_name}},$line); 331 } 388 push(@{$brs_rec->{$field_name}},$line); 332 389 } 333 390 } … … 335 392 { 336 393 my $field_entry = ""; 337 while ($brs_lines[0] !~ m/^\.\.[^:]+:$/) 394 #while ($brs_lines[0] !~ m/^\.\.[^:]+:$/) 395 while ($brs_lines[0] !~ m/$meta_key/) 338 396 { 339 397 $field_entry .= shift(@brs_lines); … … 379 437 { 380 438 my $field_name = $brs_field_table[$i]->{'field_name'}; 439 381 440 if (defined($brs_rec->{$field_name})) 382 441 { … … 390 449 $long_lines .= "<tr valign=top><td><b>$field_label:</b></td><td colspan=5>"; 391 450 $long_lines .= "<a href=\"_httpquerytitle_&q=$safe_value\">$field_value</a></td></tr>\n"; 392 $long_lines .= "$field_value</td></tr>\n"; 393 451 $long_lines .= "$field_value </td></tr>\n"; 394 452 } else { 395 453 … … 427 485 $field_value = "<a href=\"_httpqueryzzabn_&q=$safe_value\">$field_value</a>"; 428 486 } 429 487 if ($field_label =~ /^(RFTI)/){ 488 $field_value = join(" ",@{$brs_rec->{'RFTI'}}); 489 #print STDERR "**** $field_label, $field_value\n"; 490 } 430 491 $table_line .= "<td><b>$field_label:</b></td><td>$field_value</td>\n"; 431 492 } … … 445 506 sub process_brs_record 446 507 { 508 my $self = shift (@_); 509 447 510 my ($processor, $brs_rec, $file, $outhandle) = @_; 448 511 449 512 if (defined($brs_rec)) 450 513 { 451 452 514 # only include those records in the chosen subcats - these lines 453 515 # should be commented out to build the entire collection 454 516 455 # National Sound Archive collection 456 #if (!defined ($brs_rec->{'SUBC'}) ||457 #$brs_rec->{'SUBC'} !~ /^(RADCOMP|RADIOX|RADPROG|RADNEWS|BDSPROG|UNCATRAD|RADIOREF|WILDSOUND)$/) {458 #return;459 #}460 517 # National Sound Archive collection-Stephan 518 #if (!defined ($brs_rec->{'SUBC'}) || 519 # $brs_rec->{'SUBC'} !~ /^(RADCOMP|RADIOX|RADPROG|RADNEWS|BDSPROG|UNCATRAD|RADIOREF|WILDSOUND)$/) { 520 # return; 521 #} 522 461 523 # British Film Institute collection 462 #if (!defined ($brs_rec->{'SUBC'}) ||463 #$brs_rec->{'SUBC'} !~ /^(LONPROG|NEWS)$/) {464 #return;465 #}466 524 #if (!defined ($brs_rec->{'SUBC'}) || 525 # $brs_rec->{'SUBC'} !~ /^(LONPROG|NEWS)$/) { 526 # return; 527 #} 528 467 529 # "the rest" collection 468 if (!defined ($brs_rec->{'SUBC'}) || 469 $brs_rec->{'SUBC'} =~ /^(LONPROG|NEWS|RADCOMP|RADIOX|RADPROG|RADNEWS|BDSPROG|UNCATRAD|RADIOREF|WILDSOUND)$/) { 470 return; 530 #if (!defined ($brs_rec->{'SUBC'}) || 531 # $brs_rec->{'SUBC'} =~ /^(LONPROG|NEWS|RADCOMP|RADIOX|RADPROG|RADNEWS|BDSPROG|UNCATRAD|RADIOREF|WILDSOUND)$/) { 532 # return; 533 #} 534 #} 535 536 # modified Chi-Yu Huang 537 if (defined $self->{'bbc_collections'}){ 538 # National Sound Archive collection 539 if ($self->{'bbc_collections'} eq "nsa"){ 540 #print STDERR "***This is NSA collections\n"; 541 if (!defined ($brs_rec->{'SUBC'}) || 542 $brs_rec->{'SUBC'} !~ /^(RADCOMP|RADIOX|RADPROG|RADNEWS|BDSPROG|UNCATRAD|RADIOREF|WILDSOUND)$/) { 543 return; 544 } 545 } 546 elsif ($self->{'bbc_collections'} eq "bfi"){ 547 print STDERR "***This is BFI collections\n"; 548 # British Film Institute collection 549 if (!defined ($brs_rec->{'SUBC'}) || 550 $brs_rec->{'SUBC'} !~ /^(LONPROG|NEWS)$/) { 551 return; 552 } 553 } 554 elsif ($self->{'bbc_collections'} eq "bbcother"){ 555 #print STDERR "*** This is bbc Other collections\n"; 556 # "the rest" collection 557 if (!defined ($brs_rec->{'SUBC'}) || 558 $brs_rec->{'SUBC'} =~ /^(LONPROG|NEWS|RADCOMP|RADIOX|RADPROG|RADNEWS|BDSPROG|UNCATRAD|RADIOREF|WILDSOUND)$/) { 559 return; 560 } 561 } else { 562 # build the whole collections 563 #print STDERR "*** This is to build the whole collection\n"; 564 } 565 } else { 566 #build the whole collections 471 567 } 472 568 … … 500 596 else 501 597 { 502 $title = $brs_rec->{$pot_title}; 503 } 598 if ($pot_title =~ /^RF/){ 599 $title = join (" ", @{$brs_rec->{$pot_title}}); 600 } else{ 601 $title = $brs_rec->{$pot_title}; 602 } 603 #$title = $brs_rec->{$pot_title}; 604 } 605 606 #print STDERR "*** What is the title=$title\n"; 504 607 505 608 my $tl_ref = $doc_obj->get_metadata ($cursection, "Title"); … … 589 692 $doc_obj->add_utf8_metadata ($cursection, "zzabn", $zzabn); 590 693 } 591 694 592 695 if (defined($brs_rec->{'RFN'})) 593 696 { … … 766 869 next if $record !~ /\w/; # first record will be empty 767 870 my $brs_rec = &read_brs_record(\$record, $file, $self->{'outhandle'}); 768 &process_brs_record ($ processor, $brs_rec, $file, $self->{'outhandle'});871 &process_brs_record ($self, $processor, $brs_rec, $file, $self->{'outhandle'}); 769 872 } 873 874 $self->{'num_processed'} += $brs_processed_count; 770 875 771 876 print $outhandle "\nNumber of BRS records = $brs_doc_count\n";
Note:
See TracChangeset
for help on using the changeset viewer.