mirror of
https://github.com/tubearchivist/tubearchivist-frontend.git
synced 2024-11-22 03:40:14 +00:00
add optin returnyoutubedislike.com integration
This commit is contained in:
parent
6aef3dfb96
commit
dc2fb65312
@ -23,7 +23,8 @@
|
||||
"format": false,
|
||||
"add_metadata": false,
|
||||
"add_thumbnail": false,
|
||||
"throttledratelimit": false
|
||||
"throttledratelimit": false,
|
||||
"integrate_ryd": false
|
||||
},
|
||||
"application": {
|
||||
"app_root": "/app",
|
||||
|
@ -56,11 +56,18 @@ class ApplicationSettingsForm(forms.Form):
|
||||
("1", "embed thumbnail"),
|
||||
]
|
||||
|
||||
RYD_CHOICES = [
|
||||
("", "-- change ryd integrations"),
|
||||
("0", "disable ryd integration"),
|
||||
("1", "enable ryd integration"),
|
||||
]
|
||||
|
||||
subscriptions_channel_size = forms.IntegerField(required=False)
|
||||
downloads_limit_count = forms.IntegerField(required=False)
|
||||
downloads_limit_speed = forms.IntegerField(required=False)
|
||||
downloads_throttledratelimit = 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_add_metadata = forms.ChoiceField(
|
||||
widget=forms.Select, choices=METADATA_CHOICES, required=False
|
||||
@ -68,7 +75,9 @@ class ApplicationSettingsForm(forms.Form):
|
||||
downloads_add_thumbnail = forms.ChoiceField(
|
||||
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):
|
||||
|
@ -14,6 +14,7 @@ from time import sleep
|
||||
import requests
|
||||
import yt_dlp
|
||||
from bs4 import BeautifulSoup
|
||||
from ryd_client import ryd_client
|
||||
from home.src.config import AppConfig
|
||||
from home.src.helper import DurationConverter, UrlListParser, clean_string
|
||||
from home.src.thumbnails import ThumbManager
|
||||
@ -282,6 +283,7 @@ class YoutubeVideo:
|
||||
ES_AUTH = CONFIG["application"]["es_auth"]
|
||||
CACHE_DIR = CONFIG["application"]["cache_dir"]
|
||||
VIDEOS = CONFIG["application"]["videos"]
|
||||
RYD = CONFIG["downloads"]["integrate_ryd"]
|
||||
|
||||
def __init__(self, youtube_id):
|
||||
self.youtube_id = youtube_id
|
||||
@ -303,6 +305,8 @@ class YoutubeVideo:
|
||||
break
|
||||
|
||||
self.vid_dict = vid_dict
|
||||
if self.RYD:
|
||||
self.get_ryd_stats()
|
||||
|
||||
def get_youtubedl_vid_data(self):
|
||||
"""parse youtubedl extract info"""
|
||||
@ -446,6 +450,23 @@ class YoutubeVideo:
|
||||
# delete thumbs from cache
|
||||
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:
|
||||
"""represent a single playlist on YouTube"""
|
||||
|
@ -95,6 +95,14 @@
|
||||
{{ app_form.downloads_add_thumbnail }}
|
||||
</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>
|
||||
</form>
|
||||
<div class="title-bar">
|
||||
|
@ -4,6 +4,7 @@ Django==4.0
|
||||
Pillow==8.4.0
|
||||
redis==4.1.0
|
||||
requests==2.26.0
|
||||
ryd-client==0.0.3
|
||||
uWSGI==2.0.20
|
||||
whitenoise==5.3.0
|
||||
yt_dlp==2021.12.27
|
||||
|
Loading…
Reference in New Issue
Block a user