diff --git a/js_modules/dl.js b/js_modules/dl.js index 2e2ea56..063bcf3 100644 --- a/js_modules/dl.js +++ b/js_modules/dl.js @@ -11,25 +11,41 @@ const wrap = document.getElementById('wrap'); const container = document.getElementById('downloadContainer'); const loading = document.getElementById('progress-bar'); -const addEntry = (u, height, source, title) => { +const getResolutionTitle = (e) => { + if (e < 720) return 'SD'; + else if (e < 1080) return 'HD'; + else if (e < 1440) return 'FHD'; + else if (e < 2160) return 'QHD'; + else if (e < 4320) return 'UHD'; + else if (e >= 4320) return 'UHD+'; +}; + +function getResolutionHeight(text) { + if (text == 'SD') return '480'; + else if (text == 'HD') return '720'; + else if (text == 'FHD') return '1080'; + else if (text == 'QHD') return '1440'; + else if (text == 'UHD') return '2160'; + else if (text == 'UHD+') return '4320'; + else return text; +} + +const addEntry = (height, source, title, free) => { const title2 = encodeURIComponent(title); - let height2 = height; - if (height === 'NA') { - height2 = 'AUDIO'; - } else if (parseInt(height)) { - height2 = `${height}P`; - }; + let isDisabled = 'disabled'; + const h = getResolutionHeight(height); + if (getResolutionTitle(free) === height) isDisabled = ''; return `
`; }; -const addProResolutionEntries = (url, res, source, title) => { +const addProResolutionEntries = (res, source, title, free) => { const set = new Set(); res[0].forEach((e) => { if (e < 720) set.add('SD'); @@ -40,45 +56,29 @@ const addProResolutionEntries = (url, res, source, title) => { else if (e >= 4320) set.add('UHD+'); }); - let elements = ` -