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

View File

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