Skip to content

Commit

Permalink
Merge branch 'development' into feature/playlist-2023-05-w-quick-book…
Browse files Browse the repository at this point in the history
…mark

* development: (53 commits)
  Add dearrow support for thumbnails (FreeTubeApp#4520)
  Translated using Weblate (French)
  Fix hardware acceleration flag for Linux (FreeTubeApp#4532)
  Translated using Weblate (Bengali)
  Translated using Weblate (Czech)
  Translated using Weblate (Hungarian)
  Translated using Weblate (Turkish)
  Translated using Weblate (Spanish)
  Translated using Weblate (Arabic)
  Translated using Weblate (Italian)
  Translated using Weblate (Polish)
  Translated using Weblate (Russian)
  Translated using Weblate (French)
  Translated using Weblate (Chinese (Simplified))
  Add toggle to suppress sending additional args to external players (FreeTubeApp#4515)
  Translated using Weblate (English (United Kingdom))
  Translated using Weblate (Italian)
  Translated using Weblate (French)
  Translated using Weblate (Finnish)
  Translated using Weblate (Polish)
  ...

# Conflicts:
#	src/renderer/store/modules/settings.js
  • Loading branch information
PikachuEXE committed Jan 15, 2024
2 parents 20ed0f8 + ae7a2fa commit 8d5f3b2
Show file tree
Hide file tree
Showing 39 changed files with 2,227 additions and 426 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

# For bug reports
- name: New bug issue
uses: alex-page/github-project-automation-plus@v0.8.3
uses: alex-page/github-project-automation-plus@v0.9.0
if: contains(github.event.issue.labels.*.name, 'bug') && github.event.action == 'opened'
with:
project: Bug Reports
Expand All @@ -22,7 +22,7 @@ jobs:
action: update

- name: Bug issue closed
uses: alex-page/github-project-automation-plus@v0.8.3
uses: alex-page/github-project-automation-plus@v0.9.0
if: github.event.action == 'closed' || github.event.action == 'deleted'
with:
action: delete
Expand All @@ -31,7 +31,7 @@ jobs:
repo-token: ${{ secrets.PUSH_TOKEN }}

- name: Bug issue reopened
uses: alex-page/github-project-automation-plus@v0.8.3
uses: alex-page/github-project-automation-plus@v0.9.0
if: contains(github.event.issue.labels.*.name, 'bug') && github.event.action == 'reopened'
with:
project: Bug Reports
Expand All @@ -41,7 +41,7 @@ jobs:

# For feature requests
- name: New feature issue
uses: alex-page/github-project-automation-plus@v0.8.3
uses: alex-page/github-project-automation-plus@v0.9.0
if: contains(github.event.issue.labels.*.name, 'enhancement') && github.event.action == 'opened'
with:
project: Feature Requests
Expand All @@ -50,7 +50,7 @@ jobs:
action: update

- name: Feature request issue closed
uses: alex-page/github-project-automation-plus@v0.8.3
uses: alex-page/github-project-automation-plus@v0.9.0
if: github.event.action == 'closed' || github.event.action == 'deleted'
with:
action: delete
Expand All @@ -59,7 +59,7 @@ jobs:
repo-token: ${{ secrets.PUSH_TOKEN }}

- name: Feature request issue reopened
uses: alex-page/github-project-automation-plus@v0.8.3
uses: alex-page/github-project-automation-plus@v0.9.0
if: contains(github.event.issue.labels.*.name, 'enhancement') && github.event.action == 'reopened'
with:
project: Feature Requests
Expand Down
4 changes: 0 additions & 4 deletions _scripts/ProcessLocalesPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ class ProcessLocalesPlugin {
}
}

if (Object.prototype.hasOwnProperty.call(data, 'Locale Name')) {
delete data['Locale Name']
}

this.removeEmptyValues(data)

let filename = `${this.outputDir}/${locale}.json`
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@
"copy-webpack-plugin": "^11.0.0",
"css-loader": "^6.8.1",
"css-minimizer-webpack-plugin": "^5.0.1",
"electron": "^28.1.0",
"electron": "^28.1.1",
"electron-builder": "^24.9.1",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsonc": "^2.11.2",
"eslint-plugin-n": "^16.6.0",
"eslint-plugin-n": "^16.6.1",
"eslint-plugin-prettier": "^5.1.2",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-unicorn": "^50.0.1",
Expand All @@ -109,11 +109,11 @@
"lefthook": "^1.5.5",
"mini-css-extract-plugin": "^2.7.6",
"npm-run-all": "^4.1.5",
"postcss": "^8.4.32",
"postcss": "^8.4.33",
"postcss-scss": "^4.0.9",
"prettier": "^2.8.8",
"rimraf": "^5.0.5",
"sass": "^1.69.6",
"sass": "^1.69.7",
"sass-loader": "^13.3.3",
"stylelint": "^16.1.0",
"stylelint-config-sass-guidelines": "^11.0.0",
Expand Down
8 changes: 5 additions & 3 deletions src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,11 @@ function runApp() {
let mainWindow
let startupUrl

app.commandLine.appendSwitch('enable-accelerated-video-decode')
app.commandLine.appendSwitch('enable-file-cookies')
app.commandLine.appendSwitch('ignore-gpu-blacklist')
if (process.platform === 'linux') {
// Enable hardware acceleration via VA-API
// https://chromium.googlesource.com/chromium/src/+/refs/heads/main/docs/gpu/vaapi.md
app.commandLine.appendSwitch('enable-features', 'VaapiVideoDecodeLinuxGL')
}

// Work around for context menus in the devtools being displayed behind the window
// https://github.com/electron/electron/issues/38790
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ export default defineComponent({
externalPlayerIgnoreWarnings: function () {
return this.$store.getters.getExternalPlayerIgnoreWarnings
},
externalPlayerIgnoreDefaultArgs: function () {
return this.$store.getters.getExternalPlayerIgnoreDefaultArgs
},
externalPlayerCustomArgs: function () {
return this.$store.getters.getExternalPlayerCustomArgs
},
Expand All @@ -58,6 +61,7 @@ export default defineComponent({
'updateExternalPlayer',
'updateExternalPlayerExecutable',
'updateExternalPlayerIgnoreWarnings',
'updateExternalPlayerIgnoreDefaultArgs',
'updateExternalPlayerCustomArgs'
])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
:tooltip="$t('Tooltips.External Player Settings.Ignore Warnings')"
@change="updateExternalPlayerIgnoreWarnings"
/>
<ft-toggle-switch
:label="$t('Settings.External Player Settings.Ignore Default Arguments')"
:default-value="externalPlayerIgnoreDefaultArgs"
:disabled="externalPlayer===''"
:compact="true"
:tooltip="$t('Tooltips.External Player Settings.Ignore Default Arguments')"
@change="updateExternalPlayerIgnoreDefaultArgs"
/>
</ft-flex-box>
<ft-flex-box
v-if="externalPlayer !== ''"
Expand Down
65 changes: 59 additions & 6 deletions src/renderer/components/ft-list-video/ft-list-video.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import {
openExternalLink,
showToast,
toLocalePublicationString,
toDistractionFreeTitle
toDistractionFreeTitle,
deepCopy
} from '../../helpers/utils'
import { deArrowData } from '../../helpers/sponsorblock'
import { deArrowData, deArrowThumbnail } from '../../helpers/sponsorblock'
import debounce from 'lodash.debounce'

export default defineComponent({
name: 'FtListVideo',
Expand Down Expand Up @@ -103,6 +105,7 @@ export default defineComponent({
isPremium: false,
hideViews: false,
addToPlaylistPromptCloseCallback: null,
debounceGetDeArrowThumbnail: null,
}
},
computed: {
Expand Down Expand Up @@ -307,6 +310,14 @@ export default defineComponent({
},

thumbnail: function () {
if (this.thumbnailPreference === 'hidden') {
return require('../../assets/img/thumbnail_placeholder.svg')
}

if (this.useDeArrowThumbnails && this.deArrowCache?.thumbnail != null) {
return this.deArrowCache.thumbnail
}

let baseUrl
if (this.backendPreference === 'invidious') {
baseUrl = this.currentInvidiousInstance
Expand All @@ -321,8 +332,6 @@ export default defineComponent({
return `${baseUrl}/vi/${this.id}/mq2.jpg`
case 'end':
return `${baseUrl}/vi/${this.id}/mq3.jpg`
case 'hidden':
return require('../../assets/img/thumbnail_placeholder.svg')
default:
return `${baseUrl}/vi/${this.id}/mqdefault.jpg`
}
Expand Down Expand Up @@ -371,6 +380,13 @@ export default defineComponent({
}
},

displayDuration: function () {
if (this.useDeArrowTitles && (this.duration === '' || this.duration === '0:00') && this.deArrowCache?.videoDuration) {
return formatDurationAsTimestamp(this.deArrowCache.videoDuration)
}
return this.duration
},

playlistIdTypePairFinal() {
if (this.playlistId) {
return {
Expand Down Expand Up @@ -458,6 +474,10 @@ export default defineComponent({
return this.$store.getters.getUseDeArrowTitles
},

useDeArrowThumbnails: function () {
return this.$store.getters.getUseDeArrowThumbnails
},

deArrowCache: function () {
return this.$store.getters.getDeArrowCache[this.id]
},
Expand All @@ -478,21 +498,54 @@ export default defineComponent({
this.parseVideoData()
this.checkIfWatched()

if (this.useDeArrowTitles && !this.deArrowCache) {
if ((this.useDeArrowTitles || this.useDeArrowThumbnails) && !this.deArrowCache) {
this.fetchDeArrowData()
}

if (this.useDeArrowThumbnails && this.deArrowCache && this.deArrowCache.thumbnail == null) {
if (this.debounceGetDeArrowThumbnail == null) {
this.debounceGetDeArrowThumbnail = debounce(this.fetchDeArrowThumbnail, 1000)
}

this.debounceGetDeArrowThumbnail()
}
},
methods: {
fetchDeArrowThumbnail: async function() {
if (this.thumbnailPreference === 'hidden') { return }
const videoId = this.id
const thumbnail = await deArrowThumbnail(videoId, this.deArrowCache.thumbnailTimestamp)
if (thumbnail) {
const deArrowCacheClone = deepCopy(this.deArrowCache)
deArrowCacheClone.thumbnail = thumbnail
this.$store.commit('addThumbnailToDeArrowCache', deArrowCacheClone)
}
},
fetchDeArrowData: async function() {
const videoId = this.id
const data = await deArrowData(this.id)
const cacheData = { videoId, title: null }
const cacheData = { videoId, title: null, videoDuration: null, thumbnail: null, thumbnailTimestamp: null }
if (Array.isArray(data?.titles) && data.titles.length > 0 && (data.titles[0].locked || data.titles[0].votes >= 0)) {
cacheData.title = data.titles[0].title
}
if (Array.isArray(data?.thumbnails) && data.thumbnails.length > 0 && (data.thumbnails[0].locked || data.thumbnails[0].votes >= 0)) {
cacheData.thumbnailTimestamp = data.thumbnails.at(0).timestamp
} else if (data?.videoDuration != null) {
cacheData.thumbnailTimestamp = data.videoDuration * data.randomTime
}
cacheData.videoDuration = data?.videoDuration ? Math.floor(data.videoDuration) : null

// Save data to cache whether data available or not to prevent duplicate requests
this.$store.commit('addVideoToDeArrowCache', cacheData)

// fetch dearrow thumbnails if enabled
if (this.useDeArrowThumbnails && this.deArrowCache?.thumbnail === null) {
if (this.debounceGetDeArrowThumbnail == null) {
this.debounceGetDeArrowThumbnail = debounce(this.fetchDeArrowThumbnail, 1000)
}

this.debounceGetDeArrowThumbnail()
}
},

handleExternalPlayer: function () {
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/ft-list-video/ft-list-video.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
>
</router-link>
<div
v-if="isLive || isUpcoming || (duration !== '' && duration !== '0:00')"
v-if="isLive || isUpcoming || (displayDuration !== '' && displayDuration !== '0:00')"
class="videoDuration"
:class="{
live: isLive,
upcoming: isUpcoming
}"
>
{{ isLive ? $t("Video.Live") : (isUpcoming ? $t("Video.Upcoming") : duration) }}
{{ isLive ? $t("Video.Live") : (isUpcoming ? $t("Video.Upcoming") : displayDuration) }}
</div>
<ft-icon-button
v-if="externalPlayer !== ''"
Expand Down
8 changes: 8 additions & 0 deletions src/renderer/components/ft-video-player/ft-video-player.js
Original file line number Diff line number Diff line change
Expand Up @@ -1832,6 +1832,8 @@ export default defineComponent({
const bCode = captionB.language_code.split('-')
const aName = (captionA.label) // ex: english (auto-generated)
const bName = (captionB.label)
const aIsAutotranslated = captionA.is_autotranslated
const bIsAutotranslated = captionB.is_autotranslated
const userLocale = this.currentLocale.split('-') // ex. [en,US]
if (aCode[0] === userLocale[0]) { // caption a has same language as user's locale
if (bCode[0] === userLocale[0]) { // caption b has same language as user's locale
Expand All @@ -1841,6 +1843,12 @@ export default defineComponent({
} else if (aName.search('auto') !== -1) {
// prefer caption b: a is auto-generated captions
return 1
} else if (bIsAutotranslated) {
// prefer caption a: b is auto-translated captions
return -1
} else if (aIsAutotranslated) {
// prefer caption b: a is auto-translated captions
return 1
} else if (aCode[1] === userLocale[1]) {
// prefer caption a: caption a has same county code as user's locale
return -1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ export default defineComponent({

useDeArrowTitles: function () {
return this.$store.getters.getUseDeArrowTitles
}
},
useDeArrowThumbnails: function () {
return this.$store.getters.getUseDeArrowThumbnails
},
deArrowThumbnailGeneratorUrl: function () {
return this.$store.getters.getDeArrowThumbnailGeneratorUrl
},
},
methods: {
handleUpdateSponsorBlock: function (value) {
Expand All @@ -53,12 +59,22 @@ export default defineComponent({
this.updateUseDeArrowTitles(value)
},

handleUpdateUseDeArrowThumbnails: function (value) {
this.updateUseDeArrowThumbnails(value)
},

handleUpdateSponsorBlockUrl: function (value) {
const sponsorBlockUrlWithoutTrailingSlash = value.replace(/\/$/, '')
const sponsorBlockUrlWithoutApiSuffix = sponsorBlockUrlWithoutTrailingSlash.replace(/\/api$/, '')
this.updateSponsorBlockUrl(sponsorBlockUrlWithoutApiSuffix)
},

handleUpdateDeArrowThumbnailGeneratorUrl: function (value) {
const urlWithoutTrailingSlash = value.replace(/\/$/, '')
const urlWithoutApiSuffix = urlWithoutTrailingSlash.replace(/\/api$/, '')
this.updateDeArrowThumbnailGeneratorUrl(urlWithoutApiSuffix)
},

handleUpdateSponsorBlockShowSkippedToast: function (value) {
this.updateSponsorBlockShowSkippedToast(value)
},
Expand All @@ -67,7 +83,9 @@ export default defineComponent({
'updateUseSponsorBlock',
'updateSponsorBlockUrl',
'updateSponsorBlockShowSkippedToast',
'updateUseDeArrowTitles'
'updateUseDeArrowTitles',
'updateUseDeArrowThumbnails',
'updateDeArrowThumbnailGeneratorUrl'
])
}
})
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@
:tooltip="$t('Tooltips.SponsorBlock Settings.UseDeArrowTitles')"
@change="handleUpdateUseDeArrowTitles"
/>
<ft-toggle-switch
:label="$t('Settings.SponsorBlock Settings.UseDeArrowThumbnails')"
:default-value="useDeArrowThumbnails"
:tooltip="$t('Tooltips.SponsorBlock Settings.UseDeArrowThumbnails')"
@change="handleUpdateUseDeArrowThumbnails"
/>
</ft-flex-box>
<template
v-if="useSponsorBlock || useDeArrowTitles"
v-if="useSponsorBlock || useDeArrowTitles || useDeArrowThumbnails"
>
<ft-flex-box
v-if="useSponsorBlock"
Expand All @@ -37,6 +43,19 @@
@input="handleUpdateSponsorBlockUrl"
/>
</ft-flex-box>
<ft-flex-box
v-if="useDeArrowThumbnails"
>
<ft-input
v-if="useDeArrowThumbnails"
:placeholder="$t('Settings.SponsorBlock Settings[\'DeArrow Thumbnail Generator API Url (Default is https://dearrow-thumb.ajay.app)\']')"
:show-action-button="false"
:show-label="true"
:value="deArrowThumbnailGeneratorUrl"
@input="handleUpdateDeArrowThumbnailGeneratorUrl"
/>
</ft-flex-box>

<ft-flex-box
v-if="useSponsorBlock"
>
Expand Down
Loading

0 comments on commit 8d5f3b2

Please sign in to comment.