diff --git a/gancioff b/gancioff index 9559920..3838538 100755 --- a/gancioff +++ b/gancioff @@ -18,7 +18,7 @@ $SNAME='GancioFF'; $ENAME=strtolower($SNAME); -$SVERS='0.4.1'; +$SVERS='0.4.2'; require __DIR__.'/lib/gettlds.php'; require __DIR__.'/lib/mastodon-postLength.php'; @@ -296,8 +296,8 @@ if (is_null($conf['max_post_length'])) { } //print_r($conf); -$refs=[]; vecho($opts['verbose'],"Info: trying to load the references to already posted announcements from state file «{$conf['state_file_absolute_path']}».\n"); +$refs=[]; if (file_exists($conf['state_file_absolute_path'])) { if (!is_file($conf['state_file_absolute_path'])) dieYoung("Error: «{$conf['state_file_absolute_path']}» exists but it’s not a file.\n",1); if (!is_readable($conf['state_file_absolute_path'])) dieYoung("Error: «{$conf['state_file_absolute_path']}» exists but it’s not readable.\n",1); @@ -349,17 +349,20 @@ $goodPostsCount=0; $index=0; foreach ($feed->channel->item as $item) { $index++; - //print_r($item); if (!isset($item->guid) || !isset($item->title) || !isset($item->link) || !isset($item->description) || !isset($item->pubDate)) { fwrite(STDERR,"Warning: announcement #{$index} has unexpected format, skipping.\n"); } else { $guid=$item->guid->__toString(); $file=null; + $imgalt=''; $hash=$item->title.$item->pubDate; if (isset($item->enclosure[0]['url']) && isset($item->enclosure[0]['type']) && isset($item->enclosure[0]['length'])) { $file=['url'=>$item->enclosure[0]['url']->__toString(), 'type'=>$item->enclosure[0]['type']->__toString(), 'length'=>$item->enclosure[0]['length']->__toString()]; - $hash.=$item->enclosure[0]['url'].$item->enclosure[0]['type'].$item->enclosure[0]['length']; + if (preg_match('#description->__toString(),$matches)===1) $imgalt=trim($matches[1]); + $hash.=$item->enclosure[0]['url'].$item->enclosure[0]['type'].$item->enclosure[0]['length'].$imgalt; } + if ($imgalt=='') $imgalt='Flyer dell’evento'; + //