Skip to content

Commit

Permalink
Replace Plex URL by direct file
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxou44 committed Jul 8, 2019
1 parent beb8516 commit 48519a3
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/core/sessions.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,34 @@ SessionsManager.parseFFmpegParameters = async (args = [], env = {}, optimizeMode
if (typeof (data.id) !== 'undefined')
file = `${publicUrl()}library/parts/${data.id}/0/file.stream?download=1`;
} catch (e) {
file = parsedArgs[i]
file = parsedArgs[i];
}
finalArgs.push(file);
continue;
}

// Link resolver (Replace Plex file url by direct file)
if (i > 0 && parsedArgs[i - 1] === '-i' && config.custom.download.forward) {
let file = parsedArgs[i];
let partId = false;
if (file.indexOf('library/parts/') !== -1) {
partId = file.split('library/parts/')[1].split('/')[0];
}
if (!partId) {
finalArgs.push(file);
continue;
}
try {
const data = await Database.getPartFromId(partId);
if (typeof (data.file) !== 'undefined' && data.file.length)
file = data.file;
} catch (e) {
file = parsedArgs[i];
}
finalArgs.push(file);
continue
}

// Ignore parameter
finalArgs.push(e);
};
Expand Down

0 comments on commit 48519a3

Please sign in to comment.