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


Python Video.title方法代码示例

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


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

示例1: post

# 需要导入模块: from models import Video [as 别名]
# 或者: from models.Video import title [as 别名]
    def post(self):
        parse_args = video_parser.parse_args()

        new_video = Video()
        new_video.title = parse_args['title']
        new_video.type = 'LIVE'
        new_video.status = 'EMPTY'
        new_video.created_at = datetime.now()
        new_video.segment_count = -1
        new_video.segment_duration = 3000
        new_video.repr_1 = Reprs.HIGH
        new_video.repr_2 = Reprs.MEDIUM
        new_video.repr_3 = Reprs.LOW
        new_video.uri_mpd = None
        new_video.uri_m3u8 = None

        try:
            session.add(new_video)
            session.commit()

        except:
            session.rollback()
            raise

        return new_video, 201
开发者ID:tonylpt,项目名称:NUS-VideoStreaming-Server-Flask,代码行数:27,代码来源:resources.py

示例2: test_video_slugify_on_save

# 需要导入模块: from models import Video [as 别名]
# 或者: from models.Video import title [as 别名]
    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,代码行数:10,代码来源:tests.py

示例3: generate_view

# 需要导入模块: from models import Video [as 别名]
# 或者: from models.Video import title [as 别名]
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,代码行数:51,代码来源:utils.py

示例4: test_model_fields

# 需要导入模块: from models import Video [as 别名]
# 或者: from models.Video import title [as 别名]
    def test_model_fields(self):
        video = Video()
        video.title = "The Title"
        video.slug = "the-title"
        video.thumbnail_image = "thumbnail.jpg"
        video.preview_image = "preview.jpg"
        video.description = "long description here"
        video.show_notes = "show notes here"
        video.video_h264 = "video.mp4"
        video.video_webm = "video.webm"
        video.length = 12
        video.episode = 1
        video.publish_date = now()
        video.is_premium = False
        video.price = 105.00

        video.save()
        self.assertEqual(video, Video.objects.get(title__exact="The Title"))
开发者ID:abdelhai,项目名称:godjango-site,代码行数:20,代码来源:tests.py

示例5: updateVideoAndPlaylistData

# 需要导入模块: from models import Video [as 别名]
# 或者: from models.Video import title [as 别名]
    def updateVideoAndPlaylistData(self):
        yt_service = gdata.youtube.service.YouTubeService()

        # Now that we run these queries from the App Engine servers, we need to 
        # explicitly specify our developer_key to avoid being lumped together w/ rest of GAE and
        # throttled by YouTube's "Too many request" quota
        yt_service.developer_key = "AI39si6ctKTnSR_Vx7o7GpkpeSZAKa6xjbZz6WySzTvKVYRDAO7NHBVwofphk82oP-OSUwIZd0pOJyNuWK8bbOlqzJc9OFozrQ"
        yt_service.client_id = "n/a"

        video_youtube_id_dict = Video.get_dict(Video.all(), lambda video: video.youtube_id)
        video_playlist_key_dict = VideoPlaylist.get_key_dict(VideoPlaylist.all())

        association_generation = int(Setting.last_youtube_sync_generation_start())

        logging.info("Fetching playlists")
        playlist_start_index = 1
        playlist_feed = yt_service.GetYouTubePlaylistFeed(uri='http://gdata.youtube.com/feeds/api/users/KhanAcademyHebrew/playlists?start-index=%s&max-results=50' % playlist_start_index)

        while len(playlist_feed.entry) > 0:

            for playlist in playlist_feed.entry:
                logging.info("Playlist: %s", playlist.id.text)

                playlist_id = playlist.id.text.replace('http://gdata.youtube.com/feeds/api/users/KhanAcademyHebrew/playlists/', '')
                playlist_uri = playlist.id.text.replace('users/KhanAcademyHebrew/', '')
                query = Playlist.all()
                query.filter('youtube_id =', playlist_id)
                playlist_data = query.get()
                if not playlist_data:
                    playlist_data = Playlist(youtube_id=playlist_id)
                    logging.info('Creating Playlist: %s', playlist.title.text)
                playlist_data.url = playlist_uri
                playlist_data.title = playlist.title.text.decode("utf-8")
                playlist_data.description = playlist.description.text.decode("utf-8")

                playlist_data.tags = []
                for category in playlist.category:
                    if "tags.cat" in category.scheme:
                        playlist_data.tags.append(category.term)

                playlist_data.put()
                
                for i in range(0, 10):
                    start_index = i * 50 + 1
                    video_feed = yt_service.GetYouTubePlaylistVideoFeed(uri=playlist_uri + '?start-index=' + str(start_index) + '&max-results=50')
                    video_data_list = []

                    if len(video_feed.entry) <= 0:
                        # No more videos in playlist
                        break

                    for video in video_feed.entry:
                        if not video.media.player:
                            logging.warning("Could not parse video - skipping... (%s, %s)", video, video.media)
                            continue

                        video_id = cgi.parse_qs(urlparse(video.media.player.url).query)['v'][0].decode('utf-8')

                        video_data = None
                        if video_youtube_id_dict.has_key(video_id):
                            video_data = video_youtube_id_dict[video_id]
                            logging.info('Found Video: %s (%s)', video.media.title.text.decode('utf-8'), video_id)
                        
                        if not video_data:
                            video_data = Video(youtube_id=video_id)
                            logging.info('Creating Video: %s (%s)', video.media.title.text.decode('utf-8'), video_id)

                        video_data.title = video.media.title.text.decode('utf-8')
                        video_data.url = video.media.player.url.decode('utf-8')
                        video_data.duration = int(video.media.duration.seconds)

                        if video.statistics:
                            video_data.views = int(video.statistics.view_count)

                        if video.media.description.text is not None:
                            video_data.description = video.media.description.text.decode('utf-8')
                        else:
                            video_data.decription = ' '

                        if video.media.keywords.text:
                            video_data.keywords = video.media.keywords.text.decode('utf-8')
                        else:
                            video_data.keywords = ''

                        video_data.position = video.position
                        video_data_list.append(video_data)
                    db.put(video_data_list)

                    playlist_videos = []
                    for video_data in video_data_list:                
                        playlist_video = None
                        if video_playlist_key_dict.has_key(playlist_data.key()):
                            if video_playlist_key_dict[playlist_data.key()].has_key(video_data.key()):
                                playlist_video = video_playlist_key_dict[playlist_data.key()][video_data.key()]

                        if not playlist_video:
                            playlist_video = VideoPlaylist(playlist=playlist_data.key(), video=video_data.key())
                            logging.info('Creating VideoPlaylist: %s, %s', playlist_data.title, video_data.title)
                        else:
                            logging.info('Updating VideoPlaylist: %s, %s', playlist_video.playlist.title, playlist_video.video.title)
#.........这里部分代码省略.........
开发者ID:johnfelipe,项目名称:server,代码行数:103,代码来源:youtube_sync.py

示例6: updateVideoAndPlaylistData

# 需要导入模块: from models import Video [as 别名]
# 或者: from models.Video import title [as 别名]
    def updateVideoAndPlaylistData(self):
        yt_service = YouTubeService()

        video_youtube_id_dict = Video.get_dict(Video.all(), lambda video: video.youtube_id)
        video_playlist_key_dict = VideoPlaylist.get_key_dict(VideoPlaylist.all())

        association_generation = int(Setting.last_youtube_sync_generation_start())

        logging.info("Fetching playlists")
        playlist_start_index = 1
        playlist_feed = yt_service.GetYouTubePlaylistFeed(
            uri="http://gdata.youtube.com/feeds/api/users/KhanAcademyHebrew/playlists?start-index=%s&max-results=50"
            % playlist_start_index
        )

        while len(playlist_feed.entry) > 0:

            for playlist in playlist_feed.entry:
                logging.info("Playlist: %s", playlist.id.text)

                playlist_id = playlist.id.text.replace(
                    "http://gdata.youtube.com/feeds/api/users/KhanAcademyHebrew/playlists/", ""
                )
                playlist_uri = playlist.id.text.replace("users/KhanAcademyHebrew/", "")
                query = Playlist.all()
                query.filter("youtube_id =", playlist_id)
                playlist_data = query.get()
                if not playlist_data:
                    playlist_data = Playlist(youtube_id=playlist_id)
                    logging.info("Creating Playlist: %s", playlist.title.text)
                playlist_data.url = playlist_uri
                playlist_data.title = playlist.title.text.decode("utf-8")
                playlist_data.description = playlist.description.text.decode("utf-8")

                playlist_data.tags = []
                for category in playlist.category:
                    if "tags.cat" in category.scheme:
                        playlist_data.tags.append(category.term)

                playlist_data.put()

                for i in range(0, 10):
                    start_index = i * 50 + 1
                    video_feed = yt_service.GetYouTubePlaylistVideoFeed(
                        uri=playlist_uri + "?start-index=" + str(start_index) + "&max-results=50"
                    )
                    video_data_list = []

                    if len(video_feed.entry) <= 0:
                        # No more videos in playlist
                        break

                    for video in video_feed.entry:
                        if not video.media.player:
                            logging.warning("Could not parse video - skipping... (%s, %s)", video, video.media)
                            continue

                        video_id = cgi.parse_qs(urlparse(video.media.player.url).query)["v"][0].decode("utf-8")

                        video_data = None
                        if video_youtube_id_dict.has_key(video_id):
                            video_data = video_youtube_id_dict[video_id]
                            logging.info("Found Video: %s (%s)", video.media.title.text.decode("utf-8"), video_id)

                        if not video_data:
                            video_data = Video(youtube_id=video_id)
                            logging.info("Creating Video: %s (%s)", video.media.title.text.decode("utf-8"), video_id)

                        video_data.title = video.media.title.text.decode("utf-8")
                        video_data.url = video.media.player.url.decode("utf-8")
                        video_data.duration = int(video.media.duration.seconds)

                        if video.statistics:
                            video_data.views = int(video.statistics.view_count)

                        if video.media.description.text is not None:
                            video_data.description = video.media.description.text.decode("utf-8")
                        else:
                            video_data.decription = " "

                        if video.media.keywords.text:
                            video_data.keywords = video.media.keywords.text.decode("utf-8")
                        else:
                            video_data.keywords = ""

                        video_data.position = video.position
                        video_data_list.append(video_data)
                    db.put(video_data_list)

                    playlist_videos = []
                    for video_data in video_data_list:
                        playlist_video = None
                        if video_playlist_key_dict.has_key(playlist_data.key()):
                            if video_playlist_key_dict[playlist_data.key()].has_key(video_data.key()):
                                playlist_video = video_playlist_key_dict[playlist_data.key()][video_data.key()]

                        if not playlist_video:
                            playlist_video = VideoPlaylist(playlist=playlist_data.key(), video=video_data.key())
                            logging.info("Creating VideoPlaylist: %s, %s", playlist_data.title, video_data.title)
                        else:
#.........这里部分代码省略.........
开发者ID:hebkhan,项目名称:server,代码行数:103,代码来源:youtube_sync.py


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