Name | pywnp JSON |
Version |
2.0.2
JSON |
| download |
home_page | |
Summary | A python library to communicate with the WebNowPlaying-Redux browser extension |
upload_time | 2023-06-10 12:08:05 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.7 |
license | Copyright 2023 keifufu Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
webnowplaying
wnp
youtube
spotify
media
music
|
VCS |
|
bugtrack_url |
|
requirements |
aiohttp
winsdk
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# PyWNP
A Python library to communicate with the [WebNowPlaying-Redux](https://github.com/keifufu/WebNowPlaying-Redux) browser extension.
Refer to [this](https://github.com/keifufu/WebNowPlaying-Redux/blob/main/CreatingAdapters.md) if you want to create or submit your own adapter.
## Installing
Install via pip: `pip install pywnp`
## Native APIs
Built-in support for [Native APIs](https://github.com/keifufu/WebNowPlaying-Redux/blob/main/NativeAPIs.md).
## Usage
```py
from pywnp import WNPRedux
import time
# Custom logger, type can be 'Error', 'Debug' or 'Warning'
def logger(type, message):
print(f'{type}: {message}')
# Start WNP, providing a port, version number and a logger
WNPRedux.start(1234, '1.0.0', logger)
# Write the current title to the console and pause/unpause the video for 30 seconds
for i in range(30):
print(WNPRedux.media_info.title)
# You don't need to check for `supports_play_pause`, but it's good to know about.
if WNPRedux.media_info.controls.supports_play_pause:
WNPRedux.media_info.controls.try_toggle_play_pause()
time.sleep(1)
# Stop WNP
WNPRedux.stop()
```
---
### `WNPRedux.start(port, version, logger, listenAddress = '127.0.0.1')`
Starts WNP if it isn't already started.
`port` should _not_ be used by other adapters already, or interfere with any other programs.
`version` has to be 'x.x.x'.
---
### `WNPRedux.is_started`
Whether WNPRedux is started or not.
---
### `WNPRedux.is_using_native_apis`
Whether WNPRedux is pulling info from native APIs.
This is read-only, the actual value is set by the user.
It's toggled in the browser extensions settings panel.
Read more about it [here](https://github.com/keifufu/WebNowPlaying-Redux/blob/main/NativeAPIs.md).
---
### `WNPRedux.log(type, message)`
Calls the `logger` provided in `WNPRedux.start()`
---
### `WNPRedux.stop()`
Stops WNP if it's started.
---
### `WNPRedux.clients`
Number of clients currently connected.
---
### `WNPRedux.media_info`
Information about the currently active media.
Name | Default | Description
--- | --- | ---
`controls` | '' | Instance of MediaControls (Read below this table)
`player_name` | '' | Current player, e.g. YouTube, Spotify, etc.
`state` | 'STOPPED' | Current state of the player ('STOPPED', 'PLAYING', 'PAUSED')
`title` | '' | Title
`artist` | '' | Artist
`album` | '' | Album
`cover_url` | '' | URL to the cover image
`duration` | '0:00' | Duration in (hh):mm:ss (Hours are optional)
`duration_seconds` | 0 | Duration in seconds
`position` | '0:00' | Position in (hh):mm:ss (Hours are optional)
`position_seconds` | 0 | Position in seconds
`position_percent` | 0.0 | Position in percent
`volume` | 100 | Volume from 1-100
`rating` | 0 | Rating from 0-5; Thumbs Up = 5; Thumbs Down = 1; Unrated = 0;
`repeat_mode` | 'NONE' | Current repeat mode ('NONE', 'ONE', 'ALL')
`shuffle_active` | False | If shuffle is enabled
---
### MediaControls
Used in `WNPRedux.media_info.controls`
Name | Description
--- | ---
`supports_play_pause` | If the current player supports play_pause
`supports_skip_previous` | If the current player supports skip_previous
`supports_skip_next` | If the current player supports skip_next
`supports_set_position` | If the current player supports set_position
`supports_set_volume` | If the current player supports set_volume
`supports_toggle_repeat_mode` | If the current player supports toggle_repeat_mode
`supports_toggle_shuffle_active` | If the current player supports toggle_shuffle_active
`supports_set_rating` | If the current player supports set_rating
`rating_system` | 'NONE' or 'LIKE_DISLIKE' or 'LIKE' or 'SCALE' (SCALE is 0-5)
`try_play()` | Tries to play the current media
`try_pause()` | Tries to pause the current media
`try_toggle_play_pause()` | Tries to play/pause the current media
`try_skip_previous()` | Try to skip to the previous media/section
`try_skip_next()` | Try to skip to the next media/section
`try_set_position_seconds(seconds)` | Try to set the medias playback progress in seconds
`try_revert_position_seconds(seconds)` | Try to revert the medias playback progress by x seconds
`try_forward_position_seconds(seconds)` | Try to forward the medias playback progress by x seconds
`try_set_position_percent(percent)` | Try to set the medias playback progress in percent
`try_revert_position_percent(percent)` | Try to revert the medias playback progress by x percent
`try_forward_position_percent(percent)` | Try to forward the medias playback progress by x percent
`try_set_volume(volume)` | Try to set the medias volume from 1-100
`try_toggle_repeat_mode()` | Try to toggle through repeat modes
`try_toggle_shuffle_active()` | Try to toggle shuffle mode
`try_set_rating(rating)` | Sites with a binary rating system fall back to: 0 = None; 1 = Thumbs Down; 5 = Thumbs Up
Raw data
{
"_id": null,
"home_page": "",
"name": "pywnp",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "webnowplaying,wnp,youtube,spotify,media,music",
"author": "",
"author_email": "keifufu <pypi@keifufu.dev>",
"download_url": "https://files.pythonhosted.org/packages/ae/b2/4ffdc787489a2967a6456735134d1129b77adad0685f171de6dbda06c14b/pywnp-2.0.2.tar.gz",
"platform": null,
"description": "# PyWNP\r\nA Python library to communicate with the [WebNowPlaying-Redux](https://github.com/keifufu/WebNowPlaying-Redux) browser extension.\r\n\r\nRefer to [this](https://github.com/keifufu/WebNowPlaying-Redux/blob/main/CreatingAdapters.md) if you want to create or submit your own adapter.\r\n\r\n## Installing\r\nInstall via pip: `pip install pywnp`\r\n\r\n## Native APIs\r\nBuilt-in support for [Native APIs](https://github.com/keifufu/WebNowPlaying-Redux/blob/main/NativeAPIs.md).\r\n\r\n## Usage\r\n```py\r\nfrom pywnp import WNPRedux\r\nimport time\r\n\r\n# Custom logger, type can be 'Error', 'Debug' or 'Warning'\r\ndef logger(type, message):\r\n print(f'{type}: {message}')\r\n\r\n# Start WNP, providing a port, version number and a logger\r\nWNPRedux.start(1234, '1.0.0', logger)\r\n\r\n# Write the current title to the console and pause/unpause the video for 30 seconds\r\nfor i in range(30):\r\n print(WNPRedux.media_info.title)\r\n # You don't need to check for `supports_play_pause`, but it's good to know about.\r\n if WNPRedux.media_info.controls.supports_play_pause:\r\n WNPRedux.media_info.controls.try_toggle_play_pause()\r\n time.sleep(1)\r\n\r\n# Stop WNP\r\nWNPRedux.stop()\r\n```\r\n\r\n---\r\n### `WNPRedux.start(port, version, logger, listenAddress = '127.0.0.1')`\r\nStarts WNP if it isn't already started. \r\n`port` should _not_ be used by other adapters already, or interfere with any other programs. \r\n`version` has to be 'x.x.x'.\r\n\r\n---\r\n### `WNPRedux.is_started`\r\nWhether WNPRedux is started or not.\r\n\r\n---\r\n### `WNPRedux.is_using_native_apis`\r\nWhether WNPRedux is pulling info from native APIs. \r\nThis is read-only, the actual value is set by the user. \r\nIt's toggled in the browser extensions settings panel. \r\nRead more about it [here](https://github.com/keifufu/WebNowPlaying-Redux/blob/main/NativeAPIs.md).\r\n\r\n---\r\n### `WNPRedux.log(type, message)`\r\nCalls the `logger` provided in `WNPRedux.start()` \r\n\r\n---\r\n### `WNPRedux.stop()`\r\nStops WNP if it's started.\r\n\r\n---\r\n### `WNPRedux.clients`\r\nNumber of clients currently connected.\r\n\r\n---\r\n### `WNPRedux.media_info`\r\nInformation about the currently active media.\r\nName | Default | Description\r\n--- | --- | ---\r\n`controls` | '' | Instance of MediaControls (Read below this table)\r\n`player_name` | '' | Current player, e.g. YouTube, Spotify, etc.\r\n`state` | 'STOPPED' | Current state of the player ('STOPPED', 'PLAYING', 'PAUSED') \r\n`title` | '' | Title\r\n`artist` | '' | Artist\r\n`album` | '' | Album\r\n`cover_url` | '' | URL to the cover image\r\n`duration` | '0:00' | Duration in (hh):mm:ss (Hours are optional)\r\n`duration_seconds` | 0 | Duration in seconds\r\n`position` | '0:00' | Position in (hh):mm:ss (Hours are optional)\r\n`position_seconds` | 0 | Position in seconds\r\n`position_percent` | 0.0 | Position in percent\r\n`volume` | 100 | Volume from 1-100\r\n`rating` | 0 | Rating from 0-5; Thumbs Up = 5; Thumbs Down = 1; Unrated = 0;\r\n`repeat_mode` | 'NONE' | Current repeat mode ('NONE', 'ONE', 'ALL')\r\n`shuffle_active` | False | If shuffle is enabled\r\n\r\n---\r\n### MediaControls\r\nUsed in `WNPRedux.media_info.controls`\r\nName | Description\r\n--- | ---\r\n`supports_play_pause` | If the current player supports play_pause\r\n`supports_skip_previous` | If the current player supports skip_previous\r\n`supports_skip_next` | If the current player supports skip_next\r\n`supports_set_position` | If the current player supports set_position\r\n`supports_set_volume` | If the current player supports set_volume\r\n`supports_toggle_repeat_mode` | If the current player supports toggle_repeat_mode\r\n`supports_toggle_shuffle_active` | If the current player supports toggle_shuffle_active\r\n`supports_set_rating` | If the current player supports set_rating\r\n`rating_system` | 'NONE' or 'LIKE_DISLIKE' or 'LIKE' or 'SCALE' (SCALE is 0-5)\r\n`try_play()` | Tries to play the current media\r\n`try_pause()` | Tries to pause the current media\r\n`try_toggle_play_pause()` | Tries to play/pause the current media\r\n`try_skip_previous()` | Try to skip to the previous media/section\r\n`try_skip_next()` | Try to skip to the next media/section\r\n`try_set_position_seconds(seconds)` | Try to set the medias playback progress in seconds\r\n`try_revert_position_seconds(seconds)` | Try to revert the medias playback progress by x seconds\r\n`try_forward_position_seconds(seconds)` | Try to forward the medias playback progress by x seconds\r\n`try_set_position_percent(percent)` | Try to set the medias playback progress in percent\r\n`try_revert_position_percent(percent)` | Try to revert the medias playback progress by x percent\r\n`try_forward_position_percent(percent)` | Try to forward the medias playback progress by x percent\r\n`try_set_volume(volume)` | Try to set the medias volume from 1-100\r\n`try_toggle_repeat_mode()` | Try to toggle through repeat modes\r\n`try_toggle_shuffle_active()` | Try to toggle shuffle mode\r\n`try_set_rating(rating)` | Sites with a binary rating system fall back to: 0 = None; 1 = Thumbs Down; 5 = Thumbs Up\r\n",
"bugtrack_url": null,
"license": "Copyright 2023 keifufu Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \u201cSoftware\u201d), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \u201cAS IS\u201d, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
"summary": "A python library to communicate with the WebNowPlaying-Redux browser extension",
"version": "2.0.2",
"project_urls": {
"Bug Tracker": "https://github.com/keifufu/PyWNP/issues",
"Homepage": "https://github.com/keifufu/PyWNP"
},
"split_keywords": [
"webnowplaying",
"wnp",
"youtube",
"spotify",
"media",
"music"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "17182b0d6d19730e45c9c7534c8d790c22e060877df5302d211b117f1dacc9b7",
"md5": "44ec402fca1284f1d3b3fa4e572bb903",
"sha256": "8dca8e6a47d76ed8031f3f33348fbb0c4abcbc15983ed2224536dbc1d0168d9b"
},
"downloads": -1,
"filename": "pywnp-2.0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "44ec402fca1284f1d3b3fa4e572bb903",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 11431,
"upload_time": "2023-06-10T12:08:03",
"upload_time_iso_8601": "2023-06-10T12:08:03.532319Z",
"url": "https://files.pythonhosted.org/packages/17/18/2b0d6d19730e45c9c7534c8d790c22e060877df5302d211b117f1dacc9b7/pywnp-2.0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "aeb24ffdc787489a2967a6456735134d1129b77adad0685f171de6dbda06c14b",
"md5": "74dffc564260c4c56ee351d7b821a6f2",
"sha256": "5974cc6d36e78102caf9bb5f1b5daa63b5099660db26987c31649fd81b8d73aa"
},
"downloads": -1,
"filename": "pywnp-2.0.2.tar.gz",
"has_sig": false,
"md5_digest": "74dffc564260c4c56ee351d7b821a6f2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 13015,
"upload_time": "2023-06-10T12:08:05",
"upload_time_iso_8601": "2023-06-10T12:08:05.301215Z",
"url": "https://files.pythonhosted.org/packages/ae/b2/4ffdc787489a2967a6456735134d1129b77adad0685f171de6dbda06c14b/pywnp-2.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-06-10 12:08:05",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "keifufu",
"github_project": "PyWNP",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "aiohttp",
"specs": [
[
"==",
"3.8.4"
]
]
},
{
"name": "winsdk",
"specs": [
[
"==",
"1.0.0b9"
]
]
}
],
"lcname": "pywnp"
}