Skip to content

Commit ece0157

Browse files
committed
Allow legacy formats to be used even when dash and audio-only are unavailable
1 parent 36d533a commit ece0157

File tree

3 files changed

+28
-19
lines changed

3 files changed

+28
-19
lines changed

src/renderer/components/ft-shaka-video-player/ft-shaka-video-player.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export default defineComponent({
6565
},
6666
manifestSrc: {
6767
type: String,
68-
required: true
68+
default: null
6969
},
7070
manifestMimeType: {
7171
type: String,

src/renderer/helpers/api/local.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,12 @@ export async function getLocalVideoInfo(id) {
272272

273273
if (info.streaming_data) {
274274
decipherFormats(info.streaming_data.formats, webInnertube.session.player)
275-
decipherFormats(info.streaming_data.adaptive_formats, webInnertube.session.player)
275+
276+
const firstFormat = info.streaming_data.adaptive_formats[0]
277+
278+
if (firstFormat.url || firstFormat.signature_cipher || firstFormat.cipher) {
279+
decipherFormats(info.streaming_data.adaptive_formats, webInnertube.session.player)
280+
}
276281

277282
if (info.streaming_data.dash_manifest_url) {
278283
let url = info.streaming_data.dash_manifest_url

src/renderer/views/Watch/Watch.js

+21-17
Original file line numberDiff line numberDiff line change
@@ -695,25 +695,29 @@ export default defineComponent({
695695
/** @type {import('../../helpers/api/local').LocalFormat[]} */
696696
const formats = [...result.streaming_data.formats, ...result.streaming_data.adaptive_formats]
697697

698-
const downloadLinks = formats.map((format) => {
699-
const qualityLabel = format.quality_label ?? format.bitrate
700-
const fps = format.fps ? `${format.fps}fps` : 'kbps'
701-
const type = format.mime_type.split(';')[0]
702-
let label = `${qualityLabel} ${fps} - ${type}`
703-
704-
if (format.has_audio !== format.has_video) {
705-
if (format.has_video) {
706-
label += ` ${this.$t('Video.video only')}`
707-
} else {
708-
label += ` ${this.$t('Video.audio only')}`
698+
const downloadLinks = []
699+
700+
for (const format of formats) {
701+
if (format.freeTubeUrl) {
702+
const qualityLabel = format.quality_label ?? format.bitrate
703+
const fps = format.fps ? `${format.fps}fps` : 'kbps'
704+
const type = format.mime_type.split(';')[0]
705+
let label = `${qualityLabel} ${fps} - ${type}`
706+
707+
if (format.has_audio !== format.has_video) {
708+
if (format.has_video) {
709+
label += ` ${this.$t('Video.video only')}`
710+
} else {
711+
label += ` ${this.$t('Video.audio only')}`
712+
}
709713
}
710-
}
711714

712-
return {
713-
url: format.freeTubeUrl,
714-
label: label
715+
downloadLinks.push({
716+
url: format.freeTubeUrl,
717+
label: label
718+
})
715719
}
716-
})
720+
}
717721

718722
if (result.captions) {
719723
const captionTracks = result.captions?.caption_tracks?.map((caption) => {
@@ -779,7 +783,7 @@ export default defineComponent({
779783
return
780784
}
781785

782-
if (result.streaming_data?.adaptive_formats.length > 0) {
786+
if (result.streaming_data?.adaptive_formats.length > 0 && result.streaming_data.adaptive_formats[0].freeTubeUrl) {
783787
this.vrProjection = result.streaming_data.adaptive_formats
784788
.find(format => {
785789
return format.has_video &&

0 commit comments

Comments
 (0)