Open handsomeprince opened 5 years ago
代码里有呀,demo里这句就是cookie="SESSDATA=abcd68fd...",只要自己登录一下b站查一下SESSDATA然后改一下就OK了。
我考虑过编写登录的代码,但是我们能发现用户登录时需要使用滑动二维码来防止机器人介入。 我现在尚未掌握精准避免验证码的方法,因此在包中没有自动登录的模块,毕竟公司级别的登录检测还是有点水平的。 所以建议你自己从Cookie中读取SESSDATA并输入程序中,该值能在较长的时间中有效,能满足大多数场景的需要。
你好,感谢回复。 我用以下代码,下载bilibili的一个纪录片,设置的是1080p,但是下载的视频并不是1080p。所用的cookie是我从浏览器开发者工具中提取的。我不知道问题出在哪里?cookie貌似没有起作用。请帮我看看,谢谢。
代码如下:
import BiliUtil video_cache = r'F:\Bilibili'
cookie = "SESSDATA=a28e548f%2C1573724459%2C29a7a8a1" if name == 'main':
#设置视频质量限制
quality = [BiliUtil.Config.Quality.V1080P,
BiliUtil.Config.Quality.V1080Px,
BiliUtil.Config.Quality.V1080P60,
BiliUtil.Config.Quality.V720P60,
BiliUtil.Config.Quality.V720P]
#length = [40, 60000000] # 设置视频长度
#ratio = [1, 2] # 设置视频比例,只保留横屏
album = BiliUtil.Album('47665959')
album.sync(cookie=cookie)
#video_filter = BiliUtil.Filter(quality=quality, ratio=ratio)
video_list = album.get_video_list(cookie=cookie)
for v in video_list:
v.sync(cookie=cookie, quality=quality[0])
task = BiliUtil.Task(v,video_cache,name=v.name+str(v.page),cover=None)
task.start(show_process=True, no_repeat=True)
输出为:
C:\Users\Administrator>"D:/Program Files/Python37/python.exe" f:/test/getav2.py
10/18 17:15:39 [NOTICE] Downloading 1 item(s)
10/18 17:15:39 [NOTICE] Allocating disk space. Use --file-allocation=none to disable it. See --file-allocation option in man page for more details. [#49b0f5 96MiB/99MiB(96%) CN:1 DL:6.2MiB] 10/18 17:15:57 [NOTICE] Download complete: F:/Bilibili/决胜荒野 First Man Out 01 泰国丛林1.aac
Download Results: gid |stat|avg speed |path/URI ======+====+===========+======================================================= 49b0f5|OK | 5.7MiB/s|F:/Bilibili/决胜荒野 First Man Out 01 泰国丛林1.aac
Status Legend: (OK):download completed.
10/18 17:15:57 [NOTICE] Downloading 1 item(s)
10/18 17:15:57 [NOTICE] Allocating disk space. Use --file-allocation=none to disable it. See --file-allocation option in man page for more details. [#7180ed 117MiB/121MiB(97%) CN:1 DL:6.0MiB] 10/18 17:16:17 [NOTICE] Download complete: F:/Bilibili/决胜荒野 First Man Out 01 泰国丛林1.flv
Download Results: gid |stat|avg speed |path/URI ======+====+===========+======================================================= 7180ed|OK | 6.0MiB/s|F:/Bilibili/决胜荒野 First Man Out 01 泰国丛林1.flv
Status Legend: (OK):download completed. ffmpeg version N-92510-gfa08345e88 Copyright (c) 2000-2018 the FFmpeg developers built with gcc 8.2.1 (GCC) 20181017 configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth libavutil 56. 23.101 / 56. 23.101 libavcodec 58. 39.100 / 58. 39.100 libavformat 58. 22.100 / 58. 22.100 libavdevice 58. 6.100 / 58. 6.100 libavfilter 7. 46.100 / 7. 46.100 libswscale 5. 4.100 / 5. 4.100 libswresample 3. 4.100 / 3. 4.100 libpostproc 55. 4.100 / 55. 4.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'F:\Bilibili\鍐宠儨鑽掗噹 First Man Out 01 娉板浗涓涙灄1.flv': Metadata: major_brand : iso5 minor_version : 1 compatible_brands: avc1iso5dsmsmsixdash encoder : Lavf57.71.100 description : Packed by Bilibili XCoder v2.0.2 Duration: 00:43:21.08, start: 0.160000, bitrate: 390 kb/s Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x360, 0 kb/s, 25 fps, 25 tbr, 16k tbn, 50 tbc (default) Metadata: handler_name : VideoHandler Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'F:\Bilibili\鍐宠儨鑽掗噹 First Man Out 01 娉板浗涓涙灄1.aac': Metadata: major_brand : iso5 minor_version : 1 compatible_brands: avc1iso5dsmsmsixdash encoder : Lavf57.71.100 description : Packed by Bilibili XCoder v2.0.2 Duration: 00:43:21.15, start: 0.000000, bitrate: 321 kb/s Stream #1:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 0 kb/s (default) Metadata: handler_name : SoundHandler Output #0, mp4, to 'F:\Bilibili\鍐宠儨鑽掗噹 First Man Out 01 娉板浗涓涙灄1.mp4': Metadata: major_brand : iso5 minor_version : 1 compatible_brands: avc1iso5dsmsmsixdash description : Packed by Bilibili XCoder v2.0.2 encoder : Lavf58.22.100 Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x360, q=2-31, 0 kb/s, 25 fps, 25 tbr, 16k tbn, 16k tbc (default) Metadata: handler_name : VideoHandler Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 0 kb/s (default) Metadata: handler_name : SoundHandler Stream mapping: Stream #0:0 -> #0:0 (copy) Stream #1:0 -> #0:1 (copy) Press [q] to stop, [?] for help frame=65025 fps=55860 q=-1.0 Lsize= 226849kB time=00:43:21.13 bitrate= 714.4kbits/s speed=2.23e+03x video:123342kB audio:101608kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.844043%
代码没有实现用户登录功能,无法下载1080p视频,请加入登陆功能,或者告知如何实现登录,并将保存的cookie在下载视频时传给服务器,或者如何让服务器确认目前处于登录状态