Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/development' into development
Browse files Browse the repository at this point in the history
# Conflicts:
#	yarn.lock
  • Loading branch information
MarmadileManteater committed Oct 10, 2022
2 parents ec906ef + 687352f commit d5bc0cd
Show file tree
Hide file tree
Showing 13 changed files with 205 additions and 212 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/flatpak.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- uses: actions/checkout@v3
with:
repository: flathub/io.freetubeapp.FreeTube
token: ${{ secrets.PUSH_TOKEN }}
token: ${{ secrets.FLATHUB_TOKEN }}
- name: GitHub API exec action
uses: moustacheful/github-api-exec-action@v0
id: api_results
Expand Down Expand Up @@ -77,22 +77,22 @@ jobs:
date +"%Y-%m-%d" >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Update x64 File Location in yml File
uses: mikefarah/yq@v4.27.5
uses: mikefarah/yq@v4.28.1
with:
# The Command which should be run
cmd: yq w -i io.freetubeapp.FreeTube.yml modules[0].sources[0].url 'https://github.com/FreeTubeApp/FreeTube/releases/download/v${{ steps.sub.outputs.result }}-beta/freetube-${{ steps.sub.outputs.result }}-linux-portable-x64.zip'
- name: Update x64 Hash in yml File
uses: mikefarah/yq@v4.27.5
uses: mikefarah/yq@v4.28.1
with:
# The Command which should be run
cmd: yq w -i io.freetubeapp.FreeTube.yml modules[0].sources[0].sha256 ${{ env.HASH_X64 }}
- name: Update ARM File Location in yml File
uses: mikefarah/yq@v4.27.5
uses: mikefarah/yq@v4.28.1
with:
# The Command which should be run
cmd: yq w -i io.freetubeapp.FreeTube.yml modules[0].sources[1].url 'https://github.com/FreeTubeApp/FreeTube/releases/download/v${{ steps.sub.outputs.result }}-beta/freetube-${{ steps.sub.outputs.result }}-linux-portable-arm64.zip'
- name: Update ARM Hash in yml File
uses: mikefarah/yq@v4.27.5
uses: mikefarah/yq@v4.28.1
with:
# The Command which should be run
cmd: yq w -i io.freetubeapp.FreeTube.yml modules[0].sources[1].sha256 ${{ env.HASH_ARM64 }}
Expand All @@ -108,7 +108,7 @@ jobs:
# Optional but recommended
# Defaults to "Apply automatic changes"
commit_message: Update files for v${{ steps.sub.outputs.result }}
token: ${{ secrets.PUSH_TOKEN }}
token: ${{ secrets.FLATHUB_TOKEN }}

# Optional options appended to `git-commit`
# See https://git-scm.com/docs/git-commit for a list of available options
Expand All @@ -118,7 +118,7 @@ jobs:
skip_dirty_check: true
- name: Create PR
run: |
echo ${{ secrets.PUSH_TOKEN }} >> auth.txt
echo ${{ secrets.FLATHUB_TOKEN }} >> auth.txt
gh auth login --with-token < auth.txt
rm auth.txt
gh pr create --title "Release v${{ steps.sub.outputs.result }}" --body "This is an automated PR for the v${{ steps.sub.outputs.result }} release. This PR will be updated and merged once testing is complete."
36 changes: 28 additions & 8 deletions .github/workflows/report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: Project Board Automation

on:
issues:
types: [labeled, unlabeled, closed, deleted]
types: [closed, deleted, reopened, opened]

jobs:
assign-issues-to-projects:
Expand All @@ -14,37 +14,57 @@ jobs:
# For bug reports
- name: New bug issue
uses: alex-page/github-project-automation-plus@v0.8.1
if: github.event.action == 'labeled' && contains(github.event.issue.labels.*.name, 'bug')
if: contains(github.event.issue.labels.*.name, 'bug') && github.event.action == 'opened'
with:
project: Bug Reports
column: To assign
repo-token: ${{ secrets.PUSH_TOKEN }}
action: update

- name: Bug label removed
- name: Bug issue closed
uses: alex-page/github-project-automation-plus@v0.8.1
if: github.event.action == 'unlabeled' || github.event.action == 'closed' || github.event.action == 'deleted'
if: github.event.action == 'closed' || github.event.action == 'deleted'
with:
action: delete
project: Bug Reports
column: To assign
repo-token: ${{ secrets.PUSH_TOKEN }}

- name: Bug issue reopened
uses: alex-page/github-project-automation-plus@v0.8.1
if: contains(github.event.issue.labels.*.name, 'bug') && github.event.action == 'reopened'
with:
project: Bug Reports
column: To assign
repo-token: ${{ secrets.PUSH_TOKEN }}
action: update

# For feature requests
- name: New feature issue
uses: alex-page/github-project-automation-plus@v0.8.1
if: github.event.action == 'labeled' && contains(github.event.issue.labels.*.name, 'enhancement')
if: contains(github.event.issue.labels.*.name, 'enhancement') && github.event.action == 'opened'
with:
project: Feature Requests
column: To assign
repo-token: ${{ secrets.PUSH_TOKEN }}
action: update

- name: Feature request label removed
- name: Feature request issue closed
uses: alex-page/github-project-automation-plus@v0.8.1
if: github.event.action == 'unlabeled' || github.event.action == 'closed' || github.event.action == 'deleted'
if: github.event.action == 'closed' || github.event.action == 'deleted'
with:
action: delete
project: Feature Requests
column: To assign
repo-token: ${{ secrets.PUSH_TOKEN }}

- name: Feature request issue reopened
uses: alex-page/github-project-automation-plus@v0.8.1
if: contains(github.event.issue.labels.*.name, 'enhancement') && github.event.action == 'reopened'
with:
project: Feature Requests
column: To assign
repo-token: ${{ secrets.PUSH_TOKEN }}
action: update


6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"vue-router": "^3.6.5",
"vuex": "^3.6.2",
"youtube-suggest": "^1.2.0",
"yt-channel-info": "^3.1.0",
"yt-channel-info": "^3.1.1",
"yt-dash-manifest-generator": "1.1.0",
"ytdl-core": "^4.11.2",
"ytpl": "^2.3.0",
Expand Down Expand Up @@ -112,8 +112,8 @@
"html-webpack-plugin": "^5.3.2",
"js-yaml": "^4.1.0",
"json-minimizer-webpack-plugin": "^4.0.0",
"lefthook": "^1.1.1",
"mini-css-extract-plugin": "^2.2.2",
"lefthook": "^1.1.2",
"mini-css-extract-plugin": "^2.6.1",
"npm-run-all": "^4.1.5",
"prettier": "^2.3.2",
"rimraf": "^3.0.2",
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/data-settings/data-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { MAIN_PROFILE_ID } from '../../../constants'
import fs from 'fs'
import { opmlToJSON } from 'opml-to-json'
import ytch from 'yt-channel-info'
import { calculateColorLuminance } from '../../helpers/utils'

// FIXME: Missing web logic branching

Expand Down Expand Up @@ -1092,7 +1093,7 @@ export default Vue.extend({
let index = convertedData.findIndex(p => p.name === profile.value)
if (index === -1) { // profile doesn't exist yet
const randomBgColor = await this.getRandomColor()
const contrastyTextColor = await this.calculateColorLuminance(randomBgColor)
const contrastyTextColor = calculateColorLuminance(randomBgColor)
convertedData.push({
name: profile.value,
bgColor: randomBgColor,
Expand Down Expand Up @@ -1241,7 +1242,6 @@ export default Vue.extend({
'compactHistory',
'showToast',
'getRandomColor',
'calculateColorLuminance',
'showOpenDialog',
'readFileFromDialog',
'showSaveDialog',
Expand Down
8 changes: 4 additions & 4 deletions src/renderer/components/ft-profile-edit/ft-profile-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import FtFlexBox from '../../components/ft-flex-box/ft-flex-box.vue'
import FtInput from '../../components/ft-input/ft-input.vue'
import FtButton from '../../components/ft-button/ft-button.vue'
import { MAIN_PROFILE_ID } from '../../../constants'
import { calculateColorLuminance } from '../../helpers/utils'

export default Vue.extend({
name: 'FtProfileEdit',
Expand Down Expand Up @@ -70,8 +71,8 @@ export default Vue.extend({
}
},
watch: {
profileBgColor: async function (val) {
this.profileTextColor = await this.calculateColorLuminance(val)
profileBgColor: function (val) {
this.profileTextColor = calculateColorLuminance(val)
}
},
created: function () {
Expand Down Expand Up @@ -163,8 +164,7 @@ export default Vue.extend({
'updateProfile',
'removeProfile',
'updateDefaultProfile',
'updateActiveProfile',
'calculateColorLuminance'
'updateActiveProfile'
])
}
})
6 changes: 3 additions & 3 deletions src/renderer/components/ft-video-player/ft-video-player.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import 'videojs-http-source-selector'

import { IpcChannels } from '../../../constants'
import { sponsorBlockSkipSegments } from '../../helpers/sponsorblock'
import { calculateColorLuminance } from '../../helpers/utils'

export default Vue.extend({
name: 'FtVideoPlayer',
Expand Down Expand Up @@ -1175,7 +1176,7 @@ export default Vue.extend({
videojs.registerComponent('loopButton', loopButton)
},

toggleVideoLoop: async function () {
toggleVideoLoop: function () {
const loopButton = document.getElementById('loopButton')

if (!this.player.loop()) {
Expand All @@ -1187,7 +1188,7 @@ export default Vue.extend({
return color === currentTheme
})

const themeTextColor = await this.calculateColorLuminance(colorValues[nameIndex])
const themeTextColor = calculateColorLuminance(colorValues[nameIndex])

loopButton.classList.add('vjs-icon-loop-active')

Expand Down Expand Up @@ -1923,7 +1924,6 @@ export default Vue.extend({
},

...mapActions([
'calculateColorLuminance',
'updateDefaultCaptionSettings',
'showToast',
'parseScreenshotCustomFileName',
Expand Down
103 changes: 103 additions & 0 deletions src/renderer/helpers/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
export function calculateColorLuminance(colorValue) {
const cutHex = colorValue.substring(1, 7)
const colorValueR = parseInt(cutHex.substring(0, 2), 16)
const colorValueG = parseInt(cutHex.substring(2, 4), 16)
const colorValueB = parseInt(cutHex.substring(4, 6), 16)

const luminance = (0.299 * colorValueR + 0.587 * colorValueG + 0.114 * colorValueB) / 255

if (luminance > 0.5) {
return '#000000'
} else {
return '#FFFFFF'
}
}

export function calculatePublishedDate(publishedText) {
const date = new Date()
if (publishedText === 'Live') {
return publishedText
}

const textSplit = publishedText.split(' ')

if (textSplit[0].toLowerCase() === 'streamed') {
textSplit.shift()
}

const timeFrame = textSplit[1]
const timeAmount = parseInt(textSplit[0])
let timeSpan = null

if (timeFrame.indexOf('second') > -1) {
timeSpan = timeAmount * 1000
} else if (timeFrame.indexOf('minute') > -1) {
timeSpan = timeAmount * 60000
} else if (timeFrame.indexOf('hour') > -1) {
timeSpan = timeAmount * 3600000
} else if (timeFrame.indexOf('day') > -1) {
timeSpan = timeAmount * 86400000
} else if (timeFrame.indexOf('week') > -1) {
timeSpan = timeAmount * 604800000
} else if (timeFrame.indexOf('month') > -1) {
timeSpan = timeAmount * 2592000000
} else if (timeFrame.indexOf('year') > -1) {
timeSpan = timeAmount * 31556952000
}

return date.getTime() - timeSpan
}

export function buildVTTFileLocally(storyboard) {
let vttString = 'WEBVTT\n\n'
// how many images are in one image
const numberOfSubImagesPerImage = storyboard.sWidth * storyboard.sHeight
// the number of storyboard images
const numberOfImages = Math.ceil(storyboard.count / numberOfSubImagesPerImage)
const intervalInSeconds = storyboard.interval / 1000
let currentUrl = storyboard.url
let startHours = 0
let startMinutes = 0
let startSeconds = 0
let endHours = 0
let endMinutes = 0
let endSeconds = intervalInSeconds
for (let i = 0; i < numberOfImages; i++) {
let xCoord = 0
let yCoord = 0
for (let j = 0; j < numberOfSubImagesPerImage; j++) {
// add the timestamp information
const paddedStartHours = startHours.toString().padStart(2, '0')
const paddedStartMinutes = startMinutes.toString().padStart(2, '0')
const paddedStartSeconds = startSeconds.toString().padStart(2, '0')
const paddedEndHours = endHours.toString().padStart(2, '0')
const paddedEndMinutes = endMinutes.toString().padStart(2, '0')
const paddedEndSeconds = endSeconds.toString().padStart(2, '0')
vttString += `${paddedStartHours}:${paddedStartMinutes}:${paddedStartSeconds}.000 --> ${paddedEndHours}:${paddedEndMinutes}:${paddedEndSeconds}.000\n`
// add the current image url as well as the x, y, width, height information
vttString += currentUrl + `#xywh=${xCoord},${yCoord},${storyboard.width},${storyboard.height}\n\n`
// update the variables
startHours = endHours
startMinutes = endMinutes
startSeconds = endSeconds
endSeconds += intervalInSeconds
if (endSeconds >= 60) {
endSeconds -= 60
endMinutes += 1
}
if (endMinutes >= 60) {
endMinutes -= 60
endHours += 1
}
// x coordinate can only be smaller than the width of one subimage * the number of subimages per row
xCoord = (xCoord + storyboard.width) % (storyboard.width * storyboard.sWidth)
// only if the x coordinate is , so in a new row, we have to update the y coordinate
if (xCoord === 0) {
yCoord += storyboard.height
}
}
// make sure that there is no value like M0 or M1 in the parameters that gets replaced
currentUrl = currentUrl.replace('M' + i.toString() + '.jpg', 'M' + (i + 1).toString() + '.jpg')
}
return vttString
}
3 changes: 2 additions & 1 deletion src/renderer/store/modules/profiles.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { MAIN_PROFILE_ID } from '../../../constants'
import { DBProfileHandlers } from '../../../datastores/handlers/index'
import { calculateColorLuminance } from '../../helpers/utils'

const state = {
profileList: [{
Expand Down Expand Up @@ -53,7 +54,7 @@ const actions = {
if (profiles.length === 0) {
// Create a default profile and persist it
const randomColor = await dispatch('getRandomColor')
const textColor = await dispatch('calculateColorLuminance', randomColor)
const textColor = calculateColorLuminance(randomColor)
const defaultProfile = {
_id: MAIN_PROFILE_ID,
name: defaultName,
Expand Down
Loading

0 comments on commit d5bc0cd

Please sign in to comment.