File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed
api/src/processing/services Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,25 @@ async function findClientID() {
4040 } catch { }
4141}
4242
43+ const findBestForPreset = ( transcodings , preset ) => {
44+ let inferior ;
45+ for ( const entry of transcodings ) {
46+ if ( entry . snipped ) {
47+ continue ;
48+ }
49+
50+ if ( entry . preset === preset ) {
51+ if ( entry ?. format ?. protocol === 'progressive' ) {
52+ return entry ;
53+ }
54+
55+ inferior = entry ;
56+ }
57+ }
58+
59+ return inferior ;
60+ }
61+
4362export default async function ( obj ) {
4463 const clientId = await findClientID ( ) ;
4564 if ( ! clientId ) return { error : "fetch.fail" } ;
@@ -89,9 +108,9 @@ export default async function(obj) {
89108 }
90109
91110 let bestAudio = "opus" ,
92- selectedStream = json . media . transcodings . find ( v => v . preset === "opus_0_0" ) ;
111+ selectedStream = findBestForPreset ( json . media . transcodings , "opus_0_0" ) ;
93112
94- const mp3Media = json . media . transcodings . find ( v => v . preset === "mp3_0_0" ) ;
113+ const mp3Media = findBestForPreset ( json . media . transcodings , "mp3_0_0" ) ;
95114
96115 // use mp3 if present if user prefers it or if opus isn't available
97116 if ( mp3Media && ( obj . format === "mp3" || ! selectedStream ) ) {
You can’t perform that action at this time.
0 commit comments