EXAMPLE_SHELL=ns-unescape mz-unescape bkmk2db koi2win.db \
bkmk-koi bkmk-win bkmk-chk bkmk-publish bkmk-sort hotexplode.pl \
- check_title.py set-real_title.py set-title-list.py \
+ check_url.py check_title.py set-real_title.py set-title-list.py \
bkmk-add.py bkmk-add bkmk-rsync mz2ns mk-distr
--- /dev/null
+#! /usr/bin/env python
+"""
+ Robot interface - check one URL
+
+ Written by Broytman. Copyright (C) 2010 PhiloSoft Design.
+"""
+
+
+import sys
+import httplib
+
+HTTP = httplib.HTTP
+
+class MyHTTP(HTTP):
+ def _setup(self, conn):
+ HTTP._setup(self, conn)
+ self.set_debuglevel(1)
+
+httplib.HTTP = MyHTTP
+
+from bkmk_objects import Bookmark
+from Writers.bkmk_wflad import strftime
+tempfname = "check_url.tmp"
+
+
+def run():
+ print "Broytman check_url, Copyright (C) 2010 PhiloSoft Design"
+
+ if len(sys.argv) < 2:
+ sys.stderr.write("Usage: check_url.py url1 [url2...]\n")
+ sys.exit(1)
+
+ from m_lib.flog import makelog
+ log = makelog("check.log")
+
+ from robots import robot
+ robot = robot(tempfname, log)
+
+ for url in sys.argv[1:]:
+ bookmark = Bookmark(href=url, add_date=None)
+ bookmark.parent = None
+
+ rcode = robot.check_url(bookmark)
+ print "check_url: %s" % rcode
+
+ if hasattr(bookmark, 'error'):
+ print bookmark.error
+
+ else:
+ print """\
+URL: %s
+Title: %s
+LastModified: %s
+Icon: %s
+""" % (bookmark.href, getattr(bookmark, 'name', ''), strftime(bookmark.last_modified), bookmark.icon)
+
+ robot.stop()
+ log.close()
+
+
+if __name__ == '__main__':
+ run()