コード例 #1
0
def play(play_id):
    play_list = PlayList.select().where(PlayList.id == play_id).first()

    videos = Video.select().where(Video.play_list_id == play_id)
    video_dict = models_to_dict(videos)
    client = Bilibili()
    for video in video_dict:
        file = Bilibili.download_path + '/' + play_list.title + "/" + video[
            'title'] + '.mp4'

        if video['size'] == 0:
            html = client.get_response_by_cid(video['cid'])
            if 'durl' in html.keys() and len(html['durl']) == 1:
                # 如果只有一个链接,则表示单视频
                print(html['durl'][0])
                Video.update(size=html['durl'][0]['size']).where(
                    Video.cid == video['cid']).execute()
            print(html)

        if os.path.exists(file) is True:
            video['file_size'] = os.path.getsize(file)
        else:
            video['file_size'] = 0
    return render_template("play.html", play=play_list, videos=video_dict)
コード例 #2
0
ファイル: views.py プロジェクト: sargerasy/vuuvv_old_one
def nav(request):
	data = {"nav": models_to_dict(Menu.objects.all())}

	return HttpResponse(json.dumps(data))
コード例 #3
0
ファイル: views.py プロジェクト: sargerasy/vuuvv_old_one
def appdata(request):
	data = {"appdata": {
		"menus": models_to_dict(Nav.objects.all()),
	}}

	return HttpResponse(json.dumps(data))
コード例 #4
0
def index():
    return render_template('play_list.html',
                           list=models_to_dict(PlayList.select()))