marhoy / nrk-download

Download content from NRK, complete with images and subtitles:
https://nrkdownload.readthedocs.org
GNU General Public License v3.0
54 stars 10 forks source link

Download latest news (radio) #9

Closed svenove closed 5 years ago

svenove commented 6 years ago

I want to download the latest news from NRK radio (https://radio.nrk.no/serie/dagsnytt/).

Is that supported by this tool? Based on the readme, it looks like it will download all “episodes” if I enter a URL like that?

marhoy commented 6 years ago

I've had a quick look at this: Some APIs are common for tv and radio, so this should be possible. I haven't yet found out how to search for radio programs, but downloads from URLs should be possible.

Support for this might be included in the next release.

svenove commented 6 years ago

I found a way to do this myself, it worked in July, but it doesn’t handle “seasons” as it should (a month is a season).

I used this: http://psapi3-webapp-stage-we.azurewebsites.net/series/dagsnytt/latestAndNextEpisodes?futureEpisodeCount=0&pastEpisodeCount=2

But it keeps giving the last episode of July. :(

One other way is combining http://psapi3-webapp-stage-we.azurewebsites.net/series/dagsnytt (To find the seasonId of the current month)

And then using this: http://psapi3-webapp-stage-we.azurewebsites.net/series/dagsnytt/seasons/70925/episodes Then loop until today’s date (as this returns all episodes for this month/seasonId) and then loop until it finds a non-empty mediaAssetsOnDemand.

I emailed NRK about this yesterday, asking if the “latestAndNextEpisodes” has a bug about the seasons. I’ll let you know if I get a reply. :)

marhoy commented 6 years ago

If you update your repository to the latest development branch (named v.2), you can do the following in another script:

import nrkdownload

series = nrkdownload.nrktv.series_from_series_id('dagsnytt')
program = series.seasons[-1].episodes[-2]
program.get_download_details()
nrkdownload.nrktv.download_programs([program])

That will download the latest episode of 'Dagsnytt'. Experiment with either -2 or -1 (when I tried, -1 was not available for download yet).

Since I haven't really built in support for radio (yet), the file will be named .m4v, but will be audio only.

svenove commented 6 years ago

That’s great! I’ll try it out in a few days.

You might be experiencing the same as me when using -1 - the broadcast is finished, but the audio clip isn’t ready yet (seems to take 5-20 min after the broadcast). That’s why I fetched the last 2 episodes and used the newest one that had an audio clip available. :)

svenove commented 6 years ago

Btw, are you using psapi as well? Or are you using a different API? Looked briefly at the code, but didn’t find any reference to the API...

marhoy commented 5 years ago

Fixed in version 2.0.0