/[hyperestraier_wrappers]/trunk/perl/scripts/est-spider
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/perl/scripts/est-spider

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 27 by dpavlin, Sat Sep 17 23:07:52 2005 UTC revision 28 by dpavlin, Sat Sep 17 23:43:20 2005 UTC
# Line 17  my $verbose; Line 17  my $verbose;
17  my $exclude;  my $exclude;
18    
19  #$verbose = 1;  #$verbose = 1;
20    my $debug = 0;
21    
22  my $result = GetOptions(  my $result = GetOptions(
23          "collection=s" => \$collection,          "collection=s" => \$collection,
24          "path=s" => \$path_add,          "path=s" => \$path_add,
25          "verbose!" => \$verbose,          "verbose!" => \$verbose,
26          "debug!" => \$verbose,          "debug!" => \$debug,
27          "exclude=s" => \$exclude,          "exclude=s" => \$exclude,
28          "node=s" => \$node_url,          "node=s" => \$node_url,
29  );  );
# Line 133  sub file { Line 134  sub file {
134          my $path = $_;          my $path = $_;
135          my $contents;          my $contents;
136    
137          return if (-l $path || $path =~ m#/.svn#);          return if (-l $path || $path =~ m#/.svn# || $path =~ m/(~|.bak)$/);
138    
139            my $mtime = (stat($path))[9];
140            my $mtime_db = $db->get_doc_attr_by_uri("file:///$path", '@mtime') || -2;
141    
142            if ($mtime == $mtime_db) {
143                    print STDERR "# same: $path $mtime\n" if ($verbose);
144                    return;
145            } else {
146                    print STDERR "# changed: $path $mtime != $mtime_db\n" if ($debug);
147            }
148    
149            # skip files on which File::MMagic::XS croaks
150            return if ($path =~ m#\.au$#);
151    
152          my $type = $mm->checktype_filename($path);          my $type = $mm->checktype_filename($path);
153          $type =~ s/\s+/ /gs;          $type =~ s/\s+/ /gs;
154    
155          print STDERR "# $path $type\n" if ($verbose);          print STDERR "# $path $type\n" if ($debug);
156    
157          if ($pdftotext && -f $path && $type =~ m/pdf/i) {          if ($pdftotext && -f $path && $type =~ m/pdf/i) {
158    
# Line 175  sub file { Line 189  sub file {
189                          print STDERR " $page_nr" if ($verbose);                          print STDERR " $page_nr" if ($verbose);
190                          my $pre_tmp = $pre_html;                          my $pre_tmp = $pre_html;
191                          $pre_tmp =~ s/##page_nr##/$page_nr<\/title>/s;                          $pre_tmp =~ s/##page_nr##/$page_nr<\/title>/s;
192                          dump_contents($db, $pre_tmp . $page . $post_html,time(), $path) if ($page !~ m/^\s*$/s);                          dump_contents($db, $pre_tmp . $page . $post_html, $mtime, $path) if ($page !~ m/^\s*$/s);
193                          $page_nr++;                          $page_nr++;
194                  }                  }
195    
196          } else {          } else {
197    
198  #               return if (! -f $path || ! m/\.(html*|php|pl|txt|info|log|text)$/i);  #               return if (! -f $path || ! m/\.(html*|php|pl|txt|info|log|text)$/i);
199                  return if (! -f $path || (                  return unless (-f $path && $type =~ m/html/ ||
200                          $type !~ m/html/ ||                          ($type =~ m#text# && $path =~ m/\.(php|pl|txt|info|log|text)$/io)
201                          ($type !~ m#text/plain# && m/\.(php|pl|txt|info|log|text)$/)                  );
                 ));  
202    
203                  # skip index files                  # skip index files
204                  return if (m/index_[a-z]\.html*/i || m/index_symbol\.html*/i);                  return if (m/index_[a-z]\.html*/i || m/index_symbol\.html*/i);
# Line 202  sub file { Line 215  sub file {
215                  # add optional components to path                  # add optional components to path
216                  $path .= " $path_add" if ($path_add);                  $path .= " $path_add" if ($path_add);
217    
218                  dump_contents($db, $contents,time(), $path);                  dump_contents($db, $contents, $mtime, $path);
219          }          }
220    
221          print STDERR "\n" if ($verbose);          print STDERR "\n" if ($verbose);

Legend:
Removed from v.27  
changed lines
  Added in v.28

  ViewVC Help
Powered by ViewVC 1.1.26