Skip to content

Commit 8223260

Browse files
committed
Course type chooser in backend
1 parent 2da6385 commit 8223260

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/script.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const EXTENSION = 'mp4'
1111
const EXTENSION_SUBS = 'vtt'
1212

1313
const qualities = ['1280x720', '1024x768']
14-
const DEFAULT_QUALITY = qualities[0]
1514

1615
const DOWNLOAD_TIMEOUT = 3000
1716
let DURATION_PERCENT = 10 // percent max 100
@@ -119,6 +118,8 @@ const readIsLeadingZeroAlways = () => {
119118
return false;
120119
}
121120

121+
const readCourseType = () => readSharedValue('courseType')
122+
122123
const log = (message, type = 'STATUS') => console.log(`[${APPNAME}]:[${type}]: ${message}`)
123124

124125
const replaceQuotesWithSquareBrackets = name => {
@@ -169,6 +170,11 @@ const getCurrentVideoId = () => {
169170
// END:UTILITIES
170171
// ====================================================================
171172

173+
const getQuality = async () => {
174+
const courseType = await readCourseType();
175+
return courseType === "Old" ? qualities[1] : qualities[0];
176+
}
177+
172178
const getDirectoryName = (sectionIndex, sectionName, bPadding = false) => {
173179
let padIndex = `${sectionIndex + 1}`
174180
if (bPadding) {
@@ -187,6 +193,7 @@ const getFileName = (videoIndex, videoName, bPadding = false) => {
187193

188194
const getVideoURL = async videoId => {
189195
try {
196+
const quality = await getQuality();
190197
const response = await fetch(viewclipURL, {
191198
method: 'POST',
192199
headers: {
@@ -195,7 +202,7 @@ const getVideoURL = async videoId => {
195202
body: JSON.stringify({
196203
clipId: videoId,
197204
mediaType: EXTENSION,
198-
quality: DEFAULT_QUALITY,
205+
quality: quality,
199206
online: true,
200207
boundedContext: 'course',
201208
versionId: '',

0 commit comments

Comments
 (0)