Skip to content

Commit

Permalink
Merge branch 'development' into feature/playlist-2023-05
Browse files Browse the repository at this point in the history
* development:
  ! Fix playlist item fetching for local API (FreeTubeApp#4102)
  ! Fix watch page video published time parsing (FreeTubeApp#4105)
  Translated using Weblate (Serbian)
  Bump youtubei.js from 6.4.0 to 6.4.1 (FreeTubeApp#4090)
  Bump rimraf from 5.0.1 to 5.0.5 (FreeTubeApp#4091)
  Bump the stylelint group with 2 updates (FreeTubeApp#4088)
  Bump electron from 22.3.24 to 22.3.25 (FreeTubeApp#4089)
  Translated using Weblate (Bulgarian)
  Update FT history import to accept key lastViewedPlaylistId (FreeTubeApp#4038)
  Translated using Weblate (Dutch)
  Translated using Weblate (Lithuanian)
  Translated using Weblate (Japanese)
  Translated using Weblate (Croatian)
  Translated using Weblate (Estonian)
  Translated using Weblate (Croatian)

# Conflicts:
#	src/renderer/components/data-settings/data-settings.js
#	src/renderer/components/ft-list-video/ft-list-video.js
#	src/renderer/components/watch-video-info/watch-video-info.js
#	src/renderer/views/Playlist/Playlist.js
#	src/renderer/views/Watch/Watch.js
  • Loading branch information
PikachuEXE committed Oct 8, 2023
2 parents 25c75ce + 5c8d49b commit 21be0b1
Show file tree
Hide file tree
Showing 15 changed files with 941 additions and 341 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"vue-router": "^3.6.5",
"vue-tiny-slider": "^0.1.39",
"vuex": "^3.6.2",
"youtubei.js": "^6.4.0"
"youtubei.js": "^6.4.1"
},
"devDependencies": {
"@babel/core": "^7.23.0",
Expand All @@ -90,7 +90,7 @@
"copy-webpack-plugin": "^11.0.0",
"css-loader": "^6.8.1",
"css-minimizer-webpack-plugin": "^5.0.1",
"electron": "^22.3.24",
"electron": "^22.3.25",
"electron-builder": "^24.6.4",
"eslint": "^8.50.0",
"eslint-config-prettier": "^9.0.0",
Expand All @@ -110,10 +110,10 @@
"lefthook": "^1.5.0",
"mini-css-extract-plugin": "^2.7.6",
"npm-run-all": "^4.1.5",
"postcss": "^8.4.30",
"postcss-scss": "^4.0.8",
"postcss": "^8.4.31",
"postcss-scss": "^4.0.9",
"prettier": "^2.8.8",
"rimraf": "^5.0.1",
"rimraf": "^5.0.5",
"sass": "^1.68.0",
"sass-loader": "^13.3.2",
"stylelint": "^15.10.3",
Expand Down
27 changes: 19 additions & 8 deletions src/renderer/components/data-settings/data-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -698,20 +698,28 @@ export default defineComponent({
textDecode.pop()

const requiredKeys = [
'_id',
'author',
'authorId',
'description',
'isLive',
'lengthSeconds',
'paid',
'published',
'timeWatched',
'title',
'type',
'videoId',
'viewCount',
'watchProgress'
'watchProgress',
]

const optionalKeys = [
// `_id` absent if marked as watched manually
'_id',
'lastViewedPlaylistId',
]

const ignoredKeys = [
'paid',
]

textDecode.forEach((history) => {
Expand All @@ -723,15 +731,19 @@ export default defineComponent({
const historyObject = {}

Object.keys(historyData).forEach((key) => {
if (!requiredKeys.includes(key)) {
showToast(`Unknown data key: ${key}`)
} else {
if (requiredKeys.includes(key) || optionalKeys.includes(key)) {
historyObject[key] = historyData[key]
} else if (!ignoredKeys.includes(key)) {
showToast(`Unknown data key: ${key}`)
}
// Else do not import the key
})

if (Object.keys(historyObject).length < (requiredKeys.length - 2)) {
const historyObjectKeysSet = new Set(Object.keys(historyObject))
const missingKeys = requiredKeys.filter(x => !historyObjectKeysSet.has(x))
if (missingKeys.length > 0) {
showToast(this.$t('Settings.Data Settings.History object has insufficient data, skipping item'))
console.error('Missing Keys: ', missingKeys, historyData)
} else {
this.updateHistory(historyObject)
}
Expand Down Expand Up @@ -815,7 +827,6 @@ export default defineComponent({
historyObject.lengthSeconds = null
historyObject.watchProgress = 1
historyObject.isLive = false
historyObject.paid = false

this.updateHistory(historyObject)
}
Expand Down
1 change: 0 additions & 1 deletion src/renderer/components/ft-list-video/ft-list-video.js
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,6 @@ export default defineComponent({
watchProgress: 0,
timeWatched: new Date().getTime(),
isLive: false,
paid: false,
type: 'video'
}
this.updateHistory(videoData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import FtLoader from '../ft-loader/ft-loader.vue'
import FtCard from '../ft-card/ft-card.vue'
import FtListVideoLazy from '../ft-list-video-lazy/ft-list-video-lazy.vue'
import { copyToClipboard, showToast } from '../../helpers/utils'
import { getLocalPlaylist, parseLocalPlaylistVideo } from '../../helpers/api/local'
import {
getLocalPlaylist,
parseLocalPlaylistVideo,
untilEndOfLocalPlayList,
} from '../../helpers/api/local'
import { invidiousGetPlaylistInfo } from '../../helpers/api/invidious'

export default defineComponent({
Expand Down Expand Up @@ -362,21 +366,12 @@ export default defineComponent({
if (!process.env.IS_ELECTRON || this.backendPreference === 'invidious' || cachedPlaylist.continuationData === null) {
this.playlistItems = cachedPlaylist.items
} else {
const items = cachedPlaylist.items
let playlist = cachedPlaylist.continuationData
const videos = cachedPlaylist.items
await untilEndOfLocalPlayList(cachedPlaylist.continuationData, (p) => {
videos.push(...p.items.map(parseLocalPlaylistVideo))
}, { runCallbackOnceFirst: false })

do {
playlist = await playlist.getContinuation()

const parsedVideos = playlist.items.map(parseLocalPlaylistVideo)
items.push(...parsedVideos)

if (!playlist.has_continuation) {
playlist = null
}
} while (playlist !== null)

this.playlistItems = items
this.playlistItems = videos
}

this.isLoading = false
Expand All @@ -386,7 +381,7 @@ export default defineComponent({
this.isLoading = true

try {
let playlist = await getLocalPlaylist(this.playlistId)
const playlist = await getLocalPlaylist(this.playlistId)

let channelName

Expand All @@ -403,14 +398,10 @@ export default defineComponent({
this.channelName = channelName
this.channelId = playlist.info.author?.id

const videos = playlist.items.map(parseLocalPlaylistVideo)

while (playlist.has_continuation) {
playlist = await playlist.getContinuation()

const parsedVideos = playlist.items.map(parseLocalPlaylistVideo)
videos.push(...parsedVideos)
}
const videos = []
await untilEndOfLocalPlayList(playlist, (p) => {
videos.push(...p.items.map(parseLocalPlaylistVideo))
})

this.playlistItems = videos

Expand Down
41 changes: 41 additions & 0 deletions src/renderer/helpers/api/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,47 @@ export async function getLocalPlaylist(id) {
return await innertube.getPlaylist(id)
}

/**
* @param {Playlist} playlist
* @returns {Playlist|null} null when no valid playlist can be found (e.g. `empty continuation response`)
*/
export async function getLocalPlaylistContinuation(playlist) {
try {
return await playlist.getContinuation()
} catch (error) {
// Youtube can provide useless continuation data
if (!error.message.includes('Got empty continuation response.')) {
// Re-throw unhandled error
throw error
}

return null
}
}

/**
* Callback for adding two numbers.
*
* @callback untilEndOfLocalPlayListCallback
* @param {Playlist} playlist
*/

/**
* @param {Playlist} playlist
* @param {untilEndOfLocalPlayListCallback} callback
* @param {object} options
* @param {boolean} options.runCallbackOnceFirst
*/
export async function untilEndOfLocalPlayList(playlist, callback, options = { runCallbackOnceFirst: true }) {
if (options.runCallbackOnceFirst) { callback(playlist) }

while (playlist != null && playlist.has_continuation) {
playlist = await getLocalPlaylistContinuation(playlist)

if (playlist != null) { callback(playlist) }
}
}

/**
* @param {string} location
* @param {'default'|'music'|'gaming'|'movies'} tab
Expand Down
20 changes: 14 additions & 6 deletions src/renderer/views/Playlist/Playlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import PlaylistInfo from '../../components/playlist-info/playlist-info.vue'
import FtListVideoLazy from '../../components/ft-list-video-lazy/ft-list-video-lazy.vue'
import FtFlexBox from '../../components/ft-flex-box/ft-flex-box.vue'
import FtButton from '../../components/ft-button/ft-button.vue'
import { getLocalPlaylist, parseLocalPlaylistVideo } from '../../helpers/api/local'
import {
getLocalPlaylist,
getLocalPlaylistContinuation,
parseLocalPlaylistVideo,
} from '../../helpers/api/local'
import { extractNumberFromString, showToast } from '../../helpers/utils'
import { invidiousGetPlaylistInfo, youtubeImageUrlToInvidious } from '../../helpers/api/invidious'

Expand Down Expand Up @@ -302,12 +306,16 @@ export default defineComponent({
getNextPageLocal: function () {
this.isLoadingMore = true

this.continuationData.getContinuation().then((result) => {
const parsedVideos = result.items.map(parseLocalPlaylistVideo)
this.playlistItems = this.playlistItems.concat(parsedVideos)
getLocalPlaylistContinuation(this.continuationData).then((result) => {
if (result) {
const parsedVideos = result.items.map(parseLocalPlaylistVideo)
this.playlistItems = this.playlistItems.concat(parsedVideos)

if (result.has_continuation) {
this.continuationData = result
if (result.has_continuation) {
this.continuationData = result
} else {
this.continuationData = null
}
} else {
this.continuationData = null
}
Expand Down
5 changes: 3 additions & 2 deletions src/renderer/views/Watch/Watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,8 @@ export default defineComponent({
channelId: this.channelId
})

this.videoPublished = new Date(result.page[0].microformat.publish_date.replace('-', '/')).getTime()
// `result.page[0].microformat.publish_date` example value: `2023-08-12T08:59:59-07:00`
this.videoPublished = new Date(result.page[0].microformat.publish_date).getTime()

if (result.secondary_info?.description.runs) {
try {
Expand Down Expand Up @@ -1049,7 +1050,7 @@ export default defineComponent({
watchProgress: watchProgress,
timeWatched: new Date().getTime(),
isLive: false,
type: 'video'
type: 'video',
}

this.updateHistory(videoData)
Expand Down
3 changes: 3 additions & 0 deletions static/locales/bg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ Subscriptions:
All Subscription Tabs Hidden: Всички раздели на абонамента са скрити. За да виждате
съдържанието тук, моля, премахнете скриването на някои раздели в секция "{subsection}"
на "{settingsSection}".
Load More Posts: Зареждане на още публикации
Empty Posts: В момента в абонираните от вас канали няма публикации.
Trending:
Trending: 'Набиращи популярност'
Trending Tabs: Раздели за набиращи популярност
Expand Down Expand Up @@ -441,6 +443,7 @@ Settings:
Hide Channel Podcasts: Скриване на подкастите на канала
Blur Thumbnails: Размазване на миниатюрите
Hide Profile Pictures in Comments: Скриване на профилните снимки в коментарите
Hide Subscriptions Community: Скриване на абонаментите Общност
The app needs to restart for changes to take effect. Restart and apply change?: Приложението
трябва да се рестартира за да се приложат промените. Рестартиране?
Proxy Settings:
Expand Down
3 changes: 3 additions & 0 deletions static/locales/et.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ Subscriptions:
Subscriptions Tabs: Tellimuste vahekaardid
All Subscription Tabs Hidden: Kõik tellimuse vahekaardid on peidetud. Siinse sisu
nägemiseks palun eemalda kaartide peitmine jaotises „{subsection}“ / „{settingsSection}“.
Load More Posts: Lisa järgmised postitused
Empty Posts: Sinu tellitud kanalites hetkel pole ühtegi postitust.
Trending:
Trending: 'Populaarsust koguvad videod'
Trending Tabs: Populaarsust koguvad kaardid
Expand Down Expand Up @@ -408,6 +410,7 @@ Settings:
Hide Subscriptions Live: Peida tellimuste otse-eetrid
Hide Profile Pictures in Comments: Peida kommentaaride profiilipildid
Blur Thumbnails: Hägusta pisipildid
Hide Subscriptions Community: Peida tellijate loend
Proxy Settings:
Error getting network information. Is your proxy configured properly?: Võrguteavet
ei õnnestu leida. Kas sa oled puhverserveri ikka korralikult seadistanud?
Expand Down
9 changes: 6 additions & 3 deletions static/locales/hr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ Subscriptions:
Subscriptions Tabs: Kartica pretplata
All Subscription Tabs Hidden: Sve kartice pretplate su skrivene. Za prikaz sadržaja
na ovom mjestu, sakrij neke kartice u odjeljku „{subsection}” u „{settingsSection}”.
Empty Posts: Kanali na koje si pretplaćen/a trenutačno nemaju objave.
Load More Posts: Učitaj još objava
Trending:
Trending: 'U trendu'
Trending Tabs: Kartice „U trendu”
Expand Down Expand Up @@ -431,11 +433,12 @@ Settings:
Subscriptions Page: Stranica pretplata
Hide Channel Podcasts: Sakrij kanal podcastova
Hide Channel Releases: Sakrij kanal izdanja
Hide Subscriptions Shorts: Sakrij kratka videa pretplate
Hide Subscriptions Live: Sakrij videa uživo pretplate
Hide Subscriptions Videos: Sakrij videa pretplate
Hide Subscriptions Shorts: Sakrij pretplate kratkih videa
Hide Subscriptions Live: Sakrij pretplate videa uživo
Hide Subscriptions Videos: Sakrij pretplate videa
Blur Thumbnails: Zamuti minijature
Hide Profile Pictures in Comments: Sakrij slike profila u komentarima
Hide Subscriptions Community: Sakrij pretplate zajednice
The app needs to restart for changes to take effect. Restart and apply change?: Promjene
će se primijeniti nakon ponovnog pokeretanja programa. Ponovo pokrenuti program?
Proxy Settings:
Expand Down
3 changes: 3 additions & 0 deletions static/locales/ja.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ Subscriptions:
Subscriptions Tabs: 登録チャンネル タブ
All Subscription Tabs Hidden: 全ての登録チャンネル タブが非表示になっています。こちらのコンテンツをご覧いただくには、"{settingsSection}"
内の "{subsection}" 項目でいくつかのタブの非表示を解除してください。
Load More Posts: もっと見る
Empty Posts: 現在、登録しているチャンネルには動画はありません。
Trending:
Trending: '急上昇'
Trending Tabs: 急上昇のタブ
Expand Down Expand Up @@ -404,6 +406,7 @@ Settings:
Hide Channel Releases: チャンネルの新着情報の非表示
Hide Profile Pictures in Comments: コメントでプロフィール写真を隠す
Blur Thumbnails: サムネイルをぼかす
Hide Subscriptions Community: チャンネルの購読者リストの非公開
The app needs to restart for changes to take effect. Restart and apply change?: 変更の反映には、アプリの再起動が必要です。再起動して変更を適用しますか?
Proxy Settings:
Error getting network information. Is your proxy configured properly?: ネットワーク情報の取得中にエラーが発生しました。プロキシーを正しく設定してますか?
Expand Down
1 change: 1 addition & 0 deletions static/locales/lt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Global:

Live: Tiesiogiai
Shorts: Šortai
Community: Bendruomenė
Version {versionNumber} is now available! Click for more details: 'Versija {versionNumber}
jau prieinama! Spustelėkite, jei norite gauti daugiau informacijos'
Download From Site: 'Atsisiųsti iš svetainės'
Expand Down
4 changes: 4 additions & 0 deletions static/locales/nl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Global:
View Count: 1 weergave | {count} weergaven
Watching Count: 1 aan het kijken | {count} aan het kijken
Channel Count: 1 kanaal | {count} kanalen
Community: Gemeenschap
Search / Go to URL: 'Zoeken / Ga naar URL'
# In Filter Button
Search Filters:
Expand Down Expand Up @@ -102,6 +103,8 @@ Subscriptions:
All Subscription Tabs Hidden: Alle abonnementstabbladen zijn verborgen. Om de inhoud
hier te zien moet u enkele tabbladen zichtbaar maken in de sectie ‘{subsection}’
onder ‘{settingsSection}’.
Load More Posts: Meer berichten laden
Empty Posts: De kanalen waarop u geabonneerd bent hebben momenteel geen berichten.
Trending:
Trending: 'Trending'
Trending Tabs: Tending-tabbladen
Expand Down Expand Up @@ -435,6 +438,7 @@ Settings:
Hide Channel Shorts: Kanaal-Shorts verbergen
Hide Subscriptions Shorts: Abonnement-Shorts verbergen
Hide Profile Pictures in Comments: Profielfoto's in opmerkingen verbergen
Hide Subscriptions Community: Abonnement­gemeenschappen verbergen
The app needs to restart for changes to take effect. Restart and apply change?: De
app moet opnieuw worden gestart om veranderingen aan te brengen. Wilt u de app
opnieuw starten en veranderingen toepassen?
Expand Down
Loading

0 comments on commit 21be0b1

Please sign in to comment.