def post_new(self, title, content, categories = ['Mac OS X'], individual_tags = '', status = 'private', date = dt.datetime.now()): post = WordPressPost() post.title = title post.description = content tags = 'automatically posted' if (self.additional_tags == '') else self.additional_tags + ', automatically posted' tags = individual_tags + tags post.tags = tags post.date_created = date post.post_status = status post.categories = categories self.__wp.call(NewPost(post, True))
def post_new(self, title, content, categories=['Mac OS X'], individual_tags='', status='private', date=dt.datetime.now()): post = WordPressPost() post.title = title post.description = content tags = 'automatically posted' if ( self.additional_tags == '') else self.additional_tags + ', automatically posted' tags = individual_tags + tags post.tags = tags post.date_created = date post.post_status = status post.categories = categories self.__wp.call(NewPost(post, True))
# -*- coding: utf-8 -*- #depende de https://github.com/maxcutler/python-wordpress-xmlrpc from wordpress_xmlrpc import Client, WordPressPost from wordpress_xmlrpc.methods.posts import GetRecentPosts, NewPost from wordpress_xmlrpc.methods.users import GetUserInfo wp = Client('http://yupana.pontaodaeco.org/xmlrpc.php', 'gesuselva', 'kernelpanic') post = WordPressPost() post.title = 'Que as atuais máquinas informacionais e comunicacionais não se contentem em veicular conteúdos representativos, mas que concorram igualmente para a confecção de novos agenciamentos de enunciação (individuais e/ou coletivos)?' post.description = '<h1></h1><br><p>عبور الحدود aquilo que dissolve no solo e continua a jornada electroquímica dos corpos finalmente será separada daquilo que sempre esteve apenas permeando - <a href=\"https://github.com/glerm/yupana\"/>um dicionário em aglutinação movendo aqueles braços, pernas, cabeça, tripas.</a> esta árvore de sinais, continua se espalhando e entidades que חציית הגבול</p><img src=\"http://upload.wikimedia.org/wikipedia/commons/2/20/Boltzmanns-molecule.jpg\"/>' post.tags = 'yupana, kernel' post.categories = ['coding'] wp.call(NewPost(post, True))
# Get description pattern = r'<div id="showContentText">(.*?)</div>.*?<div id="showContentImageInfo"' body = re.search(pattern, res.text, re.MULTILINE | re.DOTALL).group(1) # Upload image data = { 'name': img_url.split("/")[-1], 'type': 'image/jpg', } data['bits'] = xmlrpc_client.Binary(requests.get(img_url).content) file_res = wp.call(media.UploadFile(data)) # Wordpress post post = WordPressPost() post.title = "dayviews {d}/{m}-{y}".format(d=date.day, m=date.month, y=date.year) post.content = u'<img src="{url}"><br>{body}'.format(url=file_res['url'], body=body) post.date = date post.tags = ['dayviews'] post.post_status = 'publish' wp.call(NewPost(post)) # Get url of next image pattern = r'href="(.*?)" title="Next' next_match = re.search(pattern, res.text) if next_match: next_url = next_match.group(1) i += 1 print i
p_category_id = sermon_vars['post_category_id'] p_tags = sermon_vars['post_tags'] rpc_url = sermon_vars['wp_rpc_url'] username = sermon_vars['wp_username'] password = sermon_vars['wp_password'] wp = Client(rpc_url, username, password) post = WordPressPost() post.title = p_title post.description = p_description post.format = p_format post.categories = p_categories #post.terms = post_category_name post.tags = p_tags print post.title + ": " + post.description + " [posted]" post_id = wp.call(NewPost(post, True)) #podpress: https://wordpress.org/support/topic/xml-rpc-support-1 file_prefix = today.strftime('Hoc4Service%y%b%d_') sermon_file = file_prefix + 'sermon' + '.mp3' file_url = today.strftime('http://hoctoga.org/english/recordings/%Y/' + sermon_file) print file_url fields = {} fields["URI"] = file_url fields["title"] = p_title fields["type"] = sermon_vars['file_type']