Skip to content

Commit

Permalink
Download manager now works (as much as it ever did again)
Browse files Browse the repository at this point in the history
- (quality label is almost always wrong :( )
  • Loading branch information
MarmadileManteater committed Oct 20, 2024
1 parent 7183160 commit fbc0713
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
11 changes: 9 additions & 2 deletions src/renderer/helpers/android.js
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ export async function getDownloadedVideos() {
}

export async function getVideoInformationDownloaded(videoId, component) {
console.warn(videoId)
component.isLoading = true
const downloadsDirectory = await getDownloadsDirectory()
const directoryParts = downloadsDirectory.uri.split('%3A')
Expand All @@ -599,10 +600,16 @@ export async function getVideoInformationDownloaded(videoId, component) {
component.videoChapters = response.chapters
component.videoDescription = response.description
component.videoDescriptionHtml = response.descriptionHtml
component.videoSourceList = [
component.legacyFormats = [
{
bitrate: 0,
fps: 30,
height: 360,
itag: 18,
mimeType: "video/mp4; codecs=\"avc1.42001E, mp4a.40.2\"",
qualityLabel: "360p",
url: response.uri,
qualityLabel: 'unknown'// TODO pass through information from prompt
width: 640
}
]

Expand Down
21 changes: 15 additions & 6 deletions src/renderer/views/Watch/Watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ import {
} from '../../helpers/api/invidious'
import {
createMediaSession,
getDownloadFormats
getDownloadFormats,
getVideoInformationDownloaded
} from '../../helpers/android'
import android from 'android'

Expand Down Expand Up @@ -396,11 +397,19 @@ export default defineComponent({
// this has to be below checkIfPlaylist() as theatrePossible needs to know if there is a playlist or not
this.useTheatreMode = this.defaultTheatreMode && this.theatrePossible

if (!process.env.SUPPORTS_LOCAL_API || this.backendPreference === 'invidious') {
this.getVideoInformationInvidious()
} else {
this.getVideoInformationLocal()
}
const promise = process.env.IS_ANDROID && this.$store.getters.getDownloadBehavior === 'download'
? getVideoInformationDownloaded(this.videoId, this)
: new Promise((resolve, _reject) => resolve())

promise.then((downloadedInfo) => {
if (downloadedInfo === undefined) {
if (!process.env.SUPPORTS_LOCAL_API || this.backendPreference === 'invidious') {
this.getVideoInformationInvidious()
} else {
this.getVideoInformationLocal()
}
}
})

window.addEventListener('beforeunload', this.handleWatchProgress)
},
Expand Down

0 comments on commit fbc0713

Please sign in to comment.