Skip to content

armgit / my-yt

Public Imported from GitHub
0

A clean and minimal youtube frontend, without all the ads and whistles

JavaScript

refactor: rename repository fn for transcoding videos

Christian Feiea5d54acdd86
diff --git a/lib/repository.js b/lib/repository.js
index f14ffb1..459fca2 100644
--- a/lib/repository.js
+++ b/lib/repository.js
@@ -32,7 +32,7 @@ export default class Repository {
} catch (err) {
console.error(err)
}
- if (this.settings.transcodeVideos === undefined) { this.setTranscodeVideos(true) }
+ if (this.settings.transcodeVideos === undefined) { this.setTranscodeVideosSetting(true) }
fs.readdirSync(`${this.basePath}/videos`).forEach(file => {
const format = file.substring(file.lastIndexOf('.') + 1)
@@ -170,10 +170,10 @@ export default class Repository {
}
return this.settings.videoQuality
}
- getTranscodeVideos() {
+ getTranscodeVideosSetting() {
return this.settings.transcodeVideos
}
- setTranscodeVideos(value) {
+ setTranscodeVideosSetting(value) {
this.settings.transcodeVideos = !!value
this.saveSettings()
return this.settings.transcodeVideos
diff --git a/lib/router/api.js b/lib/router/api.js
index a8c8b7e..0a8b8c9 100644
--- a/lib/router/api.js
+++ b/lib/router/api.js
@@ -257,7 +257,7 @@ async function reclaimDiskSpaceHandler(req, res, repo) {
}
async function getTranscodeVideosHandler(req, res, repo) {
- let transcodeVideos = repo.getTranscodeVideos()
+ let transcodeVideos = repo.getTranscodeVideosSetting()
res.writeHead(200, { 'Content-Type': 'application/json' })
res.end(JSON.stringify(transcodeVideos))
}
@@ -265,7 +265,7 @@ async function setTranscodeVideosHandler(req, res, repo) {
const body = await getBody(req)
const transcodeVideos = JSON.parse(body)
- repo.setTranscodeVideos(transcodeVideos)
+ repo.setTranscodeVideosSetting(transcodeVideos)
res.writeHead(200)
res.end()
}
diff --git a/lib/youtube.js b/lib/youtube.js
index a4bb273..7fe111b 100644
--- a/lib/youtube.js
+++ b/lib/youtube.js
@@ -35,7 +35,7 @@ export async function downloadVideo(id, repo, callback = () => {}) {
}
const video = repo.updateVideo(id, {location, format})
- if (repo.getTranscodeVideos() && video.location && video.format) {
+ if (repo.getTranscodeVideosSetting() && video.location && video.format) {
for await (const line of ffmpeg.transcode(video.location, video.format)) {
console.log(line)
callback(line)
diff --git a/test/repository.test.js b/test/repository.test.js
index 51f0185..9b98200 100644
--- a/test/repository.test.js
+++ b/test/repository.test.js
@@ -115,13 +115,13 @@ describe('repository', () => {
assert.equal(repo.getVideoQuality(), 1080)
})
test('gets transcode videos setting', () => {
- assert.equal(repo.getTranscodeVideos(), true)
+ assert.equal(repo.getTranscodeVideosSetting(), true)
})
test('sets transcode videos setting', () => {
- repo.setTranscodeVideos(false)
- assert.equal(repo.getTranscodeVideos(), false)
- repo.setTranscodeVideos(true)
- assert.equal(repo.getTranscodeVideos(), true)
+ repo.setTranscodeVideosSetting(false)
+ assert.equal(repo.getTranscodeVideosSetting(), false)
+ repo.setTranscodeVideosSetting(true)
+ assert.equal(repo.getTranscodeVideosSetting(), true)
})
})