{"id":115660,"date":"2009-10-07T22:49:00","date_gmt":"2009-10-07T21:49:00","guid":{"rendered":"http:\/\/pw201.livejournal.com\/115660.html"},"modified":"2009-10-07T22:49:00","modified_gmt":"2009-10-07T21:49:00","slug":"department-of-dirty-hacks","status":"publish","type":"post","link":"https:\/\/www.noctua.org.uk\/blog\/2009\/10\/07\/department-of-dirty-hacks\/","title":{"rendered":"Department of dirty hacks: the link blog script"},"content":{"rendered":"<p>As <a href=\"\/blog\/?p=114940\">promised<\/a>, the link blog stuff is now working. It&#8217;s pulling links and descriptions from <a href=\"http:\/\/delicious.com\/pw201\">my Delicious bookmarks<\/a> and posting them to LJ in batches of 10 or more, or when there&#8217;s stuff to be posted and nothing&#8217;s been posted for 4 days. Let me know if it becomes annoying.<img src='http:\/\/pw201.icons.ljtoys.org.uk\/mi\/dot.gif' border=0 alt=''><BR><BR><b>Here comes the science<\/b><BR><BR>It turns out there&#8217;s a <a href=\"http:\/\/community.livejournal.com\/lj_clients\/207396.html\">PHP script called Delicious Glue<\/a> to do this, but that would involve using PHP, so no (gateway drug: next thing you know, you&#8217;ll be using Perl). It looks like that script also doesn&#8217;t cope with the brave new world of <a href=\"http:\/\/www.joelonsoftware.com\/articles\/Unicode.html\">Unicode<\/a> terribly well, doesn&#8217;t tag the LJ post using the tags from Delicious, and doesn&#8217;t support the elaborate posting scheme described in the previous paragraph. Also, it <a href=\"http:\/\/en.wikipedia.org\/wiki\/Not_Invented_Here\">wasn&#8217;t invented here<\/a>.<BR><BR>So I did it in Python. Mark Pilgrim&#8217;s excellent <a href=\"http:\/\/www.feedparser.org\/\">Universal Feed Parser<\/a> module does much of the heavy lifting. Posting to LJ using <a href=\"http:\/\/www.xmlrpc.com\/\">XML RPC<\/a> turns out to be surprisingly easy using the built-in <a href=\"http:\/\/docs.python.org\/library\/xmlrpclib.html\">xmlrpclib<\/a>. Most of the faff comes in getting it to persist state between runs of the script, which I&#8217;m doing using <a href=\"http:\/\/docs.python.org\/library\/pickle.html\">pickle<\/a>. <a href=\"http:\/\/www.noctua.org.uk\/paul\/software\/lj-minifeed\">Here&#8217;s the code<\/a>: you&#8217;d need to be a programmer to adapt it for your own use, but if you are, it shouldn&#8217;t be hard. I&#8217;ll probably run it daily using <a href=\"http:\/\/www.unixgeeks.org\/security\/newbie\/unix\/cron-1.html\">cron<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As promised, the link blog stuff is now working. It&#8217;s pulling links and descriptions from my Delicious bookmarks and posting them to LJ in batches of 10 or more, or when there&#8217;s stuff to be posted and nothing&#8217;s been posted for 4 days. Let me know if it becomes annoying.Here comes the scienceIt turns out&hellip;<\/p>\n <a href=\"https:\/\/www.noctua.org.uk\/blog\/2009\/10\/07\/department-of-dirty-hacks\/\" title=\"Department of dirty hacks: the link blog script\" class=\"entry-more-link\"><span>Read More<\/span> <span class=\"screen-reader-text\">Department of dirty hacks: the link blog script<\/span><\/a>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"Layout":"","footnotes":"","_links_to":"","_links_to_target":""},"categories":[19,114],"tags":[54,116,146,151],"class_list":["entry","author-paul","post-115660","post","type-post","status-publish","format-standard","category-blog","category-link_blog","tag-del_ico_us","tag-livejournal","tag-programming","tag-python"],"_links":{"self":[{"href":"https:\/\/www.noctua.org.uk\/blog\/wp-json\/wp\/v2\/posts\/115660","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.noctua.org.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.noctua.org.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.noctua.org.uk\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.noctua.org.uk\/blog\/wp-json\/wp\/v2\/comments?post=115660"}],"version-history":[{"count":0,"href":"https:\/\/www.noctua.org.uk\/blog\/wp-json\/wp\/v2\/posts\/115660\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.noctua.org.uk\/blog\/wp-json\/wp\/v2\/media?parent=115660"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.noctua.org.uk\/blog\/wp-json\/wp\/v2\/categories?post=115660"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.noctua.org.uk\/blog\/wp-json\/wp\/v2\/tags?post=115660"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}