From 41157b2b49914e1d786d86972122e1d4ebbbb6b5 Mon Sep 17 00:00:00 2001
From: Bart Broere <mail@bartbroere.eu>
Date: Sun, 20 Oct 2024 12:00:44 +0200
Subject: [PATCH] Move GraphQL query into separate variable

---
 youtube_dl/extractor/npo.py | 66 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 65 insertions(+), 1 deletion(-)

diff --git a/youtube_dl/extractor/npo.py b/youtube_dl/extractor/npo.py
index 8299bfb16..a53a3c3d9 100644
--- a/youtube_dl/extractor/npo.py
+++ b/youtube_dl/extractor/npo.py
@@ -118,6 +118,70 @@ class BNNVaraIE(NPOIE):
     def _real_extract(self, url):
         url = url.rstrip('/')
         video_id = url.split('/')[-1]
+        graphql_query = """query getMedia($id: ID!, $mediaUrl: String, $hasAdConsent: Boolean!, $atInternetId: Int) {
+                            player(
+                                id: $id
+                                mediaUrl: $mediaUrl
+                                hasAdConsent: $hasAdConsent
+                                atInternetId: $atInternetId
+                            ) {
+                            ... on PlayerSucces {
+                                brand {
+                                    name
+                                    slug
+                                    broadcastsEnabled
+                                    __typename
+                                }
+                                title
+                                programTitle
+                                pomsProductId
+                                broadcasters {
+                                    name
+                                    __typename
+                                }
+                                duration
+                                classifications {
+                                    title
+                                    imageUrl
+                                    type
+                                    __typename
+                                }
+                                image {
+                                    title
+                                    url
+                                    __typename
+                                }
+                                cta {
+                                    title
+                                    url
+                                    __typename
+                                }
+                                genres {
+                                    name
+                                    __typename
+                                }
+                                subtitles {
+                                    url
+                                    language
+                                    __typename
+                                }
+                                sources {
+                                    name
+                                    url
+                                    ratio
+                                    __typename
+                                }
+                                    type
+                                    token
+                                    __typename
+                                }
+                                ... on PlayerError {
+                                    error
+                                    __typename
+                                }
+                                    __typename
+                            }
+}"""
 
         media = self._download_json('https://api.bnnvara.nl/bff/graphql',
                                     video_id,
@@ -129,7 +193,7 @@ class BNNVaraIE(NPOIE):
                                                 'hasAdConsent': False,
                                                 'atInternetId': 70
                                             },
-                                            'query': 'query getMedia($id: ID!, $mediaUrl: String, $hasAdConsent: Boolean!, $atInternetId: Int) {\n  player(\n    id: $id\n    mediaUrl: $mediaUrl\n    hasAdConsent: $hasAdConsent\n    atInternetId: $atInternetId\n  ) {\n    ... on PlayerSucces {\n      brand {\n        name\n        slug\n        broadcastsEnabled\n        __typename\n      }\n      title\n      programTitle\n      pomsProductId\n      broadcasters {\n        name\n        __typename\n      }\n      duration\n      classifications {\n        title\n        imageUrl\n        type\n        __typename\n      }\n      image {\n        title\n        url\n        __typename\n      }\n      cta {\n        title\n        url\n        __typename\n      }\n      genres {\n        name\n        __typename\n      }\n      subtitles {\n        url\n        language\n        __typename\n      }\n      sources {\n        name\n        url\n        ratio\n        __typename\n      }\n      type\n      token\n      __typename\n    }\n    ... on PlayerError {\n      error\n      __typename\n    }\n    __typename\n  }\n}'
+                                            'query': graphql_query
                                         }).encode('utf8'),
                                     headers={
                                         'Content-Type': 'application/json',