feat: add sponsorblock integration
Add the -S option to the fast forward command.
This commit is contained in:
21
sponsorblock.py
Normal file
21
sponsorblock.py
Normal file
@@ -0,0 +1,21 @@
|
||||
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]
|
||||
Reference in New Issue
Block a user