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


Python Video.select方法代码示例

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


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

示例1: searchVideos

# 需要导入模块: from models import Video [as 别名]
# 或者: from models.Video import select [as 别名]
def searchVideos():
    videos = []
    #Subject.name ** ('%' + keyword + '%'),
    myDB.connect()
    try:
        record = json.loads(request.data)
        labels = record['labels']
        labelArray = []
        for record in labels:
            oneLabel = Label.select().where((Label.category == record['name'])
                               & (Label.label == record['value'])).get()
            #commaLabelIds = commaLabelIds + str(oneLabel.labelId) + ','
            labelArray.append(str(oneLabel.labelId))

        labelArray.sort()
        csvLabels = ",".join([str(x) for x in labelArray])

        #for record in Video.select().where(Video.status == 'N').get():
        for record in Video.select().where(Video.labelIds % ('%' + csvLabels + '%')):
            videos.append({'videoId':record.videoId, 'fileName':record.fileName,
                       'folderName':record.folderName, 'boxLink':record.boxLink})
        #print videos
    except Exception as e:
        myDB.close()
        print e
        return 'Search Videos Error', 404
    if len(videos) == 0:
        return 'No Videos'
    return jsonify(data=videos)
开发者ID:schiluka,项目名称:vmedia-heroku,代码行数:31,代码来源:app.py

示例2: saveVideo

# 需要导入模块: from models import Video [as 别名]
# 或者: from models.Video import select [as 别名]
def saveVideo():
    #Saving Video#
    print 'saveVideo called'
    try:
        myDB.connect()
        record = json.loads(request.data)
        #Get all the label ids here#
        labels = record['labels']
        videoId = record['videoId']
        labelArray = []
        #for k,v in sorted(label,key=itemgetter('year')):
        #    print k, v
        for record in labels:
            oneLabel = Label.select().where((Label.category == record['name'])
                               & (Label.label == record['value'])).get()
            #commaLabelIds = commaLabelIds + str(oneLabel.labelId) + ','
            labelArray.append(str(oneLabel.labelId))

        video = Video.select().where(Video.videoId == videoId).get()
        labelArray.sort()
        csvLabels = ",".join([str(x) for x in labelArray])
        video.labelIds = csvLabels   #commaLabelIds[:-1]
        video.status = 'Y'
        video.save()
        myDB.close()
    except Exception as e:
        myDB.close()
        traceback.print_exc(file=sys.stdout)
        return 'Save Video Error', 404
    return 'Video/Labels saved'
开发者ID:schiluka,项目名称:vmedia-heroku,代码行数:32,代码来源:app.py


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