Skip to content

Commit

Permalink
Fetch_all quality BUG
Browse files Browse the repository at this point in the history
Update code and doc
  • Loading branch information
bolinzhang committed Oct 15, 2019
1 parent 1fd926c commit 351b072
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions BiliUtil/Video/fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ def __init__(self, obj):
self.task_list = None
self.exist_list = None

def fetch_all(self, cookie=None, name_pattern=Util.Config.SET_AS_CODE):
def fetch_all(self, cookie=None, name_pattern=Util.Config.SET_AS_CODE, quality=None):
"""
自动获取用户与频道名下的所有视频信息
:param cookie: 权限信息
:param quality: 下载视频质量
:param name_pattern: 路径命名方式
:return: 所有视频的av号列表
"""
Expand Down Expand Up @@ -47,8 +48,8 @@ def fetch_all(self, cookie=None, name_pattern=Util.Config.SET_AS_CODE):

video_list = album.get_video_list()
for video in video_list:
video.sync(cookie, quality)
if name_pattern == Util.Config.SET_AS_NAME:
video.sync(cookie)
video_name = Util.legalize_name(video.name)
else:
video_name = video.aid
Expand All @@ -74,7 +75,7 @@ def load_task(self, output, exclude=None, v_filter=None):
:param v_filter:
:return: 下载列表中视频av号
"""
task_id = []
task_list = []
self.task_list = []
base_path = os.path.abspath(output)
exclude = [str(item) for item in exclude]
Expand All @@ -91,10 +92,10 @@ def load_task(self, output, exclude=None, v_filter=None):
full_path = '{}/{}/{}'.format(base_path, info['obj_name'], info['album_name'])
self.task_list.append(Video.Task(info['video'], full_path,
info['video_name'], info['album'].cover))
task_id.append(info['album'].aid)
task_list.append(info['album'].aid)

task_id = list(set(task_id))
return task_id
task_list = list(set(task_list))
return task_list

def load_exist(self, output):
"""
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -401,11 +401,11 @@ video_info = video.sync(

你可以使用用户类或频道类来初始化一个抓取器对象实例,不建议开发者操作实例中的对象数据。

#### 5.2、`fetch_all(cookie=None, name_pattern=SET_AS_CODE)`
#### 5.2、`fetch_all(cookie=None, name_pattern=SET_AS_CODE, quality=None)`

请在初始化之后使用该函数获取对象名下所有的视频列表,并储存在对象内部变量中,为后续操作提供数据。

当初始化对象为用户类时,将自动获取用户名下的所有视频。当初始化对象为频道类时,将自动获取该频道中的所有视频。当文件命名[命名方式](#config)为以名字命名时(`SET_AS_NAME`),程序将自动调用视频对象的`sync()`函数获取该视频的名称。
当初始化对象为用户类时,将自动获取用户名下的所有视频。当初始化对象为频道类时,将自动获取该频道中的所有视频。当文件命名[命名方式](#config)为以名字命名时(`SET_AS_NAME`),程序将自动调用视频对象的`sync()`函数获取该视频的名称。你还可以传入视频质量的枚举以调整视频的最高质量,若无该参数则按照最高视频质量下载。

#### 5.3、`load_exist(ouput)`

Expand Down

0 comments on commit 351b072

Please sign in to comment.