Skip to content

Commit

Permalink
Version 1.6.11
Browse files Browse the repository at this point in the history
# CLI Fixes
- When invoked directly (i.e. called with `pyncm`), undesired output is no longer produed
- Fixes k-v extraction error introduced by the last commit somehow
  • Loading branch information
mos9527 committed Sep 15, 2023
1 parent 7fd6a92 commit 2117d23
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion demos/歌单同步.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def normalize(path):
argv.append("--no-overwrite")
# 不覆写已存在歌曲
# argv 传参,调用 __main__ 即可
queuedTasks, failed_ids = __main__()
queuedTasks, failed_ids = __main__(return_tasks=True)
# 无视拓展名的文件白名单
file_tree_whitelist = [normalize(task.save_as) for task in queuedTasks]
# 只删除这些拓展名的文件
Expand Down
2 changes: 1 addition & 1 deletion pyncm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"""
__VERSION_MAJOR__ = 1
__VERSION_MINOR__ = 6
__VERSION_PATCH__ = 10
__VERSION_PATCH__ = 11

__version__ = '%s.%s.%s' % (__VERSION_MAJOR__,__VERSION_MINOR__,__VERSION_PATCH__)

Expand Down
9 changes: 6 additions & 3 deletions pyncm/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ def execute(task: BaseKeyValueClass):
apiCall = track.GetTrackAudioV1 if not task.routine.args.use_download_api else track.GetTrackDownloadURLV1
if task.routine.args.use_download_api: logger.warning("使用下载 API,可能消耗 VIP 下载额度!")
dAudio = apiCall(task.audio.id, level=task.audio.level)
assert "data" in dAudio, "其他错误: %s" % dAudio
assert "data" in dAudio, "其他错误: %s" % dAudio
dAudio = dAudio['data']
if type(dAudio) == list:
dAudio = dAudio[0]
if not dAudio['url']:
Expand Down Expand Up @@ -629,7 +630,7 @@ def print_help_and_exit():
assert args.save, "无效分享链接 %s" % ' '.join(args.url) # Allow invalid links for this one
return args , []

def __main__():
def __main__(return_tasks=False):
args , tasks = parse_args()
log_stream = sys.stdout
# Getting tqdm & logger to work nicely together
Expand Down Expand Up @@ -764,7 +765,9 @@ def report():
report()
logger.info(f'任务完成率 {(executor.finished_tasks * 100 / max(1,len(queuedTasks))):.1f}%')
# To get actually downloaded tasks, filter by exlcuding failed_ids against task.song.ID
return queuedTasks, failed_ids
if return_tasks:
return queuedTasks, failed_ids
return


if __name__ == "__main__":
Expand Down

0 comments on commit 2117d23

Please sign in to comment.