예제 #1
0
def convert(mtfile, urlbase, forum):
    entries = mt.parse_export(mtfile)

    disqus = Disqus()
    for e in entries:
        if "comment" in e:
            for c in e["comment"]:
                url = make_url(urlbase, e)
                title = e["metadata"]["title"]

                thread = disqus.get_thread_by_url(forum, url)
                if not thread:
                    thread = disqus.thread_by_identifier(forum, title, title)
                disqus.update_thread(forum, thread["id"], title=title, slug=e["metadata"]["basename"], url=url)

                disqus.create_post(
                    forum,
                    thread["id"],
                    c["data"],
                    c["author"],
                    c.get("email", "anonymous"),
                    c.get("url"),
                    c["ip"],
                    c["date"],
                )
예제 #2
0
def post(comfile, urlbase, forum):
    disqus = Disqus()
    comments = json.loads(open(comfile).read())

    for comment in comments:
	url = '%s/%s/%s/' % \
	    (urlbase, comment['post']['date'], comment['post']['slug'])
	title = comment['post']['title']
        date = datetime.strptime(comment["date"],
				 "%Y-%m-%dT%H:%M:%S")
        
	thread = disqus.get_thread_by_url(forum, url)
	if not thread:
	    thread = disqus.thread_by_identifier(forum, title, title)
	disqus.update_thread(forum, thread['id'], 
			     title=title,
			     slug=comment['post']['slug'],
			     url=url)
		
	disqus.create_post(forum, thread['id'], comment['body'],
			   comment['author'], comment['email'],
			   comment.get('url'), comment['ip'], date)