Move all file operations code to single file

This commit is contained in:
Rafał Dzięgiel
2021-04-01 21:52:19 +02:00
parent 295af9fd24
commit 7f69bee11c
5 changed files with 99 additions and 103 deletions

View File

@@ -2,6 +2,7 @@ const { Gdk, Gio, GObject, Gst, GstClapper, Gtk } = imports.gi;
const ByteArray = imports.byteArray;
const Dash = imports.src.dash;
const Debug = imports.src.debug;
const FileOps = imports.src.fileOps;
const Misc = imports.src.misc;
const YouTube = imports.src.youtube;
const { PlayerBase } = imports.src.playerBase;
@@ -88,9 +89,19 @@ class ClapperPlayer extends PlayerBase
throw new Error('no YouTube video info');
const dash = Dash.generateDash(info);
const videoUri = (dash)
? await Dash.saveDashPromise(dash).catch(debug)
: this.ytClient.getBestCombinedUri(info);
let videoUri = null;
if(dash) {
const dashFile = await FileOps.saveFilePromise(
'tmp', null, 'clapper.mpd', dash
).catch(debug);
if(dashFile)
videoUri = dashFile.get_uri();
}
if(!videoUri)
videoUri = this.ytClient.getBestCombinedUri(info);
if(!videoUri)
throw new Error('no YouTube video URI');