Command line tool to fetch video IDs from a niconico user page.
Fetches video IDs from one or more nicovideo.jp/user/<id> pages, filters them by comment count and date range, sorts the results, and prints them to stdout.
go install github.com/sh4869221b/go-nico-list@latestPrebuilt binaries are available on the GitHub Releases page.
go-nico-list [nicovideo.jp/user/<id>...] [flags]Examples:
go-nico-list nicovideo.jp/user/12345
go-nico-list https://www.nicovideo.jp/user/12345/video --url
go-nico-list nicovideo.jp/user/1 nicovideo.jp/user/2 --concurrency 10
go-nico-list --input-file users.txt
cat users.txt | go-nico-list --stdin- One video ID per line (example:
sm123). - With
--url, each line is prefixed withhttps://www.nicovideo.jp/watch/. - With
--tab, each line is prefixed with tabs. - With
--json, stdout is a single JSON object (line output is disabled).
0: no fetch errors (invalid inputs are skipped; may produce no output).- non-zero: at least one fetch failed (any successfully retrieved IDs are still printed).
- Validation errors (for example,
--concurrency < 1) return non-zero. context.Canceled/context.DeadlineExceededduring fetch is treated as a successful empty result.
| Flag | Description | Default |
|---|---|---|
-c, --comment |
lower comment limit number | 0 |
-a, --dateafter |
date YYYYMMDD after |
10000101 |
-b, --datebefore |
date YYYYMMDD before |
99991231 |
-t, --tab |
id tab separated flag | false |
-u, --url |
output id add url | false |
-n, --concurrency |
number of concurrent requests | 3 |
--rate-limit |
maximum requests per second (0 disables) | 0 |
--min-interval |
minimum interval between requests | 0s |
--max-pages |
maximum number of pages to fetch | 0 |
--max-videos |
maximum number of filtered IDs to collect | 0 |
--timeout |
HTTP client timeout | 10s |
--retries |
number of retries for requests | 10 |
--input-file |
read inputs from file (newline-separated) | "" |
--stdin |
read inputs from stdin (newline-separated) | false |
--logfile |
log output file path | "" |
--progress |
force enable progress output | false |
--no-progress |
disable progress output | false |
--strict |
return non-zero if any input is invalid | false |
--best-effort |
always exit 0 while logging fetch errors | false |
--dedupe |
remove duplicate output IDs before sorting | false |
--json |
emit JSON output to stdout | false |
Notes:
- Inputs can be provided via arguments,
--input-file, and--stdin(newline-separated). - Input lines from
--input-fileand--stdinare limited to 1 MiB per line; longer lines fail with an input read error. - Each input must contain
nicovideo.jp/user/<id>(scheme optional). Plain digits oruser/<id>without the domain are treated as invalid inputs and skipped. - Results are written to stdout; progress and logs are written to stderr. Use
--logfileto redirect logs to a file. - Setting
concurrencyorretriesto a value less than 1, ortimeoutto a value less than or equal to 0, will cause a runtime error. --dateaftermust be on or before--datebefore; inverted ranges return a validation error.--max-pagesand--max-videosare safety caps;0disables them.- When a safety cap is hit, fetching stops early and returns best-effort results without error.
- Responses with HTTP status other than 200/404 after retries are treated as fetch errors.
- HTTP 200 responses with
meta.status != 200are logged as warnings but still processed. - Rate limiting applies globally to all requests (including retries). HTTP 429
Retry-Afteris honored when present. - Progress is auto-disabled when stderr is not a TTY. Use
--progressto force-enable or--no-progressto disable (takes precedence). - A run summary is printed to stderr after processing (even when the exit code is non-zero).
--strictmakes invalid inputs return a non-zero exit code while still outputting valid results.--best-effortforces exit code 0 even when fetch errors occur (errors are still logged).--deduperemoves duplicate video IDs before sorting/output.--jsonemits a single JSON object to stdout.--tab/--urldo not affect JSONitems, and the summary still prints to stderr.- In JSON output,
usersare sorted by numericuser_idin ascending order.
This project separates the CLI layer from the domain logic so each part is easier to test and maintain.
main.go: resolves the version and bootstraps the CLI with a cancellation-aware context.cmd/: Cobra command definitions, flags, and input/output handling (stdout/stderr separation).internal/niconico/: core domain logic (fetching video lists, retries, sorting) and API response types.
- The CLI parses flags and user IDs.
- The command layer calls
internal/niconicoto fetch and filter video IDs. - Results are sorted and printed; progress is written to stderr.
GitHub Actions runs on pull requests to master and pushes to master, and enforces:
- repository ruleset protection on
master(PR-only updates with requiredgo-cistatus checks) - generated file checks (
go mod tidy,go generate ./...,git diff --exit-code) - third-party notice sync (
bash scripts/gen-third-party-notices.sh,git diff --exit-code -- THIRD_PARTY_NOTICES.md) gofmt(format + diff check)go vet ./...go test -count=1 ./...go test -race -count=1 ./...- GitHub Actions references are pinned to commit SHAs in workflow files.
- Integration-style command wiring tests:
cmd/root_test.go(httptest+ stdout/stderr/exit-code checks). - Contract tests:
internal/niconico/nico_data_contract_test.go(fixture decode frominternal/niconico/testdata/). - Fuzz tests:
internal/niconico/fuzz_test.go,cmd/root_fuzz_test.go(sorting/JSON/url-parse panic safety). - E2E tests (opt-in):
internal/niconico/e2e_test.gowith-tags=e2e. - Benchmarks (opt-in):
internal/niconico/benchmark_test.go.
Opt-in commands:
go test ./internal/niconico -run TestNicoDataContract -count=1
go test ./... -run=^$ -fuzz=Fuzz -fuzztime=10s
GO_NICO_LIST_E2E_USER_ID=<user-id> go test -tags=e2e ./internal/niconico -run TestGetVideoListE2E -count=1
go test ./internal/niconico -run=^$ -bench=BenchmarkNiconicoSort -benchmem -count=1See CONTRIBUTING.md.
Releases are published by tagging a version and pushing it to GitHub.
- Create a tag like
vX.Y.Z. - Push the tag to GitHub.
- GitHub Actions runs the release workflow (verifies
go mod tidy/go generate ./..., runs gofmt/go vet/go test/go test -race, and checks third-party notices). - GoReleaser publishes the GitHub Release and uploads artifacts.
- Close the milestone after the release workflow succeeds.
Notes:
- When a versioned milestone is complete, release using the same version number.
- Release tags (
vX.Y.Z) are governed by a repository tag ruleset.