From 2292e6506d20ae54927f9288e6902d0db69c68d6 Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 4 Apr 2022 22:55:43 +0700 Subject: [PATCH 1/3] bump libraries --- tubearchivist/requirements.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tubearchivist/requirements.txt b/tubearchivist/requirements.txt index 409ebe5e..b6ad2a8a 100644 --- a/tubearchivist/requirements.txt +++ b/tubearchivist/requirements.txt @@ -1,10 +1,10 @@ beautifulsoup4==4.10.0 -celery==5.2.3 +celery==5.2.5 Django==4.0.3 django-cors-headers==3.11.0 djangorestframework==3.13.1 -Pillow==9.0.1 -redis==4.2.1 +Pillow==9.1.0 +redis==4.2.2 requests==2.27.1 ryd-client==0.0.3 uWSGI==2.0.20 From 77228ccb65b6a102c610603fee8e73bbf4ec0d63 Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 4 Apr 2022 23:08:44 +0700 Subject: [PATCH 2/3] implement basic sponsblock indexing, #119 --- tubearchivist/home/config.json | 3 ++- tubearchivist/home/src/frontend/forms.py | 9 +++++++++ tubearchivist/home/src/index/video.py | 15 +++++++++++++++ tubearchivist/home/templates/home/settings.html | 5 +++++ 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/tubearchivist/home/config.json b/tubearchivist/home/config.json index 1b6000ee..edb63560 100644 --- a/tubearchivist/home/config.json +++ b/tubearchivist/home/config.json @@ -27,7 +27,8 @@ "subtitle_source": false, "subtitle_index": false, "throttledratelimit": false, - "integrate_ryd": false + "integrate_ryd": false, + "integrate_sponsorblock": false }, "application": { "app_root": "/app", diff --git a/tubearchivist/home/src/frontend/forms.py b/tubearchivist/home/src/frontend/forms.py index c4ac817f..53ef284a 100644 --- a/tubearchivist/home/src/frontend/forms.py +++ b/tubearchivist/home/src/frontend/forms.py @@ -62,6 +62,12 @@ class ApplicationSettingsForm(forms.Form): ("1", "enable ryd integration"), ] + SP_CHOICES = [ + ("", "-- change sponsorblock integrations"), + ("0", "disable sponsorblock integration"), + ("1", "enable sponsorblock integration"), + ] + CAST_CHOICES = [ ("", "-- change Cast integration --"), ("0", "disable Cast"), @@ -103,6 +109,9 @@ class ApplicationSettingsForm(forms.Form): downloads_integrate_ryd = forms.ChoiceField( widget=forms.Select, choices=RYD_CHOICES, required=False ) + downloads_integrate_sponsorblock = forms.ChoiceField( + widget=forms.Select, choices=SP_CHOICES, required=False + ) application_enable_cast = forms.ChoiceField( widget=forms.Select, choices=CAST_CHOICES, required=False ) diff --git a/tubearchivist/home/src/index/video.py b/tubearchivist/home/src/index/video.py index 1dafb7b3..bac9e301 100644 --- a/tubearchivist/home/src/index/video.py +++ b/tubearchivist/home/src/index/video.py @@ -306,6 +306,9 @@ class YoutubeVideo(YouTubeItem, YoutubeSubtitle): if self.config["downloads"]["integrate_ryd"]: self._get_ryd_stats() + if self.config["downloads"]["integrate_sponsorblock"]: + self._get_sponsorblock() + return def _process_youtube_meta(self): @@ -447,6 +450,18 @@ class YoutubeVideo(YouTubeItem, YoutubeSubtitle): return True + def _get_sponsorblock(self): + """get optional sponsorblock timestamps from sponsor.ajay.app""" + api = "https://sponsor.ajay.app/api" + url = f"{api}/skipSegments?videoID={self.youtube_id}" + print(f"{self.youtube_id}: get sponsorblock timestamps") + response = requests.get(url) + if not response.ok: + print(f"{self.youtube_id}: failed to get sponsorblock data") + return + + self.json_data["sponsorblock"] = response.json() + def check_subtitles(self): """optionally add subtitles""" handler = YoutubeSubtitle(self) diff --git a/tubearchivist/home/templates/home/settings.html b/tubearchivist/home/templates/home/settings.html index 740ca400..e4d9534e 100644 --- a/tubearchivist/home/templates/home/settings.html +++ b/tubearchivist/home/templates/home/settings.html @@ -128,6 +128,11 @@ Before activating that, make sure you have a scraping sleep interval of at least 3 secs set to avoid ratelimiting issues.
{{ app_form.downloads_integrate_ryd }} +
+

Integrate with SponsorBlock to get sponsored timestamps: {{ config.downloads.integrate_sponsorblock }}

+ Before activating that, make sure you have a scraping sleep interval of at least 3 secs set to avoid ratelimiting issues.
+ {{ app_form.downloads_integrate_sponsorblock }} +

Current Cast integration: {{ config.application.enable_cast }}

Enabling Cast will load an additional JS library from Google. HTTPS and a supported browser are required for this integration.
From 71c441d871e3d1c6f541ef3a632350592869b233 Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 4 Apr 2022 23:24:51 +0700 Subject: [PATCH 3/3] better error message on sponsorblock fail --- tubearchivist/home/src/index/video.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tubearchivist/home/src/index/video.py b/tubearchivist/home/src/index/video.py index bac9e301..559ad2cb 100644 --- a/tubearchivist/home/src/index/video.py +++ b/tubearchivist/home/src/index/video.py @@ -457,7 +457,7 @@ class YoutubeVideo(YouTubeItem, YoutubeSubtitle): print(f"{self.youtube_id}: get sponsorblock timestamps") response = requests.get(url) if not response.ok: - print(f"{self.youtube_id}: failed to get sponsorblock data") + print(f"{self.youtube_id}: sponsorblock failed: {response.text}") return self.json_data["sponsorblock"] = response.json()