mirror of
https://github.com/tubearchivist/tubearchivist-frontend.git
synced 2024-11-22 20:00:15 +00:00
add optin returnyoutubedislike.com integration
This commit is contained in:
parent
6aef3dfb96
commit
dc2fb65312
@ -23,7 +23,8 @@
|
|||||||
"format": false,
|
"format": false,
|
||||||
"add_metadata": false,
|
"add_metadata": false,
|
||||||
"add_thumbnail": false,
|
"add_thumbnail": false,
|
||||||
"throttledratelimit": false
|
"throttledratelimit": false,
|
||||||
|
"integrate_ryd": false
|
||||||
},
|
},
|
||||||
"application": {
|
"application": {
|
||||||
"app_root": "/app",
|
"app_root": "/app",
|
||||||
|
@ -56,11 +56,18 @@ class ApplicationSettingsForm(forms.Form):
|
|||||||
("1", "embed thumbnail"),
|
("1", "embed thumbnail"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
RYD_CHOICES = [
|
||||||
|
("", "-- change ryd integrations"),
|
||||||
|
("0", "disable ryd integration"),
|
||||||
|
("1", "enable ryd integration"),
|
||||||
|
]
|
||||||
|
|
||||||
subscriptions_channel_size = forms.IntegerField(required=False)
|
subscriptions_channel_size = forms.IntegerField(required=False)
|
||||||
downloads_limit_count = forms.IntegerField(required=False)
|
downloads_limit_count = forms.IntegerField(required=False)
|
||||||
downloads_limit_speed = forms.IntegerField(required=False)
|
downloads_limit_speed = forms.IntegerField(required=False)
|
||||||
downloads_throttledratelimit = forms.IntegerField(required=False)
|
downloads_throttledratelimit = forms.IntegerField(required=False)
|
||||||
downloads_sleep_interval = forms.IntegerField(required=False)
|
downloads_sleep_interval = forms.IntegerField(required=False)
|
||||||
|
downloads_autodelete_days = forms.IntegerField(required=False)
|
||||||
downloads_format = forms.CharField(required=False)
|
downloads_format = forms.CharField(required=False)
|
||||||
downloads_add_metadata = forms.ChoiceField(
|
downloads_add_metadata = forms.ChoiceField(
|
||||||
widget=forms.Select, choices=METADATA_CHOICES, required=False
|
widget=forms.Select, choices=METADATA_CHOICES, required=False
|
||||||
@ -68,7 +75,9 @@ class ApplicationSettingsForm(forms.Form):
|
|||||||
downloads_add_thumbnail = forms.ChoiceField(
|
downloads_add_thumbnail = forms.ChoiceField(
|
||||||
widget=forms.Select, choices=THUMBNAIL_CHOICES, required=False
|
widget=forms.Select, choices=THUMBNAIL_CHOICES, required=False
|
||||||
)
|
)
|
||||||
downloads_autodelete_days = forms.IntegerField(required=False)
|
downloads_integrate_ryd = forms.ChoiceField(
|
||||||
|
widget=forms.Select, choices=RYD_CHOICES, required=False
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class SchedulerSettingsForm(forms.Form):
|
class SchedulerSettingsForm(forms.Form):
|
||||||
|
@ -14,6 +14,7 @@ from time import sleep
|
|||||||
import requests
|
import requests
|
||||||
import yt_dlp
|
import yt_dlp
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
from ryd_client import ryd_client
|
||||||
from home.src.config import AppConfig
|
from home.src.config import AppConfig
|
||||||
from home.src.helper import DurationConverter, UrlListParser, clean_string
|
from home.src.helper import DurationConverter, UrlListParser, clean_string
|
||||||
from home.src.thumbnails import ThumbManager
|
from home.src.thumbnails import ThumbManager
|
||||||
@ -282,6 +283,7 @@ class YoutubeVideo:
|
|||||||
ES_AUTH = CONFIG["application"]["es_auth"]
|
ES_AUTH = CONFIG["application"]["es_auth"]
|
||||||
CACHE_DIR = CONFIG["application"]["cache_dir"]
|
CACHE_DIR = CONFIG["application"]["cache_dir"]
|
||||||
VIDEOS = CONFIG["application"]["videos"]
|
VIDEOS = CONFIG["application"]["videos"]
|
||||||
|
RYD = CONFIG["downloads"]["integrate_ryd"]
|
||||||
|
|
||||||
def __init__(self, youtube_id):
|
def __init__(self, youtube_id):
|
||||||
self.youtube_id = youtube_id
|
self.youtube_id = youtube_id
|
||||||
@ -303,6 +305,8 @@ class YoutubeVideo:
|
|||||||
break
|
break
|
||||||
|
|
||||||
self.vid_dict = vid_dict
|
self.vid_dict = vid_dict
|
||||||
|
if self.RYD:
|
||||||
|
self.get_ryd_stats()
|
||||||
|
|
||||||
def get_youtubedl_vid_data(self):
|
def get_youtubedl_vid_data(self):
|
||||||
"""parse youtubedl extract info"""
|
"""parse youtubedl extract info"""
|
||||||
@ -446,6 +450,23 @@ class YoutubeVideo:
|
|||||||
# delete thumbs from cache
|
# delete thumbs from cache
|
||||||
ThumbManager().delete_vid_thumb(self.youtube_id)
|
ThumbManager().delete_vid_thumb(self.youtube_id)
|
||||||
|
|
||||||
|
def get_ryd_stats(self):
|
||||||
|
"""get optional stats from returnyoutubedislikeapi.com"""
|
||||||
|
try:
|
||||||
|
print(f"get ryd stats for: {self.youtube_id}")
|
||||||
|
result = ryd_client.get(self.youtube_id)
|
||||||
|
except requests.exceptions.ConnectionError:
|
||||||
|
print(f"failed to query ryd api, skipping {self.youtube_id}")
|
||||||
|
return False
|
||||||
|
|
||||||
|
dislikes = {
|
||||||
|
"dislike_count": result["dislikes"],
|
||||||
|
"average_rating": result["rating"],
|
||||||
|
}
|
||||||
|
self.vid_dict["stats"].update(dislikes)
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
class YoutubePlaylist:
|
class YoutubePlaylist:
|
||||||
"""represent a single playlist on YouTube"""
|
"""represent a single playlist on YouTube"""
|
||||||
|
@ -95,6 +95,14 @@
|
|||||||
{{ app_form.downloads_add_thumbnail }}
|
{{ app_form.downloads_add_thumbnail }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="settings-group">
|
||||||
|
<h2 id="integrations">Integrations</h2>
|
||||||
|
<div class="settings-item">
|
||||||
|
<p>Integrate with <a href="https://returnyoutubedislike.com/">returnyoutubedislike.com</a>: <span class="settings-current">{{ config.downloads.integrate_ryd }}</span></p>
|
||||||
|
<i>Get dislikes and average ratings back.</i><br>
|
||||||
|
{{ app_form.downloads_integrate_ryd }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<button type="submit" name="application-settings">Update Application Configurations</button>
|
<button type="submit" name="application-settings">Update Application Configurations</button>
|
||||||
</form>
|
</form>
|
||||||
<div class="title-bar">
|
<div class="title-bar">
|
||||||
|
@ -4,6 +4,7 @@ Django==4.0
|
|||||||
Pillow==8.4.0
|
Pillow==8.4.0
|
||||||
redis==4.1.0
|
redis==4.1.0
|
||||||
requests==2.26.0
|
requests==2.26.0
|
||||||
|
ryd-client==0.0.3
|
||||||
uWSGI==2.0.20
|
uWSGI==2.0.20
|
||||||
whitenoise==5.3.0
|
whitenoise==5.3.0
|
||||||
yt_dlp==2021.12.27
|
yt_dlp==2021.12.27
|
||||||
|
Loading…
Reference in New Issue
Block a user