mirror of
https://github.com/tubearchivist/tubearchivist-frontend.git
synced 2024-11-22 11:50:14 +00:00
implement basic sponsblock indexing, #119
This commit is contained in:
parent
2292e6506d
commit
77228ccb65
@ -27,7 +27,8 @@
|
|||||||
"subtitle_source": false,
|
"subtitle_source": false,
|
||||||
"subtitle_index": false,
|
"subtitle_index": false,
|
||||||
"throttledratelimit": false,
|
"throttledratelimit": false,
|
||||||
"integrate_ryd": false
|
"integrate_ryd": false,
|
||||||
|
"integrate_sponsorblock": false
|
||||||
},
|
},
|
||||||
"application": {
|
"application": {
|
||||||
"app_root": "/app",
|
"app_root": "/app",
|
||||||
|
@ -62,6 +62,12 @@ class ApplicationSettingsForm(forms.Form):
|
|||||||
("1", "enable ryd integration"),
|
("1", "enable ryd integration"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
SP_CHOICES = [
|
||||||
|
("", "-- change sponsorblock integrations"),
|
||||||
|
("0", "disable sponsorblock integration"),
|
||||||
|
("1", "enable sponsorblock integration"),
|
||||||
|
]
|
||||||
|
|
||||||
CAST_CHOICES = [
|
CAST_CHOICES = [
|
||||||
("", "-- change Cast integration --"),
|
("", "-- change Cast integration --"),
|
||||||
("0", "disable Cast"),
|
("0", "disable Cast"),
|
||||||
@ -103,6 +109,9 @@ class ApplicationSettingsForm(forms.Form):
|
|||||||
downloads_integrate_ryd = forms.ChoiceField(
|
downloads_integrate_ryd = forms.ChoiceField(
|
||||||
widget=forms.Select, choices=RYD_CHOICES, required=False
|
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(
|
application_enable_cast = forms.ChoiceField(
|
||||||
widget=forms.Select, choices=CAST_CHOICES, required=False
|
widget=forms.Select, choices=CAST_CHOICES, required=False
|
||||||
)
|
)
|
||||||
|
@ -306,6 +306,9 @@ class YoutubeVideo(YouTubeItem, YoutubeSubtitle):
|
|||||||
if self.config["downloads"]["integrate_ryd"]:
|
if self.config["downloads"]["integrate_ryd"]:
|
||||||
self._get_ryd_stats()
|
self._get_ryd_stats()
|
||||||
|
|
||||||
|
if self.config["downloads"]["integrate_sponsorblock"]:
|
||||||
|
self._get_sponsorblock()
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def _process_youtube_meta(self):
|
def _process_youtube_meta(self):
|
||||||
@ -447,6 +450,18 @@ class YoutubeVideo(YouTubeItem, YoutubeSubtitle):
|
|||||||
|
|
||||||
return True
|
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):
|
def check_subtitles(self):
|
||||||
"""optionally add subtitles"""
|
"""optionally add subtitles"""
|
||||||
handler = YoutubeSubtitle(self)
|
handler = YoutubeSubtitle(self)
|
||||||
|
@ -128,6 +128,11 @@
|
|||||||
<i>Before activating that, make sure you have a scraping sleep interval of at least 3 secs set to avoid ratelimiting issues.</i><br>
|
<i>Before activating that, make sure you have a scraping sleep interval of at least 3 secs set to avoid ratelimiting issues.</i><br>
|
||||||
{{ app_form.downloads_integrate_ryd }}
|
{{ app_form.downloads_integrate_ryd }}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="settings-item">
|
||||||
|
<p>Integrate with <a href="https://sponsor.ajay.app/">SponsorBlock</a> to get sponsored timestamps: <span class="settings-current">{{ config.downloads.integrate_sponsorblock }}</span></p>
|
||||||
|
<i>Before activating that, make sure you have a scraping sleep interval of at least 3 secs set to avoid ratelimiting issues.</i><br>
|
||||||
|
{{ app_form.downloads_integrate_sponsorblock }}
|
||||||
|
</div>
|
||||||
<div class="settings-item">
|
<div class="settings-item">
|
||||||
<p>Current Cast integration: <span class="settings-current">{{ config.application.enable_cast }}</span></p>
|
<p>Current Cast integration: <span class="settings-current">{{ config.application.enable_cast }}</span></p>
|
||||||
<i>Enabling Cast will load an additional JS library from Google. HTTPS and a supported browser are required for this integration.</i><br>
|
<i>Enabling Cast will load an additional JS library from Google. HTTPS and a supported browser are required for this integration.</i><br>
|
||||||
|
Loading…
Reference in New Issue
Block a user