Skip to content
Open
Changes from 4 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
3b31478
Fix support for NPO downloads
bartbroere Mar 31, 2023
b4776f2
Import from compat
bartbroere Mar 31, 2023
fb2b4e2
Add line comment
bartbroere Mar 31, 2023
9e1acb2
Fix flake8
bartbroere Mar 31, 2023
6328978
Accept suggestions on PR; comply with conventions
bartbroere Apr 3, 2023
0c7261d
Update npo.py
dirkf Apr 6, 2023
c409a8c
Merge branch 'ytdl-org:master' into fix-npo-support
bartbroere Feb 25, 2024
f76d58c
Skip a test
bartbroere Feb 26, 2024
da3d1f4
Add notes on new npo.nl site
bartbroere Mar 1, 2024
5773681
Fix token URL
bartbroere Mar 1, 2024
29724e7
Delete all broken extractors
bartbroere Mar 1, 2024
21eb451
Convert the description into code
bartbroere Mar 1, 2024
0dc7d95
Comply with coding conventions a bit more
bartbroere Mar 1, 2024
fb7b717
Speculate about other ways of getting productId
bartbroere Mar 1, 2024
f9e59b0
Add the possibility to add 'hls' later
bartbroere Mar 1, 2024
8b1a7d9
Use provided util
bartbroere Mar 1, 2024
34b5b20
Refactor into reusable method
bartbroere Mar 3, 2024
4fc4238
Fix lint
bartbroere Mar 5, 2024
28ba01f
Add Ongehoord Nederland and test URL for BNNVARA
bartbroere Mar 5, 2024
eb6e396
First version of a VPRO regex
bartbroere Mar 5, 2024
d36d50f
Re-add Zapp
bartbroere Mar 5, 2024
d426a92
Encoding suggestion from PR
bartbroere Mar 5, 2024
3b3d73c
Use program-detail endpoint and remove a test
bartbroere Mar 6, 2024
4b24e5f
Re-add SchoolTV
bartbroere Mar 6, 2024
681b390
Fix flake8 and better error reporting
bartbroere Mar 6, 2024
159f825
Add scaffolding for last few extractors and change order so the PR di…
bartbroere Mar 6, 2024
0cbcd1a
Make diff better
bartbroere Mar 6, 2024
0ab79c3
Reusable code for two NTR sites
bartbroere Mar 7, 2024
c08f29f
Update unit tests
bartbroere Mar 10, 2024
28624cf
Work work
bartbroere Mar 10, 2024
1ca4e68
Add an MD5
bartbroere Mar 10, 2024
4398f68
Fix zapp extractor
bartbroere Mar 11, 2024
58d7a00
Resolve some of the pull request feedback
bartbroere Mar 11, 2024
d4250c8
Merge branch 'ytdl-org:master' into fix-npo-support
bartbroere Mar 12, 2024
ad64f37
Improve regex
bartbroere Mar 14, 2024
bc86c5f
Make regex more specific and remove redundant .*
bartbroere Mar 14, 2024
4c90b2f
Adhere to code style
bartbroere Mar 14, 2024
007bbea
Remove afspelen and trailing slashes with one regex
bartbroere Mar 14, 2024
a60972e
Fix indent from suggestion
bartbroere Mar 15, 2024
179c8b0
Merge branch 'ytdl-org:master' into fix-npo-support
bartbroere Sep 11, 2024
ad6ee6f
Commit two suggestions from the PR
bartbroere Sep 21, 2024
bf91db4
Use suggested util
bartbroere Sep 21, 2024
6de650f
Use traverse_obj in another place as well
bartbroere Sep 21, 2024
c748eca
Automatically obtain NextJS buildId and change item to video-item
bartbroere Oct 20, 2024
41157b2
Move GraphQL query into separate variable
bartbroere Oct 20, 2024
c3026dd
Apply suggestion from PR
bartbroere Oct 20, 2024
7f1c09b
Use _sort_formats util
bartbroere Oct 20, 2024
0e1a0cf
Apply some more PR feedback
bartbroere Oct 20, 2024
817e2e5
Fix some missing imports
bartbroere Oct 20, 2024
75266ce
Fix old metadata reference
bartbroere Oct 20, 2024
6f27142
Update tests
bartbroere Oct 20, 2024
224e0a7
Merge branch 'ytdl-org:master' into fix-npo-support
bartbroere Jan 4, 2025
4aa57d6
Merge remote-tracking branch 'ytdl-org/master' into fix-npo-support
bartbroere Jan 31, 2025
91e279f
Fix name of key
bartbroere Jan 31, 2025
1fe43de
Merge remote-tracking branch 'ytdl-org/master' into fix-npo-support
bartbroere Feb 10, 2025
4f8b323
Merge remote-tracking branch 'ytdl-org/master' into fix-npo-support
bartbroere Mar 15, 2025
0a61173
Merge remote-tracking branch 'ytdl-org/master' into fix-npo-support
bartbroere Mar 22, 2025
82d496f
Merge remote-tracking branch 'ytdl-org/master' into fix-npo-support
bartbroere Apr 1, 2025
c4e5b23
Merge remote-tracking branch 'ytdl-org/master' into fix-npo-support
bartbroere Apr 9, 2025
35857bf
download_webpage() without _handle
dirkf May 4, 2025
8611871
Take the first result without breaking from a loop
bartbroere May 19, 2025
8fd477c
Match HTML tags
bartbroere May 19, 2025
958f9aa
Merge remote-tracking branch 'ytdl-org/master' into fix-npo-support
bartbroere May 19, 2025
0d1fa41
Fix variable name and add capture group to regex
bartbroere May 19, 2025
2de603b
Fix test that is no longer available
bartbroere May 19, 2025
2f1c1f0
Add new test for BNNVara site if the resource is a simple mp4 URL
bartbroere May 19, 2025
dce0e96
Don't get a handle if we don't use it
bartbroere May 19, 2025
d763512
Fix flake8
bartbroere May 25, 2025
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
23 changes: 18 additions & 5 deletions youtube_dl/extractor/npo.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from ..compat import (
compat_HTTPError,
compat_str,
compat_urllib_parse_unquote_plus,
compat_cookies_SimpleCookie,
)
from ..utils import (
determine_ext,
Expand Down Expand Up @@ -184,21 +186,29 @@ def _real_extract(self, url):
return self._get_info(url, video_id) or self._get_old_info(video_id)

def _get_info(self, url, video_id):
token = self._download_json(
_, xsrf_token_response = self._download_webpage_handle(
'https://www.npostart.nl/api/token', video_id,
'Downloading token', headers={
'Referer': url,
'X-Requested-With': 'XMLHttpRequest',
})['token']
})
cookies = compat_cookies_SimpleCookie()
cookies.load(xsrf_token_response.headers['Set-Cookie'])
cookies = {k: v.value for k, v in cookies.items()}
xsrf_token = cookies['XSRF-TOKEN']

player = self._download_json(
'https://www.npostart.nl/player/%s' % video_id, video_id,
'Downloading player JSON', data=urlencode_postdata({
'Downloading player JSON',
headers={
"x-xsrf-token": compat_urllib_parse_unquote_plus(xsrf_token)
},
data=urlencode_postdata({
'autoplay': 0,
'share': 1,
'pageUrl': url,
'isFavourite': "false",
'hasAdConsent': 0,
'_token': token,
}))

player_token = player['token']
Expand All @@ -215,7 +225,10 @@ def _get_info(self, url, video_id):
'quality': 'npo',
'tokenId': player_token,
'streamType': 'broadcast',
})
},
data=b"")
# Empty byte string in the call above to force a POST request
# Without it HTTP 405 will happen
if not streams:
continue
stream = streams.get('stream')
Expand Down