Refactoring helper functions

This commit is contained in:
freearhey 2019-07-20 10:32:57 +03:00
parent 06b6279574
commit 4dc6ac3632
2 changed files with 8 additions and 6 deletions

View File

@ -17,7 +17,7 @@ function init() {
countries = countries.slice(0, 1)
}
util.createFile(outputFile)
util.createFile(outputFile, '#EXTM3U\n')
for(let country of countries) {
@ -39,7 +39,9 @@ function init() {
} else {
util.writeToFile(outputFile, info, file)
const data = '#EXTINF:' + info + '\n' + file + '\n'
util.writeToFile(outputFile, data)
addToCache(file)

View File

@ -80,12 +80,12 @@ function sortByTitle(arr) {
return arr.sort(byTitle)
}
function writeToFile(filename, info, file) {
fs.appendFileSync(path.resolve(__dirname) + '/../' + filename, '#EXTINF:' + info + '\n' + file + '\n')
function writeToFile(filename, data) {
fs.appendFileSync(path.resolve(__dirname) + '/../' + filename, data)
}
function createFile(filename) {
fs.writeFileSync(path.resolve(__dirname) + '/../' + filename, '#EXTM3U\n')
function createFile(filename, data) {
fs.writeFileSync(path.resolve(__dirname) + '/../' + filename, data)
}
function getBasename(filename) {