An horrible hack: Create daily posts of delicious.com links to your blog

As i wanted to revive the daily posts with links i found useful during a day, i hacked a short script into the system to do this task. Maybe it’s useful to someone out there. You have to change at least the red parts of the script:

#!/usr/bin/perl

# Script to publish a daily linkdump into your blog based
# on your delicious account
# v0.2 18.03.2013 jm


# use strict; 
#
# It's highly probable that you have to install this modules.
# Easiest way:  perl -MCPAN -e 'install Net::Delicious'
#
use Net::Delicious;
use WordPress::XMLRPC;
use WWW::Shorten::Bitly;
use Date::Format;
use Log::Dispatch::Screen;	


#
# Adapt this $config_ variables to your needs.
#
<font color="red">
# Filename for saving Timestamp of the last run
my $config_timestampfile=""; 
# Username at delicious
my $config_delicious_username="";
# Password at delicious
my $config_delicious_password="";
# Username at bitly.com
my $config_bitly_username="";
# API key for bitly
my $config_bitly_apikey="";
# username to post into your blog
my $config_blog_username="";
# password to post into your blog
my $config_blog_password="";
# XMLRPC Endpoint for your blog software
my $config_blog_xmlrpcproxy="";
# Category for the blog entry. 
# The name of it, not the number ... at least for S9Y
my $config_blog_category="";
# 0 = draft, 1 = publish
my $config_blog_publish=0;
</font>

# some initialisation
my $numberoflinks=0;
my $blogentry;

#
# Doing the timestamp stuff in order to ensure
# that just links entered since the last script run
# will be put into the blog entry
#

my &#64;zt = gmtime(time); # Delicious wants Zulu-Time.
my &#64;lt = localtime(time); # Joerg wants localtime

my $datestring        = strftime("%d-%b-%Y", &#64;lt);
my $delicioustime_new = strftime("%Y-%m-%dT%H:%M:%SZ", &#64;zt);

open(TIMESTAMP,"$config_timestampfile");
my $oldtime = &lt;TIMESTAMP&gt;;
chomp($oldtime);
close(TIMESTAMP);

open(TIMESTAMP,"&gt;$config_timestampfile");
print TIMESTAMP "$delicioustime_new";
close(TIMESTAMP);

# Connecting to Delicious and create the text of the blog entry.
# While doing so, get short-links from bit.ly

my $del = Net::Delicious-&gt;new({user =&gt; "$config_delicious_username",
                               pswd =&gt; "$config_delicious_password"});

$blogentry .= "&lt;ul&gt;\n";
foreach my $p ($del-&gt;posts({dt=&gt;"$oldtime"})) {
      my $url=$p-&gt;url();
      my $description=$p-&gt;description();
      my $extended=$p-&gt;extended();
      my $tags=$p-&gt;tags();
      my $shorturl = makeashorterlink($url, "$config_bitly_username", "$config_bitly_apikey");
      $blogentry .= "&lt;li&gt;\n";
      $blogentry .= "&lt;a href=\"$shorturl\"&gt;$description&lt;/a&gt;&lt;br&gt;\n";
      $blogentry .= "$extended&lt;br&gt;\n" if $extended ne "";
      my &#64;tag=split(" ",$tags);
      my $linkified_tags="";
      foreach my $unlinkified_tag (&#64;tag) {
       $linkified_tags = $linkified_tags . 
          "&lt;a href=\"https://delicious.com/" .
          $config_delicious_username . "/" . $unlinkified_tag .
          "\"&gt;" . $unlinkified_tag . "&lt;/a&gt; ";
      }
      $blogentry .="&lt;small&gt; (tags: $linkified_tags)&lt;/small&gt;&lt;br&gt;\n" 
        if $linkified_tags ne "";
      $blogentry .= "&lt;/li&gt;\n";
      $numberoflinks++;
} 
$blogentry .= "&lt;/ul&gt;";

# No links? The story ends here!
exit(0) if $numberoflinks==0;

# Send blog entry.
my $o= WordPress::XMLRPC-&gt;new({
     username =&gt; "$config_blog_username",
     password =&gt; "$config_blog_password",
     proxy =&gt; "$config_blog_xmlrpcproxy",
});

my &#64;entrystructure = 	{
 categories =&gt; [
  "$config_blog_category"
 ],
 title =&gt; '<font color=red>::linkbuf for </font>' . $datestring,
 description =&gt; "$blogentry"
};

$o-&gt;publish($config_blog_publish);
$o-&gt;newPost(&#64;entrystructure) or die($o-&gt;errstr);