本文整理汇总了Python中tumblr.Api.write_regular方法的典型用法代码示例。如果您正苦于以下问题:Python Api.write_regular方法的具体用法?Python Api.write_regular怎么用?Python Api.write_regular使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tumblr.Api
的用法示例。
在下文中一共展示了Api.write_regular方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post_to_tumblr
# 需要导入模块: from tumblr import Api [as 别名]
# 或者: from tumblr.Api import write_regular [as 别名]
def post_to_tumblr(self, title, url):
api = Api(BLOG, USER, PASSWORD)
try:
html = '<img src="%s" alt="%s" />' % (url, title)
api.write_regular(title, html)
except TumblrError, e:
logging.error(e)
示例2: testEdit
# 需要导入模块: from tumblr import Api [as 别名]
# 或者: from tumblr.Api import write_regular [as 别名]
def testEdit(self):
api = Api(BLOG, USER, PASSWORD)
newpost = api.write_regular('title','body')
np = {}
np['post-id'] = newpost['id']
np['regular-body'] = 'edited body'
editedpost = api.write_regular(np)
import pprint
pp = pprint.PrettyPrinter(indent=4)
pp.pprint(newpost)
assert editedpost['regular-body'] == 'body'
示例3: send_message
# 需要导入模块: from tumblr import Api [as 别名]
# 或者: from tumblr.Api import write_regular [as 别名]
def send_message(message):
blog = settings.get('tumblr', 'blog')
email = settings.get('tumblr', 'email')
password = settings.get('tumblr', 'password')
api = Api(blog, email, password)
post = api.write_regular(title=None, body=message)
print post['url']
示例4: testWrite
# 需要导入模块: from tumblr import Api [as 别名]
# 或者: from tumblr.Api import write_regular [as 别名]
def testWrite(self):
api = Api(BLOG, USER, PASSWORD)
newpost = api.write_regular('title','body')
post = api.read(newpost['id'])
assert newpost['id'] == post['id']
newpost = api.write_link('http://www.google.com')
post = api.read(newpost['id'])
assert newpost['id'] == post['id']
newpost = api.write_quote('it was the best of times...')
post = api.read(newpost['id'])
assert newpost['id'] == post['id']
newpost = api.write_conversation('me: wow\nyou: double wow!')
post = api.read(newpost['id'])
assert newpost['id'] == post['id']
newpost = api.write_video('http://www.youtube.com/watch?v=60og9gwKh1o')
post = api.read(newpost['id'])
assert newpost['id'] == post['id']
newpost = api.write_photo('http://www.google.com/intl/en_ALL/images/logo.gif')
post = api.read(newpost['id'])
assert newpost['id'] == post['id']
示例5: tumblr_text
# 需要导入模块: from tumblr import Api [as 别名]
# 或者: from tumblr.Api import write_regular [as 别名]
def tumblr_text(request):
conversation_id = request.POST['conversation_id']
title = request.POST['title']
body = request.POST['body']
# create a dictionary mapping names to random strings so they are unrecognizable but consistent
replacements = generate_replacements()
# strip credit card numbers
credit_pattern = re.compile(r"\d{3,5}\D*\d{3,5}\D*\d{3,5}\D*\d{3,5}")
body = credit_pattern.sub("XXXX-XXXX-XXXX-XXXX", body)
# strip phone numbers
phone_pattern = re.compile(r"(\d{3}\D*)?(\d{3})\D*(\d{4})")
body = phone_pattern.sub("XXX-XXXX", body)
# strip names
#TODO: make sure names.txt is in correct directory relative to server
names_path = os.path.dirname(__file__) + '/../names.txt'
names = open(names_path, 'r')
for name in names:
name = name.rstrip() # remove newline
name_pattern = re.compile(r"\b" + name + r"\b", re.IGNORECASE)
body = name_pattern.sub(replacements[name], body)
tumblr = Api(BLOG,USER,PASSWORD)
post = tumblr.write_regular(title, body)
return HttpResponse(title + "\n" + body)
示例6: Text
# 需要导入模块: from tumblr import Api [as 别名]
# 或者: from tumblr.Api import write_regular [as 别名]
class Text(gui.CeFrame):
def __init__(self, api):
self.api = api
gui.CeFrame.__init__(self, title="Opentumblr CE")
self.l_text = gui.Label(self, "Add a Text Post", align = "center")
self.l_title = gui.Label(self, "Title (optional)")
self.tc_title = gui.Edit(self)
self.l_post = gui.Label(self, "Post")
self.tc_post = gui.Edit(self,multiline = True)
self.b_create = gui.Button(self, "Create Post")
self.b_cancel = gui.Button(self, "Cancel")
self.b_create.bind(clicked = self.OnCreatePost)
self.b_cancel.bind(clicked = self.OnCancel)
self.__set_properties()
self.__do_layout()
def __set_properties(self):
pass
def __do_layout(self):
s_text = gui.VBox(border = (5,5,5,5), spacing = 5)
s_text.add(self.l_text)
s_text.add(self.l_title)
s_text.add(self.tc_title)
s_text.add(self.l_post)
s_text.add(self.tc_post)
s_text.add(self.b_create)
s_text.add(self.b_cancel)
self.sizer = s_text
def OnCreatePost(self, evt):
self.title = self.tc_title.get_text()
self.body = self.tc_post.get_text()
if self.body:
self.api = Api(self.api.name, self.api.email, self.api.password)
try:
self.post = self.api.write_regular(self.title, self.body)
except:
print "Posteado en el primario"
self.close()
else:
gui.Message.ok(title = 'Warning', caption = 'Post is required')
def OnCancel(self, evt):
self.close()
#if __name__ == '__main__':
# app = gui.Application(Text())
# app.run()
示例7: Api
# 需要导入模块: from tumblr import Api [as 别名]
# 或者: from tumblr.Api import write_regular [as 别名]
#!/usr/bin/env python
from tumblr import Api
import feedparser
BLOG='YOU.tumblr.com'
USER='YOUREMAIL'
PASSWORD='YOURPASSWORD'
api = Api(BLOG,USER,PASSWORD)
d = feedparser.parse('http://feeds.weatherbug.com/rss.aspx?zipcode=27702&feed=curr&zcode=z4641')
for e in d.entries:
api.write_regular(e.title,e.summary)
示例8: len
# 需要导入模块: from tumblr import Api [as 别名]
# 或者: from tumblr.Api import write_regular [as 别名]
#!/usr/bin/env python
from tumblr import Api
import sys
BLOG='YOU.tumblr.com'
USER='YOUREMAIL'
PASSWORD='YOURPASSWORD'
if len(sys.argv) != 3:
print "Usage: tumbl <title> <body>"
sys.exit(-1)
title = sys.argv[1]
body = sys.argv[2]
api = Api(BLOG,USER,PASSWORD)
post = api.write_regular(title,body)
print "Published: ", post['url']
示例9: Api
# 需要导入模块: from tumblr import Api [as 别名]
# 或者: from tumblr.Api import write_regular [as 别名]
from tumblr import Api
import sys, random
from enpersonator import Enpersonator
BLOG='soniayuditskaya.tumblr.com'
USER='[email protected]'
PASSWORD='graphicdesign'
api = Api(BLOG,USER,PASSWORD)
enp = Enpersonator()
lines = []
title = enp.generateLine(2, 8)
for i in range(random.randint(3, 12)):
lines.append(enp.generateLine(random.randint(2, 3), random.randint(50, 300)))
postBody = "\n\n".join(lines)
print "TITLE: ",title, "\n"
print postBody
post = api.write_regular(title, postBody)
print "Published: ", post['url']
示例10: upload_image_to_picasaweb
# 需要导入模块: from tumblr import Api [as 别名]
# 或者: from tumblr.Api import write_regular [as 别名]
if imgsrc.startswith('/') or imgsrc.startswith('resolveuid') or imgsrc.startswith('..') or imgsrc.startswith('/photo-album') or imgsrc.startswith('/images') or imgsrc.startswith('http://kokorice.org'):
# Download the image & upload to picasaweb
oldsrc = 'http://kokorice.org/'+imgsrc
print "Downloading %s ..." % oldsrc
downloadedimg = TMPDIR+slug+str(imgidx)
content = subprocess.Popen(["wget",
oldsrc,
"--output-document="+downloadedimg],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE).communicate()[0]
print "Downloaded %s" % downloadedimg
image = upload_image_to_picasaweb(gd_client, downloadedimg, entry.title+' '+str(imgidx), album)
if image:
print "Uploaded image to %s" % image.content.src
# rewrite out the img src attributes
imgtag.set('src', image.content.src)
print "Rewrote IMG src attribute to %s" % imgtag.get('src')
processedimg = True
imgidx = imgidx+1
if processedimg:
entrysummary = tostring(etsummary)
else:
entrysummary = entry.summary
entrytags = '"%s"' % '","'.join(entrytags)
importedpost = api.write_regular(entry.title, entrysummary, date=entry.date, tags=entrytags, slug=slug)
print "Imported blog entry here: %s" % importedpost['url-with-slug']
print "-------------------------"
if len(unprocessedimgs) > 0:
print "The following images couldn't be uploaded to picasaweb:\n"
for unprocessedimg in unprocessedimgs:
print "%s : %s\n" % (unprocessedimg[0], unprocessedimg[1])
示例11: testDelete
# 需要导入模块: from tumblr import Api [as 别名]
# 或者: from tumblr.Api import write_regular [as 别名]
def testDelete(self):
api = Api(BLOG, USER, PASSWORD)
newpost = api.write_regular('title','body')
post = api.read(newpost['id'])
api.delete(post['id'])