Small repo refactoring

This commit is contained in:
freearhey 2019-04-30 15:45:02 +03:00
parent 624bc78287
commit ee754bc44e
6 changed files with 12 additions and 17 deletions

View File

@ -8,7 +8,7 @@ Collection of 6000+ free IPTV channels from all over the world.
To open the playlist in VLC player you just need click `File` - > `Open Network...` and in the window that opens, insert a link to the playlist itself: `https://raw.githubusercontent.com/freearhey/iptv/master/index.m3u`
![VLC Network Panel](https://github.com/freearhey/iptv/raw/master/images/vlc-network-panel.png)
![VLC Network Panel](https://github.com/freearhey/iptv/raw/master/preview.png)
then just press the 'Open' button

View File

@ -2,7 +2,7 @@ const parsers = require('playlist-parser')
const M3U = parsers.M3U
const fs = require("fs")
const path = require('path')
const helper = require('./helper')
const urlParser = require('url')
let outputPath = path.resolve(__dirname) + '/../index.all.m3u'
let channels = 0
@ -59,13 +59,20 @@ function writeToFile(title, file) {
}
function addToCache(url) {
let id = helper.getUrlPath(url)
let id = getUrlPath(url)
cache[id] = true
}
function checkCache(url) {
let id = helper.getUrlPath(url)
let id = getUrlPath(url)
return cache.hasOwnProperty(id)
}
function getUrlPath(u) {
let parsed = urlParser.parse(u)
let searchQuery = parsed.search || ''
return parsed.host + parsed.pathname + searchQuery
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

View File

@ -11,7 +11,7 @@
"main": "index.m3u",
"scripts": {
"test": "node test/index.js",
"generate": "node src/generate.js"
"generate": "node helpers/generate.js"
},
"repository": {
"type": "git",

View File

Before

Width:  |  Height:  |  Size: 404 KiB

After

Width:  |  Height:  |  Size: 404 KiB

View File

@ -1,12 +0,0 @@
const parser = require('url')
function getUrlPath(u) {
let parsedUrl = parser.parse(u)
let searchQuery = parsedUrl.search || ''
return parsedUrl.host + parsedUrl.pathname + searchQuery
}
module.exports = {
getUrlPath
}