ErrorNoCord/sponsorblock.py
ErrorNoInternet 640e750e3d
feat: add sponsorblock integration
Add the -S option to the fast forward command.
2025-01-22 14:47:00 -05:00

22 lines
615 B
Python

import hashlib
import requests
from state import sponsorblock_cache
def get_segments(videoId: str):
if videoId in sponsorblock_cache:
return sponsorblock_cache[videoId]
hashPrefix = hashlib.sha256(videoId.encode()).hexdigest()[:4]
response = requests.get(
f'https://sponsor.ajay.app/api/skipSegments/{hashPrefix}?categories=["music_offtopic"]'
)
print(response.text)
if response.status_code == 200 and (
results := list(filter(lambda v: videoId == v["videoID"], response.json()))
):
sponsorblock_cache[videoId] = results[0]
return results[0]