feat: embedded own sponsorblock in youtube
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Hellow 2024-04-25 20:35:36 +02:00
parent c0ef24a28e
commit 14f1fe4b16
5 changed files with 13 additions and 39 deletions

View File

@ -25,6 +25,7 @@
"musify", "musify",
"OKBLUE", "OKBLUE",
"Referer", "Referer",
"sponsorblock",
"tracksort", "tracksort",
"unmap", "unmap",
"youtube" "youtube"

View File

@ -2,8 +2,7 @@ from typing import List, Optional, Type, Tuple
from urllib.parse import urlparse, urlunparse, parse_qs from urllib.parse import urlparse, urlunparse, parse_qs
from enum import Enum from enum import Enum
import sponsorblock import python_sponsorblock
from sponsorblock.errors import HTTPException, NotFoundException
from ..objects import Source, DatabaseObject, Song, Target from ..objects import Source, DatabaseObject, Song, Target
from .abstract import Page from .abstract import Page
@ -63,8 +62,9 @@ class YouTube(SuperYouTube):
) )
# the stuff with the connection is, to ensure sponsorblock uses the proxies, my programm does # the stuff with the connection is, to ensure sponsorblock uses the proxies, my programm does
_sponsorblock_connection: Connection = Connection(host="https://sponsor.ajay.app/") _sponsorblock_connection: Connection = Connection()
self.sponsorblock_client = sponsorblock.Client(session=_sponsorblock_connection.session) self.sponsorblock = python_sponsorblock.SponsorBlock(silent=True, session=_sponsorblock_connection.session)
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
@ -344,10 +344,10 @@ class YouTube(SuperYouTube):
segments = [] segments = []
try: try:
segments = self.sponsorblock_client.get_skip_segments(parsed.id) segments = self.sponsorblock.get_segments(parsed.id)
except NotFoundException: except NotFoundException:
self.LOGGER.debug(f"No sponsor found for the video {parsed.id}.") self.LOGGER.debug(f"No sponsor found for the video {parsed.id}.")
except HTTPException as e: except HTTPException as e:
self.LOGGER.warning(f"{e}") self.LOGGER.warning(f"{e}")
return [(segment.start, segment.end) for segment in segments] return [(segment.segment[0], segment.segment[1]) for segment in segments]

View File

@ -3,8 +3,7 @@ from urllib.parse import urlparse, urlunparse, parse_qs
from enum import Enum from enum import Enum
import requests import requests
import sponsorblock import python_sponsorblock
from sponsorblock.errors import HTTPException, NotFoundException
from ...objects import Source, DatabaseObject, Song, Target from ...objects import Source, DatabaseObject, Song, Target
from ..abstract import Page from ..abstract import Page
@ -143,9 +142,8 @@ class SuperYouTube(Page):
) )
# the stuff with the connection is, to ensure sponsorblock uses the proxies, my programm does # the stuff with the connection is, to ensure sponsorblock uses the proxies, my programm does
_sponsorblock_connection: Connection = Connection(host="https://sponsor.ajay.app/") _sponsorblock_connection: Connection = Connection()
self.sponsorblock_client = sponsorblock.Client(session=_sponsorblock_connection.session) self.sponsorblock = python_sponsorblock.SponsorBlock(silent=True, session=_sponsorblock_connection.session)
def get_source_type(self, source: Source) -> Optional[Type[DatabaseObject]]: def get_source_type(self, source: Source) -> Optional[Type[DatabaseObject]]:
_url_type = { _url_type = {
@ -213,10 +211,10 @@ class SuperYouTube(Page):
segments = [] segments = []
try: try:
segments = self.sponsorblock_client.get_skip_segments(parsed.id) segments = self.sponsorblock.get_segments(parsed.id)
except NotFoundException: except NotFoundException:
self.LOGGER.debug(f"No sponsor found for the video {parsed.id}.") self.LOGGER.debug(f"No sponsor found for the video {parsed.id}.")
except HTTPException as e: except HTTPException as e:
self.LOGGER.warning(f"{e}") self.LOGGER.warning(f"{e}")
return [(segment.start, segment.end) for segment in segments] return [(segment.segment[0], segment.segment[1]) for segment in segments]

View File

@ -69,7 +69,7 @@ dependencies = [
"toml~=0.10.2", "toml~=0.10.2",
"typing_extensions~=4.7.1", "typing_extensions~=4.7.1",
"sponsorblock~=0.1.3", "python-sponsorblock~=0.0.0",
"youtube_dl", "youtube_dl",
] ]
dynamic = [ dynamic = [

View File

@ -1,25 +0,0 @@
requests~=2.31.0
mutagen~=1.46.0
musicbrainzngs~=0.7.1
jellyfish~=0.9.0
beautifulsoup4~=4.11.1
pycountry~=24.0.1
python-dateutil~=2.8.2
pandoc~=2.3
SQLAlchemy~=2.0.7
setuptools~=68.2.0
tqdm~=4.65.0
ffmpeg-python~=0.2.0
platformdirs~=4.2.0
transliterate~=1.10.2
sponsorblock~=0.1.3
regex~=2022.9.13
pyffmpeg~=2.4.2.18
ffmpeg-progress-yield~=0.7.8
pathvalidate~=2.5.2
guppy3~=3.1.3
toml~=0.10.2
typing_extensions~=4.7.1
responses~=0.24.1
youtube_dl
merge_args~=0.1.5