Skip to content

Commit

Permalink
Merge commit 'refs/pull/5705/head' of https://github.com/freetubeapp/…
Browse files Browse the repository at this point in the history
…freetube into dev-electron-dwngrade
  • Loading branch information
OothecaPickle committed Sep 16, 2024
2 parents 284193a + 996faf3 commit 74a36a3
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,17 @@ export default defineComponent({

// #region player config

const seekingIsPossible = computed(() => {
if (props.manifestMimeType !== 'application/x-mpegurl') {
return true
}

const match = props.manifestSrc.match(/\/(?:manifest|playlist)_duration\/(\d+)\//)

// Check how many seconds we are allowed to seek, 30 is too short, 3600 is an hour which is great
return match != null && parseInt(match[1] || '0') > 30
})

/**
* @param {'dash'|'audio'|'legacy'} format
* @param {boolean} useAutoQuality
Expand All @@ -545,7 +556,7 @@ export default defineComponent({
dash: {
manifestPreprocessorTXml: manifestPreprocessorTXml
},
availabilityWindowOverride: props.manifestMimeType === 'application/x-mpegurl' ? 0 : NaN
availabilityWindowOverride: seekingIsPossible.value ? NaN : 0
},
abr: {
enabled: useAutoQuality,
Expand Down Expand Up @@ -794,7 +805,7 @@ export default defineComponent({
function configureUI(firstTime = false) {
if (firstTime) {
const firstTimeConfig = {
addSeekBar: props.manifestMimeType !== 'application/x-mpegurl',
addSeekBar: seekingIsPossible.value,
customContextMenu: true,
contextMenuElements: ['ft_stats'],
enableTooltips: true,
Expand Down Expand Up @@ -1136,15 +1147,29 @@ export default defineComponent({
} else if (type === RequestType.MANIFEST && context.type === AdvancedRequestType.MEDIA_PLAYLIST) {
const url = new URL(response.uri)

let modifiedText

// Fixes proxied HLS manifests, as Invidious replaces the path parameters with query parameters,
// so shaka-player isn't able to infer the mime type from the `/file/seg.ts` part like it does for non-proxied HLS manifests.
// Shaka-player does attempt to detect it with HEAD request but the `Content-Type` header is `application/octet-stream`,
// which still doesn't tell shaka-player how to handle the stream because that's the equivalent of saying "binary data".
if (url.searchParams.has('local')) {
const stringBody = new TextDecoder().decode(response.data)
const fixed = stringBody.replaceAll(/https?:\/\/.+$/gm, hlsProxiedUrlReplacer)

response.data = new TextEncoder().encode(fixed).buffer
modifiedText = stringBody.replaceAll(/https?:\/\/.+$/gm, hlsProxiedUrlReplacer)
}

// The audio-only streams are actually raw AAC, so correct the file extension from `.ts` to `.aac`
if (/\/itag\/23[34]\//.test(url.pathname) || url.searchParams.get('itag') === '233' || url.searchParams.get('itag') === '234') {
if (!modifiedText) {
modifiedText = new TextDecoder().decode(response.data)
}

modifiedText = modifiedText.replaceAll('/file/seg.ts', '/file/seg.aac')
}

if (modifiedText) {
response.data = new TextEncoder().encode(modifiedText).buffer
}
}
}
Expand Down Expand Up @@ -1334,7 +1359,7 @@ export default defineComponent({
stats.bitrate = (newTrack.bandwidth / 1000).toFixed(2)

// Combined audio and video HLS streams
if (newTrack.videoCodec.includes(',')) {
if (newTrack.videoCodec?.includes(',')) {
stats.codecs.audioItag = ''
stats.codecs.videoItag = ''

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class AudioTrackSelection extends shaka.ui.SettingsMenu {

this.button.setAttribute('shaka-status', this.currentSelection.innerText)

if (knownLabels.size > 0) {
if (knownLabels.size > 1) {
this.button.classList.remove('shaka-hidden')
} else {
this.button.classList.add('shaka-hidden')
Expand Down
7 changes: 2 additions & 5 deletions src/renderer/helpers/api/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,16 +284,13 @@ export async function getLocalVideoInfo(id) {
info.storyboards = iosInfo.storyboards
} else if (iosInfo.streaming_data) {
info.streaming_data.adaptive_formats = iosInfo.streaming_data.adaptive_formats
info.streaming_data.hls_manifest_url = iosInfo.streaming_data.hls_manifest_url

// Use the legacy formats from the original web response as the iOS client doesn't have any legacy formats

for (const format of info.streaming_data.adaptive_formats) {
format.freeTubeUrl = format.url
}

// don't overwrite for live streams
if (!info.streaming_data.hls_manifest_url) {
info.streaming_data.hls_manifest_url = iosInfo.streaming_data.hls_manifest_url
}
}

if (info.streaming_data) {
Expand Down
10 changes: 6 additions & 4 deletions src/renderer/views/Watch/Watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -1201,8 +1201,10 @@ export default defineComponent({
}

if (this.manifestSrc === null ||
// HLS consists of combined audio and video files, so we can't do audio only
((this.isLive || this.isPostLiveDvr) && this.manifestMimeType !== MANIFEST_TYPE_DASH)) {
((this.isLive || this.isPostLiveDvr) &&
// The WEB HLS manifests only contain combined audio and video files, so we can't do audio only
// The IOS HLS manifests have audio-only streams
this.manifestMimeType === MANIFEST_TYPE_HLS && !this.manifestSrc.includes('/demuxed/1'))) {
showToast(this.$t('Change Format.Audio formats are not available for this video'))
return
}
Expand Down Expand Up @@ -1341,10 +1343,10 @@ export default defineComponent({
// live streams don't have legacy formats, so only switch between dash and audio

if (this.activeFormat === 'dash') {
console.error('Unable to play audio formats. Reverting to DASH formats...')
console.error('Unable to play DASH formats. Reverting to audio formats...')
this.enableAudioFormat()
} else {
console.error('Unable to play DASH formats. Reverting to audio formats...')
console.error('Unable to play audio formats. Reverting to DASH formats...')
this.enableDashFormat()
}
} else {
Expand Down
8 changes: 8 additions & 0 deletions static/locales/cs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ Global:
Subscriber Count: 1 odběratel | {count} odběratelů
View Count: 1 zhlédnutí | {count} zhlédnutí
Watching Count: 1 sledující | {count} sledujících
Like Count: 1 líbí se mi | {count} líbí se mi
Comment Count: 1 komentář | {count} komentářů
Input Tags:
Length Requirement: Štítek musí být dlouhý alespoň {number} znaků
Version {versionNumber} is now available! Click for more details: 'Verze {versionNumber}
Expand Down Expand Up @@ -822,6 +824,10 @@ Channel:
votes: '{votes} hlasů'
Reveal Answers: Odhalit odpovědi
Video hidden by FreeTube: Video skryté programem FreeTube
View Full Post: Zobrazit celý příspěvek
Viewing Posts Only Supported By Invidious: Zobrazení příspěvků je podporováno
pouze službou Invidious. Přejděte do karty komunity kanálu pro zobrazení jejího
obsahu bez Invidious.
Live:
Live: Živě
This channel does not currently have any live streams: Tento kanál v současné
Expand Down Expand Up @@ -1072,6 +1078,8 @@ Comments:
View {replyCount} replies: Zobrazit {replyCount} odpovědí
Hearted: Se srdíčkem
Subscribed: Odebíráno
There are no comments available for this post: U tohoto příspěvku nejsou dostupné
žádné komentáře
Up Next: 'Další'

#Tooltips
Expand Down
6 changes: 6 additions & 0 deletions static/locales/sr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ Global:
View Count: 1 преглед | {count} прегледа
Watching Count: 1 гледање | {count} гледања
Channel Count: 1 канал | {count} канала
Comment Count: 1 коментар | {count} коментара
Like Count: 1 свиђање | {count} свиђања
Live: Уживо
Community: Заједница
Shorts: Shorts
Expand Down Expand Up @@ -775,6 +777,9 @@ Channel:
Hide Answers: Сакриј одговоре
votes: 'Гласова: {votes}'
Video hidden by FreeTube: Видео снимак сакрио је FreeTube
View Full Post: Погледај целу објаву
Viewing Posts Only Supported By Invidious: Гледање објава подржава само Invidious.
Идите на картицу заједнице канала да видите садржај тамо без Invidious-a.
Live:
Live: Уживо
This channel does not currently have any live streams: Овај канал тренутно нема
Expand Down Expand Up @@ -1074,6 +1079,7 @@ Comments:
There are no more comments for this video: Нема више коментара за овај видео снимак
And others: и осталих
Newest first: Најновије прво
There are no comments available for this post: Нема доступних коментара за ову објаву
Hashtags have not yet been implemented, try again later: Хеш-ознаке још увек нису
имплементиране, покушајте поново касније
Share:
Expand Down

0 comments on commit 74a36a3

Please sign in to comment.