示例#1
0
    def post(self):
        title = unicode(self.request.get('title')).strip()
        abs = unicode(self.request.get('abs')).strip()
        tags = unicode(self.request.get('tags')).strip()
        classify = int(self.request.get('classify'))
        usr = users.get_current_user()
        if title and abs and usr:
            art = Article(key_name=MukioTools.rndvid(5),
                          author=usr,
                          title=title,
                          abs=abs,
                          classify=classify,
                          tags=tags.split())
            if art:
                art.put()

        self.redirect('/addvideo/' + art.key().name() + '/')
示例#2
0
  def post(self):
    title = unicode(self.request.get('title')).strip()
    abs = unicode(self.request.get('abs')).strip()
    tags = unicode(self.request.get('tags')).strip()
    classify = int(self.request.get('classify'))
    usr = users.get_current_user()
    if title and abs and usr:
      art = Article(key_name=MukioTools.rndvid(5),
                    author=usr,
                    title=title,
                    abs=abs,
                    classify=classify,
                    tags=tags.split()
                    )
      if art:
        art.put()

    self.redirect('/addvideo/' + art.key().name() +'/')
示例#3
0
    def post(self):
        parttitle = unicode(self.request.get('parttitle')).strip()
        #vid = unicode(self.request.get('vid')).strip()
        fileurl = unicode(self.request.get('fileurl')).strip()
        typ = unicode(self.request.get('typ')).strip()
        artkeystr = unicode(self.request.get('articleId')).strip()
        artkey = db.Key(artkeystr)
        if not artkey:
            self.redirect('/')

        art = Article.get(artkey)
        usr = users.get_current_user()
        if art.author == usr:
            self.redirect('/')

        if typ == 'bokecc':

            reg = re.compile(r'http://.*vid=([^&]+)', re.I)
            res = reg.findall(fileurl)

            if len(res) == 1:
                vid = res[0]
            else:
                vid = fileurl

            fileurl = ''
            keyname = 'vid' + vid

        elif typ == 'sina' or typ == 'youku' or typ == '6room' or typ == 'qq':
            vid = fileurl
            fileurl = ''
            keyname = 'vid' + vid

        elif typ == 'video':
            vid = ''
            keyname = MukioTools.rndvid(4)

        else:
            self.error(404)
        '''typ = 'sina'
    if not vid:
      typ = 'video'
      if not fileurl:
        typ = 'none'

    if typ == 'none':
      self.redirect('/')
    else:
      if typ == 'sina':
        keyname = 'vid' + vid
      else:
        reg = re.compile(r'vid=([^&]+)',re.I)
        res = reg.findall(fileurl)
        if len(res) == 1:
          typ = 'bokecc'
          vid = res[0]
          keyname = 'vid' + res[0]
        else:
          keyname = MukioTools.rndvid(4)'''

        video = Video(key_name=keyname,
                      typ=typ,
                      vid=vid,
                      fileurl=fileurl,
                      parttitle=parttitle,
                      art=artkey)
        if video:
            video.put()
            self.redirect('/addvideo/' + artkey.name() + '/')
        else:
            self.redirect('/')
示例#4
0
    def compareAndUpdate(self, article, videos, oldvideos):
        def addkey(i):
            i.keyname = i.key().name()
            return i

        oldvideos = map(addkey, oldvideos)
        for video in videos:
            # logging.info('video:%r' % video)
            flag = 0
            if video[3] != '0':
                for v in oldvideos:
                    if v.keyname == video[3]:
                        if (v.typ != 'video' and v.typ != 'sound'
                                and v.keyname != video[2] and v.keyname !=
                                'vid' + video[2]) or v.typ != video[1]:
                            MukioTools.delete_video_by_key_name(v.keyname)
                            try:
                                newvideo = Video(key_name='vid' + video[2],
                                                 parttitle=video[0],
                                                 fileurl='',
                                                 vid=video[2],
                                                 typ=video[1],
                                                 art=article.key())
                                newvideo.put()
                            except:
                                logging.info('插入视频失败 %r' % (video))
                        else:
                            v.parttitle = video[0]
                            v.typ = video[1]
                            if v.typ == 'video' or v.typ == 'sound':
                                v.fileurl = video[2]
                                v.vid = ''
                            else:
                                v.fileurl = ''
                                v.vid = video[2]
                            v.postdate = datetime.now()
                            v.put()
                        oldvideos.remove(v)
                        flag = 1
                        break
            if flag != 1:
                # logging.info('new video:%r' % video)
                if video[1] == 'video' or video[1] == 'sound':
                    keyname = MukioTools.rndvid(4)
                    fileurl = video[2]
                    vid = ''
                    # logging.info('new video type video or sound:%r' % video[1])
                else:
                    keyname = 'vid' + video[2]
                    fileurl = ''
                    vid = video[2]
                    # logging.info('new video type not video or sound:%r' % video[1])
                # logging.info('hello')
                # logging.info('%r %r %r %r %r' % (keyname,video[1],vid,fileurl,video[0]))
                try:
                    newvideo = Video(key_name=keyname,
                                     typ=video[1],
                                     vid=vid,
                                     fileurl=fileurl,
                                     parttitle=video[0],
                                     art=article.key())
                    if not newvideo:
                        logging.info('new video Objected failed:%r' % video[1])
                    else:
                        # logging.info('new video Objected success:%r' % video[1])
                        newvideo.put()
                except:
                    logging.info('插入视频失败 %r' % (video))
        for v in oldvideos:
            MukioTools.delete_video_by_key_name(v.keyname)
示例#5
0
  def post(self):
    parttitle = unicode(self.request.get('parttitle')).strip()
    #vid = unicode(self.request.get('vid')).strip()
    fileurl = unicode(self.request.get('fileurl')).strip()
    typ = unicode(self.request.get('typ')).strip()
    artkeystr = unicode(self.request.get('articleId')).strip()
    artkey = db.Key(artkeystr)
    if not artkey:
      self.redirect('/')

    art = Article.get(artkey)
    usr = users.get_current_user()
    if art.author == usr:
      self.redirect('/')

    if typ == 'bokecc':

      reg = re.compile(r'http://.*vid=([^&]+)',re.I)
      res = reg.findall(fileurl)

      if len(res) == 1:
        vid = res[0]
      else:
        vid = fileurl

      fileurl = ''
      keyname = 'vid' + vid

    elif typ == 'sina' or typ == 'youku' or typ == '6room' or typ == 'qq':
      vid = fileurl
      fileurl = ''
      keyname = 'vid' + vid

    elif typ == 'video':
      vid = ''
      keyname = MukioTools.rndvid(4)

    else:
      self.error(404)
      
    '''typ = 'sina'
    if not vid:
      typ = 'video'
      if not fileurl:
        typ = 'none'

    if typ == 'none':
      self.redirect('/')
    else:
      if typ == 'sina':
        keyname = 'vid' + vid
      else:
        reg = re.compile(r'vid=([^&]+)',re.I)
        res = reg.findall(fileurl)
        if len(res) == 1:
          typ = 'bokecc'
          vid = res[0]
          keyname = 'vid' + res[0]
        else:
          keyname = MukioTools.rndvid(4)'''

    video = Video(key_name=keyname,
                  typ=typ,
                  vid=vid,
                  fileurl=fileurl,
                  parttitle=parttitle,
                  art=artkey
                  )
    if video:
      video.put()
      self.redirect('/addvideo/' + artkey.name() + '/')
    else:
      self.redirect('/')
示例#6
0
 def compareAndUpdate(self,article,videos,oldvideos):
   def addkey(i):
     i.keyname = i.key().name()
     return i
   oldvideos = map(addkey,oldvideos)
   for video in videos:
     # logging.info('video:%r' % video)
     flag = 0
     if video[3] != '0':
       for v in oldvideos:
         if v.keyname == video[3]:
           if (v.typ !='video' and v.typ !='sound' and v.keyname != video[2] and v.keyname != 'vid'+video[2]) or v.typ != video[1]:
             MukioTools.delete_video_by_key_name(v.keyname)
             try:
               newvideo = Video(key_name = 'vid'+video[2],
                                parttitle = video[0],
                                fileurl = '',
                                vid = video[2],
                                typ = video[1],
                                art = article.key())
               newvideo.put()
             except:
               logging.info('插入视频失败 %r' % (video))
           else:
             v.parttitle = video[0]
             v.typ = video[1]
             if v.typ == 'video' or v.typ == 'sound':
               v.fileurl = video[2]
               v.vid = ''
             else:
               v.fileurl = ''
               v.vid = video[2]
             v.postdate = datetime.now()
             v.put()
           oldvideos.remove(v)
           flag = 1
           break
     if flag != 1:
       # logging.info('new video:%r' % video)
       if video[1] == 'video' or video[1] == 'sound':
         keyname = MukioTools.rndvid(4)
         fileurl = video[2]
         vid = ''
         # logging.info('new video type video or sound:%r' % video[1])
       else:
         keyname = 'vid'+video[2]
         fileurl = ''
         vid = video[2]
         # logging.info('new video type not video or sound:%r' % video[1])
       # logging.info('hello')
       # logging.info('%r %r %r %r %r' % (keyname,video[1],vid,fileurl,video[0]))
       try:
         newvideo = Video(key_name = keyname,
                          typ = video[1],
                          vid = vid,
                          fileurl = fileurl,
                          parttitle = video[0],
                          art = article.key())
         if not newvideo:
           logging.info('new video Objected failed:%r' % video[1])
         else:
           # logging.info('new video Objected success:%r' % video[1])
           newvideo.put()
       except:
         logging.info('插入视频失败 %r' % (video))
   for v in oldvideos:
     MukioTools.delete_video_by_key_name(v.keyname)