-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate using transcript page as file naming source
As per the exploit mentioned in 0f595a7, it is decided to shift file and folder generation to use data provided in the course info. Without logging in transcripts can't be taken, therefore breaking the process. For now, slides ("exercise files") download are being looked into.
- Loading branch information
Showing
5 changed files
with
93 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
const fs = require('fs'); | ||
const converter = require('./converter.js'); | ||
const func = require('./functions.js'); | ||
|
||
function fileNameSanitizer(fileName) { | ||
return fileName | ||
.replace(/\?/g, "") | ||
.replace(/\:/g, "-") | ||
.replace(/\®/g, "") | ||
.replace(/\//g, "") | ||
.replace(/\\/g, ""); | ||
} | ||
|
||
function generatePaths(courseInfo) { | ||
return new Promise(async (resolve, reject) => { | ||
var videoList = []; | ||
await courseInfo.modules.forEach((module, index) => { | ||
// Output transcript based on folder | ||
var courseIndex = ++index; | ||
var folderName = ".\/output\/" + fileNameSanitizer(courseInfo.title) + "\/"; | ||
|
||
// Create course output directory if it doesn't exist | ||
if (!fs.existsSync(folderName)) { | ||
try { | ||
fs.mkdirSync(folderName.slice(0, -1)); | ||
} catch (err) { | ||
console.log(err); | ||
} | ||
} | ||
|
||
// Generate subfolder name. | ||
folderName = folderName.concat(func.numString(courseIndex)); | ||
folderName = folderName + " - " + fileNameSanitizer(module.title); | ||
|
||
// Generate subfolder | ||
if (!fs.existsSync(folderName)) { | ||
try { | ||
fs.mkdirSync(folderName); | ||
} catch (err) { | ||
console.log(err.message); | ||
} | ||
} | ||
|
||
// Add key to folder name. | ||
folderName += "11B42C394C6217C5135BF7E4AC23E"; | ||
|
||
module.clips.forEach((clip, fileIndex) => { | ||
// Generate file name | ||
var fileName = folderName + "\/"; | ||
|
||
// Append course index | ||
fileName += func.numString(courseIndex) + "."; | ||
|
||
// Check for class index | ||
fileName += func.numString(fileIndex) + " - "; | ||
|
||
fileName += fileNameSanitizer(clip.title); | ||
|
||
videoList.push(fileName); | ||
|
||
}); | ||
|
||
}); | ||
|
||
resolve(videoList); | ||
}); | ||
} | ||
|
||
/** | ||
* Generates output path and writes into videoList.json | ||
* @param {Object} courseInfo | ||
*/ | ||
module.exports.generatePaths = (courseInfo) => { | ||
return new Promise(async (resolve, reject) => { | ||
generatePaths(courseInfo).then((videoList) => { | ||
fs.writeFileSync("./output/videoList.json", JSON.stringify(videoList, null, 2)); | ||
resolve(videoList); | ||
}); | ||
|
||
}); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters