예제 #1
0
 def new_tie(self, tieba_name, title, content, image_file=None, vedio=None, smiley=None):    
     params = {}
     vcode_ret = self.check_need_vcode(tieba_name)
     
     if vcode_ret is not None:
         code = raw_input("vcode save to %s > " % vcode_ret[0]).strip()
         params.update({"vcode" : code, "vcode_md5" : vcode_ret[1]})
         
     pic_dict = None
     params.update({"kw" : tieba_name, "ie" : "utf-8", "rich_text" : 1, "floor_num" : 0,
               "tid" : 0, "fid" : self.get_forum_id(tieba_name), 
               "mouse_pwd_isclick" : 1, "mouse_pwd_t" : utils.timestamp,
               "anonymous" : 0, "tbs" : self.get_common_tbs(), 
               "title" : title})
     
     if image_file is not None:
         pic_ret = self.upload_pic(image_file)
         if pic_ret:
             pic_dict = pic_ret[0]
             params.update({"hasuploadpic": 1, "picsign" : pic_ret[1]})
             
     params.update({"content" : utils.format_content(content, pic_dict, vedio, smiley)})        
     print params
     ret = self.api_request("/f/commit/thread/add", "POST", extra_data=params)
     print ret
예제 #2
0
파일: posterlib.py 프로젝트: vipwp/autotie
    def new_tie(self,
                tieba_name,
                title,
                content,
                image_file=None,
                vedio=None,
                smiley=None):
        params = {}
        vcode_ret = self.check_need_vcode(tieba_name)

        if vcode_ret is not None:
            code = raw_input("vcode save to %s > " % vcode_ret[0]).strip()
            params.update({"vcode": code, "vcode_md5": vcode_ret[1]})

        pic_dict = None
        params.update({
            "kw": tieba_name,
            "ie": "utf-8",
            "rich_text": 1,
            "floor_num": 0,
            "tid": 0,
            "fid": self.get_forum_id(tieba_name),
            "mouse_pwd_isclick": 1,
            "mouse_pwd_t": utils.timestamp,
            "anonymous": 0,
            "tbs": self.get_common_tbs(),
            "title": title
        })

        if image_file is not None:
            pic_ret = self.upload_pic(image_file)
            if pic_ret:
                pic_dict = pic_ret[0]
                params.update({"hasuploadpic": 1, "picsign": pic_ret[1]})

        params.update({
            "content":
            utils.format_content(content, pic_dict, vedio, smiley)
        })
        print params
        ret = self.api_request("/f/commit/thread/add",
                               "POST",
                               extra_data=params)
        print ret
예제 #3
0
파일: tests.py 프로젝트: praekelt/mobileu
 def test_strip_p_tags(self):
     content = "<p><b>Test</b></p>"
     result = format_content(content)
     self.assertEquals(result, "<div><b>Test</b><br/></div>")
예제 #4
0
파일: tests.py 프로젝트: praekelt/mobileu
 def test_filters_empty(self):
     content = ""
     output = format_content(content)
     self.assertEquals(output, u'<div></div>')
예제 #5
0
파일: tests.py 프로젝트: praekelt/mobileu
 def test_format_content_small_image(self):
     content = '<img style="width:60px"/>'
     result = format_content(content)
     self.assertEquals(result, u'<div><img style="width:60px;'
                               u'vertical-align:middle"/></div>')
예제 #6
0
파일: tests.py 프로젝트: praekelt/mobileu
 def test_already_format_content(self):
     content = '<img style="width:100%"/>'
     result = format_content(content)
     self.assertEquals(result, u'<div><img style="width:100%;'
                               u'vertical-align:middle"/></div>')