Created
January 7, 2025 16:26
-
-
Save nomadicloudz/3d93bb35eb62024a91482e109c1ce25c to your computer and use it in GitHub Desktop.
laste ned radio-filer fra nrk skal ikke være lett nei..
This file contains hidden or 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
<# | |
needed to get one song from | |
https://radio.nrk.no/serie/vahkkoloahppa/SAPR04030320 | |
eventually figured out that they stream the audio in .ts | |
chunks. you will need to find the chunk url, for example: | |
https://nrkod98-cdn0-47115-odedge1.dna.contentdelivery.net/47115-odedge1/open/ps/sany/sany01011324/ae83c997-2.smil/sc-gaFEAA/ | |
at the end there will be something like a1_F0000.ts | |
we need to loop through every one. you can either loop | |
until you get a 404, or find the a1 index.m3u8 file (in this case) | |
and count from 0 to the end. | |
fore example i wanted ONE song from this radio programme | |
Jan Ole Hermansen - Movttegis Nieiddat | |
(not available anywhere else i've found..) | |
this was a1_F0000.ts -> a1_F2692.ts | |
now you need to combine all of the .ts files into one | |
ffmpeg is the best tool for the job | |
https://nrk-od-world-98.akamaized.net/open/ps/sany/sany01011324/ae83c997-2.smil/sc-gaFEAA/a1_index.m3u8 | |
a1_F0000.ts | |
... | |
a1_F2692.ts | |
a1_F0125.ts | |
a1_F0176.ts | |
#> | |
# in my case | |
# change this to suit your needs | |
$root = "https://nrkod98-cdn0-47115-odedge1.dna.contentdelivery.net/47115-odedge1/open/ps/sany/sany01011324/ae83c997-2.smil/sc-gaFEAA/{0}" | |
$chunks = "C:\path\to\dl\chunks" | |
0..2692 | % { | |
$chunk = "a1_F{0}.ts" -f $_ | |
$url = $root -f $chunk | |
$fp = Join-Path $chunks $chunk | |
Invoke-WebRequest $url -OutFile $fp | |
} | |
<# | |
now you need to make a txt file to concat all | |
of the .ts files with ffmpeg. | |
$tsfiles = dir $chunks <where they are stored | select -expandproperty fullname | |
$combinedts = "where you want the concat text file stored combinedTS.txt" | |
if (!(test-path $combinedts)) { | |
new-item -Path $combinedts -ItemType File | |
} | |
foreach ($ts in $tsfiles) { | |
$lineName = "file '{0}'" -f $ts | |
Add-Content -Value $lineName -Path $combinedts -Encoding UTF8 | |
} | |
#> | |
<# | |
now with ffmpeg.exe: | |
ffmpeg -f concat -safe 0 -i .\combinedTS.txt -c copy -bsf:a aac_adtstoasc video.mp4 | |
PS: the combined file NEEDS to be UTF8, not "UTF with bom" | |
if you get an error, check tat. | |
#> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment