Compare commits
9 Commits
2080c21898
...
0.1
| Author | SHA1 | Date | |
|---|---|---|---|
| dd3714f8c8 | |||
| 760e12889c | |||
| 7d14fef3f5 | |||
| 65b1d17253 | |||
| b57991c3ce | |||
| 17203825ed | |||
| e97ee0ea13 | |||
| 68919e2c35 | |||
| 03e094a497 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -160,3 +160,5 @@ cython_debug/
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
#.idea/
|
||||
|
||||
# setuptools-scm
|
||||
_version.py
|
||||
|
||||
36
.woodpecker.yml
Normal file
36
.woodpecker.yml
Normal file
@@ -0,0 +1,36 @@
|
||||
labels:
|
||||
platform: linux/amd64
|
||||
|
||||
steps:
|
||||
build:
|
||||
image: python
|
||||
commands:
|
||||
- python -m pip install hatch requests
|
||||
- python -m unittest
|
||||
- hatch build
|
||||
when:
|
||||
- event: manual
|
||||
- event: tag
|
||||
|
||||
publish-gitea:
|
||||
image: gitea.elara.ws/music-kraken/plugin-twine
|
||||
settings:
|
||||
repository_url: "https://gitea.elara.ws/api/packages/music-kraken/pypi"
|
||||
username:
|
||||
from_secret: gitea_username
|
||||
password:
|
||||
from_secret: gitea_password
|
||||
when:
|
||||
- event: manual
|
||||
- event: tag
|
||||
|
||||
publish-pypi:
|
||||
image: gitea.elara.ws/music-kraken/plugin-twine
|
||||
settings:
|
||||
username:
|
||||
from_secret: pypi_username
|
||||
password:
|
||||
from_secret: pypi_password
|
||||
when:
|
||||
- event: manual
|
||||
- event: tag
|
||||
@@ -1,5 +1,7 @@
|
||||
# Python Sponsorblock
|
||||
|
||||
[](https://ci.elara.ws/repos/61)
|
||||
|
||||
<img src="https://gitea.elara.ws/music-kraken/python-sponsorblock/raw/branch/main/assets/logo.svg" width=300 alt="python-sponsorblock logo"/>
|
||||
|
||||
This is a wrapper for the sponsorblock api, enabling you to get the timestamps of sponsor segments from Youtube videos.
|
||||
@@ -8,7 +10,7 @@ This is a wrapper for the sponsorblock api, enabling you to get the timestamps o
|
||||
|
||||
```bash
|
||||
# using this gitea repository (recommended)
|
||||
pip install --index-url https://gitea.elara.ws/api/packages/music-kraken/pypi/simple/ music-kraken
|
||||
pip install --index-url https://gitea.elara.ws/api/packages/music-kraken/pypi/simple/ python-sponsorblock
|
||||
```
|
||||
|
||||
```bash
|
||||
|
||||
@@ -12,7 +12,16 @@ include = ["python_sponsorblock/*.py", "python_sponsorblock/**/*.py" ]
|
||||
packages = ["python_sponsorblock"]
|
||||
|
||||
[tool.hatch.version]
|
||||
path = "python_sponsorblock/__about__.py"
|
||||
source = "vcs"
|
||||
path = "python_sponsorblock/_version.py"
|
||||
fallback-version = "0.0.0"
|
||||
|
||||
[tool.hatch.version.raw-options]
|
||||
local_scheme = "no-local-version"
|
||||
|
||||
[tool.hatch.build.hooks.vcs]
|
||||
version-file = "python_sponsorblock/_version.py"
|
||||
|
||||
|
||||
[project]
|
||||
name = "python-sponsorblock"
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
__version__ = '0.0.0'
|
||||
@@ -7,7 +7,7 @@ import json
|
||||
from functools import wraps
|
||||
|
||||
from .exceptions import SponsorBlockError, SponsorBlockIdNotFoundError, ReturnDefault
|
||||
from .constants import Segment
|
||||
from .constants import Segment, Category
|
||||
|
||||
|
||||
def error_handling(default: Any) -> Callable:
|
||||
@@ -99,14 +99,25 @@ class SponsorBlock:
|
||||
return data
|
||||
|
||||
@error_handling(default=[])
|
||||
def get_segments(self, video: str) -> List[Segment]:
|
||||
def get_segments(self, video: str, categories: List[Category] = None) -> List[Segment]:
|
||||
"""
|
||||
Retrieves the skip segments for a given video.
|
||||
|
||||
Args:
|
||||
video (str): The video identifier.
|
||||
categories (List[Category], optional): A list of categories to filter the skip segments. Defaults to all categories.
|
||||
|
||||
Returns:
|
||||
List[Segment]: A list of skip segments for the given video.
|
||||
"""
|
||||
video_id = self._get_video_id(video)
|
||||
categories = categories or [c for c in Category]
|
||||
|
||||
# build query parameters
|
||||
query = {
|
||||
"videoID": video_id
|
||||
"videoID": video_id,
|
||||
"categories": json.dumps([c.value for c in categories])
|
||||
}
|
||||
|
||||
print(query)
|
||||
r = self._request(method="GET", endpoint="/api/skipSegments?" + urlencode(query))
|
||||
return [constants.Segment(**d) for d in r]
|
||||
|
||||
Reference in New Issue
Block a user