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


Python models.Video类代码示例

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


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


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