diff --git a/.vscode/settings.json b/.vscode/settings.json index aca8e78..9dfbaa3 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -25,6 +25,7 @@ "musify", "OKBLUE", "Referer", + "sponsorblock", "tracksort", "unmap", "youtube" diff --git a/music_kraken/pages/youtube.py b/music_kraken/pages/youtube.py index 4ce6633..73b92ad 100644 --- a/music_kraken/pages/youtube.py +++ b/music_kraken/pages/youtube.py @@ -2,8 +2,7 @@ from typing import List, Optional, Type, Tuple from urllib.parse import urlparse, urlunparse, parse_qs from enum import Enum -import sponsorblock -from sponsorblock.errors import HTTPException, NotFoundException +import python_sponsorblock from ..objects import Source, DatabaseObject, Song, Target 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 - _sponsorblock_connection: Connection = Connection(host="https://sponsor.ajay.app/") - self.sponsorblock_client = sponsorblock.Client(session=_sponsorblock_connection.session) + _sponsorblock_connection: Connection = Connection() + self.sponsorblock = python_sponsorblock.SponsorBlock(silent=True, session=_sponsorblock_connection.session) + super().__init__(*args, **kwargs) @@ -344,10 +344,10 @@ class YouTube(SuperYouTube): segments = [] try: - segments = self.sponsorblock_client.get_skip_segments(parsed.id) + segments = self.sponsorblock.get_segments(parsed.id) except NotFoundException: self.LOGGER.debug(f"No sponsor found for the video {parsed.id}.") except HTTPException as 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] diff --git a/music_kraken/pages/youtube_music/super_youtube.py b/music_kraken/pages/youtube_music/super_youtube.py index d391370..420c46d 100644 --- a/music_kraken/pages/youtube_music/super_youtube.py +++ b/music_kraken/pages/youtube_music/super_youtube.py @@ -3,8 +3,7 @@ from urllib.parse import urlparse, urlunparse, parse_qs from enum import Enum import requests -import sponsorblock -from sponsorblock.errors import HTTPException, NotFoundException +import python_sponsorblock from ...objects import Source, DatabaseObject, Song, Target 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 - _sponsorblock_connection: Connection = Connection(host="https://sponsor.ajay.app/") - self.sponsorblock_client = sponsorblock.Client(session=_sponsorblock_connection.session) - + _sponsorblock_connection: Connection = Connection() + self.sponsorblock = python_sponsorblock.SponsorBlock(silent=True, session=_sponsorblock_connection.session) def get_source_type(self, source: Source) -> Optional[Type[DatabaseObject]]: _url_type = { @@ -213,10 +211,10 @@ class SuperYouTube(Page): segments = [] try: - segments = self.sponsorblock_client.get_skip_segments(parsed.id) + segments = self.sponsorblock.get_segments(parsed.id) except NotFoundException: self.LOGGER.debug(f"No sponsor found for the video {parsed.id}.") except HTTPException as 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] diff --git a/pyproject.toml b/pyproject.toml index 16fac20..9c8232b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -69,7 +69,7 @@ dependencies = [ "toml~=0.10.2", "typing_extensions~=4.7.1", - "sponsorblock~=0.1.3", + "python-sponsorblock~=0.0.0", "youtube_dl", ] dynamic = [ diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 7ba18a1..0000000 --- a/requirements.txt +++ /dev/null @@ -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 \ No newline at end of file