• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.Video类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: save_manifest_in_model

def save_manifest_in_model(house_id, m3u8_manifest):
    
    # 
    # Search de Video, if exist return Error
    try:
	video = Video.objects.get(house_id=house_id)
	return False
    except:
	video = Video()
	video.house_id = house_id
	video.format   = 'hls'
	video.save()

    for rendition in m3u8_manifest.files:
	profile = Profile()
	profile.video = video
	profile.bandwidth  	= rendition['bandwidth']
        profile.average    	= rendition['average']
        profile.codecs     	= rendition['codecs']
        profile.resolution 	= rendition['resolution']
        profile.filename   	= rendition['filename']
	profile.version	   	= rendition['rendition'].header['version']
	profile.media_seq  	= rendition['rendition'].header['media_seq']
	profile.allow_cache	= rendition['rendition'].header['allow_cache']
	profile.target_duration = rendition['rendition'].header['target_duration']
	profile.save()
	for tsfile in rendition['rendition'].files:
	    profile_file = ProfileFile()
	    profile_file.profile  = profile
	    profile_file.number   = tsfile['number']
	    profile_file.extinf   = tsfile['extinf']
	    profile_file.filename = tsfile['filename']
	    profile_file.save()

    return True
开发者ID:emilianobilli,项目名称:content-manager,代码行数:35,代码来源:Utils.py


示例2: add_video_to_db

def add_video_to_db(video_url, thumbnail_url, video_type, object_id, username=None):
    if not Video.query.filter(Video.url==video_url).count():
        v = Video(url=video_url, thumbnail=thumbnail_url, video_type=video_type, object_id=object_id)
        if username:
            v.username=username
        db.session.add(v)
        db.session.commit()
开发者ID:Aranjedeath,项目名称:fbackend,代码行数:7,代码来源:video_db.py


示例3: create_or_edit_video

def create_or_edit_video(request, project_slug, video_slug=None):
    project = get_object_or_404(Project, slug=project_slug)
    if video_slug:
        if not project.get_perms(request.user).get("has_member_perm", False):
            request.user.message_set.create(message=NEED_MEMBER_PERM)
            
        else:
            video = get_object_or_404(Video, slug=video_slug, project=project)
            if request.method == "POST" and  "update" in request.POST:
                video.sync_with_yt()
                video.save()
                request.user.message_set.create(message="Video infromation was updated.")
            else:
                request.user.message_set.create(message="Invalid data.")
        return HttpResponseRedirect(video.get_absolute_url())
    else:
        action = "Add new Video"
        form_class = forms.VideoCreationForm
        video = Video(project=project, added_by=request.user)
    
    if request.method == 'POST':
        form = form_class(data=request.POST, instance=video)
        form.project = project
        if form.is_valid():
            video = form.save()
            return HttpResponseRedirect(video.get_absolute_url())
            
    else:
        form = form_class(instance=video)
        
    return render_to_response('projects/create_or_edit_video.html', locals(),
                               context_instance=RequestContext(request))            
开发者ID:gdos,项目名称:pygame,代码行数:32,代码来源:views.py


示例4: new_video

def new_video():
    form = VideoForm()
    if form.validate_on_submit():
        now = moment.now().format('dddd, MMMM D YYYY')
        today = Day.query.filter_by(date=now).first()
        if today is not None:
            video = Video(title=form.title.data,description=form.description.data,video_link=form.video_link.data,day_id=today.id)
            db.session.add(video)
            db.session.flush()
            video.generate_hash()
            video.generate_thumbnail(app.config["UPLOAD_FOLDER"], form.thumbnail.data, app.config["ALLOWED_EXTENSIONS"])
            db.session.add(video)
            db.session.commit()
            flash("Video Successfully Added")
            return redirect(url_for("index"))
        else:
            day = Day(date=now)
            db.session.add(day)
            db.session.flush()
            video = Video(title=form.title.data,description=form.description.data,video_link=form.video_link.data,day_id=day.id)
            db.session.add(video)
            db.session.flush()
            video.generate_hash()
            video.generate_thumbnail(app.config["UPLOAD_FOLDER"], form.thumbnail.data, app.config["ALLOWED_EXTENSIONS"])
            db.session.add(video)
            db.session.commit()
            flash("Video Successfully Added")
            return redirect(url_for("index"))
    return render_template("videos/new.html",form=form)
开发者ID:ErikCruz,项目名称:OnSmash,代码行数:29,代码来源:views.py


示例5: test_parse_video

    def test_parse_video(self):

        owner = GroupFactory(remote_id=GROUP_ID)
        album = AlbumFactory(remote_id=ALBUM_ID, owner=owner)

        response = '''{"photo_130": "http://cs313422.vk.me/u163668241/video/s_6819a7d1.jpg",
            "repeat": 0,
            "photo_320": "http://cs313422.vk.me/u163668241/video/l_4cc8a38a.jpg",
            "description": "bla bla bla",
            "title": "Эстафета Олимпийского огня «Сочи 2014». Неделя 3-я",
            "can_repost": 1, "views": 928, "album_id": 50850761, "comments": 12, "player": "http://www.youtube.com/embed/UmDAmM53bU0", "date": 1386074580, "likes": {"count": 191, "user_likes": 0}, "duration": 206, "can_comment": 1, "id": 166742757, "owner_id": -16297716}
        '''
        d = json.loads(response)

        instance = Video()
        instance.parse(d.copy())
        instance.save()

        self.assertEqual(instance.album, album)
        self.assertEqual(instance.owner, owner)

        self.assertEqual(instance.remote_id, d['id'])
        self.assertEqual(instance.title, d['title'])
        self.assertEqual(instance.description, d['description'])
        self.assertEqual(instance.photo_130, d['photo_130'])
        self.assertEqual(instance.player, d['player'])
        self.assertEqual(instance.views_count, d['views'])
        self.assertEqual(instance.comments_count, d['comments'])
        self.assertEqual(instance.likes_count, d['likes']['count'])
        self.assertEqual(instance.duration, d['duration'])

        self.assertIsNotNone(instance.date)
开发者ID:Andertaker,项目名称:django-vkontakte-video,代码行数:32,代码来源:tests.py


示例6: test_model_video_url

    def test_model_video_url(self):
        video = Video(title="I is title",description="i is desc")
        video.video_h264 = "h264.mp4"
        video.video_webm = "webm.webm"
        video.save()

        self.assertEqual("/media/episode-%s/%s" % (video.id, "h264.mp4"), video.h264)
        self.assertEqual("/media/episode-%s/%s" % (video.id, "webm.webm"), video.webm)
开发者ID:destos,项目名称:godjango-site,代码行数:8,代码来源:tests.py


示例7: test_video_slugify_on_save

    def test_video_slugify_on_save(self):
        video = Video()
        video.title = "I am an awesome title"
        video.description = "I am a description"

        video.save()

        self.assertEqual("i-am-an-awesome-title", video.slug)
开发者ID:abdelhai,项目名称:godjango-site,代码行数:8,代码来源:tests.py


示例8: add_to_db

def add_to_db(video_files):
    for video_file in video_files:
        video_filename = video_file.rsplit('/', 1)[1] # Get filename
        
        if not Video.objects.filter(filename=video_filename).exists():
            video = Video(title=os.path.splitext(video_filename)[0], \
                          filename=video_filename, \
                          fspath=video_file, \
                          media_url=MEDIA_URL + video_file.split(MEDIA_ROOT)[1])
            video.save()
            print 'Added to DB: ' + video_filename
开发者ID:thecosmicfrog,项目名称:media-thingy,代码行数:11,代码来源:__init__.py


示例9: process_play_complete

    def process_play_complete(self, timestamp):
       next_video = None

       if self.force_play_id:
           print "force video lined up"
           next_video = Video.objects(id = self.force_play_id)   
           self.force_play_id = None

       if not next_video:
           print "get next video based on timestamp"
           next_video = Video.objects(created_at__gt=timestamp)

       if next_video:
           self.play_async(next_video[0]['video_url'], next_video[0]['created_at'])
开发者ID:innosam,项目名称:raspberry-play,代码行数:14,代码来源:player.py


示例10: generate_view

def generate_view(request):

    bilibili_url = request.GET.get('url','') 
    aid = get_aid(bilibili_url)
    
    if not aid:
        sys.exit()
    data_dict = view_data(aid)
    error = data_dict.get('error','')

    if error:
#        remove the data which have problem
        print '@253', error
        return HttpResponse('finished')

    cid,pages = data_dict['cid'],int(data_dict['pages'])

#    source_json = get_video_source(cid)
    video_list = Video.objects.filter(aid = aid)
    
    if len(video_list) == 0:
        v = Video(aid=aid)
        v.title = data_dict['title']
        v.pic_url = data_dict['pic']
        v.save()
    else:
        v = video_list[0]
    

    for i in range(1,pages+1):
        time.sleep(5)
        data_dict = view_data(aid,i)
        
        cid = data_dict['cid']
        partname = data_dict['partname']
        video_title = data_dict['title']
        video_path = video_title

        source_json = get_video_source(cid)

        title = data_dict['partname']
        if not title:
            title = data_dict['title']
        code,path = get_video(source_json,'%s' % (title))
        
        if code == 0 and path: 
            save_part(data_dict,v,path)

    return HttpResponse('finished')
开发者ID:lpj0017,项目名称:b-tv,代码行数:49,代码来源:utils.py


示例11: video_title_dicts

def video_title_dicts():
    return map(lambda video: {
        "title": video.title,
        "key": str(video.key()),
        "ka_url": video.relative_url, # remove once js clients update
        "url": video.relative_url
    }, [v for v in Video.get_all_live() if v is not None])
开发者ID:KhanWorld,项目名称:KhanAcademy,代码行数:7,代码来源:autocomplete.py


示例12: get

 def get(self, id=1):
   video = Video.get(id)
   debug = str(video)
   render_template(self, 'video.html', {
     'video': video,
     'debug': debug,
   })
开发者ID:jibberia,项目名称:jibberia-code,代码行数:7,代码来源:main.py


示例13: library_content_html

def library_content_html(mobile=False, version_number=None):

    if version_number:
        version = TopicVersion.get_by_number(version_number)
    else:
        version = TopicVersion.get_default_version()

    tree = Topic.get_root(version).make_tree(types = ["Topics", "Video", "Exercise", "Url"])

    videos = [item for item in walk_children(tree) if item.kind()=="Video"]

    root, = prepare(tree)
    topics = root.subtopics

    timestamp = time.time()

    template_values = {
        'topics': topics,
        'is_mobile': mobile,
        # convert timestamp to a nice integer for the JS
        'timestamp': int(round(timestamp * 1000)),
        'version_date': str(version.made_default_on),
        'version_id': version.number,
        'approx_vid_count': Video.approx_count(),
        'exercise_count': Exercise.get_count(),
    }

    html = shared_jinja.get().render_template("library_content_template.html", **template_values)

    return html
开发者ID:di445,项目名称:server,代码行数:30,代码来源:library.py


示例14: saveVideo

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,代码行数:30,代码来源:app.py


示例15: searchVideos

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,代码行数:29,代码来源:app.py


示例16: video_title_dicts

def video_title_dicts():
    live_video_dict = {}
    for video_playlist in VideoPlaylist.all().filter('live_association = ', True):
        live_video_dict[VideoPlaylist.video.get_value_for_datastore(video_playlist)] = True

    live_videos = filter(lambda video: video.key() in live_video_dict, Video.all())
    return map(lambda video: {"title": video.title, "url": "/video/%s" % video.readable_id}, live_videos)
开发者ID:adamwulf,项目名称:old-khan,代码行数:7,代码来源:autocomplete.py


示例17: test_derive_key_name_from_video

 def test_derive_key_name_from_video(self):
     self._set_responses_xrange(BATCH_SIZE)
     _task_handler('UUID')
     videos = Video.all().fetch(BATCH_SIZE)
     for v in videos:
         key = VideoSubtitles.get_key_name('en', v.youtube_id)
         subs = VideoSubtitles.get_by_key_name(key)
         self.assertIsNotNone(subs)
开发者ID:di445,项目名称:server,代码行数:8,代码来源:__init___test.py


示例18: post

 def post(self, id):
   video = Video.get(id)
   
   author = cgi.escape(self.request.get('author'))
   text = cgi.escape(self.request.get('text'))
   
   comment = Comment(video=video, author=author, text=text)
   comment.save()
   self.redirect('/video/%s' % id)
开发者ID:jibberia,项目名称:jibberia-code,代码行数:9,代码来源:main.py


示例19: _process_fullcopy

def _process_fullcopy(key):

    # Set the content-type correctly
    bucket = helper.get_bucket()
    k = bucket.lookup(key)
    k.copy(k.bucket, k.name, preserve_acl=True, metadata={'Content-Type': helper.get_mimetype(k.name)})

    orig_video = Video(key=key, status='downloading')
    db.add(orig_video)
    db.commit()
    url = helper.get_s3url(key)
    orig_path = download_url(url)

    orig_video.update(get_video_attrs(orig_path))
    orig_video.status = 'done'

    for preset in FFMPEG_PRESETS.iterkeys():

        # Transcode/Upload based on ffmpeg preset
        iphone_path = os.path.splitext(orig_path)[0] + preset
        iphone_video = Video(key=os.path.basename(iphone_path), status='transcoding')
        db.add(iphone_video)
        db.commit()

        try:
            make_iphone(orig_path, iphone_path, preset)
            iphone_video.update(get_video_attrs(iphone_path))
        except:
            iphone_video.status = 'transcoding error'
        else:
            iphone_video.status = 'uploading'

        db.commit()

        if iphone_video.status == 'uploading':
            upload_to_s3(iphone_path)
            iphone_video.status = 'done'
            db.commit()
            os.remove(iphone_path)

    os.remove(orig_path)
开发者ID:reidransom,项目名称:reid-uploader,代码行数:41,代码来源:worker.py


示例20: cm_PostCuePoint

def cm_PostCuePoint(request):
    if request.method == 'GET':
        return TemplateResponse(request, 'cue_manager.html')

    if request.method != 'POST':
        status = http_METHOD_NOT_ALLOWED
        return HttpResponse('', status=status)

    if 'house_id' in request.POST.keys():
        house_id = request.POST['house_id']
    else:
       status = http_BAD_REQUEST
       return HttpResponse('', status=status)

    if house_id == '':
        status = http_BAD_REQUEST
        return HttpResponse('', status=status)

    languages = Language.objects.all()

    for key, value  in request.POST.iteritems():
        if key.endswith('_tc') and value != '':
            i, t = key.split('_')
            for lang in languages:
                lang_key = '%s_%s' % (i, lang.code)
                if lang_key in request.POST.keys() and request.POST[lang_key] != '':
                    try:
                        video = Video.objects.get(house_id = house_id)
                    except:
                        video = Video()
                        video.house_id = house_id
                        video.save()
                    cuepoint          = CuePoint()
                    cuepoint.video    = video
                    cuepoint.timecode = value
                    cuepoint.language = lang
                    cuepoint.name     = request.POST[lang_key]
                    cuepoint.save()

    status = http_POST_OK
    return TemplateResponse(request, 'cue_manager.html')
开发者ID:emilianobilli,项目名称:content-manager,代码行数:41,代码来源:views.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Vote类代码示例发布时间:2022-05-27
下一篇:
Python models.Usuario类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap