Created
August 24, 2024 17:44
-
-
Save okaits/44df2ca21e427b38a202ff98e67ec4aa to your computer and use it in GitHub Desktop.
ニコニコ動画にて、特定の投稿者が投稿した全ての動画をダウンロードするスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
"""ニコニコ動画にて、特定の投稿者が投稿した全ての動画をダウンロードする。 | |
10秒ほど間隔を開けさせています。 | |
CAUTION: 悪用厳禁(無断転載などの、公序良俗に反する行為や法令に違反する行為などのために使用しないこと。) | |
OSSではありません。 | |
""" | |
import time | |
import argparse | |
import nicovideo | |
import nndownload | |
parser = argparse.ArgumentParser(prog="get_all_videos.py", | |
description=__doc__) | |
parser.add_argument("user_id", metavar="USER_ID", help="投稿者のユーザーID") | |
parser.add_argument("--session_token", help="ニコニコのユーザセッショントークン", required=False) | |
args = parser.parse_args() | |
for video in nicovideo.user.get_metadata(user_id=int(args.user_id)).videolist: | |
print(f'Now downloading: "{video.title}"') | |
video_url = f"https://www.nicovideo.jp/watch/{video.nicovideo_id}" | |
if args.session_token: | |
nndownload.execute("--session-cookie",args.session_token, | |
"--add-metadata", video_url) | |
else: | |
nndownload.execute("--no-login", "--add-metadata", video_url) | |
time.sleep(10) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nicovideo.py>=4.1.1 | |
nndownload>=1.18 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment