Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
Lovligheten rundt dette verktøyet er uklart, anbefaler å bare benytte verktøyet til privat, ikke-kommersiell bruk.<br>
**Bruk av verktøyet gjøres på egen risiko.** [Opphavsrett på NRK](https://www.nrk.no/etikk/opphavsrett-pa-nrk.no-1.2843522)

Dette prosjektet ble startet etter at det ble kjent at NRK innhold fra før 1997 kan bli borte fra NRK om det ikke kommer en ny avtale på plass med Norwaco, derfor bestemte jeg meg for å lage et script som gjør at man lett kan laste ned innehold fra NRK, slik at man kan holde på denne arven.
Dette prosjektet ble startet etter at det ble kjent at NRK innhold fra før 1997 kan bli borte fra NRK om det ikke kommer en ny avtale på plass med Norwaco, derfor bestemte jeg meg for å lage et script som gjør at man lett kan laste ned innhold fra NRK, slik at man kan holde på denne arven.

Avtalen med Norwaco ble fornyet, derfor ble motivet til dette prosjeket endret til å fokusere på å laste ned programmer/serier som stadig blir fjernet fra NRK sitt arkiv, rapporter over hvilke programmer/serier som blir fjernet, kan du finne her: [NRK-Expire](https://github.com/ljskatt/nrk-expire)
Avtalen med Norwaco ble fornyet, derfor ble motivet til dette prosjektet endret til å fokusere på å laste ned programmer/serier som stadig blir fjernet fra NRK sitt arkiv, rapporter over hvilke programmer/serier som blir fjernet, kan du finne her: [NRK-Expire](https://github.com/ljskatt/nrk-expire)

## Windows

Expand All @@ -14,7 +14,7 @@ Avtalen med Norwaco ble fornyet, derfor ble motivet til dette prosjeket endret t
Dette vil automatisk bli lastet ned når du kjører scriptet:

- yt-dlp.exe - Denne pakken gjør at man kan laste ned videofilene fra NRK sine servere
- ffmpeg.exe - yt-dlp benytter dette programmet når det evenuelt er problemer med video eller lyd
- ffmpeg.exe - yt-dlp benytter dette programmet når det skal slå sammen video og lyd

### Start

Expand All @@ -25,35 +25,35 @@ Last ned filen og kjør kommandoen for å begynne å laste ned episoden/episoder
### Eksempel

```
https://tv.nrk.no/program/FDRI40003290
https://tv.nrk.no/serie/fleksnes
https://tv.nrk.no/program/KOID20001420
```

`.\nrk-dl.ps1 "FDRI40003290"`
Scriptet vil laste ned programmet

`.\nrk-dl.ps1 "fleksnes"`
Scriptet vil laste ned alle episodene av Fleksnes

`.\nrk-dl.ps1 "fantorangen" -SeasonFilter 3`
Scriptet vil laste ned alle episodene av Fantorangen i sesong 3

`.\nrk-dl.ps1 "KOID20001420"`
Scriptet vil laste ned programmet

### Alignment filer

- [x] Poirot - [Issue](https://github.com/ljskatt/nrk-dl/issues/5)
- [ ] Vera - [Issue](https://github.com/ljskatt/nrk-dl/issues/4)

## Linux
:warning: &nbsp; Dette scriptet fungerer ikke lenger, dette blir oppdatert fortløpende, men Powershell (Windows) er prioritert først :warning:
:warning: &nbsp; Dette scriptet fungerer ikke lenger, dette blir oppdatert fortløpende, men PowerShell (Windows) er prioritert først :warning:

### Dependencies

Dette vil automatisk bli lastet ned når du kjører scriptet (Støtter Debian-baserte, Arch-baserte distroer og CentOS for øyeblikket)

- yt-dlp - Denne pakken gjør at man kan laste ned videofilen fra NRK sine servere
- curl - Denne pakken trenger man for å kunne kommunisere med NRK sitt API
- jq - Denne pakken brukes til å hente ut informasjon fra responsen til NRK sitt api
- screen - Denne pakken brukes når man laster ned parallellt
- jq - Denne pakken brukes til å hente ut informasjon fra responsen til NRK sitt API
- screen - Denne pakken brukes når man laster ned parallelt

### Start
Scriptet kan startes med å bare kjøre det, eller legge til flere parametere i kommandoen slik at man kjappere kan laste ned flere serier/programmer.
Expand All @@ -63,7 +63,7 @@ Scriptet kan startes med å bare kjøre det, eller legge til flere parametere i

### Parametere

- Kjøre det parallellt: (0/1)
- Kjøre det parallelt: (0/1)
- Hvor mange nedlastninger skal kjøre samtidig: (2-99)
- Program: (program)

Expand All @@ -74,7 +74,7 @@ Scriptet kan startes med å bare kjøre det, eller legge til flere parametere i

`./nrk-dl.sh "1" "5" "fleksnes"`

Nedlastningen vil kjøre parallellt med 5 samtidige nedlastninger av Fleksnes
Nedlastningen vil kjøre parallelt med 5 samtidige nedlastninger av Fleksnes

<br>

Expand Down
80 changes: 55 additions & 25 deletions nrk-dl.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ param (

[Parameter()]
[switch]
$DisableSSLCertVerify, # This will only affect yt-dlp downloads and not connection to NRK api, SHOULD ONLY BE USED IF YOU GET ERRORS LIKE: [SSL: CERTIFICATE_VERIFY_FAILED]
$DisableSSLCertVerify, # This will only affect yt-dlp downloads and not connection to NRK API, SHOULD ONLY BE USED IF YOU GET ERRORS LIKE: [SSL: CERTIFICATE_VERIFY_FAILED]

[Parameter()]
[switch]
Expand Down Expand Up @@ -163,7 +163,7 @@ else {
if (-not (Test-Path -Path "C:\Windows\System32\MSVCR100.dll" -PathType "leaf")) {
Write-Host -Object ""
Write-Host -BackgroundColor "Red" -ForegroundColor "White" -Object " MSVCR100.dll (required by yt-dlp) is missing, please install missing C++ library: " -NoNewline; Write-Host -ForegroundColor "DarkGray" -Object "|"
Write-Host -BackgroundColor "Red" -ForegroundColor "White" -Object " https://www.microsoft.com/en-US/download/details.aspx?id=8328 " -NoNewline; Write-Host -ForegroundColor "DarkGray" -Object "|"
Write-Host -BackgroundColor "Red" -ForegroundColor "White" -Object " https://www.microsoft.com/en-US/download/details.aspx?id=26999 " -NoNewline; Write-Host -ForegroundColor "DarkGray" -Object "|"
Write-Host -Object ""
}
}
Expand All @@ -179,12 +179,37 @@ if ($IsMacOS -or $IsLinux) {
else {
if (-not (Test-Path -PathType "Leaf" -Path "ffmpeg.exe")) {
$downloadaccept = $null
$downloadaccept = Read-Host -Prompt "ffmpeg.exe (required-package) is not installed, do you want us to download it? Source: https://cdn.serverhost.no/ljskatt/ffmpeg.exe (Y/n)`n"
$downloadaccept = Read-Host -Prompt "ffmpeg.exe (required-package) is not installed, do you want us to download it? Source: https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip (Y/n)`n"
if ($downloadaccept -in '','y','yes') {
Write-Output "Downloading ffmpeg"
Invoke-WebRequest -Uri "https://cdn.serverhost.no/ljskatt/ffmpeg.exe" -OutFile "ffmpeg.exe"
if (Test-Path -PathType "Leaf" -Path "ffmpeg.exe") {
Write-Host -Object "|" -NoNewline; Write-Host -BackgroundColor "Green" -ForegroundColor "Black" -Object " Success " -NoNewline; Write-Host -Object "|"; Write-Host ""
$tempZipPath = "ffmpeg-temp.zip"
Invoke-WebRequest -Uri "https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip" -OutFile "$tempZipPath"

if (Test-Path -PathType "Leaf" -Path "$tempZipPath") {
Expand-Archive -Path "$tempZipPath" -DestinationPath "." -Force
$extractedFolder = Get-ChildItem -Directory | Where-Object { $_.Name -like "ffmpeg-*-essentials_build" } | Select-Object -First 1

if ($extractedFolder -and (Test-Path -PathType "Leaf" -Path "$($extractedFolder.FullName)\bin\ffmpeg.exe")) {
Copy-Item -Path "$($extractedFolder.FullName)\bin\ffmpeg.exe" -Destination "." -Force
Remove-Item -Path "$tempZipPath" -Force
Remove-Item -Path $extractedFolder.FullName -Recurse -Force

if (Test-Path -PathType "Leaf" -Path "ffmpeg.exe") {
Write-Host -Object "|" -NoNewline; Write-Host -BackgroundColor "Green" -ForegroundColor "Black" -Object " Success " -NoNewline; Write-Host -Object "|"; Write-Host ""
}
else {
Write-Host -Object "|" -NoNewline; Write-Host -BackgroundColor "Red" -ForegroundColor "Black" -Object " Failed " -NoNewline; Write-Host -Object "|"
exit
}
}
else {
Remove-Item -Path "$tempZipPath" -Force
if ($extractedFolder) {
Remove-Item -Path $extractedFolder.FullName -Recurse -Force
}
Write-Host -Object "|" -NoNewline; Write-Host -BackgroundColor "Red" -ForegroundColor "Black" -Object " Failed " -NoNewline; Write-Host -Object "|"
exit
}
}
else {
Write-Host -Object "|" -NoNewline; Write-Host -BackgroundColor "Red" -ForegroundColor "Black" -Object " Failed " -NoNewline; Write-Host -Object "|"
Expand All @@ -211,16 +236,32 @@ if (-not (Test-Path -PathType "Container" -Path "downloads")) {

$seasons = $null
$standalone = $null
$series_req = Invoke-RestMethod -Uri "https://psapi.nrk.no/tv/catalog/series/$name"
$seasons = $series_req._links.seasons.name

if ($Alignment_TheTVDB) {
$alignment_file = "alignment-thetvdb-$name.json"
if (Test-Path -Path $alignment_file) {
$alignment = Get-Content -Path $alignment_file | ConvertFrom-Json
try {
$series_req = Invoke-RestMethod -Uri "https://psapi.nrk.no/tv/catalog/series/$name"
$seasons = $series_req._links.seasons.name

if ($Alignment_TheTVDB) {
$alignment_file = "alignment-thetvdb-$name.json"
if (Test-Path -Path $alignment_file) {
$alignment = Get-Content -Path $alignment_file | ConvertFrom-Json
}
else {
Write-Host -BackgroundColor "Red" -ForegroundColor "Black" -Object " Alignmentfile ($alignment_file) does not exist " -NoNewline; Write-Host -ForegroundColor "DarkGray" -Object "|"
exit
}
}
else {
Write-Host -BackgroundColor "Red" -ForegroundColor "Black" -Object " Alignmentfile ($alignment_file) does not exist " -NoNewline; Write-Host -ForegroundColor "DarkGray" -Object "|"
}
catch {
try {
$standalone_req = (Invoke-RestMethod -Uri "https://psapi.nrk.no/tv/catalog/programs/$name")
$standalone = $standalone_req._links.share.href
if ($standalone_req) {
$type = "standalone"
}
}
catch {
Write-Host -BackgroundColor "Red" -ForegroundColor "Black" -Object " Could not find program/series " -NoNewline; Write-Host -ForegroundColor "DarkGray" -Object "|"
exit
}
}
Expand Down Expand Up @@ -281,17 +322,6 @@ if ($seasons) {
$seriestitle = Format-Name -Name ($series_req.standard.titles.title)
}
}
else {
$standalone_req = (Invoke-RestMethod -Uri "https://psapi.nrk.no/tv/catalog/programs/$name")
$standalone = $standalone_req._links.share.href
if ($standalone_req) {
$type = "standalone"
}
else {
Write-Host -BackgroundColor "Red" -ForegroundColor "Black" -Object " Could not find program/series " -NoNewline; Write-Host -ForegroundColor "DarkGray" -Object "|"
exit
}
}

Write-Output "--------------------" "" "$name (Type: $type)" "Download folder: $root_location\downloads\$name" ""
Write-Host "Video: |" -NoNewline
Expand Down