Last active
May 31, 2023 20:25
-
-
Save a-sync/e8c1f1d01b8ff8ce0181051cb72bda04 to your computer and use it in GitHub Desktop.
radio1.hu tracklista URL alapján letölti az mp3 fájlokat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
title radio1-downloader @ https://gist.github.com/a-sync | |
powershell -NoProfile -ExecutionPolicy Unrestricted -Command "[System.Net.ServicePointManager]::SecurityProtocol=[System.Net.SecurityProtocolType]::Tls12;[System.Net.WebRequest]::DefaultWebProxy.Credentials=[System.Net.CredentialCache]::DefaultCredentials;$Url=Read-Host -Prompt 'radio1.hu URL';$wc=New-Object System.Net.WebClient;$wc.Encoding=[System.Text.Encoding]::UTF8;$Links=$wc.DownloadString($Url.Trim())|Select-String -Pattern '<audio data-artist=\""(.*?)\"" data-title=\""(.*?)\"".*?>\n.*?<source src=\""(.*?)\"" type=\""audio/mp3\"">' -AllMatches;Foreach($i in $Links.Matches){$Name=\""$($i.Groups[1].Value) $($i.Groups[2].Value)\"".Split([IO.Path]::GetInvalidFileNameChars()) -join '_';Write-Host $Name;$wc.Headers.Add('Referer','https://www.radio1.hu');$wc.DownloadFile(\""https://www.radio1.hu$($i.Groups[3].Value)\"",\""$Name.mp3\"")}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
process.title = 'radio1-downloader @ https://gist.github.com/a-sync'; | |
if (process.argv.length >= 3 && process.argv[2]) { | |
console.log('radio1.hu URL:', process.argv[2]); | |
main(process.argv[2]); | |
} else { | |
const rli = require('readline').createInterface({input:process.stdin, output:process.stdout}); | |
rli.question('radio1.hu URL: ', url => { | |
return main(url).then(() => { | |
rli.terminal = false; | |
setTimeout(() => rli.close()); | |
}); | |
}); | |
} | |
function main(url) { | |
return dl(url).then(data => { | |
const matches = data.matchAll('<audio data-artist=\"(.*?)\" data-title=\"(.*?)\".*?>\n.*?<source src=\"(.*?)\" type=\"audio/mp3\">'); | |
const promises = []; | |
for (const m of matches) { | |
console.log('߷', m[1], m[2]); | |
promises.push(dl('https://www.radio1.hu' + m[3], String(m[1] + ' ' + m[2] + '.mp3').replace(/[/\\?%*:|"<>]/g, '_'))); | |
} | |
return Promise.allSettled(promises); | |
}) | |
.catch(console.error); | |
} | |
function dl(url, filepath) { | |
return new Promise((resolve, reject) => { | |
require('https').get(url, {headers: {'Referer': 'https://www.radio1.hu'}}, resp => { | |
if (filepath) { | |
const file = require('fs').createWriteStream(filepath); | |
resp.pipe(file); | |
file.on('finish', () => { | |
console.log('✓', filepath); | |
file.close(); | |
resolve(); | |
}); | |
} else { | |
let data = ''; | |
resp.on('data', chunk => { | |
data += chunk; | |
}); | |
resp.on('end', () => { | |
resolve(data); | |
}); | |
} | |
}).on('error', err => { | |
reject(err); | |
}); | |
}); | |
}; |
@mucden frissítettem a .bat fájlt, töltsd le újra és próbáld meg megint.
Elméletleg mostantól a rendszer proxy beállításait használja a hálózati kérésekhez ha van ilyen.
@a-sync Így már működik, köszönöm.
Köszönöm! Szuper!! Kellemes ünnepeket!
hogyan lehet életre kelteni eszt ? tök jó lenne letölteni esti mixeket
@mateoo1989
letöltöd a bat fájlt, dupla kattintással elindítod, majd bemásolod a mix weboldal URL-t és enter-t nyomsz.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sajnos céges a gép, nincs jogom nodejs-t telepíteni. Sőt semmit sem, ami nincs benne a céges repo-ban vagy nem munka releváns.