|
@@ -51,9 +51,13 @@ function extract_metadata_from_html(string $html): array {
|
|
|
if($date !== false) {
|
|
|
$meta['published'] = strftime('%s', $date);
|
|
|
}
|
|
|
- $author = json_decode(pup_selector($html, 'td.titoloFTR .small strong json{}'))[0]->{'text'};
|
|
|
- if($author !== '') {
|
|
|
- $meta['author'] = $author;
|
|
|
+ $authors = json_decode(pup_selector($html, 'td.titoloFTR .small strong json{}'));
|
|
|
+ $meta['author'] = '';
|
|
|
+ if(count($authors) > 0) {
|
|
|
+ $author = $authors[0]->{'text'};
|
|
|
+ if($author !== '') {
|
|
|
+ $meta['author'] = $author;
|
|
|
+ }
|
|
|
}
|
|
|
return $meta;
|
|
|
}
|
|
@@ -81,9 +85,13 @@ function extract_comments_from_html(string $html): array {
|
|
|
if($date !== false) {
|
|
|
$meta['published'] = strftime('%s', $date);
|
|
|
}
|
|
|
- $author = json_decode(pup_selector($comment, 'table td.titoloFTR .small strong json{}'))[0]->{'text'};
|
|
|
- if($author !== '') {
|
|
|
- $meta['author'] = $author;
|
|
|
+ $authors = json_decode(pup_selector($html, 'td.titoloFTR .small strong json{}'));
|
|
|
+ $meta['author'] = '';
|
|
|
+ if(count($authors) > 0) {
|
|
|
+ $author = $authors[0]->{'text'};
|
|
|
+ if($author !== '') {
|
|
|
+ $meta['author'] = $author;
|
|
|
+ }
|
|
|
}
|
|
|
array_push($comments, $meta);
|
|
|
}
|
|
@@ -192,6 +200,7 @@ $parser = (new ParserFactory)->create(ParserFactory::PREFER_PHP5);
|
|
|
$i = 0;
|
|
|
$db->beginTransaction();
|
|
|
while($f = fgets(STDIN)) {
|
|
|
+ echo $f;
|
|
|
$f = str_replace("\n", '', $f);
|
|
|
parse_save($db, $f, $parser);
|
|
|
$i++;
|