Skip to main content

检测正在运行的 Python 脚本,并按地区打开对应视频。

Project description

nbpl

安装 nbpl 后,不需要在任何脚本中导入它。它会通过 Python 的 sitecustomize 启动钩子,在执行 Python 源文件时自动使用系统默认浏览器打开一个视频:

公网 IP 所在国家/地区代码 打开的链接
CN(中国大陆) https://www.bilibili.com/video/BV1GJ411x7h7
其他代码,或定位失败 https://www.youtube.com/watch?v=dQw4w9WgXcQ

地区查询使用 https://ipapi.co/json/。本包仅会读取进程命令行并发起一次 IP 地理位置查询;不会上传检测到的脚本路径。

安装

pip install nbpl

也可以直接从本仓库安装:

pip install git+https://github.com/hekuo5310/nbpl.git

自动使用

安装后,直接运行任意 Python 文件即可自动触发:

python app.py

如果只想作为独立监控器使用,仍可运行:

nbpl

独立监控器默认每秒检查一次;发现其他 Python 脚本后打开对应链接并退出。修改检查间隔:

nbpl --interval 2

本地测试时可跳过 IP 查询,直接指定地区:

nbpl --country-code CN

临时关闭自动触发

为避免自动打开浏览器,可在运行命令前设置环境变量:

NBPL_DISABLE_AUTO_OPEN=1 python app.py

Windows PowerShell:

$env:NBPL_DISABLE_AUTO_OPEN = "1"; python app.py

Python API

from nbpl import run_once, watch

run_once()  # 仅当已有其他 Python 脚本在运行时才打开链接
watch(interval=1.0)  # 等待脚本出现,打开链接后返回

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nbpl-0.1.1.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nbpl-0.1.1-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file nbpl-0.1.1.tar.gz.

File metadata

  • Download URL: nbpl-0.1.1.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for nbpl-0.1.1.tar.gz
Algorithm Hash digest
SHA256 eeca70a5fe60a4cf79f72892a9153242a030cf94c0726a1aa46b519e651062f5
MD5 c82199de544a82f7a5ef1fd5e60eeb4c
BLAKE2b-256 e7f7dfa20dadedf9b5fadfe2a7cda30ae57116952e62da8c1befa20b6d94520e

See more details on using hashes here.

Provenance

The following attestation bundles were made for nbpl-0.1.1.tar.gz:

Publisher: publish.yml on hekuo5310/nbpl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nbpl-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: nbpl-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for nbpl-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 24f7c916680dc96e30ea12962c0f868f16f861e7d81fb3d5a56bdc088cc29ce6
MD5 8ff3767d8c55d809f4d41d4dbf6844d5
BLAKE2b-256 e83f5887dbda91918508f20d7195ecd418a5884fcceb4b3dbccf351fbc48e20c

See more details on using hashes here.

Provenance

The following attestation bundles were made for nbpl-0.1.1-py3-none-any.whl:

Publisher: publish.yml on hekuo5310/nbpl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page