Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RYD and RYD Proxy support #3215

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
45 changes: 45 additions & 0 deletions src/renderer/components/ryd-settings/ryd-settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { defineComponent } from 'vue'
import { mapActions } from 'vuex'
import FtSettingsSection from '../ft-settings-section/ft-settings-section.vue'
import FtToggleSwitch from '../ft-toggle-switch/ft-toggle-switch.vue'
import FtInput from '../ft-input/ft-input.vue'
import FtFlexBox from '../ft-flex-box/ft-flex-box.vue'

import { getRYDInstances } from '../../helpers/returnyoutubedislike'

export default defineComponent({
name: 'RydSettings',
components: {
'ft-settings-section': FtSettingsSection,
'ft-toggle-switch': FtToggleSwitch,
'ft-input': FtInput,
'ft-flex-box': FtFlexBox,
},
computed: {
useReturnYoutubeDislikes: function () {
return this.$store.getters.getUseReturnYouTubeDislikes
},
returnYoutubeDislikesUrl: function () {
return this.$store.getters.getReturnYouTubeDislikesUrl
},
returnYoutubeDislikesInstances: function() {
return getRYDInstances()
}
},
methods: {
handleUpdateUseReturnYoutubeDislike: function (value) {
this.updateUseReturnYouTubeDislikes(value)
},

handleUpdateReturnYouTubeDislikesUrl: function (value) {
const RYDUrlWithoutTrailingSlash = value.replace(/\/$/, '')
const RYDUrlWithoutVotesSuffix = RYDUrlWithoutTrailingSlash.replace(/\/votes$/i, '')
this.updateReturnYouTubeDislikesUrl(RYDUrlWithoutVotesSuffix)
},

...mapActions([
'updateUseReturnYouTubeDislikes',
'updateReturnYouTubeDislikesUrl',
])
}
})
29 changes: 29 additions & 0 deletions src/renderer/components/ryd-settings/ryd-settings.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<template>
<ft-settings-section
:title="$t('Settings.Return YouTube Dislikes Settings.Return YouTube Dislikes Settings')"
>
<ft-flex-box class="settingsFlexStart500px">
<ft-toggle-switch
:label="$t('Settings.Return YouTube Dislikes Settings.Enable Return YouTube Dislikes')"
:default-value="useReturnYoutubeDislikes"
@change="handleUpdateUseReturnYoutubeDislike"
/>
</ft-flex-box>
<div
v-if="useReturnYoutubeDislikes"
>
<ft-flex-box>
<ft-input
:placeholder="$t('Settings.Return YouTube Dislikes Settings.Return YouTube Dislikes Url')"
:show-action-button="false"
:show-label="true"
:data-list="returnYoutubeDislikesInstances"
:value="returnYoutubeDislikesUrl"
@input="handleUpdateReturnYouTubeDislikesUrl"
/>
</ft-flex-box>
</div>
</ft-settings-section>
</template>

<script src="./ryd-settings.js" />
4 changes: 4 additions & 0 deletions src/renderer/components/watch-video-info/watch-video-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ export default defineComponent({

defaultPlayback: function () {
return this.$store.getters.getDefaultPlayback
},

useReturnYoutubeDislikes: function () {
return this.$store.getters.getUseReturnYouTubeDislikes
}
},
mounted: function () {
Expand Down
25 changes: 9 additions & 16 deletions src/renderer/components/watch-video-info/watch-video-info.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,6 @@
<div class="viewCount">
{{ parsedViewCount }}
</div>
<div
v-if="!hideVideoLikesAndDislikes"
class="likeBarContainer"
>
<div
class="likeSection"
>
<div>
<span class="likeCount"><font-awesome-icon :icon="['fas', 'thumbs-up']" /> {{ parsedLikeCount }}</span>
</div>
</div>
</div>
<!--
// Uncomment if suitable solution for bringing back dislikes is introduced
<div
v-if="!hideVideoLikesAndDislikes"
class="likeBarContainer"
Expand All @@ -71,16 +57,23 @@
class="likeSection"
>
<div
v-if="useReturnYoutubeDislikes"
class="likeBar"
:style="{ background: `linear-gradient(to right, var(--accent-color) ${likePercentageRatio}%, #9E9E9E ${likePercentageRatio}%` }"
/>
<div>
<span class="likeCount"><font-awesome-icon :icon="['fas', 'thumbs-up']" /> {{ parsedLikeCount }}</span>
<span class="dislikeCount"><font-awesome-icon :icon="['fas', 'thumbs-down']" /> {{ parsedDislikeCount }}</span>
<span
v-if="useReturnYoutubeDislikes"
class="dislikeCount"
>
&nbsp;
<font-awesome-icon :icon="['fas', 'thumbs-down']" />
{{ parsedDislikeCount }}
</span>
</div>
</div>
</div>
-->
<div class="videoOptions">
<ft-icon-button
v-if="!isUpcoming"
Expand Down
25 changes: 25 additions & 0 deletions src/renderer/helpers/returnyoutubedislike.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import store from '../store/index'

export async function getVideoDislikes(videoId) {
let requestUrl

const url = store.getters.getReturnYouTubeDislikesUrl
if (new URL(url).hostname.replace('www.', '') === 'returnyoutubedislikeapi.com') {
requestUrl = `https://returnyoutubedislikeapi.com/Votes?videoId=${videoId}`
} else {
requestUrl = `${url}/votes/${videoId}`
}

const response = await fetch(requestUrl).then(res => res.json())

return response.dislikes
}

export function getRYDInstances() {
// hopefully we get an official instance list at some point instead of hard coding...
return [
'https://returnyoutubedislikeapi.com',
'https://ryd-proxy.kavin.rocks',
'https://ryd-proxy.privacydev.net'
]
}
2 changes: 2 additions & 0 deletions src/renderer/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import {
faStepBackward,
faStepForward,
faSync,
faThumbsDown,
faThumbsUp,
faThumbtack,
faTimes,
Expand Down Expand Up @@ -112,6 +113,7 @@ library.add(
faStepBackward,
faStepForward,
faSync,
faThumbsDown,
faThumbsUp,
faThumbtack,
faTimes,
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/store/modules/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@ const state = {
fetchSubscriptionsAutomatically: true,
settingsPassword: '',
allowDashAv1Formats: false,
returnYouTubeDislikesUrl: 'https://ryd-proxy.kavin.rocks',
useReturnYouTubeDislikes: false,
}

const stateWithSideEffects = {
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/views/Settings/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import ParentControlSettings from '../../components/parental-control-settings/pa
import ExperimentalSettings from '../../components/experimental-settings/experimental-settings.vue'
import PasswordSettings from '../../components/password-settings/password-settings.vue'
import PasswordDialog from '../../components/password-dialog/password-dialog.vue'
import RydSettings from '../../components/ryd-settings/ryd-settings.vue'

export default defineComponent({
name: 'Settings',
Expand All @@ -33,6 +34,7 @@ export default defineComponent({
'experimental-settings': ExperimentalSettings,
'password-settings': PasswordSettings,
'password-dialog': PasswordDialog,
'ryd-settings': RydSettings,
},
data: function () {
return {
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/views/Settings/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
<parental-control-settings />
<hr>
<sponsor-block-settings />
<hr>
<ryd-settings />
<hr v-if="usingElectron">
<experimental-settings v-if="usingElectron" />
<hr>
Expand Down
15 changes: 15 additions & 0 deletions src/renderer/views/Watch/Watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
parseLocalWatchNextVideo
} from '../../helpers/api/local'
import { invidiousGetVideoInformation, youtubeImageUrlToInvidious } from '../../helpers/api/invidious'
import { getVideoDislikes } from '../../helpers/returnyoutubedislike'

export default defineComponent({
name: 'Watch',
Expand Down Expand Up @@ -182,6 +183,9 @@ export default defineComponent({
},
allowDashAv1Formats: function () {
return this.$store.getters.getAllowDashAv1Formats
},
useReturnYouTubeDislikes: function () {
return this.$store.getters.getUseReturnYouTubeDislikes
}
},
watch: {
Expand Down Expand Up @@ -329,6 +333,12 @@ export default defineComponent({

// YouTube doesn't return dislikes anymore
this.videoDislikeCount = 0

if (this.useReturnYouTubeDislikes) {
getVideoDislikes(this.videoId).then(dislikes => {
this.videoDislikeCount = isNaN(dislikes) ? 0 : dislikes
})
}
}

this.isLive = !!result.basic_info.is_live
Expand Down Expand Up @@ -669,6 +679,11 @@ export default defineComponent({
} else {
this.videoLikeCount = result.likeCount
this.videoDislikeCount = result.dislikeCount
if (this.useReturnYouTubeDislikes) {
getVideoDislikes(this.videoId).then((dislikes) => {
this.videoDislikeCount = isNaN(dislikes) ? 0 : dislikes
})
}
}
if (this.hideChannelSubscriptions) {
this.channelSubscriptionCountText = ''
Expand Down
4 changes: 4 additions & 0 deletions static/locales/en-US.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,10 @@ Settings:
Prompt To Skip: Prompt To Skip
Do Nothing: Do Nothing
Category Color: Category Color
Return YouTube Dislikes Settings:
Return YouTube Dislikes Settings: Return YouTube Dislikes Settings
Enable Return YouTube Dislikes: Enable Return YouTube Dislikes
Return YouTube Dislikes Url: Return YouTube dislikes API Url (Default is https://ryd-proxy.kavin.rocks/)
Parental Control Settings:
Parental Control Settings: Parental Control Settings
Hide Unsubscribe Button: Hide Unsubscribe Button
Expand Down