mirror of https://github.com/FreeTubeApp/FreeTube
Add SUPPORTS_LOCAL_API build flag (#4931)
This commit is contained in:
parent
559671fd24
commit
af2913592e
|
@ -119,6 +119,7 @@ const config = {
|
|||
new webpack.DefinePlugin({
|
||||
'process.env.IS_ELECTRON': true,
|
||||
'process.env.IS_ELECTRON_MAIN': false,
|
||||
'process.env.SUPPORTS_LOCAL_API': true,
|
||||
'process.env.LOCALE_NAMES': JSON.stringify(processLocalesPlugin.localeNames),
|
||||
'process.env.GEOLOCATION_NAMES': JSON.stringify(readdirSync(path.join(__dirname, '..', 'static', 'geolocations')).map(filename => filename.replace('.json', ''))),
|
||||
'process.env.SWIPER_VERSION': `'${swiperVersion}'`
|
||||
|
|
|
@ -116,6 +116,7 @@ const config = {
|
|||
new webpack.DefinePlugin({
|
||||
'process.env.IS_ELECTRON': false,
|
||||
'process.env.IS_ELECTRON_MAIN': false,
|
||||
'process.env.SUPPORTS_LOCAL_API': false,
|
||||
'process.env.SWIPER_VERSION': `'${swiperVersion}'`,
|
||||
|
||||
// video.js' vhs-utils supports both atob() in web browsers and Buffer in node
|
||||
|
|
|
@ -1152,7 +1152,7 @@ export default defineComponent({
|
|||
copyToClipboard(err)
|
||||
})
|
||||
|
||||
if (process.env.IS_ELECTRON && this.backendFallback && this.backendPreference === 'invidious') {
|
||||
if (process.env.SUPPORTS_LOCAL_API && this.backendFallback && this.backendPreference === 'invidious') {
|
||||
showToast(this.$t('Falling back to Local API'))
|
||||
resolve(this.getChannelInfoLocal(channelId))
|
||||
} else {
|
||||
|
|
|
@ -95,7 +95,7 @@ export default defineComponent({
|
|||
this.postText = 'Shared post'
|
||||
this.type = 'text'
|
||||
let authorThumbnails = ['', 'https://yt3.ggpht.com/ytc/AAUvwnjm-0qglHJkAHqLFsCQQO97G7cCNDuDLldsrn25Lg=s88-c-k-c0x00ffffff-no-rj']
|
||||
if (!process.env.IS_ELECTRON || this.backendPreference === 'invidious') {
|
||||
if (!process.env.SUPPORTS_LOCAL_API || this.backendPreference === 'invidious') {
|
||||
authorThumbnails = authorThumbnails.map(thumbnail => {
|
||||
thumbnail.url = youtubeImageUrlToInvidious(thumbnail.url)
|
||||
return thumbnail
|
||||
|
@ -106,7 +106,7 @@ export default defineComponent({
|
|||
}
|
||||
this.postText = autolinker.link(this.data.postText)
|
||||
const authorThumbnails = deepCopy(this.data.authorThumbnails)
|
||||
if (!process.env.IS_ELECTRON || this.backendPreference === 'invidious') {
|
||||
if (!process.env.SUPPORTS_LOCAL_API || this.backendPreference === 'invidious') {
|
||||
authorThumbnails.forEach(thumbnail => {
|
||||
thumbnail.url = youtubeImageUrlToInvidious(thumbnail.url)
|
||||
})
|
||||
|
|
|
@ -1314,7 +1314,7 @@ export default defineComponent({
|
|||
|
||||
this.useDash = false
|
||||
this.useHls = false
|
||||
this.activeSourceList = (this.proxyVideos || !process.env.IS_ELECTRON)
|
||||
this.activeSourceList = (this.proxyVideos || !process.env.SUPPORTS_LOCAL_API)
|
||||
// use map here to return slightly different list without modifying original
|
||||
? this.sourceList.map((source) => {
|
||||
return {
|
||||
|
|
|
@ -24,10 +24,14 @@ export default defineComponent({
|
|||
},
|
||||
data: function () {
|
||||
return {
|
||||
backendValues: [
|
||||
'invidious',
|
||||
'local'
|
||||
],
|
||||
backendValues: process.env.SUPPORTS_LOCAL_API
|
||||
? [
|
||||
'invidious',
|
||||
'local'
|
||||
]
|
||||
: [
|
||||
'invidious'
|
||||
],
|
||||
viewTypeValues: [
|
||||
'grid',
|
||||
'list'
|
||||
|
@ -99,6 +103,10 @@ export default defineComponent({
|
|||
return this.defaultPages.map((route) => route.path.substring(1))
|
||||
},
|
||||
backendPreference: function () {
|
||||
if (!process.env.SUPPORTS_LOCAL_API && this.$store.getters.getBackendPreference === 'local') {
|
||||
this.handlePreferredApiBackend('invidious')
|
||||
}
|
||||
|
||||
return this.$store.getters.getBackendPreference
|
||||
},
|
||||
landingPage: function () {
|
||||
|
@ -149,10 +157,16 @@ export default defineComponent({
|
|||
},
|
||||
|
||||
backendNames: function () {
|
||||
return [
|
||||
this.$t('Settings.General Settings.Preferred API Backend.Invidious API'),
|
||||
this.$t('Settings.General Settings.Preferred API Backend.Local API')
|
||||
]
|
||||
if (process.env.SUPPORTS_LOCAL_API) {
|
||||
return [
|
||||
this.$t('Settings.General Settings.Preferred API Backend.Invidious API'),
|
||||
this.$t('Settings.General Settings.Preferred API Backend.Local API')
|
||||
]
|
||||
} else {
|
||||
return [
|
||||
this.$t('Settings.General Settings.Preferred API Backend.Invidious API')
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
viewTypeNames: function () {
|
||||
|
|
|
@ -125,7 +125,7 @@ export default defineComponent({
|
|||
|
||||
const postListFromRemote = (await Promise.all(channelsToLoadFromRemote.map(async (channel) => {
|
||||
let posts = []
|
||||
if (!process.env.IS_ELECTRON || this.backendPreference === 'invidious') {
|
||||
if (!process.env.SUPPORTS_LOCAL_API || this.backendPreference === 'invidious') {
|
||||
posts = await this.getChannelPostsInvidious(channel)
|
||||
} else {
|
||||
posts = await this.getChannelPostsLocal(channel)
|
||||
|
@ -229,7 +229,7 @@ export default defineComponent({
|
|||
showToast(`${errorMessage}: ${err}`, 10000, () => {
|
||||
copyToClipboard(err)
|
||||
})
|
||||
if (process.env.IS_ELECTRON && this.backendPreference === 'invidious' && this.backendFallback) {
|
||||
if (process.env.SUPPORTS_LOCAL_API && this.backendPreference === 'invidious' && this.backendFallback) {
|
||||
showToast(this.$t('Falling back to Local API'))
|
||||
resolve(this.getChannelPostsLocal(channel))
|
||||
} else {
|
||||
|
|
|
@ -135,7 +135,7 @@ export default defineComponent({
|
|||
let videos = []
|
||||
let name, thumbnailUrl
|
||||
|
||||
if (!process.env.IS_ELECTRON || this.backendPreference === 'invidious') {
|
||||
if (!process.env.SUPPORTS_LOCAL_API || this.backendPreference === 'invidious') {
|
||||
if (useRss) {
|
||||
({ videos, name, thumbnailUrl } = await this.getChannelLiveInvidiousRSS(channel))
|
||||
} else {
|
||||
|
@ -315,7 +315,7 @@ export default defineComponent({
|
|||
resolve(this.getChannelLiveInvidiousRSS(channel, failedAttempts + 1))
|
||||
break
|
||||
case 1:
|
||||
if (process.env.IS_ELECTRON && this.backendFallback) {
|
||||
if (process.env.SUPPORTS_LOCAL_API && this.backendFallback) {
|
||||
showToast(this.$t('Falling back to Local API'))
|
||||
resolve(this.getChannelLiveLocal(channel, failedAttempts + 1))
|
||||
} else {
|
||||
|
@ -360,7 +360,7 @@ export default defineComponent({
|
|||
case 0:
|
||||
return this.getChannelLiveInvidious(channel, failedAttempts + 1)
|
||||
case 1:
|
||||
if (process.env.IS_ELECTRON && this.backendFallback) {
|
||||
if (process.env.SUPPORTS_LOCAL_API && this.backendFallback) {
|
||||
showToast(this.$t('Falling back to Local API'))
|
||||
return this.getChannelLiveLocalRSS(channel, failedAttempts + 1)
|
||||
} else {
|
||||
|
|
|
@ -120,7 +120,7 @@ export default defineComponent({
|
|||
let videos = []
|
||||
let name
|
||||
|
||||
if (!process.env.IS_ELECTRON || this.backendPreference === 'invidious') {
|
||||
if (!process.env.SUPPORTS_LOCAL_API || this.backendPreference === 'invidious') {
|
||||
({ videos, name } = await this.getChannelShortsInvidious(channel))
|
||||
} else {
|
||||
({ videos, name } = await this.getChannelShortsLocal(channel))
|
||||
|
@ -234,7 +234,7 @@ export default defineComponent({
|
|||
})
|
||||
switch (failedAttempts) {
|
||||
case 0:
|
||||
if (process.env.IS_ELECTRON && this.backendFallback) {
|
||||
if (process.env.SUPPORTS_LOCAL_API && this.backendFallback) {
|
||||
showToast(this.$t('Falling back to Local API'))
|
||||
return this.getChannelShortsLocal(channel, failedAttempts + 1)
|
||||
} else {
|
||||
|
|
|
@ -135,7 +135,7 @@ export default defineComponent({
|
|||
let videos = []
|
||||
let name, thumbnailUrl
|
||||
|
||||
if (!process.env.IS_ELECTRON || this.backendPreference === 'invidious') {
|
||||
if (!process.env.SUPPORTS_LOCAL_API || this.backendPreference === 'invidious') {
|
||||
if (useRss) {
|
||||
({ videos, name, thumbnailUrl } = await this.getChannelVideosInvidiousRSS(channel))
|
||||
} else {
|
||||
|
@ -312,7 +312,7 @@ export default defineComponent({
|
|||
resolve(this.getChannelVideosInvidiousRSS(channel, failedAttempts + 1))
|
||||
break
|
||||
case 1:
|
||||
if (process.env.IS_ELECTRON && this.backendFallback) {
|
||||
if (process.env.SUPPORTS_LOCAL_API && this.backendFallback) {
|
||||
showToast(this.$t('Falling back to Local API'))
|
||||
resolve(this.getChannelVideosLocalScraper(channel, failedAttempts + 1))
|
||||
} else {
|
||||
|
@ -358,7 +358,7 @@ export default defineComponent({
|
|||
case 0:
|
||||
return this.getChannelVideosInvidiousScraper(channel, failedAttempts + 1)
|
||||
case 1:
|
||||
if (process.env.IS_ELECTRON && this.backendFallback) {
|
||||
if (process.env.SUPPORTS_LOCAL_API && this.backendFallback) {
|
||||
showToast(this.$t('Falling back to Local API'))
|
||||
return this.getChannelVideosLocalRSS(channel, failedAttempts + 1)
|
||||
} else {
|
||||
|
|
|
@ -284,7 +284,7 @@ export default defineComponent({
|
|||
this.searchSuggestionsDataList = results.suggestions
|
||||
}).catch((err) => {
|
||||
console.error(err)
|
||||
if (process.env.IS_ELECTRON && this.backendFallback) {
|
||||
if (process.env.SUPPORTS_LOCAL_API && this.backendFallback) {
|
||||
console.error(
|
||||
'Error gettings search suggestions. Falling back to Local API'
|
||||
)
|
||||
|
|
|
@ -151,7 +151,7 @@ export default defineComponent({
|
|||
|
||||
getCommentData: function () {
|
||||
this.isLoading = true
|
||||
if (!process.env.IS_ELECTRON || this.backendPreference === 'invidious') {
|
||||
if (!process.env.SUPPORTS_LOCAL_API || this.backendPreference === 'invidious') {
|
||||
this.getCommentDataInvidious()
|
||||
} else {
|
||||
this.getCommentDataLocal()
|
||||
|
@ -162,7 +162,7 @@ export default defineComponent({
|
|||
if (this.commentData.length === 0 || this.nextPageToken === null || typeof this.nextPageToken === 'undefined') {
|
||||
showToast(this.$t('Comments.There are no more comments for this video'))
|
||||
} else {
|
||||
if (!process.env.IS_ELECTRON || this.backendPreference === 'invidious') {
|
||||
if (!process.env.SUPPORTS_LOCAL_API || this.backendPreference === 'invidious') {
|
||||
this.getCommentDataInvidious()
|
||||
} else {
|
||||
this.getCommentDataLocal(true)
|
||||
|
@ -179,7 +179,7 @@ export default defineComponent({
|
|||
},
|
||||
|
||||
getCommentReplies: function (index) {
|
||||
if (process.env.IS_ELECTRON) {
|
||||
if (process.env.SUPPORTS_LOCAL_API) {
|
||||
switch (this.commentData[index].dataType) {
|
||||
case 'local':
|
||||
this.getCommentRepliesLocal(index)
|
||||
|
@ -292,7 +292,7 @@ export default defineComponent({
|
|||
showToast(`${errorMessage}: ${err}`, 10000, () => {
|
||||
copyToClipboard(err)
|
||||
})
|
||||
if (process.env.IS_ELECTRON && this.backendFallback && this.backendPreference === 'invidious') {
|
||||
if (process.env.SUPPORTS_LOCAL_API && this.backendFallback && this.backendPreference === 'invidious') {
|
||||
showToast(this.$t('Falling back to Local API'))
|
||||
this.getCommentDataLocal()
|
||||
} else {
|
||||
|
|
|
@ -94,7 +94,7 @@ export default defineComponent({
|
|||
this.liveChatInstance = null
|
||||
},
|
||||
created: function () {
|
||||
if (!process.env.IS_ELECTRON) {
|
||||
if (!process.env.SUPPORTS_LOCAL_API) {
|
||||
this.hasError = true
|
||||
this.errorMessage = this.$t('Video["Live Chat is currently not supported in this build."]')
|
||||
this.isLoading = false
|
||||
|
|
|
@ -210,7 +210,7 @@ export default defineComponent({
|
|||
},
|
||||
playlistId: function (newVal, oldVal) {
|
||||
if (oldVal !== newVal) {
|
||||
if (!process.env.IS_ELECTRON || this.backendPreference === 'invidious') {
|
||||
if (!process.env.SUPPORTS_LOCAL_API || this.backendPreference === 'invidious') {
|
||||
this.getPlaylistInformationInvidious()
|
||||
} else {
|
||||
this.getPlaylistInformationLocal()
|
||||
|
@ -249,7 +249,7 @@ export default defineComponent({
|
|||
|
||||
if (this.selectedUserPlaylist != null) {
|
||||
this.parseUserPlaylist(this.selectedUserPlaylist)
|
||||
} else if (!process.env.IS_ELECTRON || this.backendPreference === 'invidious') {
|
||||
} else if (!process.env.SUPPORTS_LOCAL_API || this.backendPreference === 'invidious') {
|
||||
this.getPlaylistInformationInvidious()
|
||||
} else {
|
||||
this.getPlaylistInformationLocal()
|
||||
|
@ -386,7 +386,7 @@ export default defineComponent({
|
|||
this.channelName = cachedPlaylist.channelName
|
||||
this.channelId = cachedPlaylist.channelId
|
||||
|
||||
if (!process.env.IS_ELECTRON || this.backendPreference === 'invidious' || cachedPlaylist.continuationData === null) {
|
||||
if (!process.env.SUPPORTS_LOCAL_API || this.backendPreference === 'invidious' || cachedPlaylist.continuationData === null) {
|
||||
this.playlistItems = cachedPlaylist.items
|
||||
} else {
|
||||
const videos = cachedPlaylist.items
|
||||
|
@ -462,7 +462,7 @@ export default defineComponent({
|
|||
showToast(`${errorMessage}: ${err}`, 10000, () => {
|
||||
copyToClipboard(err)
|
||||
})
|
||||
if (process.env.IS_ELECTRON && this.backendPreference === 'invidious' && this.backendFallback) {
|
||||
if (process.env.SUPPORTS_LOCAL_API && this.backendPreference === 'invidious' && this.backendFallback) {
|
||||
showToast(this.$t('Falling back to Local API'))
|
||||
this.getPlaylistInformationLocal()
|
||||
} else {
|
||||
|
|
|
@ -321,10 +321,10 @@ export function filterInvidiousFormats(formats, allowAv1 = false) {
|
|||
// Which is caused by Invidious API limitation on AV1 formats (see related issues)
|
||||
// Commented code to be restored after Invidious issue fixed
|
||||
//
|
||||
// As we generate our own DASH manifest (using YouTube.js) for multiple audio track support in Electron,
|
||||
// we can allow AV1 in that situation. If we aren't in electron,
|
||||
// As we generate our own DASH manifest (using YouTube.js) for multiple audio track support when the local API is supported,
|
||||
// we can allow AV1 in that situation. When the local API isn't supported,
|
||||
// we still can't use them until Invidious fixes the issue on their side
|
||||
if (process.env.IS_ELECTRON && allowAv1 && av1Formats.length > 0) {
|
||||
if (process.env.SUPPORTS_LOCAL_API && allowAv1 && av1Formats.length > 0) {
|
||||
return [...audioFormats, ...av1Formats]
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { ClientType, Endpoints, Innertube, Misc, Utils, YT } from 'youtubei.js'
|
||||
import { ClientType, Endpoints, Innertube, Misc, UniversalCache, Utils, YT } from 'youtubei.js'
|
||||
import Autolinker from 'autolinker'
|
||||
import { join } from 'path'
|
||||
|
||||
|
@ -39,8 +39,12 @@ const TRACKING_PARAM_NAMES = [
|
|||
async function createInnertube({ withPlayer = false, location = undefined, safetyMode = false, clientType = undefined, generateSessionLocally = true } = {}) {
|
||||
let cache
|
||||
if (withPlayer) {
|
||||
const userData = await getUserDataPath()
|
||||
cache = new PlayerCache(join(userData, 'player_cache'))
|
||||
if (process.env.IS_ELECTRON) {
|
||||
const userData = await getUserDataPath()
|
||||
cache = new PlayerCache(join(userData, 'player_cache'))
|
||||
} else {
|
||||
cache = new UniversalCache(false)
|
||||
}
|
||||
}
|
||||
|
||||
return await Innertube.create({
|
||||
|
|
|
@ -11,7 +11,7 @@ import { getLocalChannel } from './api/local'
|
|||
*/
|
||||
async function findChannelById(id, backendOptions) {
|
||||
try {
|
||||
if (!process.env.IS_ELECTRON || backendOptions.preference === 'invidious') {
|
||||
if (!process.env.SUPPORTS_LOCAL_API || backendOptions.preference === 'invidious') {
|
||||
return await invidiousGetChannelInfo(id)
|
||||
} else {
|
||||
return await getLocalChannel(id)
|
||||
|
@ -21,7 +21,7 @@ async function findChannelById(id, backendOptions) {
|
|||
if (err.message && err.message === 'This channel does not exist.') {
|
||||
return { invalid: true }
|
||||
}
|
||||
if (process.env.IS_ELECTRON && backendOptions.fallback) {
|
||||
if (process.env.SUPPORTS_LOCAL_API && backendOptions.fallback) {
|
||||
if (backendOptions.preference === 'invidious') {
|
||||
return await getLocalChannel(id)
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ export async function findChannelTagInfo(id, backendOptions) {
|
|||
if (!checkYoutubeChannelId(id)) return { invalidId: true }
|
||||
try {
|
||||
const channel = await findChannelById(id, backendOptions)
|
||||
if (!process.env.IS_ELECTRON || backendOptions.preference === 'invidious') {
|
||||
if (!process.env.SUPPORTS_LOCAL_API || backendOptions.preference === 'invidious') {
|
||||
if (channel.invalid) return { invalidId: true }
|
||||
return {
|
||||
preferredName: channel.author,
|
||||
|
|
|
@ -28,7 +28,7 @@ const actions = {
|
|||
return !(instance[0].includes('.onion') ||
|
||||
instance[0].includes('.i2p') ||
|
||||
!instance[1].api ||
|
||||
(!process.env.IS_ELECTRON && !instance[1].cors))
|
||||
(!process.env.SUPPORTS_LOCAL_API && !instance[1].cors))
|
||||
}).map((instance) => {
|
||||
return instance[1].uri.replace(/\/$/, '')
|
||||
})
|
||||
|
@ -50,7 +50,7 @@ const actions = {
|
|||
console.warn('reading static file for invidious instances')
|
||||
const fileData = process.env.IS_ELECTRON ? await fs.readFile(filePath, 'utf8') : await (await fetch(createWebURL(filePath))).text()
|
||||
instances = JSON.parse(fileData).filter(e => {
|
||||
return process.env.IS_ELECTRON || e.cors
|
||||
return process.env.SUPPORTS_LOCAL_API || e.cors
|
||||
}).map(e => {
|
||||
return e.url
|
||||
})
|
||||
|
|
|
@ -165,8 +165,8 @@ const state = {
|
|||
allSettingsSectionsExpandedByDefault: false,
|
||||
autoplayPlaylists: true,
|
||||
autoplayVideos: true,
|
||||
backendFallback: process.env.IS_ELECTRON,
|
||||
backendPreference: !process.env.IS_ELECTRON ? 'invidious' : 'local',
|
||||
backendFallback: process.env.SUPPORTS_LOCAL_API,
|
||||
backendPreference: !process.env.SUPPORTS_LOCAL_API ? 'invidious' : 'local',
|
||||
barColor: false,
|
||||
checkForBlogPosts: true,
|
||||
checkForUpdates: true,
|
||||
|
@ -237,7 +237,7 @@ const state = {
|
|||
proxyHostname: '127.0.0.1',
|
||||
proxyPort: '9050',
|
||||
proxyProtocol: 'socks5',
|
||||
proxyVideos: !process.env.IS_ELECTRON,
|
||||
proxyVideos: !process.env.SUPPORTS_LOCAL_API,
|
||||
region: 'US',
|
||||
rememberHistory: true,
|
||||
saveWatchedProgress: true,
|
||||
|
|
|
@ -351,7 +351,7 @@ export default defineComponent({
|
|||
this.errorMessage = ''
|
||||
|
||||
// Re-enable auto refresh on sort value change AFTER update done
|
||||
if (!process.env.IS_ELECTRON || this.backendPreference === 'invidious') {
|
||||
if (!process.env.SUPPORTS_LOCAL_API || this.backendPreference === 'invidious') {
|
||||
this.getChannelInfoInvidious()
|
||||
this.autoRefreshOnSortByChangeEnabled = true
|
||||
} else {
|
||||
|
@ -449,7 +449,7 @@ export default defineComponent({
|
|||
}
|
||||
|
||||
// Enable auto refresh on sort value change AFTER initial update done
|
||||
if (!process.env.IS_ELECTRON || this.backendPreference === 'invidious') {
|
||||
if (!process.env.SUPPORTS_LOCAL_API || this.backendPreference === 'invidious') {
|
||||
this.getChannelInfoInvidious()
|
||||
this.autoRefreshOnSortByChangeEnabled = true
|
||||
} else {
|
||||
|
@ -462,7 +462,7 @@ export default defineComponent({
|
|||
resolveChannelUrl: async function (url, tab = undefined) {
|
||||
let id
|
||||
|
||||
if (!process.env.IS_ELECTRON || this.backendPreference === 'invidious') {
|
||||
if (!process.env.SUPPORTS_LOCAL_API || this.backendPreference === 'invidious') {
|
||||
id = await invidiousGetChannelId(url)
|
||||
} else {
|
||||
id = await getLocalChannelId(url)
|
||||
|
@ -1051,7 +1051,7 @@ export default defineComponent({
|
|||
showToast(`${errorMessage}: ${err}`, 10000, () => {
|
||||
copyToClipboard(err)
|
||||
})
|
||||
if (process.env.IS_ELECTRON && this.backendPreference === 'invidious' && this.backendFallback) {
|
||||
if (process.env.SUPPORTS_LOCAL_API && this.backendPreference === 'invidious' && this.backendFallback) {
|
||||
showToast(this.$t('Falling back to Local API'))
|
||||
this.getChannelLocal()
|
||||
} else {
|
||||
|
@ -1329,7 +1329,7 @@ export default defineComponent({
|
|||
showToast(`${errorMessage}: ${err}`, 10000, () => {
|
||||
copyToClipboard(err)
|
||||
})
|
||||
if (process.env.IS_ELECTRON && this.backendPreference === 'invidious' && this.backendFallback) {
|
||||
if (process.env.SUPPORTS_LOCAL_API && this.backendPreference === 'invidious' && this.backendFallback) {
|
||||
showToast(this.$t('Falling back to Local API'))
|
||||
if (!this.channelInstance) {
|
||||
this.channelInstance = await getLocalChannel(this.id)
|
||||
|
@ -1370,7 +1370,7 @@ export default defineComponent({
|
|||
showToast(`${errorMessage}: ${err}`, 10000, () => {
|
||||
copyToClipboard(err)
|
||||
})
|
||||
if (process.env.IS_ELECTRON && this.backendPreference === 'invidious' && this.backendFallback) {
|
||||
if (process.env.SUPPORTS_LOCAL_API && this.backendPreference === 'invidious' && this.backendFallback) {
|
||||
showToast(this.$t('Falling back to Local API'))
|
||||
this.getChannelLocal()
|
||||
} else {
|
||||
|
@ -1449,7 +1449,7 @@ export default defineComponent({
|
|||
showToast(`${errorMessage}: ${err}`, 10000, () => {
|
||||
copyToClipboard(err)
|
||||
})
|
||||
if (process.env.IS_ELECTRON && this.backendPreference === 'invidious' && this.backendFallback) {
|
||||
if (process.env.SUPPORTS_LOCAL_API && this.backendPreference === 'invidious' && this.backendFallback) {
|
||||
showToast(this.$t('Falling back to Local API'))
|
||||
if (!this.channelInstance) {
|
||||
this.channelInstance = await getLocalChannel(this.id)
|
||||
|
@ -1483,7 +1483,7 @@ export default defineComponent({
|
|||
showToast(`${errorMessage}: ${err}`, 10000, () => {
|
||||
copyToClipboard(err)
|
||||
})
|
||||
if (process.env.IS_ELECTRON && this.backendPreference === 'invidious' && this.backendFallback) {
|
||||
if (process.env.SUPPORTS_LOCAL_API && this.backendPreference === 'invidious' && this.backendFallback) {
|
||||
showToast(this.$t('Falling back to Local API'))
|
||||
this.getChannelLocal()
|
||||
} else {
|
||||
|
@ -1562,7 +1562,7 @@ export default defineComponent({
|
|||
showToast(`${errorMessage}: ${err}`, 10000, () => {
|
||||
copyToClipboard(err)
|
||||
})
|
||||
if (process.env.IS_ELECTRON && this.backendPreference === 'invidious' && this.backendFallback) {
|
||||
if (process.env.SUPPORTS_LOCAL_API && this.backendPreference === 'invidious' && this.backendFallback) {
|
||||
showToast(this.$t('Falling back to Local API'))
|
||||
if (!this.channelInstance) {
|
||||
this.channelInstance = await getLocalChannel(this.id)
|
||||
|
@ -1596,7 +1596,7 @@ export default defineComponent({
|
|||
showToast(`${errorMessage}: ${err}`, 10000, () => {
|
||||
copyToClipboard(err)
|
||||
})
|
||||
if (process.env.IS_ELECTRON && this.backendPreference === 'invidious' && this.backendFallback) {
|
||||
if (process.env.SUPPORTS_LOCAL_API && this.backendPreference === 'invidious' && this.backendFallback) {
|
||||
showToast(this.$t('Falling back to Local API'))
|
||||
this.getChannelLocal()
|
||||
} else {
|
||||
|
@ -1716,7 +1716,7 @@ export default defineComponent({
|
|||
showToast(`${errorMessage}: ${err}`, 10000, () => {
|
||||
copyToClipboard(err)
|
||||
})
|
||||
if (process.env.IS_ELECTRON && this.backendPreference === 'invidious' && this.backendFallback) {
|
||||
if (process.env.SUPPORTS_LOCAL_API && this.backendPreference === 'invidious' && this.backendFallback) {
|
||||
showToast(this.$t('Falling back to Local API'))
|
||||
if (!this.channelInstance) {
|
||||
this.channelInstance = await getLocalChannel(this.id)
|
||||
|
@ -1939,7 +1939,7 @@ export default defineComponent({
|
|||
showToast(`${errorMessage}: ${err}`, 10000, () => {
|
||||
copyToClipboard(err)
|
||||
})
|
||||
if (process.env.IS_ELECTRON && this.backendPreference === 'invidious' && this.backendFallback) {
|
||||
if (process.env.SUPPORTS_LOCAL_API && this.backendPreference === 'invidious' && this.backendFallback) {
|
||||
showToast(this.$t('Falling back to Local API'))
|
||||
this.searchChannelLocal()
|
||||
} else {
|
||||
|
|
|
@ -85,7 +85,7 @@ export default defineComponent({
|
|||
showToast(`${errorMessage}: ${error}`, 10000, () => {
|
||||
copyToClipboard(error)
|
||||
})
|
||||
if (process.env.IS_ELECTRON && this.backendPreference === 'invidious' && this.backendFallback) {
|
||||
if (process.env.SUPPORTS_LOCAL_API && this.backendPreference === 'invidious' && this.backendFallback) {
|
||||
showToast(this.$t('Falling back to Local API'))
|
||||
this.resetData()
|
||||
this.getLocalHashtag(hashtag)
|
||||
|
|
|
@ -313,7 +313,7 @@ export default defineComponent({
|
|||
this.isLoading = false
|
||||
}).catch((err) => {
|
||||
console.error(err)
|
||||
if (process.env.IS_ELECTRON && this.backendPreference === 'invidious' && this.backendFallback) {
|
||||
if (process.env.SUPPORTS_LOCAL_API && this.backendPreference === 'invidious' && this.backendFallback) {
|
||||
console.warn('Error getting data with Invidious, falling back to local backend')
|
||||
this.getPlaylistLocal()
|
||||
} else {
|
||||
|
|
|
@ -246,7 +246,7 @@ export default defineComponent({
|
|||
showToast(`${errorMessage}: ${err}`, 10000, () => {
|
||||
copyToClipboard(err)
|
||||
})
|
||||
if (process.env.IS_ELECTRON && this.backendPreference === 'invidious' && this.backendFallback) {
|
||||
if (process.env.SUPPORTS_LOCAL_API && this.backendPreference === 'invidious' && this.backendFallback) {
|
||||
showToast(this.$t('Falling back to Local API'))
|
||||
this.performSearchLocal(payload)
|
||||
} else {
|
||||
|
|
|
@ -85,7 +85,7 @@ export default defineComponent({
|
|||
this.$store.commit('clearTrendingCache')
|
||||
}
|
||||
|
||||
if (!process.env.IS_ELECTRON || this.backendPreference === 'invidious') {
|
||||
if (!process.env.SUPPORTS_LOCAL_API || this.backendPreference === 'invidious') {
|
||||
this.getTrendingInfoInvidious()
|
||||
} else {
|
||||
this.getTrendingInfoLocal()
|
||||
|
@ -161,7 +161,7 @@ export default defineComponent({
|
|||
copyToClipboard(err.responseText)
|
||||
})
|
||||
|
||||
if (process.env.IS_ELECTRON && (this.backendPreference === 'invidious' && this.backendFallback)) {
|
||||
if (process.env.SUPPORTS_LOCAL_API && (this.backendPreference === 'invidious' && this.backendFallback)) {
|
||||
showToast(this.$t('Falling back to Local API'))
|
||||
this.getTrendingInfoLocal()
|
||||
} else {
|
||||
|
|
|
@ -289,7 +289,7 @@ export default defineComponent({
|
|||
this.checkIfPlaylist()
|
||||
this.checkIfTimestamp()
|
||||
|
||||
if (!process.env.IS_ELECTRON || this.backendPreference === 'invidious') {
|
||||
if (!process.env.SUPPORTS_LOCAL_API || this.backendPreference === 'invidious') {
|
||||
this.getVideoInformationInvidious()
|
||||
} else {
|
||||
this.getVideoInformationLocal()
|
||||
|
@ -870,8 +870,8 @@ export default defineComponent({
|
|||
this.audioTracks = []
|
||||
this.dashSrc = await this.createInvidiousDashManifest()
|
||||
|
||||
if (process.env.IS_ELECTRON && this.audioTracks.length > 0) {
|
||||
// when we are in Electron and the video has multiple audio tracks,
|
||||
if (process.env.SUPPORTS_LOCAL_API && this.audioTracks.length > 0) {
|
||||
// when the local API is supported and the video has multiple audio tracks,
|
||||
// we populate the list inside createInvidiousDashManifest
|
||||
// as we need to work out the different audio tracks for the DASH manifest anyway
|
||||
this.audioSourceList = this.audioTracks.find(track => track.isDefault).sourceList
|
||||
|
@ -908,7 +908,7 @@ export default defineComponent({
|
|||
copyToClipboard(err.responseText)
|
||||
})
|
||||
console.error(err)
|
||||
if (process.env.IS_ELECTRON && this.backendPreference === 'invidious' && this.backendFallback) {
|
||||
if (process.env.SUPPORTS_LOCAL_API && this.backendPreference === 'invidious' && this.backendFallback) {
|
||||
showToast(this.$t('Falling back to Local API'))
|
||||
this.getVideoInformationLocal()
|
||||
} else {
|
||||
|
@ -1233,7 +1233,7 @@ export default defineComponent({
|
|||
copyToClipboard(err)
|
||||
})
|
||||
console.error(err)
|
||||
if (!process.env.IS_ELECTRON || (this.backendPreference === 'local' && this.backendFallback)) {
|
||||
if (!process.env.SUPPORTS_LOCAL_API || (this.backendPreference === 'local' && this.backendFallback)) {
|
||||
showToast(this.$t('Falling back to Invidious API'))
|
||||
this.getVideoInformationInvidious()
|
||||
}
|
||||
|
@ -1471,7 +1471,7 @@ export default defineComponent({
|
|||
// If we are in Electron,
|
||||
// we can use YouTube.js' DASH manifest generator to generate the manifest.
|
||||
// Using YouTube.js' gives us support for multiple audio tracks (currently not supported by Invidious)
|
||||
if (process.env.IS_ELECTRON) {
|
||||
if (process.env.SUPPORTS_LOCAL_API) {
|
||||
// Invidious' API response doesn't include the height and width (and fps and qualityLabel for AV1) of video streams
|
||||
// so we need to extract them from Invidious' manifest
|
||||
const response = await fetch(url)
|
||||
|
|
Loading…
Reference in New Issue