当前位置: 首页>>代码示例>>Python>>正文


Python WordPressPost.post_type方法代码示例

本文整理汇总了Python中wordpress_xmlrpc.WordPressPost.post_type方法的典型用法代码示例。如果您正苦于以下问题:Python WordPressPost.post_type方法的具体用法?Python WordPressPost.post_type怎么用?Python WordPressPost.post_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wordpress_xmlrpc.WordPressPost的用法示例。


在下文中一共展示了WordPressPost.post_type方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: process_comment

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import post_type [as 别名]
def process_comment(wp, video_id, parent_post_id, comment):
    post = WordPressPost()
    post.title = comment['text'][6:50]
    post.content = get_post_content(video_id,comment)
    post.post_type = 'video-highlight'
    post.post_status = 'publish'
    post.parent_id = parent_post_id
    #logger.info("Created post with ID [%s]", wp.call(NewPost(post)))
    print "Created post with ID [%s]" % wp.call(NewPost(post))
开发者ID:kalsop,项目名称:Vimeo-video-comments-to-Wordpress-post,代码行数:11,代码来源:vimeo_wp.py

示例2: testUpdate

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import post_type [as 别名]
def testUpdate(pid):
    client = initClient()
    post = WordPressPost()
    post.title = 'My new title update 2'
    post.content = 'This is the body of my new post.'
    post.slug= 'helloword'
    post.post_type = 'post'
    post.post_status = 'draft'
    print client.call(posts.EditPost(pid, post))
开发者ID:tl3shi,项目名称:markdown2wordpress,代码行数:11,代码来源:md2wp.py

示例3: sourcename

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import post_type [as 别名]
def sourcename(url, cat1=None, cat2=None, cat3=None, d=True):
    html = getPage(url, "page1.html")
    os.remove('pages/page1.html')
    title = html.select('h1')[0].text
    first_para = html.select('.story-content > p:nth-of-type(1)')[0].text
    second_para = html.select('.story-content > p:nth-of-type(2)')[0].text
    try:
        image = html.select('.image > img')[0].get('src')
    except Exception:
        image = None
    wp = Client('http://www.domain.com/xml-rpc.php', 'username', 'password')
    if image:
        filename = 'http://www.livemint.com' + image
        path = os.getcwd() + "\\00000001.jpg"
        f = open(path, 'wb')
        f.write(urllib.urlopen(filename).read())
        f.close()
        # prepare metadata
        data = {
            'name': 'picture.jpeg',
            'type': 'image/jpeg',  # mimetype
        }

        with open(path, 'rb') as img:
            data['bits'] = xmlrpc_client.Binary(img.read())
        response = wp.call(media.UploadFile(data))
    post = WordPressPost()
    post.title = title
    post.user = 14
    post.post_type = "post"
    post.content = first_para + '\n' + '\n' + second_para
    if d:
        post.post_status = "draft"
    else:
        post.post_status = "publish"
    if image:
        attachment_id = response['id']
        post.thumbnail = attachment_id
    post.custom_fields = []
    post.custom_fields.append({
        'key': 'custom_source_url',
        'value': url
    })
    if cat1:
        cat1 = wp.call(taxonomies.GetTerm('category', cat1))
        post.terms.append(cat1)
    if cat2:
        cat2 = wp.call(taxonomies.GetTerm('category', cat2))
        post.terms.append(cat2)
    if cat3:
        cat3 = wp.call(taxonomies.GetTerm('category', cat3))
        post.terms.append(cat3)
    addpost = wp.call(posts.NewPost(post))
开发者ID:trujunzhang,项目名称:djzhang-targets,代码行数:55,代码来源:sample_code.py

示例4: create_new_empty_wp_post

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import post_type [as 别名]
def create_new_empty_wp_post(component, event_category, event_map_location, location_gps):

    summary = component.get('SUMMARY').encode('UTF-8', 'backslashreplace')
    start_event = component.get('DTSTART').dt.strftime('%Y-%m-%d %H:%M')
    end_event = component.get('DTEND').dt.strftime('%Y-%m-%d %H:%M')
    end_frequency_event = component.get('DTEND').dt.strftime('%Y-%m-%d')
    uid = component.get('UID').encode('UTF-8', 'backslashreplace')
    event_description = component.get('DESCRIPTION')
    if event_description is None:
        event_description = " "
    else:
        event_description = component.get('DESCRIPTION').encode('UTF-8', 'backslashreplace')

    # Create a new post
    new_post = WordPressPost()
    new_post.title = summary
    new_post.content = event_description
    new_post.post_type = "event"
    new_post.post_status = "publish"
    new_post.terms_names = {'event-category': [event_category]}
    new_post.custom_fields = []

    meta_adds = (['imic_event_start_dt', start_event],
                 ['imic_event_end_dt', end_event],
                 ['imic_event_frequency_end', end_frequency_event],
                 ['imic_featured_event', 'no'],
                 ['slide_template', 'default'],
                 ['imic_event_day_month', 'first'],
                 ['imic_event_week_day', 'sunday'],
                 ['imic_event_frequency_type', '0'],
                 ['imic_event_frequency', '35'],
                 ['imic_event_registration', '0'],
                 ['imic_custom_event_registration_target', '0'],
                 ['imic_sidebar_columns_layout', '3'],
                 ['imic_google_map_track', '1'],
                 ['imic_event_address2', event_map_location],
                 ['imic_event_map_location', location_gps],
                 ['imic_pages_banner_overlay', '0'],
                 ['imic_pages_banner_animation', '0'],
                 ['imic_pages_select_revolution_from_list', '[rev_slider fsl]'],
                 ['imic_pages_slider_pagination', 'no'],
                 ['imic_pages_slider_auto_slide', 'no'],
                 ['imic_pages_slider_direction_arrows', 'no'],
                 ['imic_pages_slider_interval', '7000'],
                 ['imic_pages_slider_effects', 'fade'],
                 ['imic_pages_nivo_effects', 'sliceDown'],
                 ['imic_import_uid', uid])

    # Iterate over array creating meta in post
    for i in meta_adds:
        new_post.custom_fields.append({'key': i[0], 'value': i[1]})

    return new_post
开发者ID:abjectio,项目名称:wp-labora-py,代码行数:55,代码来源:wputil.py

示例5: _create_wp_post

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import post_type [as 别名]
def _create_wp_post(song, content):
    # Create the NewPost object - see docs at
    # http://python-wordpress-xmlrpc.readthedocs.io/en/latest/ref/wordpress.html
    # We're missing some fields but ehhhh who knows if they even exist anymore
    post = WordPressPost()
    post.title = str(song)
    post.content = content
    post.comment_status = 'open'
    post.ping_status = 'closed'
    post.post_status = 'publish'
    post.post_type = 'post'
    post.excerpt = song.tagline
    post.date = datetime.now(tz=timezone.utc)
    post.date_modified = datetime.now(tz=timezone.utc)

    return NewPost(post)
开发者ID:katstevens,项目名称:jukebox-tnj,代码行数:18,代码来源:views.py

示例6: parseDocument

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import post_type [as 别名]
def parseDocument(filename):
    lines = open(filename, 'r').readlines()
    values = {'title':'', 'permalink':'', 'layout':'post', 'tags':'', 'categories':'default', 'published': 'false'}
    start = False
    config = False
    for i in range(len(lines)):
        line = lines[i].strip()
        if config == False:
            if line == '---':
                if (start == False):
                    start = True
                else: # end
                    if (values['title'] == '' or values['permalink'] == ''):
                        printf('title and permalink should not be null!\n'); exit()
                    else:# config ok 
                        config = True
            else:
                try:
                    key = line[:line.find(':')]
                    value = line[line.find(':')+1:]
                    values[key] = value.strip()
                except:
                    printf('config failed! (key, value) = (' + key + ', ' + value + ')\n');exit()
        else: #config ok
            while len(lines[i]) <= 1: #filter first blank lines
                i+=1
            rawcontent = parseMedia(lines[i:])
            rawfilename = filename[:-3] + '.raw.id-'
            open(rawfilename, 'w').writelines(rawcontent)
            post = WordPressPost()
            post.title = values['title']
            post.slug = values['permalink']
            post.content = pandocTool.md2html(rawfilename)
            post.post_type = values['layout']
            post.post_status = 'publish' if values['published'].lower() == 'true' else 'draft'
            post.comment_status = 'open' #default
            post.pint_status = 'open' #default
            post.terms_names = {}
            #values['tags'] = values['tags'].replace(',', ',') compatible with jekyll, use blank
            #values['categories'] = values['categories'].replace(',', ',')
            if len(values['tags']) > 0:
                post.terms_names['post_tag'] = [ tag.strip() for tag in values['tags'].split() if len(tag) > 0] 
            if len(values['categories']) > 0:
                post.terms_names['category'] = [ cate.strip() for cate in values['categories'].split() if len(cate) > 0] 
            return post
开发者ID:tl3shi,项目名称:markdown2wordpress,代码行数:47,代码来源:md2wp.py

示例7: post_to_wordpress

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import post_type [as 别名]
    def post_to_wordpress(
        self,
        title,
        content,
        detail_url,
        image_upload_id,
        retry,
        ):
        
        # now post the post and the image
        post = WordPressPost()
        post.post_type = 'portfolio'
        post.title = title
        post.content = content
        post.post_status = 'publish'
        post.thumbnail = image_upload_id

        if self.wp.call(NewPost(post)):
            return True
开发者ID:basilleaf,项目名称:marsfromspace,代码行数:21,代码来源:publish.py

示例8: add_or_edit_wp_post

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import post_type [as 别名]
def add_or_edit_wp_post(title, content, slug, more_info_url, local_img_file):

    # first upload the image
    if local_img_file:
        data = {
            'name': local_img_file.split('/')[-1],
            'type': 'image/jpg',  # mimetype
        }

        # read the binary file and let the XMLRPC library encode it into base64
        with open(local_img_file, 'rb') as img:
            data['bits'] = xmlrpc_client.Binary(img.read())
        response = wp.call(media.UploadFile(data))
        attachment_id = response['id']

    # now post the post and the image
    post = WordPressPost()
    post.post_type = 'post'  # stupid effing theme
    post.title = title
    post.content = content
    post.post_status = 'publish'
    post.slug = slug

    if local_img_file:
        post.thumbnail = attachment_id

    if not get_wp_post_id(slug):
        # this is a new post
        wp.call(NewPost(post))
        msg = "posted"

    else:
        # this post exists, update it
        post.id = get_wp_post_id(slug)
        wp.call(EditPost(post.id, post))
        msg = "edited"

    print "%s %s as %s" % (msg, title, post.slug)
开发者ID:JeffAMcGee,项目名称:exofranck,代码行数:40,代码来源:wp_post.py

示例9: upload_post

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import post_type [as 别名]
def upload_post(auth, **args):
    wp = Client(auth['site'], auth['user'], auth['pass'])

    post = WordPressPost()

    post.post_type = args.get('type', None)
    post.title = args.get('title', None)
    post.content = args.get('content', None)
    post.date = gen_datetime(args['date'], args.get('date-format', None),
                             args.get('zone', 0))

    terms = {key: [value] for key, value in args.get('terms', {}).items()}
    post.terms_names = terms

    if args.get('path', None) is not None:
        post.custom_fields = [{'key': 'enclosure',
                               'value': upload_media(args['path'], wp)
                               }]

    if args.get('publish', False):
        post.post_status = 'publish'

    post.id = wp.call(posts.NewPost(post))
开发者ID:noahmorrison,项目名称:wmup,代码行数:25,代码来源:upload.py

示例10: _post_newpost_to_wordpress

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import post_type [as 别名]
    def _post_newpost_to_wordpress(self, item, attachment_id):
        post = WordPressPost()
        post.title = item['title']
        post.content = item['content']
        post.post_type = "post"
        post.post_status = "publish"
        post.terms_names = {
            'post_tag': item['tags'],
            'category': [item['url_from']]
        }
        post.custom_fields = []
        post.custom_fields.append({
            'key': 'custom_source_url',
            'value': item['url']
        })
        # cat1 = self.wp.call(taxonomies.GetTerm('category', 'wanghao'))
        # post.terms.append(cat1)

        if attachment_id:
            post.thumbnail = attachment_id

        addpost = self.wp.call(posts.NewPost(post))

        return addpost
开发者ID:trujunzhang,项目名称:djzhang-targets,代码行数:26,代码来源:wordpress_xml_rpc_utils.py

示例11: exit

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import post_type [as 别名]
        exit()
    c = ''
    if os.path.isfile('pages/'+filename):
        print("Loading the data via the file.")
        f = open('pages/'+filename, 'r')
        c = f.read()
    else:
        print("Fetching the data via the URL.")
        result = requests.get(url)
        c = result.content
        f = open('pages/'+filename,'w')
        f.write(c)
    f.close()
    c = BeautifulSoup(c)
    return c

html = getPage("http://news.ycombinator.com/", "page1.html")

rows = html.select('#hnmain > tr:nth-of-type(3) > td > table > tr');

for row in rows:
    if row.select('.title'):
        link = row.select('td:nth-of-type(3) a')
        print link[0].text
        post = WordPressPost()
        post.title = link[0].text
        post.post_type = "post"
        post.content = link[0].get('href')
        post.post_status = "publish"
        addpost = client.call(posts.NewPost(post))
开发者ID:Mixanologos,项目名称:Simple-Python-WordPress-Scraper,代码行数:32,代码来源:scraper.py


注:本文中的wordpress_xmlrpc.WordPressPost.post_type方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。