Exemplo n.º 1
0
def update_youku_online_info(youku_video_id):
    """
    将youku_video_id的本地youku对象的属性,在优酷上进行更新
    注意:无法对视频进行关于playlist的操作
    :param youku_video_id:
    :return:
    """
    youku = Youku.objects.get(youku_video_id=youku_video_id)

    service = YoukuVideos(CLIENT_ID)

    youku_access_token = youku_get_authenticate()

    updated_youku_video_id = service.update_video(
        access_token=youku_access_token,
        video_id=youku_video_id,
        title=youku.title,
        tags=youku.tags,
        category=youku.category,
        copyright_type=None,
        public_type=None,
        watch_password=None,
        description=youku.description,
        thumbnail_seq=None)
    return updated_youku_video_id
Exemplo n.º 2
0
def delete_youku_video(youku_video_id):
    """
    在优酷网上删除youku_video_id的视频,成功的话将数据库youku.youku_video_id清零
    :param youku_video_id:
    :return:
    """
    service = YoukuVideos(CLIENT_ID)
    youku_access_token = youku_get_authenticate()
    delete_youku_video_id = service.destroy_video(
        access_token=youku_access_token, video_id=youku_video_id)

    if delete_youku_video_id == youku_video_id:
        # 在优酷网上成功删除视频后,在本地将youku.youku_video_id清空
        youku = Youku.objects.get(youku_video_id=youku_video_id)
        youku.youku_video_id = ''
        youku.save()
    return delete_youku_video_id
Exemplo n.º 3
0
def get_youku_video_info_view(request, video_id):
    """
    根据优酷的video id,获取优酷网上video视频的相关信息
    :param request:
    :param video_id:
    :return:
    """
    youku_service = YoukuVideos(CLIENT_ID)
    video_info = youku_service.find_video_by_id(video_id)

    published = datetime.strptime(video_info['published'], "%Y-%m-%d %H:%M:%S")
    youku, created = Youku.objects.update_or_create(
        youku_video_id=video_id,
        defaults={
            'title': video_info['title'],
            'tags': video_info['tags'],
            'description': video_info['description'],
            'category': video_info['category'],
            'published': published
        })

    return render_to_response('result.html', {'dict_items': video_info})