
Untitled
By: a guest on
May 25th, 2012 | syntax:
None | size: 1.36 KB | hits: 9 | expires: Never
# Modify this configs with your credentials. See requirements.txt for required packages
DB_PATH = '/path/to/memonic.db'
ZT_USER = 'user'
ZT_PASS = 'pass'
ZT_API_KEY = '8e3f989331c3d687a75b96d9e5505008'
from pyzootool import controller
import sqlite3
zoocontrol = controller.ZooControl(apikey=ZT_API_KEY, username=ZT_USER, password=ZT_PASS)
try:
conn = sqlite3.connect(DB_PATH)
except Exception:
print 'Can\'t open sqlite DB (%s)' % DB_PATH
exit(1)
ci = conn.cursor()
cu = conn.cursor()
ct = conn.cursor()
ci.execute('select * from item')
count = 0
for item in ci:
title = item[2].encode('ascii', 'ignore')
# get the link
cu.execute('select * from itemdata where item = "%s"' % item[0])
for data in cu:
if data[1] == 'source':
url = data[2].encode('ascii', 'ignore')
# get the tags
ct.execute('select tag.title from tag inner join tag_item on tag.id = tag_item.tag where tag_item.item = "%s"' % item[0])
tags = ['memonic_import']
for tag in ct:
tags.append(tag[0].encode('ascii', 'ignore'))
print '%u: %s - %s, %s' % (count, title, url, ', '.join(tags))
try:
i = zoocontrol.item.add_item(url=url, title=title, tags=', '.join(tags))
except Exception:
print 'Wrong username/password, probably. :)'
exit(1)
count += 1
print '%u items imported from Memonic' % count