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.0.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.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nbpl-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 445ac18e708033cc23d126212e2b907d4b78cbac289b0f0c448a5c657da39a8a
MD5 7e5b875e811594636122b152785a23c4
BLAKE2b-256 368d6b83b87abf083f32f5eadac464956d09b7ceb2415eb2e16e2c01ba9f767d

See more details on using hashes here.

Provenance

The following attestation bundles were made for nbpl-0.1.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: nbpl-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f205b5604e2022670d2927bb873af3450bcc5254afaafb1317f346f4dcdc0401
MD5 a7df1f1215cd594fcb9bc3e7fb430418
BLAKE2b-256 36cbdfe8196c1adb1f1a95bad1afde597175894f5b12c92e3041d33027849e02

See more details on using hashes here.

Provenance

The following attestation bundles were made for nbpl-0.1.0-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